/*!
 * 珍妮白話翻譯器 — App 樣式（殼層/auth/翻譯頁/設定頁）
 * © 2026 宥爵智能科技有限公司
 * 顏色一律 var(--*)（tokens.css 唯一真相源）。
 */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
}

button { font-family: var(--font); cursor: pointer; }
input, select { font-family: var(--font); }

/* ============ 按鈕 ============ */
.btn-primary {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px 22px;
    font-size: 15px;
    font-weight: 700;
    transition: background 0.15s;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 14px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
}
.btn-ghost:hover { border-color: var(--text-muted); color: var(--text); }

/* ============ Auth Overlay ============ */
.auth-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}
.auth-overlay.hidden { display: none; }

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 34px 30px;
}
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-logo {
    width: 52px; height: 52px;
    margin: 0 auto 12px;
    background: var(--primary);
    color: #fff;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; font-weight: 800;
}
.auth-brand h1 { font-size: 20px; font-weight: 800; }
.auth-brand p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.auth-tabs {
    display: flex;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 18px;
}
.auth-tab {
    flex: 1;
    background: none;
    border: none;
    border-radius: 6px;
    padding: 9px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-muted);
}
.auth-tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.auth-error {
    background: color-mix(in srgb, var(--danger) 10%, transparent);
    color: var(--danger);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 13px;
    margin-bottom: 14px;
}

.auth-form { display: none; }
.auth-form.active { display: block; }
.auth-form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin: 12px 0 6px;
}
.auth-form input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 11px 12px;
    font-size: 15px;
    color: var(--text);
}
.auth-form input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
.auth-form .btn-primary { width: 100%; margin-top: 18px; }
.auth-hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0 14px;
    color: var(--text-muted);
    font-size: 12px;
}
.auth-divider::before, .auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}
.google-btn-slot { display: flex; justify-content: center; }

/* ============ 殼層 ============ */
.app-container { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 250px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
}
.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px 16px;
}
.sidebar-logo {
    width: 38px; height: 38px;
    background: var(--primary);
    color: #fff;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; font-weight: 800;
    flex-shrink: 0;
}
.sidebar-brand { font-size: 15px; font-weight: 800; }
.sidebar-tagline { font-size: 11px; color: var(--text-muted); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 6px 12px; }
.nav-sec {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 14px 8px 6px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); }
.nav-icon { width: 20px; text-align: center; }

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.user-card { display: flex; align-items: center; gap: 10px; }
.user-avatar {
    width: 34px; height: 34px;
    background: var(--primary-soft);
    color: var(--primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800;
    flex-shrink: 0;
}
.user-meta { min-width: 0; }
.user-name { font-size: 13px; font-weight: 700; }
.user-email {
    font-size: 11px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.main-content {
    flex: 1;
    margin-left: 250px;
    padding: 22px 26px;
    min-width: 0;
}

.page { display: none; }
.page.active { display: block; animation: pageIn 0.22s ease; }
@keyframes pageIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

.page-header { margin-bottom: 20px; }
.page-header h1 { font-size: 22px; font-weight: 800; }
.page-header p { font-size: 13px; color: var(--text-muted); margin-top: 3px; }

/* 手機 */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 14px; left: 14px;
    z-index: 90;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    width: 40px; height: 40px;
    font-size: 17px;
    color: var(--text);
    box-shadow: var(--shadow);
}
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 95;
}
.sidebar-backdrop.active { display: block; }

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.22s ease; }
    .sidebar.open { transform: none; }
    .mobile-toggle { display: block; }
    .main-content { margin-left: 0; padding: 64px 14px 20px; }
}

/* ============ Toast ============ */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(16px);
    background: var(--text);
    color: var(--bg);
    border-radius: 999px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    opacity: 0;
    transition: all 0.25s ease;
    z-index: 3000;
    max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); color: #fff; }
.toast.success { background: var(--accent); color: #fff; }

/* ============ Modal ============ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 24px;
    max-width: 440px;
    width: 100%;
}

/* ============ 翻譯頁 ============ */
.tr-langbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 14px;
    margin-bottom: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
}
.tr-mode-badge {
    background: var(--primary-soft);
    color: var(--primary);
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 700;
}

.tr-feed {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: calc(100vh - 130px);
    min-height: 45vh;
    overflow-y: auto;
    padding: 4px 2px 40px;
    -webkit-overflow-scrolling: touch;
}

.tr-feed-hint {
    margin: auto;
    text-align: center;
    color: var(--text-muted);
}
.tr-feed-hint-icon { font-size: 44px; margin-bottom: 12px; opacity: 0.6; }
.tr-feed-hint p { font-size: 18px; font-weight: 700; color: var(--text); }
.tr-feed-hint .tr-feed-hint-sub { font-size: 13px; font-weight: 500; color: var(--text-muted); margin-top: 6px; }

.tr-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 20px;
    font-size: 22px;
    font-weight: 600;
    line-height: 1.5;
    word-break: break-word;
    overflow-wrap: anywhere;
    animation: cardIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes cardIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}
.tr-card.to-a { border-left: 4px solid var(--side-a); }
.tr-card.to-a strong { color: var(--side-a); }
.tr-card.to-b { border-left: 4px solid var(--side-b); }
.tr-card.to-b strong { color: var(--side-b); }
.tr-card p { margin: 0 0 6px; }
.tr-card p:last-child { margin-bottom: 0; }
.tr-card ul { margin: 0; padding-inline-start: 1.2em; }
.tr-card li { margin: 5px 0; }
.tr-card[dir="rtl"] { text-align: right; }

.tr-statusbar {
    position: fixed;
    bottom: 18px;
    right: 18px;
    z-index: 900;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: var(--shadow);
    padding: 7px 15px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.tr-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.tr-dot.listening { background: var(--accent); animation: trPulse 1.6s ease-in-out infinite; }
.tr-dot.reconnecting { background: var(--warn); }
@keyframes trPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.8); }
}

.tr-overlay {
    position: fixed;
    inset: 0;
    z-index: 2500;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 30px;
    cursor: pointer;
}
.tr-overlay-icon { font-size: 52px; margin-bottom: 16px; }
.tr-overlay-title { font-size: 24px; font-weight: 800; line-height: 1.4; max-width: 480px; }
.tr-overlay-hint { font-size: 16px; font-weight: 600; color: var(--text-muted); margin-top: 10px; }
.tr-retry-btn { margin-top: 24px; padding: 13px 36px; font-size: 16px; border-radius: 999px; }

@media (max-width: 768px) {
    .tr-feed { height: calc(100vh - 170px); }
    .tr-card { font-size: 19px; padding: 14px 16px; }
}

/* ============ 設定頁 ============ */
.settings-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 14px;
    max-width: 620px;
}
.settings-section h3 { font-size: 15px; font-weight: 800; margin-bottom: 4px; }
.settings-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }

.input-group { margin-top: 10px; }
.input-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.input-group input,
.input-group select {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 14px;
    color: var(--text);
}
.input-group input:focus,
.input-group select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.input-row { display: flex; gap: 10px; align-items: flex-end; }
.input-row .grow { flex: 1; }

/* 可搜尋語言選單 */
.lang-picker { position: relative; }
.lang-search.searching { border-color: var(--primary); }
.lang-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    max-height: 260px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 50;
}
.lang-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 12px;
    font-size: 14px;
    cursor: pointer;
}
.lang-item:hover, .lang-item.active { background: var(--surface-2); }
.lang-item.selected { color: var(--primary); font-weight: 700; }
.lang-beta {
    background: var(--surface-2);
    color: var(--text-muted);
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 11px;
    font-weight: 700;
}

/* ============ 管理頁（管理員限定）統計磚 ============ */
.admin-period { margin-bottom: 26px; }
.admin-period h3 {
    font-size: 15px;
    font-weight: 800;
    color: var(--text-muted);
    margin: 0 0 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.admin-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}
.admin-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px 18px;
}
.admin-tile-value {
    font-size: 26px;
    font-weight: 800;
    color: var(--text);
    line-height: 1.2;
}
.admin-tile-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}
.admin-tile.accent { border-color: var(--primary); }
.admin-tile.accent .admin-tile-value { color: var(--primary); }
.admin-footnote {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}
