/* みじ - Liquid Glass デザイン */
:root {
    --glass-bg: rgba(255, 255, 255, 0.45);
    --glass-border: rgba(255, 255, 255, 0.6);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    --glass-blur: 20px;
    --primary-color: #7cc9a8;
    --primary-dark: #5fb892;
    --primary-glow: rgba(124, 201, 168, 0.3);
    --accent-coral: #f08a74;
    --accent-yellow: #f5d983;
    --success-color: #10b981;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 10px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
input, button, select, textarea { font-family: inherit; }

body {
    font-family: 'LINE Seed JP', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
    min-height: auto;
    color: var(--text-main);
    line-height: 1.6;
    background: linear-gradient(135deg, #fce4dc 0%, #e0f5ea 30%, #fef3d0 60%, #dbeafe 100%);
    background-attachment: fixed;
}

/* ====== レイアウト ====== */
.logo-area {
    text-align: center;
    padding: 24px 20px 16px;
}

.panels-wrapper {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 0 20px 24px;
    gap: 20px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-panel {
    width: 100%;
    max-width: 520px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.side-panel {
    width: 0;
    height: 0;
    max-width: 360px;
    overflow: hidden;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.side-panel.active {
    width: 100%;
    height: auto;
    opacity: 1;
}

/* Glass Card */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--glass-shadow), inset 0 1px 0 rgba(255,255,255,0.6);
}

/* 入力フィールド */
.input-group { margin-bottom: 16px; }

label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 600;
}

input[type="text"],
input[type="url"],
input[type="password"],
input[type="datetime-local"],
input[type="time"],
input[type="date"],
select {
    width: 100%;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.04);
}

input:focus, select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px var(--primary-glow), inset 0 1px 2px rgba(0,0,0,0.04);
    background: rgba(255, 255, 255, 0.8);
}

/* メインURL入力 */
.url-main-input {
    padding: 16px 20px;
    font-size: 1.05rem;
    border-radius: var(--radius-md);
}

/* ボタン共通 */
.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 14px 28px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* メインボタン */
.btn-primary {
    background: linear-gradient(135deg, #7cc9a8, #5fb892);
    color: #fff;
    width: 100%;
    box-shadow: 0 4px 16px rgba(124, 201, 168, 0.4);
    margin-top: 8px;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #6bbf9c, #4fad86);
    box-shadow: 0 6px 24px rgba(124, 201, 168, 0.55);
    transform: translateY(-2px);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(124, 201, 168, 0.3);
}

/* 結果表示 */
.result {
    display: none;
    position: relative;
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid rgba(138, 212, 181, 0.4);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-top: 16px;
    text-align: center;
    animation: slideUp 0.4s ease;
}

.result-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    line-height: 1;
    transition: all 0.2s ease;
}

.result-close:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-main);
}

.result.active { display: block; }

.result p {
    color: var(--success-color);
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.result-url {
    display: block;
    font-size: 1.3rem;
    font-weight: 700;
    color: #e07460;
    word-break: break-all;
    margin: 8px 0 16px 0;
    text-decoration: none;
    transition: color 0.2s;
}

.result-buttons {
    margin-bottom: 12px;
}

.qr-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid rgba(0,0,0,0.06);
}

.qr-area img {
    width: 150px;
    height: 150px;
    border-radius: 8px;
}

.qr-download {
    font-size: 0.8rem;
    color: var(--primary-dark);
    text-decoration: none;
    font-weight: 600;
}
.qr-download:hover { text-decoration: underline; }

.result-url:hover {
    color: #f08a74;
    text-decoration: underline;
    text-underline-offset: 4px;
}

/* コピーボタン */
.btn-copy {
    background: linear-gradient(135deg, var(--accent-coral), #e07460);
    color: #fff;
    padding: 10px 28px;
    font-size: 0.9rem;
    font-weight: 700;
    border: none;
    box-shadow: 0 3px 12px rgba(240, 138, 116, 0.35);
    position: relative;
    overflow: hidden;
}

.btn-copy::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255,255,255,0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
}

.btn-copy:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 6px 20px rgba(240, 138, 116, 0.5);
    background: linear-gradient(135deg, #e87f6f, #d9705f);
}

.btn-copy:hover::after {
    width: 200px;
    height: 200px;
}

.btn-copy:active {
    transform: translateY(0) scale(0.98);
}

/* エラー */
.error-msg {
    color: #dc2626;
    background: rgba(254, 226, 226, 0.6);
    backdrop-filter: blur(10px);
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: 12px;
    display: none;
    text-align: center;
    border: 1px solid rgba(220, 38, 38, 0.2);
}

.error-msg.active { display: block; }

/* オプション開閉トグル */
.options-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    margin-top: 14px;
    background: rgba(255,255,255,0.35);
    border: 1px solid rgba(255,255,255,0.5);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: all 0.3s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.options-toggle:hover {
    color: var(--primary-dark);
    background: rgba(255,255,255,0.55);
    border-color: rgba(124, 201, 168, 0.4);
}

.options-toggle .toggle-icon {
    transition: transform 0.3s ease;
    font-size: 1rem;
    line-height: 1;
    display: inline-block;
}

.options-toggle.open .toggle-icon {
    transform: rotate(0deg);
}

/* URL プレフィックス付き入力 */
.url-prefix-input {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.04);
}

.url-prefix-input:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px var(--primary-glow), inset 0 1px 2px rgba(0,0,0,0.04);
    background: rgba(255, 255, 255, 0.8);
}

.url-prefix {
    padding: 12px 0 12px 14px;
    color: var(--text-muted);
    font-size: 0.92rem;
    font-weight: 600;
    white-space: nowrap;
    user-select: none;
    flex-shrink: 0;
}

.url-prefix-input input[type="text"] {
    border: none;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    padding: 12px 14px 12px 0;
    font-size: 0.92rem;
    border-radius: 0;
    min-width: 0;
    flex: 1;
}

.url-prefix-input input[type="text"]:focus {
    border-color: transparent;
    box-shadow: none;
    background: transparent;
}

/* サイドパネル内のオプション */
.side-panel .glass-card {
    padding: 24px;
}

.side-panel h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

/* 独立オプションブロック */
.option-block {
    background: rgba(255,255,255,0.3);
    border: 1px solid rgba(255,255,255,0.5);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    overflow: hidden;
}

.option-block-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-main);
    font-weight: 600;
    user-select: none;
    padding: 12px 16px;
    margin-bottom: 0;
    transition: background 0.2s;
}

.option-block-toggle:hover {
    background: rgba(255,255,255,0.35);
}

.option-block-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
    cursor: pointer;
    flex-shrink: 0;
}

.option-block-body {
    display: none;
    padding: 0 16px 16px;
    animation: fadeIn 0.3s ease;
}

.option-block-body.active {
    display: block;
}

/* 有効期限 入力行 */
.expiry-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.expiry-number {
    width: 80px;
    padding: 10px 12px;
    text-align: center;
    font-size: 1rem;
    font-weight: 700;
    -moz-appearance: textfield;
}

.expiry-number::-webkit-inner-spin-button,
.expiry-number::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.expiry-unit {
    width: auto;
    padding: 10px 14px;
    font-size: 0.9rem;
    font-weight: 600;
}

.expiry-hint {
    font-size: 0.82rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* オプション内パネル（A/Bテスト条件） */
.option-panel {
    display: none;
    background: rgba(255,255,255,0.3);
    border: 1px solid rgba(255,255,255,0.5);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 16px;
}

.option-panel.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.select-row {
    display: flex;
    gap: 12px;
    align-items: end;
}
.select-row > * { flex: 1; }

/* ====== 管理画面 ====== */
.admin-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 40px 20px;
}

.admin-container h1 {
    font-size: 1.8rem;
    color: var(--text-main);
    font-weight: 800;
}

.subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 24px;
    font-size: 0.95rem;
}

.card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 24px;
    box-shadow: var(--glass-shadow);
}

.search-bar {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 0;
}

.search-bar .input-group { margin-bottom: 0; }

.search-bar .btn-primary {
    width: auto;
    padding: 12px 24px;
    margin-top: 0;
}

/* テーブル */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-md);
    padding: 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th {
    background: rgba(241, 245, 249, 0.7);
    color: #475569;
    padding: 14px 16px;
    text-align: left;
    font-weight: 700;
    border-bottom: 2px solid rgba(226, 232, 240, 0.6);
    white-space: nowrap;
}

td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(241, 245, 249, 0.5);
    color: #334155;
    vertical-align: middle;
}

tr:hover td {
    background: rgba(248, 250, 252, 0.5);
}

.url-cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #64748b;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-active { background: rgba(220, 252, 231, 0.7); color: #166534; }
.badge-expired { background: rgba(254, 226, 226, 0.7); color: #991b1b; }
.badge-used { background: rgba(254, 243, 199, 0.7); color: #92400e; }
.badge-onetime { background: rgba(224, 231, 255, 0.7); color: #3730a3; }

.counter {
    font-weight: 700;
    color: var(--primary-color);
    font-family: monospace;
    font-size: 1rem;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 32px;
}

.pagination a, .pagination span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    border-radius: 8px;
    font-size: 0.9rem;
    text-decoration: none;
    font-weight: 500;
}

.pagination a {
    background: rgba(255,255,255,0.5);
    border: 1px solid rgba(255,255,255,0.7);
    color: #64748b;
    transition: all 0.2s;
}

.pagination a:hover {
    background: rgba(255,255,255,0.8);
    color: #334155;
}

.pagination .current {
    background: var(--primary-color);
    color: #fff;
    border: 1px solid var(--primary-color);
}

.admin-container p a {
    display: inline-block;
    color: var(--primary-color);
    font-weight: 600;
    margin-top: 16px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.admin-container p a:hover {
    background: rgba(124, 201, 168, 0.15);
}

/* 検索ボタン */
.btn-search {
    padding: 10px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    text-align: center;
    display: inline-block;
    background: linear-gradient(135deg, #7cc9a8, #5fb892);
    color: #fff;
}
.btn-search:hover { opacity: 0.85; }

.btn-search-reset {
    background: rgba(100, 116, 139, 0.12);
    color: #64748b;
}
.btn-search-reset:hover { background: rgba(100, 116, 139, 0.22); }

/* URLカード型一覧 */
.url-card { padding: 20px 24px; }

.url-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.url-card-code {
    font-size: 1.1rem;
    font-weight: 800;
    color: #6366f1;
    text-decoration: none;
}
.url-card-code:hover { text-decoration: underline; }

.url-card-actions {
    margin-left: auto;
    display: flex;
    gap: 6px;
}

.url-card-urls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 0.85rem;
}

.url-card-label {
    flex-shrink: 0;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    background: rgba(0,0,0,0.04);
    padding: 2px 8px;
    border-radius: 4px;
}

.url-card-link {
    color: var(--text-muted);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.url-card-link:hover { color: var(--primary-dark); text-decoration: underline; }

.url-card-meta {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(0,0,0,0.05);
    font-size: 0.78rem;
    color: var(--text-muted);
}

.url-card-meta strong {
    color: var(--text-main);
}

/* 操作ボタン */
.btn-action {
    padding: 5px 12px;
    border: none;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.btn-toggle {
    background: rgba(245, 158, 11, 0.12);
    color: #d97706;
}
.btn-toggle:hover { background: rgba(245, 158, 11, 0.25); }

.btn-enable {
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
}
.btn-enable:hover { background: rgba(16, 185, 129, 0.25); }

.btn-delete {
    background: rgba(220, 38, 38, 0.1);
    color: #dc2626;
}
.btn-delete:hover { background: rgba(220, 38, 38, 0.22); }

.badge-disabled { background: rgba(148, 163, 184, 0.3); color: #475569; }

/* 詳細ページ */
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.detail-code {
    display: block;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-dark);
    text-decoration: none;
    margin-top: 4px;
    word-break: break-all;
}
.detail-code:hover { text-decoration: underline; }

.detail-stats {
    display: flex;
    gap: 16px;
}

.stat-box {
    text-align: center;
    background: rgba(255,255,255,0.5);
    border: 1px solid rgba(255,255,255,0.7);
    border-radius: var(--radius-sm);
    padding: 12px 20px;
}

.stat-num {
    display: block;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-color);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

/* 日別グラフ */
.chart-container {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.chart-bar-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 28px;
}

.chart-bar-wrap {
    display: flex;
    align-items: flex-end;
    height: 130px;
}

.chart-bar {
    width: 22px;
    background: linear-gradient(to top, var(--primary-color), #a8e6cf);
    border-radius: 4px 4px 0 0;
    position: relative;
    transition: height 0.3s;
}

.chart-bar:hover { opacity: 0.8; }

.chart-bar-value {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    white-space: nowrap;
}

.chart-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 4px;
    white-space: nowrap;
}

/* デバイス比率 */
.device-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.device-label {
    width: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    flex-shrink: 0;
}

.device-bar-wrap {
    flex: 1;
    height: 20px;
    background: rgba(0,0,0,0.04);
    border-radius: 10px;
    overflow: hidden;
}

.device-bar {
    height: 100%;
    border-radius: 10px;
    transition: width 0.4s;
}

.device-pct {
    width: 40px;
    text-align: right;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
    flex-shrink: 0;
}

/* リファラー */
.ref-list { font-size: 0.85rem; }

.ref-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(0,0,0,0.04);
    gap: 12px;
}

.ref-url {
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.ref-count {
    font-weight: 700;
    color: var(--text-main);
    flex-shrink: 0;
}

/* 詳細2カラム */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 700px) {
    .detail-grid { grid-template-columns: 1fr; }
    .detail-header { flex-direction: column; }
}

/* ログイン画面 */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

/* アニメーション */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* レスポンシブ */
@media (max-width: 800px) {
    .panels-wrapper {
        flex-direction: column;
        align-items: center;
    }

    .main-panel {
        max-width: 100%;
    }

    .side-panel {
        max-width: 100%;
    }

    .side-panel.active {
        width: 100%;
    }

    /* スマホ: オプション展開時にボタン・結果を下に移動した際のスタイル */
    .panels-wrapper > #action-area {
        width: 100%;
        max-width: 520px;
    }
}

@media (max-width: 600px) {
    .panels-wrapper { padding: 0 14px 16px; }
    .logo-area { padding: 16px 14px 12px; }
    .admin-container { padding: 24px 14px; }
    .glass-card { padding: 24px 18px; }
    .card { padding: 20px 16px; }
    .checkbox-group { flex-direction: column; gap: 8px; }
    .search-bar { flex-direction: column; }
    .select-row { flex-direction: column; gap: 0; }
}
