/*
 * ExamNova interactive dark-mode completion.
 *
 * This file deliberately loads after page stacks.  Page-level assets can stay
 * focused on their component layout while this layer owns the final dark
 * surface contract.  Use html[data-bs-theme] as the source of truth; the
 * legacy body.dark-version class is retained only by theme-manager.js for
 * Material Dashboard compatibility.
 */

html[data-bs-theme="dark"] {
    color-scheme: dark;
}

html[data-bs-theme="dark"] body.admin-layout,
html[data-bs-theme="dark"] body.auth-layout,
html[data-bs-theme="dark"] body.exam-player-body {
    background: var(--exn-page) !important;
    color: var(--exn-text);
}

/* Shared interactive surfaces and Bootstrap overlays. */
html[data-bs-theme="dark"] .admin-layout .card,
html[data-bs-theme="dark"] .admin-layout .dropdown-menu,
html[data-bs-theme="dark"] .admin-layout .modal-content,
html[data-bs-theme="dark"] .admin-layout .offcanvas,
html[data-bs-theme="dark"] .admin-layout .popover,
html[data-bs-theme="dark"] .admin-layout .list-group-item,
html[data-bs-theme="dark"] .admin-layout .accordion-item,
html[data-bs-theme="dark"] .exam-player-body .modal-content,
html[data-bs-theme="dark"] .exam-player-body .offcanvas,
html[data-bs-theme="dark"] .auth-layout .modal-content,
html[data-bs-theme="dark"] .auth-layout .offcanvas {
    background: var(--exn-panel);
    border-color: var(--exn-line);
    color: var(--exn-text);
}

html[data-bs-theme="dark"] .admin-layout .card-header,
html[data-bs-theme="dark"] .admin-layout .card-footer,
html[data-bs-theme="dark"] .admin-layout .modal-header,
html[data-bs-theme="dark"] .admin-layout .modal-footer,
html[data-bs-theme="dark"] .admin-layout .offcanvas-header,
html[data-bs-theme="dark"] .admin-layout .accordion-button,
html[data-bs-theme="dark"] .exam-player-body .modal-header,
html[data-bs-theme="dark"] .exam-player-body .modal-footer,
html[data-bs-theme="dark"] .auth-layout .modal-header,
html[data-bs-theme="dark"] .auth-layout .modal-footer {
    background: var(--exn-surface-raised);
    border-color: var(--exn-line);
    color: var(--exn-ink);
}

html[data-bs-theme="dark"] .admin-layout .dropdown-item,
html[data-bs-theme="dark"] .admin-layout .dropdown-header,
html[data-bs-theme="dark"] .admin-layout .list-group-item,
html[data-bs-theme="dark"] .admin-layout .accordion-button,
html[data-bs-theme="dark"] .admin-layout .modal-title,
html[data-bs-theme="dark"] .admin-layout .offcanvas-title {
    color: var(--exn-text);
}

html[data-bs-theme="dark"] .admin-layout .dropdown-item:hover,
html[data-bs-theme="dark"] .admin-layout .dropdown-item:focus,
html[data-bs-theme="dark"] .admin-layout .list-group-item-action:hover,
html[data-bs-theme="dark"] .admin-layout .accordion-button:not(.collapsed) {
    background: var(--exn-surface-hover);
    color: var(--exn-ink);
}

html[data-bs-theme="dark"] .admin-layout .dropdown-divider,
html[data-bs-theme="dark"] .admin-layout .list-group-item,
html[data-bs-theme="dark"] .admin-layout .accordion-item,
html[data-bs-theme="dark"] .admin-layout .accordion-button {
    border-color: var(--exn-line);
}

html[data-bs-theme="dark"] .admin-layout .nav-tabs,
html[data-bs-theme="dark"] .admin-layout .nav-tabs .nav-link,
html[data-bs-theme="dark"] .admin-layout hr,
html[data-bs-theme="dark"] .exam-player-body hr,
html[data-bs-theme="dark"] .auth-layout hr {
    border-color: var(--exn-line);
}

html[data-bs-theme="dark"] .admin-layout .nav-tabs .nav-link {
    color: var(--exn-muted);
}

html[data-bs-theme="dark"] .admin-layout .nav-tabs .nav-link:hover,
html[data-bs-theme="dark"] .admin-layout .nav-tabs .nav-link.active {
    background: var(--exn-surface-raised);
    border-color: var(--exn-line) var(--exn-line) var(--exn-surface-raised);
    color: var(--exn-ink);
}

html[data-bs-theme="dark"] .admin-layout .form-control,
html[data-bs-theme="dark"] .admin-layout .form-select,
html[data-bs-theme="dark"] .admin-layout .form-control:disabled,
html[data-bs-theme="dark"] .admin-layout .form-select:disabled,
html[data-bs-theme="dark"] .exam-player-body .form-control,
html[data-bs-theme="dark"] .exam-player-body .form-select,
html[data-bs-theme="dark"] .auth-layout .form-control,
html[data-bs-theme="dark"] .auth-layout .form-select {
    background-color: var(--exn-surface-inset) !important;
    border-color: var(--exn-line) !important;
    color: var(--exn-text) !important;
}

html[data-bs-theme="dark"] .admin-layout .form-control::placeholder,
html[data-bs-theme="dark"] .exam-player-body .form-control::placeholder,
html[data-bs-theme="dark"] .auth-layout .form-control::placeholder {
    color: var(--exn-muted);
    opacity: 1;
}

html[data-bs-theme="dark"] .admin-layout .form-control:focus,
html[data-bs-theme="dark"] .admin-layout .form-select:focus,
html[data-bs-theme="dark"] .exam-player-body .form-control:focus,
html[data-bs-theme="dark"] .auth-layout .form-control:focus {
    border-color: #60a5fa !important;
    box-shadow: 0 0 0 0.2rem var(--exn-focus-ring);
}

html[data-bs-theme="dark"] .admin-layout .text-dark,
html[data-bs-theme="dark"] .admin-layout .text-body,
html[data-bs-theme="dark"] .admin-layout .text-black,
html[data-bs-theme="dark"] .exam-player-body .text-dark,
html[data-bs-theme="dark"] .auth-layout .text-dark {
    color: var(--exn-ink) !important;
}

html[data-bs-theme="dark"] .admin-layout .text-secondary,
html[data-bs-theme="dark"] .admin-layout .text-muted,
html[data-bs-theme="dark"] .exam-player-body .text-secondary,
html[data-bs-theme="dark"] .exam-player-body .text-muted,
html[data-bs-theme="dark"] .auth-layout .text-secondary,
html[data-bs-theme="dark"] .auth-layout .text-muted {
    color: var(--exn-muted) !important;
}

html[data-bs-theme="dark"] .admin-layout .btn-outline-dark,
html[data-bs-theme="dark"] .admin-layout .btn-outline-secondary,
html[data-bs-theme="dark"] .exam-player-body .btn-outline-dark,
html[data-bs-theme="dark"] .exam-player-body .btn-outline-secondary,
html[data-bs-theme="dark"] .auth-layout .btn-outline-dark,
html[data-bs-theme="dark"] .auth-layout .btn-outline-secondary {
    border-color: var(--exn-line);
    color: var(--exn-text);
}

html[data-bs-theme="dark"] .admin-layout .btn-outline-dark:hover,
html[data-bs-theme="dark"] .admin-layout .btn-outline-secondary:hover,
html[data-bs-theme="dark"] .exam-player-body .btn-outline-dark:hover,
html[data-bs-theme="dark"] .exam-player-body .btn-outline-secondary:hover,
html[data-bs-theme="dark"] .auth-layout .btn-outline-dark:hover,
html[data-bs-theme="dark"] .auth-layout .btn-outline-secondary:hover {
    background: var(--exn-surface-hover);
    border-color: #60a5fa;
    color: #dbeafe;
}

html[data-bs-theme="dark"] .examnova-navbar .navbar-nav > .nav-item > .nav-link,
html[data-bs-theme="dark"] .examnova-navbar .navbar-nav > .nav-item > .nav-link .material-symbols-rounded,
html[data-bs-theme="dark"] .examnova-navbar .navbar-nav > .nav-item > .examnova-user {
    color: var(--exn-text) !important;
}

html[data-bs-theme="dark"] .examnova-navbar .navbar-nav > .nav-item > .nav-link:hover,
html[data-bs-theme="dark"] .examnova-navbar .navbar-nav > .nav-item > .nav-link:focus-visible {
    color: var(--exn-ink) !important;
}

html[data-bs-theme="dark"] .modal-backdrop,
html[data-bs-theme="dark"] .offcanvas-backdrop {
    --bs-backdrop-bg: #020817;
    --bs-backdrop-opacity: 0.72;
}

/* Exam delivery, instructions, integrity review, and mobile palette. */
html[data-bs-theme="dark"] .exam-player-body,
html[data-bs-theme="dark"] .exam-player-main {
    background: var(--exn-page);
}

html[data-bs-theme="dark"] .exam-topbar,
html[data-bs-theme="dark"] .exam-panel,
html[data-bs-theme="dark"] .exam-card,
html[data-bs-theme="dark"] .exam-instructions-card,
html[data-bs-theme="dark"] .exam-mobile-palette {
    background: var(--exn-panel);
    border-color: var(--exn-line);
    color: var(--exn-text);
    box-shadow: 0 12px 32px rgba(2, 8, 23, 0.28);
}

html[data-bs-theme="dark"] .exam-topbar__title h1,
html[data-bs-theme="dark"] .exam-panel__title,
html[data-bs-theme="dark"] .exam-question-text,
html[data-bs-theme="dark"] .exam-question-meta strong,
html[data-bs-theme="dark"] .exam-instructions-card h1,
html[data-bs-theme="dark"] .exam-instructions-card h2,
html[data-bs-theme="dark"] .exam-instructions-card h3,
html[data-bs-theme="dark"] .exam-instructions-card h4 {
    color: var(--exn-ink);
}

html[data-bs-theme="dark"] .exam-topbar__title span,
html[data-bs-theme="dark"] .exam-side-list,
html[data-bs-theme="dark"] .exam-side-list div,
html[data-bs-theme="dark"] .exam-instructions-card p,
html[data-bs-theme="dark"] .exam-instructions-card li {
    color: var(--exn-muted);
}

html[data-bs-theme="dark"] .exam-pill,
html[data-bs-theme="dark"] .exam-section-tabs button,
html[data-bs-theme="dark"] .exam-palette button,
html[data-bs-theme="dark"] .exam-choice,
html[data-bs-theme="dark"] .exam-textarea,
html[data-bs-theme="dark"] .exam-input {
    background: var(--exn-surface-inset);
    border-color: var(--exn-line);
    color: var(--exn-text);
}

html[data-bs-theme="dark"] .exam-section-tabs button:hover,
html[data-bs-theme="dark"] .exam-palette button:hover,
html[data-bs-theme="dark"] .exam-choice:hover {
    background: var(--exn-surface-hover);
}

html[data-bs-theme="dark"] .exam-section-tabs button.active,
html[data-bs-theme="dark"] .exam-choice:has(input:checked),
html[data-bs-theme="dark"] .exam-choice.is-selected {
    background: rgba(37, 99, 235, 0.18);
    border-color: #60a5fa;
    color: #dbeafe;
}

html[data-bs-theme="dark"] .exam-palette button.answered,
html[data-bs-theme="dark"] .exam-pill--online {
    background: var(--exn-success-soft);
    color: var(--exn-success-text);
}

html[data-bs-theme="dark"] .exam-palette button.marked,
html[data-bs-theme="dark"] .exam-integrity-warning {
    background: var(--exn-warning-soft);
    border-color: var(--exn-warning-line);
    color: var(--exn-warning-text);
}

html[data-bs-theme="dark"] .exam-palette button.skipped,
html[data-bs-theme="dark"] .exam-pill--offline {
    background: var(--exn-danger-soft);
    color: var(--exn-danger-text);
}

html[data-bs-theme="dark"] .exam-question-actions,
html[data-bs-theme="dark"] .exam-side-list div,
html[data-bs-theme="dark"] .exam-instructions-card {
    border-color: var(--exn-line);
}

html[data-bs-theme="dark"] .exam-progress {
    background: var(--exn-surface-hover);
}

/* Exam authoring, drag controls, and paper preview. */
html[data-bs-theme="dark"] .exn-paper-composer__summary > div,
html[data-bs-theme="dark"] .exn-paper-section,
html[data-bs-theme="dark"] .exn-paper-palette,
html[data-bs-theme="dark"] .exn-paper-fallback,
html[data-bs-theme="dark"] .exn-paper-question-card,
html[data-bs-theme="dark"] .exn-paper-palette-card {
    background: var(--exn-panel);
    border-color: var(--exn-line);
    color: var(--exn-text);
    box-shadow: none;
}

html[data-bs-theme="dark"] .exn-paper-section--muted,
html[data-bs-theme="dark"] .exn-paper-question-card__edit,
html[data-bs-theme="dark"] .exn-paper-palette__bulk,
html[data-bs-theme="dark"] .exn-paper-palette-card.is-added,
html[data-bs-theme="dark"] .exn-paper-composer__status.is-visible,
html[data-bs-theme="dark"] .exn-drag-handle {
    background: var(--exn-surface-inset);
    border-color: var(--exn-line);
    color: var(--exn-text);
}

html[data-bs-theme="dark"] .exn-paper-section__header,
html[data-bs-theme="dark"] .exn-paper-section__warnings,
html[data-bs-theme="dark"] .exn-paper-preview__option,
html[data-bs-theme="dark"] .exn-paper-preview__attachment {
    border-color: var(--exn-line);
}

html[data-bs-theme="dark"] .exn-paper-composer__summary strong,
html[data-bs-theme="dark"] .exn-paper-section__header h6,
html[data-bs-theme="dark"] .exn-paper-palette__header h6,
html[data-bs-theme="dark"] .exn-paper-section__stats strong,
html[data-bs-theme="dark"] .exn-paper-question-card__text,
html[data-bs-theme="dark"] .exn-paper-palette-card__text,
html[data-bs-theme="dark"] .exn-paper-palette__bulk-top strong,
html[data-bs-theme="dark"] .exn-paper-preview__text,
html[data-bs-theme="dark"] .exn-paper-preview__option strong,
html[data-bs-theme="dark"] .exn-paper-preview__attachment strong {
    color: var(--exn-ink);
}

html[data-bs-theme="dark"] .exn-paper-composer__summary span,
html[data-bs-theme="dark"] .exn-paper-section__eyebrow,
html[data-bs-theme="dark"] .exn-paper-palette__header span:not(.tbl-status),
html[data-bs-theme="dark"] .exn-paper-question-card__meta,
html[data-bs-theme="dark"] .exn-paper-palette-card__meta,
html[data-bs-theme="dark"] .exn-paper-question-card__bank,
html[data-bs-theme="dark"] .exn-paper-preview__option span,
html[data-bs-theme="dark"] .exn-paper-preview__attachment span,
html[data-bs-theme="dark"] .exn-paper-section__empty {
    color: var(--exn-muted);
}

html[data-bs-theme="dark"] .exn-paper-section__stats span,
html[data-bs-theme="dark"] .exn-paper-icon-btn,
html[data-bs-theme="dark"] .exn-paper-palette-card__action,
html[data-bs-theme="dark"] .exn-paper-status__action {
    background: var(--exn-surface-raised);
    border-color: var(--exn-line);
    color: var(--exn-text);
}

html[data-bs-theme="dark"] .exn-paper-icon-btn:hover,
html[data-bs-theme="dark"] .exn-paper-icon-btn:focus-visible,
html[data-bs-theme="dark"] .exn-paper-palette-card__action:hover,
html[data-bs-theme="dark"] .exn-paper-palette-card__action:focus-visible,
html[data-bs-theme="dark"] .exn-paper-status__action:hover,
html[data-bs-theme="dark"] .exn-paper-status__action:focus-visible,
html[data-bs-theme="dark"] .exn-drag-handle:hover,
html[data-bs-theme="dark"] .exn-drag-handle:focus-visible {
    background: var(--exn-surface-hover);
    border-color: #60a5fa;
    color: #bfdbfe;
}

html[data-bs-theme="dark"] .exn-paper-section__list.is-drop-target {
    background: var(--exn-success-soft);
    box-shadow: inset 0 0 0 2px var(--exn-success-line);
}

html[data-bs-theme="dark"] .exn-paper-composer__status.is-saving,
html[data-bs-theme="dark"] .exn-sortable-status--saving {
    background: rgba(37, 99, 235, 0.16);
    border-color: rgba(96, 165, 250, 0.45);
    color: #bfdbfe;
}

html[data-bs-theme="dark"] .exn-paper-composer__status.is-success,
html[data-bs-theme="dark"] .exn-sortable-status--success {
    background: var(--exn-success-soft);
    border-color: var(--exn-success-line);
    color: var(--exn-success-text);
}

html[data-bs-theme="dark"] .exn-paper-composer__status.is-error,
html[data-bs-theme="dark"] .exn-sortable-status--error {
    background: var(--exn-danger-soft);
    border-color: var(--exn-danger-line);
    color: var(--exn-danger-text);
}

html[data-bs-theme="dark"] .exn-paper-composer .exn-sortable-ghost,
html[data-bs-theme="dark"] .exn-paper-composer .exn-paper-card-ghost,
html[data-bs-theme="dark"] .exn-sortable-ghost {
    background: rgba(37, 99, 235, 0.2) !important;
}

html[data-bs-theme="dark"] .exn-paper-preview__meta span,
html[data-bs-theme="dark"] .exn-paper-preview__option em {
    background: rgba(99, 102, 241, 0.2);
    color: #c7d2fe;
}

/* Shared selection controls and permission glossary custom surfaces. */
html[data-bs-theme="dark"] .mms-label,
html[data-bs-theme="dark"] .mms-hint,
html[data-bs-theme="dark"] .mms-icon {
    color: var(--exn-muted);
}

html[data-bs-theme="dark"] .mms-icon {
    background: var(--exn-surface-raised);
    border-color: var(--exn-line);
}

html[data-bs-theme="dark"] .select2-container--default .select2-selection--multiple {
    background: var(--exn-surface-inset);
    border-color: var(--exn-line);
}

html[data-bs-theme="dark"] .select2-selection__choice {
    background: rgba(37, 99, 235, 0.18) !important;
    color: #bfdbfe !important;
}

html[data-bs-theme="dark"] .select2-selection__choice__remove {
    color: #bfdbfe !important;
}

html[data-bs-theme="dark"] .perm-glossary {
    --bg-card: var(--exn-panel);
    --bg-soft: var(--exn-surface-inset);
    --text: var(--exn-ink);
    --muted: var(--exn-muted);
    --border: var(--exn-line);
    --border-strong: #60a5fa;
}

html[data-bs-theme="dark"] .perm-glossary .ins-select2-menu {
    background: var(--exn-panel);
    border-color: var(--exn-line);
}

html[data-bs-theme="dark"] .perm-glossary .ins-select2-opt:hover {
    background: var(--exn-surface-hover);
}

/* Auth is intentionally a dark reading surface when the visitor chooses dark mode. */
html[data-bs-theme="dark"] .auth-card,
html[data-bs-theme="dark"] .auth-right {
    background: var(--exn-panel);
    border-color: var(--exn-line);
    color: var(--exn-text);
}

html[data-bs-theme="dark"] .auth-card__header-wrap,
html[data-bs-theme="dark"] .auth-tabs,
html[data-bs-theme="dark"] .auth-info {
    background: var(--exn-surface-raised);
    border-color: var(--exn-line);
}

html[data-bs-theme="dark"] .auth-title,
html[data-bs-theme="dark"] .auth-field label,
html[data-bs-theme="dark"] .auth-info-header .mphb__title,
html[data-bs-theme="dark"] .auth-info-header .mphb__badge,
html[data-bs-theme="dark"] .auth-info__text {
    color: var(--exn-ink);
}

html[data-bs-theme="dark"] .auth-subtitle,
html[data-bs-theme="dark"] .auth-hint,
html[data-bs-theme="dark"] .auth-meta,
html[data-bs-theme="dark"] .auth-backlink,
html[data-bs-theme="dark"] .auth-info-header .mphb__subtitle,
html[data-bs-theme="dark"] .otp-meta {
    color: var(--exn-muted);
}

html[data-bs-theme="dark"] .auth-input,
html[data-bs-theme="dark"] .otp-box,
html[data-bs-theme="dark"] .auth-switch input[type="checkbox"] {
    background: var(--exn-surface-inset);
    border-color: var(--exn-line);
    color: var(--exn-ink);
}

html[data-bs-theme="dark"] .auth-input:focus,
html[data-bs-theme="dark"] .otp-box:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 4px var(--exn-focus-ring);
}

html[data-bs-theme="dark"] .auth-error {
    color: var(--exn-danger-text);
}

html[data-bs-theme="dark"] .auth-button--dark {
    background: #1e3a5f;
    border-color: #31547f;
    color: #eff6ff;
}

html[data-bs-theme="dark"] .auth-tab.is-active {
    background: var(--exn-panel);
    border-color: var(--exn-line);
    color: var(--exn-ink);
    box-shadow: none;
}

html[data-bs-theme="dark"] .auth-alert {
    background: var(--exn-surface-raised);
    border-color: var(--exn-line);
    color: var(--exn-text);
}

html[data-bs-theme="dark"] .auth-alert--success {
    background: var(--exn-success-soft);
    border-color: var(--exn-success-line);
    color: var(--exn-success-text);
}

html[data-bs-theme="dark"] .auth-alert--danger,
html[data-bs-theme="dark"] .danger-panel {
    background: var(--exn-danger-soft);
    border-color: var(--exn-danger-line);
    color: var(--exn-danger-text);
}

html[data-bs-theme="dark"] .warn-panel {
    background: var(--exn-warning-soft);
    border-color: var(--exn-warning-line);
    color: var(--exn-warning-text);
}

html[data-bs-theme="dark"] .danger-panel .mphb__title,
html[data-bs-theme="dark"] .danger-panel .mphb__subtitle,
html[data-bs-theme="dark"] .danger-panel .mphb__badge,
html[data-bs-theme="dark"] .danger-panel__text,
html[data-bs-theme="dark"] .danger-panel__chip {
    background: transparent;
    border-color: var(--exn-danger-line);
    color: var(--exn-danger-text);
}

html[data-bs-theme="dark"] .warn-panel__title,
html[data-bs-theme="dark"] .warn-panel__text,
html[data-bs-theme="dark"] .warn-panel__chip {
    background: transparent;
    border-color: var(--exn-warning-line);
    color: var(--exn-warning-text);
}

/* Third-party feedback surfaces are appended directly to body. */
html[data-bs-theme="dark"] .swal2-popup,
html[data-bs-theme="dark"] .swal2-toast,
html[data-bs-theme="dark"] #toast-container > div {
    background: var(--exn-panel);
    border: 1px solid var(--exn-line);
    color: var(--exn-text);
    box-shadow: 0 18px 42px rgba(2, 8, 23, 0.42);
}

html[data-bs-theme="dark"] .swal2-title,
html[data-bs-theme="dark"] .swal2-html-container,
html[data-bs-theme="dark"] #toast-container > div,
html[data-bs-theme="dark"] #toast-container > div .toast-title,
html[data-bs-theme="dark"] #toast-container > div .toast-message {
    color: var(--exn-ink);
}

@media (prefers-reduced-motion: reduce) {
    html[data-bs-theme="dark"] *,
    html[data-bs-theme="dark"] *::before,
    html[data-bs-theme="dark"] *::after {
        transition-duration: 0.01ms !important;
    }
}
