/*
 * Databad dark theme.
 *
 * Only semantic tokens and unavoidable framework adapters belong here.
 * Component layout remains in the shared stylesheets, and print/PDF/mail
 * layouts deliberately do not load this file.
 */

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

    --theme-page-bg: #0b1220;
    --theme-surface-bg: #111c2e;
    --theme-surface-muted-bg: #172338;
    --theme-surface-subtle-bg: #142035;
    --theme-surface-raised-bg: #1a2940;
    --theme-text: #e6edf7;
    --theme-text-muted: #a8b6ca;
    --theme-text-subtle: #8292aa;
    --theme-border: #2b3b53;
    --theme-border-soft: #223149;
    --theme-border-primary: #345c94;
    --theme-border-primary-strong: #4c78b6;
    --theme-data-control-border: #6b7280;
    --theme-primary: #71a7ff;
    --theme-primary-hover: #93bbff;
    --theme-primary-dark: #a9c8ff;
    --theme-primary-soft: #172e52;
    --theme-primary-row-soft: rgba(113, 167, 255, 0.07);
    --theme-primary-row-hover: rgba(113, 167, 255, 0.13);
    --theme-secondary: #a8b6ca;
    --theme-secondary-dark: #c5d0df;
    --theme-header-bg: #192b4b;
    --theme-header-text: #b8ceff;
    --theme-header-border: #355987;
    --theme-header-border-strong: #456b9d;
    --theme-header-focus: rgba(113, 167, 255, 0.28);

    --theme-success: #40d39a;
    --theme-success-dark: #76e8bb;
    --theme-success-soft: #102f2a;
    --theme-success-disabled: #588d7b;
    --theme-success-border: #25775f;
    --theme-warning: #f6bd4b;
    --theme-warning-dark: #ffd274;
    --theme-warning-contrast: #241800;
    --theme-warning-soft: #352812;
    --theme-warning-text: #ffd274;
    --theme-warning-border: #775b22;
    --theme-danger: #ff6b6b;
    --theme-danger-dark: #ff9292;
    --theme-danger-bright: #ff7777;
    --theme-danger-soft: #371a22;
    --theme-danger-panel: #472029;
    --theme-danger-border: #713440;
    --theme-danger-border-strong: #98505b;
    --theme-danger-rose-text: #ffb4bf;

    --theme-status-normal: #e6edf7;
    --theme-status-alarm: #ff7957;
    --theme-status-tolerance: #d28aff;
    --theme-status-alarm-tolerance: #74a7ff;
    --theme-chart-axis: #51627a;
    --theme-chart-grid: #2b3b53;
    --theme-chart-plotband-bg: rgba(64, 211, 154, 0.14);
    --theme-toggle-off: #51627a;
    --theme-form-border: #3a4c66;
    --theme-nav-button-border: #3d5f8e;
    --theme-dashboard-blue-dark: #a9c8ff;
    --theme-panel-alt-bg: #14233a;
    --theme-purple: #c5a7ff;
    --theme-purple-dark: #d5c3ff;
    --theme-purple-soft: #2c2247;
    --theme-purple-text: #d9c9ff;
    --theme-purple-border: #6c5697;
    --theme-autofill-bg: #233a5e;

    --theme-front-outline: rgba(183, 204, 236, 0.2);
    --theme-front-muted-alt: #9dadc2;
    --theme-front-pill-bg: #1b3154;
    --theme-front-pill-text: #b8ceff;
    --theme-assistant-handle-bg: #52647d;
    --theme-assistant-handle-hover-bg: #667993;
    --theme-assistant-panel-bg: #172338;
    --theme-assistant-accent: #82b3ef;
    --theme-assistant-text: #e6edf7;
    --theme-legacy-dark: #d4deeb;
    --theme-legacy-muted: #53647c;
    --theme-legacy-subtle: #8292aa;
    --theme-legacy-muted-strong: #72839b;
    --theme-legacy-neutral-bg: #202e43;

    --theme-shadow-xs: rgba(0, 0, 0, 0.18);
    --theme-shadow-xs-soft: rgba(0, 0, 0, 0.14);
    --theme-shadow-xs-strong: rgba(0, 0, 0, 0.22);
    --theme-shadow-black-sm: rgba(0, 0, 0, 0.28);
    --theme-shadow-black-md: rgba(0, 0, 0, 0.38);
    --theme-shadow-black-lg: rgba(0, 0, 0, 0.48);
    --theme-shadow-sm: rgba(0, 0, 0, 0.2);
    --theme-shadow-md: rgba(0, 0, 0, 0.26);
    --theme-shadow-lg: rgba(0, 0, 0, 0.32);
    --theme-shadow-lg-strong: rgba(0, 0, 0, 0.38);
    --theme-shadow-xl: rgba(0, 0, 0, 0.48);
    --theme-shadow-xl-soft: rgba(0, 0, 0, 0.4);
    --theme-shadow-xl-muted: rgba(0, 0, 0, 0.44);
    --theme-shadow-xxl: rgba(0, 0, 0, 0.56);
    --theme-focus-primary: rgba(113, 167, 255, 0.16);
    --theme-focus-primary-soft: rgba(113, 167, 255, 0.12);
    --theme-focus-primary-strong: rgba(113, 167, 255, 0.28);
    --theme-focus-primary-stronger: rgba(113, 167, 255, 0.38);

    --theme-audit-created-bg: #14344b;
    --theme-audit-created-text: #95d7ff;
    --theme-audit-updated-bg: #3a2e16;
    --theme-audit-updated-text: #ffd274;
    --theme-audit-deleted-bg: #3d1d26;
    --theme-audit-deleted-text: #ffadb7;
    --theme-audit-restored-bg: #153729;
    --theme-audit-restored-text: #8be6bb;
    --theme-audit-old-bg: #341c26;
    --theme-audit-new-bg: #163427;
    --theme-audit-changed-bg: #3a3018;
    --theme-audit-changed-border: #b88921;
    --theme-audit-changed-text: #ffe099;
    --theme-diagnostic-error-bg: #3d2027;
    --theme-diagnostic-error-text: #ffadb7;
    --theme-diagnostic-warning-bg: #3a3018;
    --theme-diagnostic-warning-text: #ffe099;
    --theme-diagnostic-success-bg: #173529;
    --theme-diagnostic-success-text: #8be6bb;

    --theme-public-ink: #e6edf7;
    --theme-public-link: #b2c0d3;
    --theme-public-link-active: #8cb5ff;
    --theme-public-action: #27b78c;
    --theme-public-action-hover: #45cba2;
    --theme-public-footer-bg: #080e19;
    --theme-public-footer-text: #d8e3f2;
    --theme-public-footer-muted: #aebed3;
    --theme-public-footer-link: #c0d1e6;
    --theme-public-footer-subtle: #91a4be;
    --theme-public-header-bg: rgba(11, 18, 32, 0.96);
    --theme-public-control-border: #3a4c66;
    --theme-cookie-heading-bg: #192b43;
    --theme-cookie-heading-text: #c4d7ef;
    --theme-cookie-text: #b4c3d6;
    --theme-cookie-code: #9dc6ff;
    --theme-cookie-border: #33465f;
    --theme-cookie-summary-bg: #172338;
    --theme-cookie-summary-hover-bg: #20304a;

    --theme-reports-ink: #e6edf7;
    --theme-reports-primary: #8cb5ff;
    --theme-reports-primary-soft: #192f52;
    --theme-reports-action: #27b78c;
    --theme-reports-action-hover: #45cba2;
    --theme-reports-border: #2b3b53;
    --theme-reports-muted: #a8b6ca;
    --theme-reports-surface: #111c2e;
    --theme-reports-page-bg: #0b1220;
    --theme-reports-row-bg: #152136;
    --theme-reports-row-hover: #1b2940;
    --theme-reports-control-bg: #19263b;
    --theme-reports-disabled-bg: #182236;
    --theme-reports-disabled-text: #718198;
    --theme-reports-day-text: #a9c8ff;
    --theme-reports-day-bg: #18325a;
    --theme-reports-week-text: #cfb5ff;
    --theme-reports-week-bg: #30244c;
    --theme-reports-month-text: #ffd18b;
    --theme-reports-month-bg: #3a2b17;

    --theme-pricing-ink: #e6edf7;
    --theme-pricing-muted: #a8b6ca;
    --theme-pricing-primary: #8cb5ff;
    --theme-pricing-action: #27b78c;
    --theme-pricing-action-hover: #45cba2;
    --theme-pricing-border: #2b3b53;
    --theme-pricing-dark-start: #0b1629;
    --theme-pricing-dark-end: #17365f;
    --theme-pricing-feature-bg: rgba(17, 28, 46, 0.94);
    --theme-pricing-difference-bg: #142743;
    --theme-pricing-difference-border: #31547f;
    --theme-pricing-outcome-start: #12332c;
    --theme-pricing-outcome-end: #172f2b;
    --theme-pricing-outcome-border: #2d6655;

    --theme-highlight-bg: #463716;
    --theme-highlight-border: #806323;
    --theme-highlight-shadow: rgba(0, 0, 0, 0.25);
    --theme-highlight-text: #ffe29b;

    --bs-body-color: var(--theme-text);
    --bs-body-bg: var(--theme-page-bg);
    --bs-border-color: var(--theme-border);
    --bs-secondary-color: var(--theme-text-muted);
    --bs-tertiary-bg: var(--theme-surface-muted-bg);
    --bs-link-color: var(--theme-primary);
    --bs-link-hover-color: var(--theme-primary-hover);
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
    color-scheme: dark;
}

html[data-theme="dark"] .navbar,
html[data-theme="dark"] nav.navbar .dropdown-menu {
    /* The shared Bootstrap adapter uses a forced legacy-navbar declaration. */
    background-color: var(--theme-surface-bg) !important;
}

/* Bootstrap's light tab and close-button defaults otherwise become black on
 * dark surfaces. Keep this adapter global for authenticated tabs/modals. */
html[data-theme="dark"] .nav-tabs .nav-link.active,
html[data-theme="dark"] .nav-tabs .nav-item.show .nav-link {
    background-color: var(--theme-surface-bg);
    border-color: var(--theme-border) var(--theme-border) var(--theme-surface-bg);
    color: var(--theme-text);
}

html[data-theme="dark"] .nav-tabs .nav-link:hover,
html[data-theme="dark"] .nav-tabs .nav-link:focus-visible {
    border-color: var(--theme-border-soft) var(--theme-border-soft) var(--theme-border);
    color: var(--theme-primary-hover);
}

html[data-theme="dark"] .modal-header .btn-close {
    background-color: transparent;
    border: 0;
    box-shadow: none;
    filter: invert(1) grayscale(100%) brightness(200%);
    opacity: 0.75;
}

html[data-theme="dark"] .modal-header .btn-close:hover,
html[data-theme="dark"] .modal-header .btn-close:focus-visible {
    opacity: 1;
}

html[data-theme="dark"] .note-editor.note-frame {
    background: var(--theme-surface-bg);
    border-color: var(--theme-border);
    color: var(--theme-text);
}

html[data-theme="dark"] .note-editor .note-toolbar,
html[data-theme="dark"] .note-editor .note-statusbar {
    background: var(--theme-surface-muted-bg);
    border-color: var(--theme-border);
}

html[data-theme="dark"] .note-editor .note-editable,
html[data-theme="dark"] .note-editor .note-codable {
    background: var(--theme-surface-bg) !important;
    color: var(--theme-text) !important;
}

html[data-theme="dark"] .agreement-editor .note-editor .note-editable {
    background: var(--document-surface) !important;
    color: var(--document-text) !important;
}

html[data-theme="dark"] .note-editor .note-btn {
    background: var(--theme-surface-muted-bg);
    border-color: var(--theme-border);
    color: var(--theme-text);
}

html[data-theme="dark"] .note-editor .note-btn:hover,
html[data-theme="dark"] .note-editor .note-btn:focus-visible,
html[data-theme="dark"] .note-editor .note-btn.active {
    background: var(--theme-primary-soft);
    color: var(--theme-primary-hover);
}

html[data-theme="dark"] .note-editor .dropdown-menu {
    background: var(--theme-surface-bg);
    border-color: var(--theme-border);
    color: var(--theme-text);
}

html[data-theme="dark"] .note-editor .dropdown-menu > *,
html[data-theme="dark"] .note-editor .dropdown-menu a,
html[data-theme="dark"] .note-editor .dropdown-menu button,
html[data-theme="dark"] .note-editor .dropdown-style h2,
html[data-theme="dark"] .note-editor .dropdown-style h3,
html[data-theme="dark"] .note-editor .dropdown-style h4,
html[data-theme="dark"] .note-editor .dropdown-style p,
html[data-theme="dark"] .note-editor .dropdown-style blockquote,
html[data-theme="dark"] .note-editor .note-palette-title,
html[data-theme="dark"] .note-editor .note-color-reset {
    color: var(--theme-text) !important;
}

html[data-theme="dark"] .note-editor .dropdown-menu a:hover,
html[data-theme="dark"] .note-editor .dropdown-menu a:focus,
html[data-theme="dark"] .note-editor .note-color-reset:hover,
html[data-theme="dark"] .note-editor .note-color-reset:focus {
    background: var(--theme-primary-soft) !important;
    color: var(--theme-primary-hover) !important;
}

html[data-theme="dark"] .note-editor .note-palette-title {
    border-color: var(--theme-border) !important;
}

html[data-theme="dark"] .note-editor .note-dimension-picker-unhighlighted {
    filter: brightness(.55) contrast(1.3);
}

html[data-theme="dark"] .note-editor.fullscreen,
html[data-theme="dark"] .note-editor.fullscreen .note-editable {
    background: var(--theme-surface-bg) !important;
}

html[data-theme="dark"] .agreement-editor .note-editor.fullscreen .note-editable {
    background: var(--document-surface) !important;
    color: var(--document-text) !important;
}

html[data-theme="dark"] .note-modal .modal-content,
html[data-theme="dark"] .note-modal .modal-header,
html[data-theme="dark"] .note-modal .modal-body,
html[data-theme="dark"] .note-modal .modal-footer {
    background: var(--theme-surface-bg);
    border-color: var(--theme-border);
    color: var(--theme-text);
}

html[data-theme="dark"] .note-modal input,
html[data-theme="dark"] .note-modal select {
    background: var(--theme-surface-muted-bg);
    border-color: var(--theme-border);
    color: var(--theme-text);
}

html[data-theme="dark"] .popover {
    --bs-popover-bg: var(--theme-surface-bg);
    --bs-popover-border-color: var(--theme-border);
    --bs-popover-header-bg: var(--theme-surface-muted-bg);
    --bs-popover-header-color: var(--theme-text);
    --bs-popover-body-color: var(--theme-text);
}

html[data-theme="dark"] .admin-brand img,
html[data-theme="dark"] .about-brand img,
html[data-theme="dark"] .contact-brand img,
html[data-theme="dark"] .preview-brand img,
html[data-theme="dark"] .create-brand img,
html[data-theme="dark"] .profile-brand img,
html[data-theme="dark"] .security-brand img,
html[data-theme="dark"] .privacy-brand img,
html[data-theme="dark"] .cookies-brand img,
html[data-theme="dark"] .help-brand img {
    filter: brightness(0) invert(1);
}

html[data-theme="dark"] .public-site-brand img,
html[data-theme="dark"] .public-footer-brand img {
    filter: brightness(0) invert(1);
}
