/*
 * Dark theme for Sneat free.
 * Sneat free only ships Bootstrap's base dark variables; this fills in the
 * theme layer (paper, menu, navbar, borders, shadows) with the Sneat Pro
 * dark palette, plus the handful of components that hard-code light colours.
 * Activated by <html data-bs-theme="dark">.
 */

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

  --bs-body-bg: #232333;
  --bs-body-bg-rgb: 35, 35, 51;
  --bs-paper-bg: #2b2c40;
  --bs-paper-bg-rgb: 43, 44, 64;
  --bs-body-color: #b2b2c4;
  --bs-body-color-rgb: 178, 178, 196;
  --bs-heading-color: #d5d5e2;
  --bs-emphasis-color: #e4e4f0;
  --bs-emphasis-color-rgb: 228, 228, 240;
  --bs-base-color: #e4e4f0;
  --bs-base-color-rgb: 228, 228, 240;
  --bs-secondary-color: #8a8ba5;
  --bs-secondary-color-rgb: 138, 139, 165;
  --bs-secondary-bg: #3a3b55;
  --bs-secondary-bg-rgb: 58, 59, 85;
  --bs-tertiary-color: rgba(178, 178, 196, .5);
  --bs-tertiary-bg: #323348;
  --bs-tertiary-bg-rgb: 50, 51, 72;
  --bs-border-color: #444564;
  --bs-border-color-translucent: rgba(228, 228, 240, .12);

  --bs-white: #fff;
  --bs-black: #e4e4f0;
  --bs-gray-25: #2e2f45;
  --bs-gray-50: #30314a;
  --bs-gray-60: #33344c;
  --bs-gray-80: #36374f;
  --bs-gray-100: #393a55;
  --bs-gray-200: #444564;
  --bs-gray-300: #5a5b79;
  --bs-gray-400: #6f708e;
  --bs-gray-500: #8a8ba5;
  --bs-gray-600: #a3a4bb;
  --bs-gray-700: #b2b2c4;
  --bs-gray-800: #c8c8d8;
  --bs-gray-900: #d5d5e2;

  --bs-link-color: #8587ff;
  --bs-link-color-rgb: 133, 135, 255;
  --bs-link-hover-color: #9a9cff;
  --bs-link-hover-color-rgb: 154, 156, 255;

  --bs-primary-bg-subtle: #35365f;
  --bs-secondary-bg-subtle: #383a50;
  --bs-success-bg-subtle: #36483f;
  --bs-info-bg-subtle: #25445c;
  --bs-warning-bg-subtle: #4d4036;
  --bs-danger-bg-subtle: #4d2f3a;
  --bs-primary-text-emphasis: #a5a7ff;
  --bs-highlight-bg: #5c4a1a;
  --bs-highlight-color: #e4e4f0;
  --bs-code-color: #ff7eb6;

  --bs-box-shadow: 0 .1875rem .5rem 0 rgba(10, 10, 20, .4);
  --bs-box-shadow-xs: 0 .0625rem .3175rem 0 rgba(10, 10, 20, .3);
  --bs-box-shadow-sm: 0 .125rem .375rem 0 rgba(10, 10, 20, .36);
  --bs-box-shadow-lg: 0 .25rem .75rem 0 rgba(10, 10, 20, .45);
  --bs-box-shadow-xl: 0 .3125rem 1.375rem 0 rgba(10, 10, 20, .5);
  --bs-floating-component-shadow: 0 .1875rem .5rem 0 rgba(10, 10, 20, .4);

  --bs-navbar-box-shadow: 0 0 10px rgba(10, 10, 20, .45);
  --bs-navbar-border-color: var(--bs-paper-bg);
  --bs-nav-border-color: var(--bs-paper-bg);

  --bs-menu-color: #c3c3d6;
  --bs-menu-color-rgb: 195, 195, 214;
  --bs-menu-hover-bg: rgba(228, 228, 240, .06);
  --bs-menu-hover-color: #e4e4f0;
  --bs-menu-active-toggle-bg: rgba(228, 228, 240, .08);
  --bs-menu-active-bg: rgba(105, 108, 255, .18);
  --bs-menu-sub-active-bg: rgba(105, 108, 255, .18);
  --bs-menu-box-shadow: 0 .125rem .375rem 0 rgba(10, 10, 20, .4);
  --bs-menu-divider-color: var(--bs-paper-bg);
}

/* ── Components that hard-code light values ─────────────────────────── */
[data-bs-theme=dark] .dropdown-menu {
  --bs-dropdown-bg: var(--bs-paper-bg);
  --bs-dropdown-color: var(--bs-body-color);
  --bs-dropdown-border-color: var(--bs-border-color);
  --bs-dropdown-link-color: var(--bs-heading-color);
  --bs-dropdown-link-hover-color: var(--bs-heading-color);
  --bs-dropdown-link-hover-bg: rgba(228, 228, 240, .06);
  --bs-dropdown-divider-bg: var(--bs-border-color);
  --bs-dropdown-header-color: var(--bs-secondary-color);
  --bs-dropdown-box-shadow: var(--bs-box-shadow-lg);
}
[data-bs-theme=dark] .table {
  --bs-table-border-color: var(--bs-border-color);
  --bs-table-hover-bg: rgba(228, 228, 240, .04);
  --bs-table-striped-bg: rgba(228, 228, 240, .03);
}
[data-bs-theme=dark] .table-light,
[data-bs-theme=dark] .table > thead.table-light {
  --bs-table-bg: #30314a;
  --bs-table-color: var(--bs-heading-color);
  --bs-table-border-color: var(--bs-border-color);
}
[data-bs-theme=dark] .pagination {
  --bs-pagination-bg: rgba(228, 228, 240, .06);
  --bs-pagination-border-color: rgba(228, 228, 240, .14);
  --bs-pagination-hover-border-color: rgba(228, 228, 240, .14);
  --bs-pagination-disabled-bg: rgba(228, 228, 240, .04);
  --bs-pagination-disabled-border-color: rgba(228, 228, 240, .1);
}
[data-bs-theme=dark] .list-group {
  --bs-list-group-action-hover-bg: rgba(228, 228, 240, .05);
  --bs-list-group-action-active-bg: rgba(228, 228, 240, .07);
}
[data-bs-theme=dark] .modal-backdrop { --bs-backdrop-bg: #0f0f18; }
[data-bs-theme=dark] .layout-overlay,
[data-bs-theme=dark] .app-overlay.show { background-color: rgba(10, 10, 20, .6); }

[data-bs-theme=dark] .form-control,
[data-bs-theme=dark] .form-select,
[data-bs-theme=dark] .input-group-text {
  border-color: #4f5070;
  color: var(--bs-heading-color);
}
[data-bs-theme=dark] .form-control:disabled,
[data-bs-theme=dark] .form-select:disabled { background-color: rgba(228, 228, 240, .05); }
[data-bs-theme=dark] .form-control::placeholder { color: #7d7e98; }
[data-bs-theme=dark] .form-check-input:not(:checked) { border-color: #6f708e; }
[data-bs-theme=dark] .form-switch .form-check-input:not(:checked) { background-color: #4f5070; }
[data-bs-theme=dark] input[type=date],
[data-bs-theme=dark] input[type=time],
[data-bs-theme=dark] input[type=datetime-local] { color-scheme: dark; }

[data-bs-theme=dark] .btn-outline-secondary { --bs-btn-color: #b2b2c4; --bs-btn-border-color: #5a5b79; --bs-btn-hover-bg: rgba(228, 228, 240, .08); --bs-btn-hover-color: #e4e4f0; --bs-btn-hover-border-color: #6f708e; }
[data-bs-theme=dark] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }
/* Sneat draws the modal X itself (paper-coloured button + masked icon): inverting it makes a white square */
[data-bs-theme=dark] .modal .btn-close { filter: none; }
[data-bs-theme=dark] .modal .btn-close:hover::before { background-color: var(--bs-heading-color); }
[data-bs-theme=dark] .bg-white { background-color: var(--bs-paper-bg) !important; }
[data-bs-theme=dark] .bg-light, [data-bs-theme=dark] .bg-lighter { background-color: rgba(228, 228, 240, .05) !important; }
[data-bs-theme=dark] .text-dark { color: var(--bs-heading-color) !important; }
[data-bs-theme=dark] .text-black { color: #e4e4f0 !important; }
[data-bs-theme=dark] .border-light { border-color: var(--bs-border-color) !important; }
[data-bs-theme=dark] .bg-label-secondary { background-color: rgba(133, 146, 163, .2) !important; }
[data-bs-theme=dark] .bg-label-dark { background-color: rgba(228, 228, 240, .1) !important; color: #d5d5e2 !important; }
[data-bs-theme=dark] .badge.bg-light { color: var(--bs-heading-color); }
[data-bs-theme=dark] .alert { --bs-alert-bg: transparent; }
[data-bs-theme=dark] hr { color: var(--bs-border-color); opacity: 1; }
[data-bs-theme=dark] ::selection { background: rgba(105, 108, 255, .4); }
[data-bs-theme=dark] ::-webkit-scrollbar-thumb { background: #4a4b68; border-radius: 6px; }
[data-bs-theme=dark] .ps__thumb-y, [data-bs-theme=dark] .ps__thumb-x { background-color: #5a5b79 !important; }

/* App-specific pieces */
[data-bs-theme=dark] .form-actions-sticky { background: rgba(43, 44, 64, .92); }
[data-bs-theme=dark] .cal-day.is-other { background: rgba(228, 228, 240, .02); }
[data-bs-theme=dark] .matrix-wrap tr.module-row > * { background: #30314a !important; }
[data-bs-theme=dark] .ev-yellow { color: #ffcd66; }
[data-bs-theme=dark] .mail-body { color: var(--bs-body-color); }
/* HTML emails are designed for white paper: keep them readable */
[data-bs-theme=dark] .mail-body.mail-html { background: #fff; color: #222; border-radius: .375rem; padding: 1rem; }
[data-bs-theme=dark] .compose-editor { color: var(--bs-heading-color); }

/* Smooth swap when the toggle is used */
html.theme-switching *, html.theme-switching *::before, html.theme-switching *::after { transition: none !important; }
