/* ==========================================================================
   Apple Account & Proxy Manager — theme
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --sidebar-width: 252px;
    --topbar-height: 66px;
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --accent: #4f6bfe;
    --accent-dark: #3c53e0;
    --accent-soft: rgba(79, 107, 254, .1);
    --shadow-sm: 0 1px 2px rgba(20, 22, 30, .04), 0 1px 3px rgba(20, 22, 30, .06);
    --shadow-md: 0 4px 14px rgba(20, 22, 30, .07);
    --shadow-lg: 0 12px 32px rgba(20, 22, 30, .12);
    --border-soft: rgba(20, 22, 30, .07);
    --bg-page: #f6f7fb;
    --text-muted: #868a9b;
}

[data-bs-theme="dark"] {
    --border-soft: rgba(255, 255, 255, .08);
    --bg-page: #121319;
    --text-muted: #9599ab;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, .35);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }

body {
    background: var(--bg-page);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    color: #1c1e28;
    -webkit-font-smoothing: antialiased;
}

[data-bs-theme="dark"] body { color: #e7e8ee; }

a { transition: color .15s ease; }

/* ---------------- Layout Shell ---------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #1a1d29 0%, #14161f 100%);
    color: #fff;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 1050;
    transition: transform .25s ease;
}

.sidebar-brand {
    display: flex; align-items: center; gap: 11px;
    padding: 24px 22px; font-weight: 800; font-size: 1.08rem;
    letter-spacing: -.01em;
    border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-brand i {
    font-size: 1.15rem;
    width: 34px; height: 34px;
    display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--accent), #7c5cff);
    border-radius: 10px;
}

.sidebar-nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a {
    color: rgba(255,255,255,.68);
    text-decoration: none;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; gap: 12px;
    font-size: .92rem;
    font-weight: 500;
    transition: background .15s ease, color .15s ease;
}
.sidebar-nav a i { width: 18px; text-align: center; font-size: .95rem; }
.sidebar-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav a.active {
    background: linear-gradient(135deg, var(--accent), #7c5cff);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(79, 107, 254, .35);
}
.sidebar-divider { border-color: rgba(255,255,255,.08); margin: 10px 12px; }

.sidebar-overlay {
    display: none;
    position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1040;
    backdrop-filter: blur(2px);
}

.main-area { flex: 1; margin-left: var(--sidebar-width); display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
    height: var(--topbar-height);
    background: var(--bs-body-bg, #fff);
    border-bottom: 1px solid var(--border-soft);
    display: flex; align-items: center; gap: 16px;
    padding: 0 24px;
    position: sticky; top: 0; z-index: 1030;
}

.topbar-search {
    flex: 1; max-width: 480px;
    display: flex; align-items: center; gap: 10px;
    background: rgba(20,22,30,.04);
    border-radius: 999px;
    padding: 9px 16px;
    transition: background .15s ease, box-shadow .15s ease;
}
.topbar-search:focus-within { box-shadow: 0 0 0 3px var(--accent-soft); background: rgba(20,22,30,.02); }
[data-bs-theme="dark"] .topbar-search { background: rgba(255,255,255,.06); }
[data-bs-theme="dark"] .topbar-search:focus-within { background: rgba(255,255,255,.04); }
.topbar-search i { color: var(--text-muted); font-size: .85rem; }
.topbar-search input {
    border: none; background: transparent; outline: none; width: 100%;
    color: inherit; font-size: .92rem;
}

.topbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }

.btn-icon {
    border: none; background: transparent; width: 40px; height: 40px;
    border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    color: inherit; font-size: 1rem; cursor: pointer;
    transition: background .15s ease, transform .1s ease;
}
.btn-icon:hover { background: rgba(20,22,30,.06); }
.btn-icon:active { transform: scale(.92); }
[data-bs-theme="dark"] .btn-icon:hover { background: rgba(255,255,255,.08); }

.content { padding: 28px; flex: 1; width: 100%; }

/* ---------------- Page bits ---------------- */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 22px; flex-wrap: wrap; gap: 12px;
}
.page-header h1 { font-size: 1.5rem; font-weight: 800; margin: 0; letter-spacing: -.015em; }

.panel {
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}
.panel h2 { font-size: 1.02rem; font-weight: 700; margin-bottom: 14px; letter-spacing: -.01em; }
.panel h2 i { color: var(--accent); margin-right: 7px; }

.form-section { margin-bottom: 30px; }
.form-section h3 { font-size: .98rem; font-weight: 700; margin-bottom: 6px; letter-spacing: -.005em; }
.form-section h3 i { color: var(--accent); margin-right: 7px; }

.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border-soft);
    padding: .55rem .8rem;
    font-size: .92rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-label { font-weight: 600; font-size: .85rem; margin-bottom: 6px; color: #444759; }
[data-bs-theme="dark"] .form-label { color: #c4c6d4; }

.btn { border-radius: var(--radius-sm); font-weight: 600; font-size: .9rem; }
.btn-lg { border-radius: 12px; padding: .65rem 1.3rem; }
.btn-primary { background: linear-gradient(135deg, var(--accent), #6f57f0); border: none; }
.btn-primary:hover { background: linear-gradient(135deg, var(--accent-dark), #5f47e0); }
.btn-dark { background: #1c1e28; border: none; }
[data-bs-theme="dark"] .btn-dark { background: #2a2d3a; }

/* ---------------- Stat cards ---------------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}
@media (max-width: 768px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }

.stat-card {
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex; align-items: center; gap: 14px;
    box-shadow: var(--shadow-sm);
    transition: transform .15s ease, box-shadow .15s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
    width: 46px; height: 46px; border-radius: 13px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; color: #fff; flex-shrink: 0;
}
.stat-total .stat-icon { background: linear-gradient(135deg, #4f6bfe, #6f57f0); }
.stat-active .stat-icon { background: linear-gradient(135deg, #22c58b, #17a575); }
.stat-used .stat-icon { background: linear-gradient(135deg, #ff9d42, #f6752e); }
.stat-unused .stat-icon { background: linear-gradient(135deg, #97a0b5, #767f92); }
.stat-value { font-size: 1.7rem; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.stat-label { color: var(--text-muted); font-size: .82rem; margin-top: 5px; font-weight: 500; }

/* ---------------- Mini rows (dashboard lists) ---------------- */
.mini-row {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 6px; text-decoration: none; color: inherit;
    border-bottom: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    transition: background .12s ease;
}
.mini-row:hover { background: rgba(79,107,254,.05); }
.mini-row:last-child { border-bottom: none; }
.mini-row-title { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .92rem; }

.color-dot {
    width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0;
    box-shadow: 0 0 0 2px var(--bs-body-bg, #fff);
}
.color-dot.lg { width: 16px; height: 16px; }

/* ---------------- Status badges ---------------- */
.badge-status { padding: 4px 11px; border-radius: 999px; font-size: .72rem; font-weight: 700; letter-spacing: .01em; }
.badge-active { background: #d7f5e8; color: #0f7b45; }
.badge-used { background: #ffe8d1; color: #b35c00; }
.badge-unused { background: #eaecf1; color: #5c6068; }
[data-bs-theme="dark"] .badge-active { background: #103826; color: #4ade80; }
[data-bs-theme="dark"] .badge-used { background: #402a0c; color: #fdba74; }
[data-bs-theme="dark"] .badge-unused { background: #2a2d33; color: #b8bcc4; }

/* ---------------- Filter bar ---------------- */
.filter-bar {
    display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px;
}
.filter-bar .form-select { max-width: 180px; }
.search-input-wrap {
    flex: 1; min-width: 240px;
    display: flex; align-items: center; gap: 10px;
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm); padding: 9px 14px;
    transition: box-shadow .15s ease;
}
.search-input-wrap:focus-within { box-shadow: 0 0 0 3px var(--accent-soft); }
.search-input-wrap i { color: var(--text-muted); }
.search-input-wrap input { border: none; outline: none; background: transparent; width: 100%; color: inherit; font-size: .92rem; }

/* ---------------- Account table ---------------- */
.account-table thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); border-bottom-width: 1px; font-weight: 700; padding-bottom: 12px; }
.account-table td { vertical-align: middle; font-size: .9rem; }
.account-table tbody tr { transition: background .12s ease; }
.account-table tbody tr:hover { background: rgba(79,107,254,.04); }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; }

/* ---------------- Mobile cards ---------------- */
.account-card-list { display: flex; flex-direction: column; gap: 12px; }
.account-mobile-card {
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    padding: 15px;
    background: var(--bs-body-bg, #fff);
    box-shadow: var(--shadow-sm);
}
.account-mobile-card-top { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.account-mobile-card-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: .84rem; margin-bottom: 11px; }
.account-mobile-card-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.account-mobile-card-actions .btn { flex: 1; min-width: 70px; }

/* ---------------- Quick Login Card ---------------- */
.quick-login-card {
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--border-soft);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
    max-width: 720px;
}
.quick-login-header { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.quick-login-name { font-size: 1.22rem; font-weight: 800; letter-spacing: -.01em; }

.qlc-group { margin-bottom: 22px; }
.qlc-group h4 { font-size: .78rem; text-transform: uppercase; color: var(--text-muted); font-weight: 700; margin-bottom: 10px; letter-spacing: .06em; }

.qlc-field {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 0; border-bottom: 1px solid var(--border-soft);
}
.qlc-label { width: 140px; flex-shrink: 0; color: var(--text-muted); font-size: .85rem; font-weight: 500; }
.qlc-value { flex: 1; font-weight: 600; word-break: break-all; font-size: .92rem; }
.qlc-secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .02em; }

.btn-copy {
    border: none; background: var(--accent-soft); color: var(--accent);
    width: 34px; height: 34px; border-radius: var(--radius-sm); flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    font-size: .85rem; cursor: pointer;
    transition: background .15s ease, transform .1s ease;
}
.btn-copy:hover { background: rgba(79,107,254,.22); }
.btn-copy:active { transform: scale(.92); }

.qlc-combo {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    background: rgba(20,22,30,.03);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm); padding: 13px 15px; margin-top: 10px;
}
[data-bs-theme="dark"] .qlc-combo { background: rgba(255,255,255,.04); }
.qlc-combo-code { word-break: break-all; font-size: .84rem; }
.qlc-combo .btn-copy { width: auto; padding: 0 12px; }

.quick-login-footer {
    display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px;
}
.quick-login-footer .btn { flex: 1; min-width: 150px; }

/* ---------------- Responsive: mobile sidebar ---------------- */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: translateX(0); }
    .main-area { margin-left: 0; }
    .sidebar-overlay.show { display: block; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .qlc-label { width: 112px; font-size: .78rem; }
}

@media (max-width: 575.98px) {
    .content { padding: 16px; }
    .page-header h1 { font-size: 1.3rem; }
    .quick-login-footer .btn { min-width: 100%; }
    .quick-login-card { padding: 18px; }
}

/* ---------------- Pagination ---------------- */
.pagination { flex-wrap: wrap; gap: 4px; }
.page-link {
    border-radius: var(--radius-sm) !important;
    border-color: var(--border-soft);
    color: inherit;
    font-weight: 600;
    font-size: .88rem;
}
.page-item.active .page-link {
    background: linear-gradient(135deg, var(--accent), #6f57f0);
    border-color: transparent;
}
.page-link:hover { background: var(--accent-soft); }

/* ---------------- Login page ---------------- */
.guest-body {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: radial-gradient(circle at top left, rgba(79,107,254,.12), transparent 55%),
                radial-gradient(circle at bottom right, rgba(124,92,255,.1), transparent 55%),
                var(--bg-page);
}
.guest-wrapper { width: 100%; max-width: 400px; padding: 20px; }
.login-card {
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 34px 30px;
    box-shadow: var(--shadow-lg);
}
.login-brand { text-align: center; margin-bottom: 26px; }
.login-brand i {
    font-size: 1.7rem; color: #fff;
    width: 56px; height: 56px;
    display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--accent), #7c5cff);
    border-radius: 16px;
    box-shadow: 0 8px 20px rgba(79,107,254,.35);
}
.login-brand h1 { font-size: 1.3rem; font-weight: 800; margin: 14px 0 2px; letter-spacing: -.01em; }

/* ---------------- iOS Safari zoom prevention ----------------
   Safari auto-zooms the page when focusing any input/select/textarea
   with a computed font-size under 16px, and that zoom can persist
   after a reload. Force 16px on all form fields on small screens. */
@media (max-width: 767.98px) {
    input, select, textarea,
    .form-control, .form-select,
    .topbar-search input, .search-input-wrap input {
        font-size: 16px !important;
    }
}
