/* Global Theme System — CSS Variables */
:root,
html[data-theme="dark"] {
    color-scheme: dark;
    --theme-bg: #0F172A;
    --theme-sidebar: #111827;
    --theme-card: #1E293B;
    --theme-border: #334155;
    --theme-primary: #3B82F6;
    --theme-primary-soft: rgba(59, 130, 246, 0.15);
    --theme-success: #22C55E;
    --theme-warning: #F59E0B;
    --theme-danger: #EF4444;
    --theme-text: #F8FAFC;
    --theme-text-secondary: #CBD5E1;
    --theme-hover: #334155;
    --theme-muted: #64748B;
    --theme-input-bg: #0F172A;
    --theme-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
    --theme-navbar: #111827;
    --cp-primary: #3B82F6;
    --cp-secondary: #60A5FA;
    --cp-success: #22C55E;
    --cp-warning: #F59E0B;
    --cp-danger: #EF4444;
    --cp-bg: #0F172A;
    --cp-card: #1E293B;
    --cp-text: #F8FAFC;
    --cp-text-muted: #CBD5E1;
    --cp-border: #334155;
    --cp-radius: 20px;
}

html[data-theme="light"] {
    color-scheme: light;
    --theme-bg: #F8FAFC;
    --theme-sidebar: #FFFFFF;
    --theme-card: #FFFFFF;
    --theme-border: #E5E7EB;
    --theme-primary: #2563EB;
    --theme-primary-soft: rgba(37, 99, 235, 0.12);
    --theme-success: #22C55E;
    --theme-warning: #F59E0B;
    --theme-danger: #EF4444;
    --theme-text: #111827;
    --theme-text-secondary: #6B7280;
    --theme-hover: #F1F5F9;
    --theme-muted: #9CA3AF;
    --theme-input-bg: #FFFFFF;
    --theme-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
    --theme-navbar: #FFFFFF;
    --cp-primary: #2563EB;
    --cp-secondary: #3B82F6;
    --cp-success: #22C55E;
    --cp-warning: #F59E0B;
    --cp-danger: #EF4444;
    --cp-bg: #F8FAFC;
    --cp-card: #FFFFFF;
    --cp-text: #111827;
    --cp-text-muted: #6B7280;
    --cp-border: #E5E7EB;
}

html {
    background: var(--theme-bg);
}

body,
body.candidate-portal,
body.bg-cpbg,
body.bg-light {
    background: var(--theme-bg) !important;
    color: var(--theme-text);
    transition: background-color 300ms ease, color 300ms ease, border-color 300ms ease;
}

/* Shared components */
.theme-transition,
.theme-transition * {
    transition: background-color 300ms ease, color 300ms ease, border-color 300ms ease, box-shadow 300ms ease;
}

.cp-card,
.glass-card,
.stat-card,
.card {
    background: var(--theme-card) !important;
    color: var(--theme-text);
    border-color: var(--theme-border) !important;
    box-shadow: var(--theme-shadow);
}

.glass-card {
    background: color-mix(in srgb, var(--theme-card) 88%, transparent) !important;
    backdrop-filter: blur(12px);
    border: 1px solid var(--theme-border);
}

.text-muted,
.text-secondary,
.text-gray-500,
.text-gray-400,
.text-gray-600 {
    color: var(--theme-text-secondary) !important;
}

.text-gray-900,
.text-gray-800,
.text-dark {
    color: var(--theme-text) !important;
}

.bg-white,
.bg-cpbg,
.bg-light,
.card-header.bg-white,
.card-header.bg-light {
    background-color: var(--theme-card) !important;
    color: var(--theme-text) !important;
}

/* Card headers — always match theme (fixes white bar + gray title in dark mode) */
.card-header,
.card .card-header,
.stat-card .card-header {
    background-color: var(--theme-hover) !important;
    color: var(--theme-text) !important;
    border-bottom: 1px solid var(--theme-border) !important;
}

.card-header h1,
.card-header h2,
.card-header h3,
.card-header h4,
.card-header h5,
.card-header h6,
.card-header .mb-0,
.card-header .text-muted,
.card-header .text-secondary {
    color: var(--theme-text) !important;
}

.card-body {
    background-color: var(--theme-card);
    color: var(--theme-text);
}

.border,
.border-gray-100,
.border-gray-200,
.border-bottom,
.border-top {
    border-color: var(--theme-border) !important;
}

/* Forms */
.form-control,
.form-select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="date"],
input[type="time"],
textarea,
select {
    background-color: var(--theme-input-bg) !important;
    color: var(--theme-text) !important;
    border-color: var(--theme-border) !important;
}

.form-control:focus,
.form-select:focus,
input:focus,
textarea:focus,
select:focus {
    border-color: var(--theme-primary) !important;
    box-shadow: 0 0 0 0.2rem var(--theme-primary-soft) !important;
}

.form-control::placeholder,
input::placeholder,
textarea::placeholder {
    color: var(--theme-muted) !important;
}

.form-control:disabled,
.form-select:disabled,
input:disabled {
    background-color: var(--theme-hover) !important;
    color: var(--theme-muted) !important;
}

/* Buttons */
.btn-primary,
.bg-primary {
    background-color: var(--theme-primary) !important;
    border-color: var(--theme-primary) !important;
}

.btn-outline-primary {
    color: var(--theme-primary) !important;
    border-color: var(--theme-primary) !important;
}

.btn-outline-primary:hover {
    background: var(--theme-primary) !important;
    color: #fff !important;
}

.btn-light,
.btn-outline-secondary {
    background: var(--theme-hover) !important;
    border-color: var(--theme-border) !important;
    color: var(--theme-text) !important;
}

/* Admin shell */
.sidebar {
    background: var(--theme-sidebar) !important;
    border-right: 1px solid var(--theme-border);
}

.sidebar-nav.nav {
    flex-wrap: nowrap !important;
    flex-direction: column !important;
    min-height: 0;
}

.sidebar-footer {
    background: var(--theme-sidebar) !important;
}

.sidebar .nav-link {
    color: var(--theme-text-secondary) !important;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    background: var(--theme-hover) !important;
    color: var(--theme-text) !important;
}

.sidebar .nav-link.active {
    box-shadow: inset 3px 0 0 var(--theme-primary);
}

.sidebar .border-bottom {
    border-color: var(--theme-border) !important;
}

.sidebar h5,
.sidebar .text-white {
    color: var(--theme-text) !important;
}

.main-content > header,
.admin-topbar {
    background: var(--theme-navbar) !important;
    border-bottom: 1px solid var(--theme-border) !important;
    color: var(--theme-text);
}

.main-content {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--theme-bg);
}

.dropdown-menu {
    background: var(--theme-card) !important;
    border-color: var(--theme-border) !important;
    color: var(--theme-text) !important;
}

.dropdown-item {
    color: var(--theme-text) !important;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background: var(--theme-hover) !important;
    color: var(--theme-text) !important;
}

.table {
    --bs-table-bg: var(--theme-card);
    --bs-table-color: var(--theme-text);
    --bs-table-border-color: var(--theme-border);
    --bs-table-striped-bg: var(--theme-hover);
    --bs-table-hover-bg: var(--theme-hover);
    color: var(--theme-text);
}

.table thead th {
    background: var(--theme-hover) !important;
    color: var(--theme-text) !important;
    border-color: var(--theme-border) !important;
}

.modal-content {
    background: var(--theme-card) !important;
    color: var(--theme-text) !important;
    border-color: var(--theme-border) !important;
}

.modal-header,
.modal-footer {
    border-color: var(--theme-border) !important;
}

.alert {
    border-color: var(--theme-border);
}

.pagination .page-link {
    background: var(--theme-card);
    color: var(--theme-text);
    border-color: var(--theme-border);
}

.pagination .page-item.active .page-link {
    background: var(--theme-primary);
    border-color: var(--theme-primary);
}

.badge.bg-secondary {
    background: var(--theme-hover) !important;
    color: var(--theme-text) !important;
}

/* Candidate portal */
.candidate-shell header,
.candidate-shell nav {
    background: color-mix(in srgb, var(--theme-navbar) 92%, transparent) !important;
    border-color: var(--theme-border) !important;
    color: var(--theme-text);
}

.candidate-shell .bg-gray-50,
.candidate-shell .bg-primary\/10 {
    background-color: var(--theme-hover) !important;
}

html[data-theme="dark"] .candidate-shell .text-gray-900,
html[data-theme="dark"] .candidate-shell .text-gray-800,
html[data-theme="dark"] .candidate-shell .text-dark {
    color: var(--theme-text);
}

/* Soft pastel badges become washed out in dark mode — force solid readable chips */
html[data-theme="dark"] .candidate-shell .bg-green-100,
html[data-theme="dark"] .candidate-shell .bg-green-50,
html[data-theme="dark"] .candidate-shell .bg-green-200 {
    background-color: rgba(34, 197, 94, 0.22) !important;
    color: #86EFAC !important;
}
html[data-theme="dark"] .candidate-shell .text-green-700,
html[data-theme="dark"] .candidate-shell .text-green-800 {
    color: #86EFAC !important;
}

html[data-theme="dark"] .candidate-shell .bg-amber-100,
html[data-theme="dark"] .candidate-shell .bg-amber-50 {
    background-color: rgba(245, 158, 11, 0.22) !important;
    color: #FCD34D !important;
}
html[data-theme="dark"] .candidate-shell .text-amber-700,
html[data-theme="dark"] .candidate-shell .text-amber-800 {
    color: #FCD34D !important;
}

html[data-theme="dark"] .candidate-shell .bg-blue-100,
html[data-theme="dark"] .candidate-shell .bg-blue-50 {
    background-color: rgba(59, 130, 246, 0.22) !important;
    color: #93C5FD !important;
}
html[data-theme="dark"] .candidate-shell .text-blue-700,
html[data-theme="dark"] .candidate-shell .text-blue-800 {
    color: #93C5FD !important;
}

html[data-theme="dark"] .candidate-shell .bg-red-100,
html[data-theme="dark"] .candidate-shell .bg-red-50,
html[data-theme="dark"] .candidate-shell .bg-red-200 {
    background-color: rgba(239, 68, 68, 0.22) !important;
    color: #FCA5A5 !important;
}
html[data-theme="dark"] .candidate-shell .text-red-700,
html[data-theme="dark"] .candidate-shell .text-red-800 {
    color: #FCA5A5 !important;
}

html[data-theme="dark"] .candidate-shell .bg-gray-100,
html[data-theme="dark"] .candidate-shell .bg-gray-200 {
    background-color: var(--theme-hover) !important;
    color: var(--theme-text-secondary) !important;
}

html[data-theme="dark"] .candidate-shell .text-gray-600 {
    color: var(--theme-text-secondary) !important;
}

/* Explicit status chips — highest contrast */
.cp-status-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    white-space: nowrap;
    border: 1px solid transparent;
}
.cp-status-badge.is-completed,
.cp-status-badge.is-ended {
    background: rgba(34, 197, 94, 0.2);
    color: #4ADE80;
    border-color: rgba(34, 197, 94, 0.35);
}
.cp-status-badge.is-active {
    background: rgba(245, 158, 11, 0.2);
    color: #FBBF24;
    border-color: rgba(245, 158, 11, 0.35);
}
.cp-status-badge.is-upcoming {
    background: rgba(59, 130, 246, 0.2);
    color: #60A5FA;
    border-color: rgba(59, 130, 246, 0.35);
}
.cp-status-badge.is-default {
    background: var(--theme-hover);
    color: var(--theme-text-secondary);
    border-color: var(--theme-border);
}
.cp-status-badge.is-fail {
    background: rgba(239, 68, 68, 0.2);
    color: #F87171;
    border-color: rgba(239, 68, 68, 0.35);
}

html[data-theme="light"] .cp-status-badge.is-completed,
html[data-theme="light"] .cp-status-badge.is-ended {
    background: #DCFCE7;
    color: #166534;
    border-color: #BBF7D0;
}
html[data-theme="light"] .cp-status-badge.is-active {
    background: #FEF3C7;
    color: #92400E;
    border-color: #FDE68A;
}
html[data-theme="light"] .cp-status-badge.is-upcoming {
    background: #DBEAFE;
    color: #1E40AF;
    border-color: #BFDBFE;
}
html[data-theme="light"] .cp-status-badge.is-fail {
    background: #FEE2E2;
    color: #991B1B;
    border-color: #FECACA;
}


html[data-theme="dark"] .from-primary {
    --tw-gradient-from: #1D4ED8 var(--tw-gradient-from-position);
}

.option-card {
    border-color: var(--theme-border) !important;
    background: var(--theme-card);
    color: var(--theme-text);
}

.option-card.selected {
    border-color: var(--theme-primary) !important;
    background: var(--theme-primary-soft) !important;
}

.palette-default {
    background: var(--theme-hover) !important;
    color: var(--theme-text) !important;
}

.skeleton {
    background: linear-gradient(90deg, var(--theme-hover) 25%, var(--theme-border) 50%, var(--theme-hover) 75%) !important;
    background-size: 200% 100%;
}

.theme-float { position: fixed; top: 12px; right: 12px; z-index: 60; }
.exam-theme-page,
.join-card {
    background: var(--theme-card) !important;
    color: var(--theme-text) !important;
    border-color: var(--theme-border) !important;
}

html[data-theme="dark"] body.exam-standalone {
    background: linear-gradient(135deg, #0F172A, #1E293B) !important;
}

html[data-theme="light"] body.exam-standalone {
    background: linear-gradient(135deg, #E2E8F0, #F8FAFC) !important;
}

html[data-theme="light"] .exam-standalone .text-white,
html[data-theme="light"] .exam-standalone .text-white-50 {
    color: var(--theme-text) !important;
}

html[data-theme="light"] .exam-standalone .text-white-50 {
    color: var(--theme-text-secondary) !important;
}

/* Theme toggle */
.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-width: 42px;
    min-height: 42px;
    padding: 0.45rem 0.75rem;
    border-radius: 12px;
    border: 1px solid var(--theme-border);
    background: var(--theme-hover);
    color: var(--theme-text);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background-color 300ms ease, color 300ms ease, border-color 300ms ease, transform 150ms ease;
}

.theme-toggle-btn:hover {
    background: var(--theme-card);
    transform: translateY(-1px);
}

.theme-toggle-btn .theme-icon-light { display: none; }
.theme-toggle-btn .theme-icon-dark { display: inline; }

html[data-theme="dark"] .theme-toggle-btn .theme-icon-light { display: inline; }
html[data-theme="dark"] .theme-toggle-btn .theme-icon-dark { display: none; }

html[data-theme="light"] .theme-toggle-btn .theme-icon-light { display: none; }
html[data-theme="light"] .theme-toggle-btn .theme-icon-dark { display: inline; }

/* Guest auth card text */
html[data-theme="dark"] .glass-card,
html[data-theme="light"] .glass-card {
    color: var(--theme-text);
}

html[data-theme="light"] body.guest-auth-body {
    background: linear-gradient(135deg, #2563EB, #0F766E, #E2E8F0) !important;
}

html[data-theme="dark"] body.guest-auth-body {
    background: linear-gradient(135deg, #0F172A, #1E3A5F, #0F766E) !important;
}

/* Global copyright footer */
.app-global-footer {
    margin-top: auto;
    border-top: 1px solid var(--theme-border);
    background: transparent;
    padding: 0.85rem 1rem;
}

.app-global-footer__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.35rem 0.65rem;
    max-width: 960px;
    margin: 0 auto;
    text-align: center;
    font-size: 0.75rem;
    line-height: 1.45;
    color: var(--theme-text-secondary);
}

.app-global-footer__sep {
    display: none;
    color: var(--theme-muted);
    user-select: none;
}

.app-global-footer__credit {
    display: block;
    width: 100%;
}

.app-global-footer__link {
    color: var(--theme-primary);
    font-weight: 600;
    text-decoration: none;
    transition: color 200ms ease, text-decoration-color 200ms ease;
}

.app-global-footer__link:hover,
.app-global-footer__link:focus-visible {
    text-decoration: underline;
    text-underline-offset: 2px;
    color: var(--theme-primary);
}

@media (min-width: 768px) {
    .app-global-footer__inner {
        flex-wrap: nowrap;
        justify-content: center;
        font-size: 0.8rem;
    }

    .app-global-footer__sep {
        display: inline;
    }

    .app-global-footer__credit {
        display: inline;
        width: auto;
    }
}

/* Admin main column footer */
.main-content > .app-global-footer {
    background: var(--theme-bg);
}

/* Candidate portal — sit above bottom nav */
.candidate-shell .app-global-footer {
    margin: 0.5rem 0 0;
    padding: 0.75rem 0.25rem 0.25rem;
    border-top: 1px solid var(--theme-border);
}

/* Guest auth pages — readable on gradient */
body.guest-auth-body > .app-global-footer {
    border-top-color: rgba(255, 255, 255, 0.18);
    background: rgba(15, 23, 42, 0.25);
    backdrop-filter: blur(8px);
}

body.guest-auth-body .app-global-footer__inner,
body.guest-auth-body .app-global-footer__copy,
body.guest-auth-body .app-global-footer__credit,
body.guest-auth-body .app-global-footer__sep {
    color: rgba(248, 250, 252, 0.78);
}

body.guest-auth-body .app-global-footer__link {
    color: #93C5FD;
}

body.guest-auth-body .app-global-footer__link:hover,
body.guest-auth-body .app-global-footer__link:focus-visible {
    color: #BFDBFE;
}

