/* =========================================================
 Dark Theme
 ========================================================= */

/* ── Core variables (dark) ── */
:root[data-theme="dark"] {
    /* Surface */
    --white: #1a1c22;
    --bg: #101216;
    --bg-soft: #161a26;
    --gray-50: #1e2129;
    --gray-100: #262a33;
    --gray-200: #30353f;
    --gray-300: #3e444f;
    --gray-400: #5e6572;
    --gray-500: #9aa1ad;
    /* Text */
    --text: #e7e9ee;
    --text-medium: #c1c5cd;
    --text-light: #9aa1ad;
    --text-muted: #6f7681;
    /* Borders */
    --border: #2c313a;
    --border-light: #24272e;
    --glass-border: rgba(255, 255, 255, .08);
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, .35);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, .45);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, .5);
    --shadow-xl: 0 12px 40px rgba(0, 0, 0, .55);
    color-scheme: dark;
}

:root[data-theme="dark"] body {
    background: var(--bg);
}

/* ── Keep true white where colour sits on a brand/gradient ── */
:root[data-theme="dark"] .sidebar-logo-text strong,
:root[data-theme="dark"] .sidebar-link.active,
:root[data-theme="dark"] .btn-primary,
:root[data-theme="dark"] .btn-primary:hover,
:root[data-theme="dark"] .btn-secondary:hover:not(:disabled),
:root[data-theme="dark"] .btn-success:hover:not(:disabled),
:root[data-theme="dark"] .btn-danger:hover:not(:disabled),
:root[data-theme="dark"] .nav-cta,
:root[data-theme="dark"] .nav-cta:hover,
:root[data-theme="dark"] .header-nav .nav-logout,
:root[data-theme="dark"] .header-nav .nav-logout:hover,
:root[data-theme="dark"] .logo-icon,
:root[data-theme="dark"] .user-avatar,
:root[data-theme="dark"] .launch-card:hover .launch-go,
:root[data-theme="dark"] .dashboard-hero,
:root[data-theme="dark"] .hero-copy h1,
:root[data-theme="dark"] .landing-hero-icon,
:root[data-theme="dark"] .glass-card-icon,
:root[data-theme="dark"] .step-number,
:root[data-theme="dark"] .auth-page-body .right-content h2,
:root[data-theme="dark"] footer,
:root[data-theme="dark"] footer a:hover {
    color: #fff;
}

:root[data-theme="dark"] .nav-cta,
:root[data-theme="dark"] .nav-cta:hover,
:root[data-theme="dark"] .header-nav .nav-logout,
:root[data-theme="dark"] .header-nav .nav-logout:hover {
    color: #fff !important;
}

/* ── App shell highlights ── */
:root[data-theme="dark"] .topbar {
    background: rgba(16, 18, 22, .85);
    border-bottom-color: rgba(255, 255, 255, .08);
}

:root[data-theme="dark"] .topbar-search {
    background: rgba(255, 255, 255, .06);
    border-color: rgba(255, 255, 255, .08);
}

    :root[data-theme="dark"] .topbar-search:focus-within {
        background: #1a1c22;
        border-color: rgba(148, 53, 111, .4);
    }

:root[data-theme="dark"] .app-footer {
    background: linear-gradient(180deg, rgba(16, 18, 22, .95) 0%, rgba(26, 28, 34, .98) 100%);
}

:root[data-theme="dark"] .bell-badge {
    border-color: #1a1c22;
}

/* ── Auth / public header ── */
:root[data-theme="dark"] .main-header,
:root[data-theme="dark"] .floating-nav {
    background: rgba(16, 18, 22, .96);
    border-bottom-color: var(--border-light);
}

:root[data-theme="dark"] .main-header {
    background: linear-gradient(135deg, #1a0c15 0%, #2b0d22 35%, #3d1530 70%, #5a1f45 100%) !important;
    border: none;
}

:root[data-theme="dark"] .auth-page-body {
    background: #0e1218;
}

:root[data-theme="dark"] .auth-page-body .login-left,
:root[data-theme="dark"] .auth-page-body .login-left::after {
    background: #1a1c22;
}

:root[data-theme="dark"] .auth-page-body .input-icon-wrap input,
:root[data-theme="dark"] .auth-page-body .input-icon-wrap select {
    background: #23262e;
    border-color: #343a46;
}

    :root[data-theme="dark"] .auth-page-body .input-icon-wrap input:focus,
    :root[data-theme="dark"] .auth-page-body .input-icon-wrap select:focus {
        background: #1a1c22;
    }

:root[data-theme="dark"] .auth-footer {
    border-top-color: #343a46;
}

/* ── Status pills / priority chips ── */
:root[data-theme="dark"] .app-status.active,
:root[data-theme="dark"] .st-resolved {
    background: #15271b;
    color: #7ed491;
}

:root[data-theme="dark"] .app-status.inactive {
    background: #331d1d;
    color: #e08a8a;
}

:root[data-theme="dark"] .app-status.disabled,
:root[data-theme="dark"] .prio-low,
:root[data-theme="dark"] .st-closed,
:root[data-theme="dark"] .st-archived {
    background: #242830;
    color: #8a919c;
}

:root[data-theme="dark"] .prio-medium,
:root[data-theme="dark"] .st-progress {
    background: #2a2110;
    color: #e9a94f;
}

:root[data-theme="dark"] .prio-high {
    background: #2b1d10;
    color: #ec9357;
}

:root[data-theme="dark"] .prio-urgent {
    background: #301318;
    color: #ef93a4;
}

:root[data-theme="dark"] .st-open {
    background: #161f33;
    color: #7fa4ea;
}

/* ── Success tinted text / badges ── */
:root[data-theme="dark"] .status-pill,
:root[data-theme="dark"] .security-banner-icon,
:root[data-theme="dark"] .security-status-text,
:root[data-theme="dark"] .settings-toast,
:root[data-theme="dark"] .profile-stat-badge.badge-ok,
:root[data-theme="dark"] .mfa-step.done .mfa-step-num {
    color: #6fe08a;
}

:root[data-theme="dark"] .alert-success {
    color: #7ed491;
}

:root[data-theme="dark"] .alert-danger,
:root[data-theme="dark"] .alert-error,
:root[data-theme="dark"] .alert-delete {
    color: #ef93a4;
}

:root[data-theme="dark"] .alert-warning {
    color: #f0be6a;
}

:root[data-theme="dark"] .alert-info {
    color: #d8a2c3;
}

/* ── Count pills (light brand tint) ── */
:root[data-theme="dark"] .audit-count,
:root[data-theme="dark"] .support-count,
:root[data-theme="dark"] .apps-count-pill {
    color: #e094bd;
}

/* ── Search / select surfaces with literal light greys ── */
:root[data-theme="dark"] .audit-search input,
:root[data-theme="dark"] .audit-filter-group select,
:root[data-theme="dark"] .audit-table thead th,
:root[data-theme="dark"] .apps-search input,
:root[data-theme="dark"] .apps-filter-field select,
:root[data-theme="dark"] .support-search input,
:root[data-theme="dark"] .support-chips .chip,
:root[data-theme="dark"] .faq-cat-head,
:root[data-theme="dark"] .profile-panel,
:root[data-theme="dark"] .signin-table thead th,
:root[data-theme="dark"] .profile-stat-arrow {
    background: var(--gray-50);
}

    :root[data-theme="dark"] .audit-search input:focus,
    :root[data-theme="dark"] .apps-search input:focus,
    :root[data-theme="dark"] .support-search input:focus {
        background: var(--white);
    }

:root[data-theme="dark"] .audit-search svg,
:root[data-theme="dark"] .apps-search svg,
:root[data-theme="dark"] .apps-filter-field svg,
:root[data-theme="dark"] .support-search svg,
:root[data-theme="dark"] .faq-search svg {
    color: var(--gray-400);
}

:root[data-theme="dark"] .support-chips .chip:hover,
:root[data-theme="dark"] .apps-filter-field select:hover {
    border-color: var(--gray-300);
}

:root[data-theme="dark"] .faq-cat-head {
    border-bottom-color: var(--border-light);
}

:root[data-theme="dark"] .signin-table thead th,
:root[data-theme="dark"] .audit-table thead th {
    border-bottom-color: var(--border-light);
}

/* ── Muted icons / dividers ── */
:root[data-theme="dark"] .ticket-meta .dot,
:root[data-theme="dark"] .ticket-arrow,
:root[data-theme="dark"] .ticket-empty svg,
:root[data-theme="dark"] .ticket-sub-row .dot,
:root[data-theme="dark"] .faq-q svg,
:root[data-theme="dark"] .faq-empty svg,
:root[data-theme="dark"] .audit-empty svg {
    color: var(--gray-400);
}

/* ── Switch / sliders ── */
:root[data-theme="dark"] .switch {
    background: #3a3f4a;
}

:root[data-theme="dark"] .switch span {
    background: #e7e9ee;
}

/* ── Theme picker ── */
:root[data-theme="dark"] .theme-option {
    background: var(--white);
    border-color: var(--border);
}

    :root[data-theme="dark"] .theme-option:hover {
        border-color: var(--gray-300);
    }

:root[data-theme="dark"] .theme-option-active {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(148, 53, 111, .15);
}

/* ── Chat / ticket surfaces ── */
:root[data-theme="dark"] .chat-msg.agent .chat-bubble {
    background: var(--white);
    border-color: var(--border);
}

:root[data-theme="dark"] .chat-composer {
    background: var(--white);
    border-color: var(--border);
}

:root[data-theme="dark"] .chat-attach-btn {
    background: var(--bg);
    border-color: var(--border);
}

:root[data-theme="dark"] .chat-msg-imgs img {
    border-color: rgba(255, 255, 255, .08);
}

/* ── Admin client-app surfaces ── */
:root[data-theme="dark"] .app-card-header,
:root[data-theme="dark"] .form-header {
    background: linear-gradient(135deg, #1c1f27, #171a24);
}

:root[data-theme="dark"] .form-card.delete-card .form-header {
    background: linear-gradient(135deg, #2a1818, #261212);
    border-bottom-color: #4a2424;
}

:root[data-theme="dark"] .client-id code,
:root[data-theme="dark"] .scope-badge {
    background: #23272f;
}

:root[data-theme="dark"] .info-box,
:root[data-theme="dark"] .scopes-box {
    background: #191c24;
}

:root[data-theme="dark"] .info-content {
    border-color: #343a46;
    background: var(--white);
}

:root[data-theme="dark"] .warning-box {
    background: #2b1414;
}

    :root[data-theme="dark"] .warning-box p,
    :root[data-theme="dark"] .warning-box ul {
        color: #ec7f7f;
    }

:root[data-theme="dark"] .card-footer-note {
    border-top-color: #343a46;
}

/* ── Auth boxes / alerts ── */
:root[data-theme="dark"] .alert-login {
    background: #2a1616;
    border-color: #472222;
    color: #eba1a1;
}

:root[data-theme="dark"] .alert-login--success {
    background: #12201a;
    border-color: #22462f;
    color: #6fc88c;
}

:root[data-theme="dark"] .alert-login--warning,
:root[data-theme="dark"] .notice-warning {
    background: #26200f;
    border-color: #4d3a14;
    border-left-color: #d68910;
}

:root[data-theme="dark"] .endpoints-box {
    background: #161a26;
}

/* ── Misc ── */
:root[data-theme="dark"] .mfa-qr {
    background: #101216;
}

:root[data-theme="dark"] .mfa-code-msg {
    color: #ec7f7f;
}

:root[data-theme="dark"] .mfa-recovery-code {
    background: #20242c;
}

:root[data-theme="dark"] .mfa-step-num {
    background: var(--border-light);
    color: var(--text-muted);
}

:root[data-theme="dark"] .signin-table thead th,
:root[data-theme="dark"] .audit-table thead th {
    background: var(--gray-50);
}

:root[data-theme="dark"] .launch-go {
    background: rgba(255, 255, 255, .06);
    border-color: rgba(255, 255, 255, .08);
}

/* =========================================================
   RESPONSIVE — THEME
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
    :root[data-theme="dark"] * {
        transition: none !important;
        animation: none !important;
    }
}