/* ===========================
   Carbon Panel - Desktop Styles
   =========================== */

:root {
        --primary-color: #4361ee;
        --danger-color: #ef233c;
        --success-color: #2a9d8f;
        --warning-color: #ff9f1c;
        --light-color: #f8f9fa;
        --dark-color: #212529;
        --border-radius: 10px;
        --box-shadow: 0 4px 20px rgba(0,0,0,0.1);
        /* Light mode tokens */
        --bg:         #f5f7fb;
        --surface:    #ffffff;
        --surface-2:  #f8f9fa;
        --text:       #212529;
        --text-muted: #6b7280;
        --border:     #e0e0e0;
        --header-bg:  #ffffff;
        --header-border: #e8e8e8;
        --input-bg:   #ffffff;
        --card-shadow: 0 4px 20px rgba(0,0,0,0.08);
    }
    body.dark-mode {
        --bg:         #0f1117;
        --surface:    #1a1d27;
        --surface-2:  #22263a;
        --text:       #e2e8f0;
        --text-muted: #94a3b8;
        --border:     #2d3248;
        --header-bg:  #1a1d27;
        --header-border: #2d3248;
        --input-bg:   #22263a;
        --card-shadow: 0 4px 20px rgba(0,0,0,0.4);
        --light-color: #22263a;
        --dark-color:  #e2e8f0;
    }
    * { margin: 0; padding: 0; box-sizing: border-box; }
    body {
        font-family: 'Segoe UI', Roboto, sans-serif;
        background-color: var(--bg);
        color: var(--text);
        line-height: 1.6;
        transition: background-color 0.25s, color 0.25s;
    }
    .container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
    h1, h2, h3 { font-weight: 600; margin-bottom: 20px; color: var(--text); }
    .card { background: var(--surface); border-radius: var(--border-radius); padding: 24px; margin-bottom: 20px; box-shadow: var(--box-shadow); }

    /* ── Top header (PC) — white bar ── */
    .top-header { background: var(--header-bg); width: 100%; padding: 0 28px; height: 60px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 500; box-shadow: 0 2px 8px rgba(0,0,0,0.08); border-bottom: 1px solid var(--header-border); gap: 0; }
    .top-header-title { font-size: 19px; font-weight: 700; color: var(--primary-color); white-space: nowrap; display: flex; align-items: center; gap: 8px; }
    .top-header-title i { font-size: 17px; }

    /* PC inline nav links */
    .pc-nav-links { display: flex; align-items: center; gap: 2px; flex: 1; padding-left: 28px; }
    .pc-nav-links button { background: none; border: none; color: var(--text-muted); font-size: 14px; font-weight: 500; padding: 6px 14px; border-radius: 6px; cursor: pointer; transition: background 0.15s, color 0.15s; width: auto; margin: 0; }
    .pc-nav-links button:hover { background: rgba(67,97,238,0.1); color: var(--primary-color); transform: none; }
    .pc-nav-links button.active { background: rgba(67,97,238,0.12); color: var(--primary-color); font-weight: 700; }

    /* PC user dropdown */
    .pc-user-dropdown { position: relative; display: flex; align-items: center; }
    .pc-user-btn { background: none; border: 1px solid var(--border); color: var(--text); font-size: 14px; font-weight: 600; padding: 7px 14px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; gap: 8px; white-space: nowrap; width: auto; margin: 0; transition: background 0.15s, border-color 0.15s; }
    .pc-user-btn:hover { background: var(--surface-2); border-color: var(--text-muted); transform: none; }
    .pc-user-btn i.fa-user-circle { font-size: 18px; color: var(--primary-color); }
    .pc-user-btn i.fa-chevron-down { font-size: 11px; color: #888; }
    .pc-dropdown-menu { display: none; position: absolute; top: calc(100% + 10px); right: 0; min-width: 210px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.12); z-index: 600; overflow: hidden; }
    .pc-user-dropdown.active .pc-dropdown-menu { display: block; }
    .pc-dropdown-header { padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 12px; color: #888; font-weight: 500; }
    .pc-dropdown-item { display: flex; align-items: center; gap: 10px; padding: 11px 16px; font-size: 14px; font-weight: 500; color: var(--text); cursor: pointer; border: none; background: var(--surface); width: 100%; text-align: left; transition: background 0.15s; margin: 0; border-radius: 0; }
    .pc-dropdown-item:hover { background: var(--surface-2); transform: none; }
    .pc-dropdown-item i { width: 16px; color: #888; }
    .pc-dropdown-logout { border-top: 1px solid #eee; color: var(--danger-color) !important; }
    .pc-dropdown-logout i { color: var(--danger-color) !important; }
    .pc-dropdown-logout:hover { background: rgba(239,35,60,0.08) !important; }

    /* Hamburger — hidden on PC */
    .hamburger-button { display: none; background: none; border: none; cursor: pointer; padding: 8px; align-items: center; justify-content: center; margin: 0; width: auto; }
    .hamburger-icon { width: 24px; height: 18px; display: flex; flex-direction: column; justify-content: space-between; }
    .hamburger-icon span { width: 100%; height: 2.5px; background: var(--dark-color); border-radius: 2px; }

    /* Mobile dropdown — hidden on PC */
    .dropdown { position: relative; display: none; }
    .dropdown-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 499; display: none; }
    .dropdown-content { display: none; position: fixed; top: 60px; right: 0; width: 270px; background: #181b2d; border-radius: 0 0 0 14px; box-shadow: -6px 6px 32px rgba(0,0,0,0.45); z-index: 600; max-height: calc(100vh - 60px); overflow-y: auto; padding-bottom: 8px; }
    .dropdown-content::-webkit-scrollbar { width: 6px; }
    #referralsList::-webkit-scrollbar { height: 6px; }
    #referralsList::-webkit-scrollbar-track { background: #f0f0f0; border-radius: 3px; }
    #referralsList::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
    #referralsList::-webkit-scrollbar-thumb:hover { background: #aaa; }

    /* ── Dark mode overrides for elements using hardcoded colours ── */
    body.dark-mode .key-history-item { background: var(--surface-2); }
    body.dark-mode .user-info-display { background: var(--surface-2); }
    body.dark-mode .expiration-banner { background: #1a3a2a; color: #6ee7b7; }
    body.dark-mode th { background: var(--surface-2) !important; color: var(--text); }
    body.dark-mode td { color: var(--text); }
    body.dark-mode .auth-nav a:not(.active) { color: var(--primary-color); }
    body.dark-mode .auth-nav a.active { background: var(--primary-color); color: #fff !important; }
    body.dark-mode .auth-nav a:hover:not(.active) { background: var(--surface-2); }
    body.dark-mode .close { color: var(--text-muted); }
    body.dark-mode .close:hover { color: var(--text); }
    body.dark-mode select option { background: var(--surface); color: var(--text); }
    body.dark-mode input:-webkit-autofill,
    body.dark-mode input:-webkit-autofill:hover,
    body.dark-mode input:-webkit-autofill:focus { -webkit-box-shadow: 0 0 0 1000px var(--input-bg) inset !important; -webkit-text-fill-color: var(--text) !important; caret-color: var(--text); border-color: var(--border) !important; }
    body.dark-mode .maintenance-content { background: var(--surface); border-color: var(--border); }
    body.dark-mode .maintenance-content h1 { color: var(--text); }
    body.dark-mode .maintenance-content p { color: var(--text-muted); }
    body.dark-mode .account-expired-message { background: var(--surface); }
    body.dark-mode .generate-tab-balance-box { background: var(--surface-2); }
    body.dark-mode label { color: var(--text); }
    body.dark-mode .section-header p { color: var(--text-muted); }
    body.dark-mode .info-label { color: var(--text-muted); }
    body.dark-mode .info-value { color: var(--text); }
    body.dark-mode .price-item { color: var(--text); }

    /* ── Notification bell ── */
    .notif-bell-wrap { position: relative; display: flex; align-items: center; margin-right: 8px; }
    .notif-bell-btn { background: none; border: none; cursor: pointer; padding: 8px; width: auto; margin: 0; color: var(--text-muted); font-size: 18px; border-radius: 8px; transition: background 0.15s; }
    .notif-bell-btn:hover { background: var(--surface-2); transform: none; }
    .notif-badge { position: absolute; top: 4px; right: 4px; background: var(--danger-color); color: #fff; font-size: 10px; font-weight: 700; border-radius: 50%; width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; pointer-events: none; }
    .notif-badge.hidden { display: none; }
    .notif-dropdown { display: none; position: absolute; top: calc(100% + 8px); right: 0; width: 320px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.15); z-index: 700; overflow: hidden; }
    .notif-bell-wrap.open .notif-dropdown { display: block; }
    .notif-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
    .notif-header span { font-size: 14px; font-weight: 600; color: var(--text); }
    .notif-header button { background: none; border: none; color: var(--primary-color); font-size: 12px; cursor: pointer; padding: 4px 8px; width: auto; margin: 0; font-weight: 600; }
    .notif-list { max-height: 300px; overflow-y: auto; }
    .notif-item { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.15s; }
    .notif-item:hover { background: var(--surface-2); }
    .notif-item.unread { background: rgba(67,97,238,0.06); }
    .notif-item.unread:hover { background: rgba(67,97,238,0.1); }
    .notif-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 5px; }
    .notif-dot.info    { background: var(--primary-color); }
    .notif-dot.success { background: var(--success-color); }
    .notif-dot.warning { background: var(--warning-color); }
    .notif-dot.danger  { background: var(--danger-color); }
    .notif-text { font-size: 13px; color: var(--text); line-height: 1.4; flex: 1; }
    .notif-time { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
    .notif-empty { padding: 24px 16px; text-align: center; font-size: 13px; color: var(--text-muted); }

    /* ── Announcement banner ── */
    .announcement-bar { padding: 12px 20px; font-size: 14px; font-weight: 500; border-radius: var(--border-radius); margin-bottom: 16px; display: none; align-items: center; justify-content: space-between; gap: 12px; }
    .announcement-bar.show { display: flex; }
    .announcement-bar.info    { background: rgba(67,97,238,0.12); color: var(--primary-color); border: 1px solid rgba(67,97,238,0.25); }
    .announcement-bar.success { background: rgba(42,157,143,0.12); color: var(--success-color); border: 1px solid rgba(42,157,143,0.25); }
    .announcement-bar.warning { background: rgba(255,159,28,0.12); color: #b36c00; border: 1px solid rgba(255,159,28,0.3); }
    .announcement-bar.danger  { background: rgba(239,35,60,0.1); color: var(--danger-color); border: 1px solid rgba(239,35,60,0.2); }
    .announcement-bar button  { background: none; border: none; cursor: pointer; font-size: 18px; padding: 0 4px; width: auto; margin: 0; opacity: 0.6; color: inherit; }
    .announcement-bar button:hover { opacity: 1; transform: none; }

    /* ── Ban badge in user table ── */
    .ban-badge { background: #fde8ea; color: var(--danger-color); padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; margin-left: 6px; }
    body.dark-mode .ban-badge { background: rgba(239,35,60,0.2); }

    /* Settings modal */
    .settings-modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); }
    .settings-modal.open { display: flex; align-items: center; justify-content: center; }
    .settings-content { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; width: 90%; max-width: 400px; box-shadow: 0 12px 40px rgba(0,0,0,0.2); animation: modalFadeIn 0.2s; color: var(--text); }
    .settings-content h3 { margin-bottom: 20px; font-size: 18px; display: flex; align-items: center; gap: 10px; }
    #changePwChevron { transition: transform 0.25s ease; flex-shrink: 0; }
    #changePwForm.pw-open { padding-top: 12px; }
    .settings-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border); }
    .settings-row:last-child { border-bottom: none; padding-bottom: 0; }
    .settings-row label { font-size: 14px; font-weight: 500; color: var(--text); }
    .settings-row p { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
    /* Toggle switch */
    .toggle-switch { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
    .toggle-switch input { opacity: 0; width: 0; height: 0; }
    .toggle-slider { position: absolute; cursor: pointer; inset: 0; background: #ccc; border-radius: 24px; transition: 0.2s; }
    .toggle-slider:before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: 0.2s; }
    input:checked + .toggle-slider { background: var(--primary-color); }
    input:checked + .toggle-slider:before { transform: translateX(20px); }
    .dropdown-content::-webkit-scrollbar-track { background: #1a1d27; }
    .dropdown-content::-webkit-scrollbar-thumb { background: #3a3f5c; border-radius: 3px; }
    .dropdown.active .dropdown-content { display: block; }

    /* Greeting header */
    .dropdown-greeting {
        padding: 18px 20px 14px;
        border-bottom: 1px solid rgba(255,255,255,0.07);
        background: linear-gradient(135deg, #12152a 0%, #1a1d2e 100%);
    }
    .dropdown-greeting-label {
        font-size: 11px;
        font-weight: 600;
        color: rgba(255,255,255,0.4);
        text-transform: uppercase;
        letter-spacing: 0.08em;
        margin-bottom: 4px;
    }
    .dropdown-greeting-name {
        font-size: 15px;
        font-weight: 700;
        color: #fff;
        display: flex;
        align-items: center;
        gap: 8px;
    }
    .dropdown-greeting-name i {
        color: var(--primary-color);
        font-size: 16px;
    }

    /* Section label inside menu */
    .dropdown-section-label {
        font-size: 10px;
        font-weight: 700;
        color: rgba(255,255,255,0.3);
        text-transform: uppercase;
        letter-spacing: 0.1em;
        padding: 12px 20px 4px;
    }

    /* Nav items */
    .dropdown-item {
        color: rgba(255,255,255,0.78);
        display: flex;
        align-items: center;
        cursor: pointer;
        border: none;
        background: transparent;
        width: 100%;
        text-align: left;
        font-size: 14px;
        font-weight: 500;
        transition: background 0.15s, color 0.15s, border-left-color 0.15s;
        white-space: nowrap;
        margin: 0;
        border-radius: 0;
        border-left: 3px solid transparent;
        min-height: 46px;
        padding: 0 20px 0 17px;
        gap: 12px;
    }
    .dropdown-item:hover {
        background: rgba(255,255,255,0.06);
        color: #fff;
        transform: none;
        border-left-color: rgba(67,97,238,0.5);
    }
    .dropdown-item.active {
        background: rgba(67,97,238,0.15);
        color: #fff;
        border-left-color: var(--primary-color);
        font-weight: 600;
    }
    .dropdown-item i {
        width: 18px;
        font-size: 14px;
        text-align: center;
        flex-shrink: 0;
        opacity: 0.7;
        margin-right: 0;
    }
    .dropdown-item.active i { opacity: 1; }
    .dropdown-item:hover i  { opacity: 1; }

    /* Icon accent colours by section */
    .dropdown-item[onclick*="dashboard"] i { color: #60a5fa; }
    .dropdown-item[onclick*="'keys'"] i    { color: #f59e0b; }
    .dropdown-item[onclick*="generateKey"] i { color: #34d399; }
    .dropdown-item[onclick*="referrals"] i { color: #a78bfa; }
    .dropdown-item[onclick*="users"] i     { color: #38bdf8; }
    .dropdown-item[onclick*="addCredits"] i { color: #fbbf24; }
    .dropdown-item[onclick*="maintenance"] i { color: #fb923c; }
    .dropdown-item[onclick*="topupRequests"] i { color: #4ade80; }
    .dropdown-item[onclick*="openSettings"] i { color: #94a3b8; }

    /* Divider before utility group */
    .dropdown-divider {
        height: 1px;
        background: rgba(255,255,255,0.07);
        margin: 6px 0;
    }

    /* Logout */
    .dropdown-logout {
        color: #fc8181 !important;
        background: transparent !important;
        border-left-color: transparent !important;
    }
    .dropdown-logout i { color: #fc8181 !important; opacity: 1 !important; }
    .dropdown-logout:hover {
        background: rgba(239,35,60,0.12) !important;
        border-left-color: var(--danger-color) !important;
        color: #ff6b6b !important;
    }

    /* ── Page layout ── */
    .page-body { padding: 24px 28px; max-width: 1280px; margin: 0 auto; }

    /* Sub-navbar (mobile only) */
    .navbar { display: none; background: var(--surface); }
    .nav-brand { font-size: 18px; font-weight: 700; color: var(--primary-color); }
    .nav-user-info { display: flex; align-items: center; gap: 10px; }
    .user-balance { background: var(--success-color); color: white; padding: 6px 14px; border-radius: 20px; font-weight: 600; font-size: 14px; }
    .user-rank { background: var(--primary-color); color: white; padding: 6px 14px; border-radius: 20px; font-weight: 600; font-size: 14px; }

    /* ── Dashboard two-column (PC) ── */
    .dashboard-grid { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
    .dashboard-left { min-width: 0; }
    .dashboard-right { display: flex; flex-direction: column; gap: 20px; }
    .welcome-bar { background: var(--surface); border-radius: var(--border-radius); padding: 13px 20px; margin-bottom: 20px; box-shadow: var(--box-shadow); font-size: 15px; color: #555; }
    .welcome-bar strong { color: var(--primary-color); }
    .info-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
    .info-row:last-child { border-bottom: none; padding-bottom: 0; }
    .info-label { color: #888; font-weight: 500; }
    .info-value { font-weight: 600; color: var(--dark-color); }

    /* ── Section page header ── */
    .section-header { margin-bottom: 20px; }
    .section-header h2 { margin: 0; font-size: 22px; color: var(--dark-color); }
    .section-header p { margin: 4px 0 0; color: #888; font-size: 14px; }

    /* ── Generate key layout ── */
    .generate-grid { display: grid; grid-template-columns: 1fr 280px; gap: 20px; align-items: start; }
    /* ── Login Loading Spinner ───────────────────────────────────────────── */
    .login-spinner-overlay {
        position: fixed; inset: 0;
        background: rgba(0,0,0,0.45);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        display: flex; align-items: center; justify-content: center;
        z-index: 9999;
    }
    .login-spinner-box {
        background: var(--surface);
        border-radius: 16px;
        padding: 36px 40px;
        display: flex; flex-direction: column; align-items: center; gap: 18px;
        box-shadow: 0 8px 32px rgba(0,0,0,0.28);
        min-width: 200px;
    }
    .login-spinner-ring {
        width: 48px; height: 48px;
        border: 4px solid var(--border);
        border-top-color: var(--primary-color);
        border-radius: 50%;
        animation: loginSpin 0.75s linear infinite;
    }
    @keyframes loginSpin {
        to { transform: rotate(360deg); }
    }
    .login-spinner-msg {
        font-size: 14px; font-weight: 500;
        color: var(--text-muted);
        text-align: center;
    }

    /* ── Show Password Toggle ────────────────────────────────────────────── */
    .input-password-wrap {
        position: relative; display: flex; align-items: center;
    }
    .input-password-wrap input {
        padding-right: 44px;
        margin-bottom: 0;
        width: 100%;
    }
    .show-password-btn {
        position: absolute; right: 0; top: 0; bottom: 0;
        width: 42px;
        background: none !important;
        border: none !important;
        color: var(--text-muted) !important;
        cursor: pointer;
        display: flex; align-items: center; justify-content: center;
        padding: 0; margin: 0;
        border-radius: 0 8px 8px 0;
        transition: color 0.15s;
        font-size: 15px;
    }
    .show-password-btn:hover {
        color: var(--primary-color) !important;
        background: none !important;
        transform: none !important;
    }
