/* ═══════════════════════════════════════════════════════
   ShuleFlow Dark Mode — comprehensive [data-theme="dark"]
   overrides for Bootstrap, glassmorphism, and custom classes.
   Token variables are defined in the dashboard inline <style>.
   ═══════════════════════════════════════════════════════ */

/* ── Body & root ─────────────────────────────────────── */
[data-theme="dark"] body {
    color: #e2e8f0;
}

/* ── Glass utilities ─────────────────────────────────── */
[data-theme="dark"] .glass {
    background: rgba(30,41,59,0.85);
    border-color: rgba(255,255,255,0.1);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    color: #e2e8f0;
}
[data-theme="dark"] .glass-medium {
    background: rgba(30,41,59,0.9);
    border-color: rgba(255,255,255,0.08);
}

/* ── Bootstrap Card ──────────────────────────────────── */
[data-theme="dark"] .card-header {
    background: rgba(15,23,42,0.6);
    border-bottom-color: rgba(255,255,255,0.08);
    color: #e2e8f0;
}
[data-theme="dark"] .card-body { color: #e2e8f0; }
[data-theme="dark"] .card-footer {
    background: rgba(15,23,42,0.4);
    border-top-color: rgba(255,255,255,0.08);
    color: #94a3b8;
}

/* ── Glassmorphism stat / content cards ──────────────── */
[data-theme="dark"] .stat-icon.primary { background: rgba(59,130,246,0.2); color: #60a5fa; }
[data-theme="dark"] .stat-icon.success { background: rgba(16,185,129,0.2); color: #34d399; }
[data-theme="dark"] .stat-icon.warning { background: rgba(245,158,11,0.2); color: #fbbf24; }
[data-theme="dark"] .stat-icon.danger  { background: rgba(239,68,68,0.2);  color: #f87171; }
[data-theme="dark"] .stat-icon.info    { background: rgba(6,182,212,0.2);  color: #22d3ee; }

/* ── Table (glassmorphism.min.css overrides) ─────────── */
[data-theme="dark"] .table {
    background: rgba(15,23,42,0.7);
    border-color: rgba(255,255,255,0.1);
    --bs-table-color: #e2e8f0;
    --bs-table-bg: transparent;
    --bs-table-border-color: rgba(255,255,255,0.08);
    --bs-table-striped-bg: rgba(255,255,255,0.03);
    --bs-table-hover-bg: rgba(59,130,246,0.1);
}
[data-theme="dark"] .table thead {
    background: linear-gradient(135deg,rgba(59,130,246,0.15) 0%,rgba(139,92,246,0.12) 100%);
    border-bottom-color: rgba(255,255,255,0.12);
}
[data-theme="dark"] .table thead th {
    color: #94a3b8;
    border-color: rgba(255,255,255,0.1);
}
[data-theme="dark"] .table tbody { background: transparent; }
[data-theme="dark"] .table tbody tr {
    border-bottom-color: rgba(255,255,255,0.06);
    background: rgba(30,41,59,0.4);
}
[data-theme="dark"] .table tbody tr:hover {
    background: rgba(59,130,246,0.1);
}
[data-theme="dark"] .table tbody td {
    color: #cbd5e1;
    border-bottom-color: rgba(255,255,255,0.06);
}
[data-theme="dark"] .table tfoot {
    background: rgba(15,23,42,0.5);
    border-top-color: rgba(59,130,246,0.2);
}
[data-theme="dark"] .table tfoot td { color: #e2e8f0; }
[data-theme="dark"] .table-striped tbody tr:nth-of-type(odd) {
    background: rgba(255,255,255,0.02);
    border-bottom-color: rgba(255,255,255,0.06);
}
[data-theme="dark"] .table-responsive {
    background: rgba(15,23,42,0.7);
    border-color: rgba(255,255,255,0.1);
}
[data-theme="dark"] .table-card {
    background: rgba(15,23,42,0.7);
    border-color: rgba(255,255,255,0.1);
}
[data-theme="dark"] .table-toolbar,
[data-theme="dark"] .table-pagination {
    background: rgba(15,23,42,0.5);
    border-color: rgba(255,255,255,0.06);
}

/* ── Forms ───────────────────────────────────────────── */
[data-theme="dark"] .form-label,
[data-theme="dark"] .col-form-label { color: #cbd5e1; }
[data-theme="dark"] .form-check-label { color: #e2e8f0; }
[data-theme="dark"] .form-text { color: #64748b; }
[data-theme="dark"] .input-group-text {
    background: rgba(15,23,42,0.7);
    border-color: rgba(255,255,255,0.15);
    color: #94a3b8;
}
[data-theme="dark"] .form-select option { background: #1e293b; color: #e2e8f0; }
[data-theme="dark"] .form-control:disabled,
[data-theme="dark"] .form-select:disabled {
    background: rgba(15,23,42,0.4);
    color: #475569;
    border-color: rgba(255,255,255,0.08) !important;
}
[data-theme="dark"] .glass-input,
[data-theme="dark"] .glass-select {
    background: rgba(15,23,42,0.6);
    border-color: rgba(255,255,255,0.15);
    color: #e2e8f0;
}
[data-theme="dark"] .glass-input:focus {
    background: rgba(15,23,42,0.85);
    border-color: #3b82f6;
}
[data-theme="dark"] select.form-select { color-scheme: dark; }

/* ── Flatpickr ───────────────────────────────────────── */
[data-theme="dark"] .flatpickr-calendar {
    background: #1e293b;
    border-color: rgba(255,255,255,0.1);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    color: #e2e8f0;
}
[data-theme="dark"] .flatpickr-months,
[data-theme="dark"] .flatpickr-weekdays { background: rgba(15,23,42,0.8); }
[data-theme="dark"] .flatpickr-weekday { color: #94a3b8; }
[data-theme="dark"] .flatpickr-day { color: #cbd5e1; }
[data-theme="dark"] .flatpickr-day:hover { background: rgba(59,130,246,0.2); border-color: transparent; }
[data-theme="dark"] .flatpickr-day.today { border-color: #3b82f6; color: #60a5fa; }
[data-theme="dark"] .flatpickr-day.prevMonthDay,
[data-theme="dark"] .flatpickr-day.nextMonthDay { color: #475569; }
[data-theme="dark"] .flatpickr-input[readonly] { background: rgba(15,23,42,0.6) !important; color: #e2e8f0; }

/* ── Modal ───────────────────────────────────────────── */
[data-theme="dark"] .modal-header {
    border-bottom-color: rgba(255,255,255,0.08);
    color: #e2e8f0;
}
[data-theme="dark"] .modal-footer {
    border-top-color: rgba(255,255,255,0.08);
}
[data-theme="dark"] .modal-title { color: #f1f5f9; }
[data-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }
/* Except the red modal close buttons — re-apply their filter on top */
[data-theme="dark"] .modal-header .btn-close,
[data-theme="dark"] .modal .btn-close[data-bs-dismiss="modal"] {
    filter: invert(27%) sepia(95%) saturate(2878%) hue-rotate(346deg) brightness(104%) contrast(97%);
    opacity: 1;
}

/* ── Dropdowns (Bootstrap) ───────────────────────────── */
[data-theme="dark"] .dropdown-menu {
    background: #1e293b;
    border-color: rgba(255,255,255,0.1);
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
    color: #e2e8f0;
}
[data-theme="dark"] .dropdown-item {
    color: #e2e8f0;
}
[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus {
    background: rgba(255,255,255,0.08);
    color: #ffffff;
}
[data-theme="dark"] .dropdown-item.active,
[data-theme="dark"] .dropdown-item:active {
    background: rgba(59,130,246,0.25);
    color: #ffffff;
}
[data-theme="dark"] .dropdown-divider { border-top-color: rgba(255,255,255,0.08); }
[data-theme="dark"] .dropdown-header { color: #64748b; }

/* ── Alerts ──────────────────────────────────────────── */
[data-theme="dark"] .alert { border-radius: 12px; }
[data-theme="dark"] .alert-success {
    background: rgba(25,135,84,0.15);
    border-color: rgba(25,135,84,0.3);
    color: #75b798;
}
[data-theme="dark"] .alert-danger {
    background: rgba(220,53,69,0.15);
    border-color: rgba(220,53,69,0.3);
    color: #ea868f;
}
[data-theme="dark"] .alert-warning {
    background: rgba(255,193,7,0.15);
    border-color: rgba(255,193,7,0.3);
    color: #ffda6a;
}
[data-theme="dark"] .alert-info {
    background: rgba(13,202,240,0.15);
    border-color: rgba(13,202,240,0.3);
    color: #6edff6;
}
[data-theme="dark"] .alert-primary {
    background: rgba(59,130,246,0.15);
    border-color: rgba(59,130,246,0.3);
    color: #93c5fd;
}

/* ── Badges ──────────────────────────────────────────── */
[data-theme="dark"] .badge.bg-light {
    background: rgba(255,255,255,0.12) !important;
    color: #e2e8f0 !important;
}
[data-theme="dark"] .badge.bg-white {
    background: rgba(255,255,255,0.1) !important;
    color: #e2e8f0 !important;
}

/* ── Lists ───────────────────────────────────────────── */
[data-theme="dark"] .list-group-item {
    background: rgba(30,41,59,0.7);
    border-color: rgba(255,255,255,0.08);
    color: #e2e8f0;
}
[data-theme="dark"] .list-group-item:hover {
    background: rgba(255,255,255,0.05);
}
[data-theme="dark"] .list-group-item.active {
    background: rgba(59,130,246,0.25);
    border-color: rgba(59,130,246,0.3);
}

/* ── Tabs ────────────────────────────────────────────── */
[data-theme="dark"] .nav-tabs { border-bottom-color: rgba(255,255,255,0.1); }
[data-theme="dark"] .nav-tabs .nav-link {
    color: #94a3b8;
    border-color: transparent;
}
[data-theme="dark"] .nav-tabs .nav-link:hover {
    border-color: rgba(255,255,255,0.1);
    color: #e2e8f0;
}
[data-theme="dark"] .nav-tabs .nav-link.active {
    background: rgba(30,41,59,0.9);
    border-color: rgba(255,255,255,0.12) rgba(255,255,255,0.12) transparent;
    color: #e2e8f0;
}
[data-theme="dark"] .nav-pills .nav-link { color: #94a3b8; }
[data-theme="dark"] .nav-pills .nav-link.active,
[data-theme="dark"] .nav-pills .show>.nav-link {
    background: rgba(59,130,246,0.25);
    color: #93c5fd;
}

/* ── Pagination ──────────────────────────────────────── */
[data-theme="dark"] .page-link {
    background: rgba(30,41,59,0.8);
    border-color: rgba(255,255,255,0.1);
    color: #e2e8f0;
}
[data-theme="dark"] .page-link:hover {
    background: rgba(59,130,246,0.2);
    border-color: rgba(59,130,246,0.3);
    color: #93c5fd;
}
[data-theme="dark"] .page-item.active .page-link {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #fff;
}
[data-theme="dark"] .page-item.disabled .page-link {
    background: rgba(30,41,59,0.4);
    border-color: rgba(255,255,255,0.06);
    color: #475569;
}
[data-theme="dark"] .pagination-global .page-link {
    background: rgba(30,41,59,0.8);
    border-color: rgba(255,255,255,0.1);
    color: #cbd5e1;
}
[data-theme="dark"] .pagination-global .page-item.active .page-link {
    background: linear-gradient(135deg,rgba(59,130,246,0.35),rgba(139,92,246,0.25));
    border-color: rgba(59,130,246,0.4);
    color: #93c5fd;
}

/* ── Accordion ───────────────────────────────────────── */
[data-theme="dark"] .accordion-item {
    background: transparent;
    border-color: rgba(255,255,255,0.08);
}
[data-theme="dark"] .accordion-button {
    background: rgba(30,41,59,0.7);
    color: #e2e8f0;
}
[data-theme="dark"] .accordion-button:not(.collapsed) {
    background: rgba(59,130,246,0.1);
    color: #e2e8f0;
    box-shadow: inset 0 -1px 0 rgba(255,255,255,0.08);
}
[data-theme="dark"] .accordion-button::after { filter: invert(1); }
[data-theme="dark"] .accordion-body {
    background: rgba(30,41,59,0.5);
    color: #e2e8f0;
}

/* ── Toast / Toasts ──────────────────────────────────── */
[data-theme="dark"] .toast {
    background: #1e293b;
    border-color: rgba(255,255,255,0.1);
    color: #e2e8f0;
}
[data-theme="dark"] .toast-header {
    background: rgba(15,23,42,0.8);
    border-bottom-color: rgba(255,255,255,0.1);
    color: #e2e8f0;
}
[data-theme="dark"] .toast-header .btn-close { filter: invert(1); }

/* ── Breadcrumbs ─────────────────────────────────────── */
[data-theme="dark"] .breadcrumb-item { color: #94a3b8; }
[data-theme="dark"] .breadcrumb-item.active { color: #64748b; }
[data-theme="dark"] .breadcrumb-item+.breadcrumb-item::before { color: #475569; }
[data-theme="dark"] .breadcrumb-item a { color: #60a5fa !important; }

/* ── Progress ────────────────────────────────────────── */
[data-theme="dark"] .progress { background: rgba(15,23,42,0.6); }

/* ── Spinners / Loading ──────────────────────────────── */
[data-theme="dark"] .spinner-border,
[data-theme="dark"] .spinner-grow { color: #60a5fa; }

/* ── Code / Pre ──────────────────────────────────────── */
[data-theme="dark"] pre,
[data-theme="dark"] code {
    background: rgba(15,23,42,0.8);
    color: #93c5fd;
    border-color: rgba(255,255,255,0.08);
}

/* ── HR / Dividers ───────────────────────────────────── */
[data-theme="dark"] hr { border-color: rgba(255,255,255,0.1); }

/* ── Text utilities ──────────────────────────────────── */
[data-theme="dark"] .text-muted   { color: #64748b !important; }
[data-theme="dark"] .text-dark    { color: #e2e8f0 !important; }
[data-theme="dark"] .text-body    { color: #e2e8f0 !important; }
[data-theme="dark"] .text-secondary { color: #94a3b8 !important; }
[data-theme="dark"] h1,[data-theme="dark"] h2,[data-theme="dark"] h3,
[data-theme="dark"] h4,[data-theme="dark"] h5,[data-theme="dark"] h6 { color: #f1f5f9; }
[data-theme="dark"] p { color: #cbd5e1; }
[data-theme="dark"] small { color: #94a3b8; }
[data-theme="dark"] label { color: #cbd5e1; }

/* ── Border utilities ────────────────────────────────── */
[data-theme="dark"] .border { border-color: rgba(255,255,255,0.1) !important; }
[data-theme="dark"] .border-top    { border-top-color: rgba(255,255,255,0.1) !important; }
[data-theme="dark"] .border-bottom { border-bottom-color: rgba(255,255,255,0.1) !important; }

/* ── Background utilities ────────────────────────────── */
[data-theme="dark"] .bg-white {
    background: rgba(30,41,59,0.9) !important;
    color: #e2e8f0 !important;
}
[data-theme="dark"] .bg-light {
    background: rgba(30,41,59,0.6) !important;
    color: #e2e8f0 !important;
}
[data-theme="dark"] .bg-body-tertiary {
    background: rgba(15,23,42,0.5) !important;
}

/* ── Outline buttons ─────────────────────────────────── */
[data-theme="dark"] .btn-outline-primary  { color: #60a5fa; border-color: #60a5fa; }
[data-theme="dark"] .btn-outline-primary:hover { background: rgba(59,130,246,0.2); color: #93c5fd; }
[data-theme="dark"] .btn-outline-secondary { color: #94a3b8; border-color: #475569; }
[data-theme="dark"] .btn-outline-secondary:hover { background: rgba(71,85,105,0.3); color: #cbd5e1; }
[data-theme="dark"] .btn-outline-success  { color: #34d399; border-color: #34d399; }
[data-theme="dark"] .btn-outline-success:hover { background: rgba(16,185,129,0.2); color: #6ee7b7; }
[data-theme="dark"] .btn-outline-danger   { color: #f87171; border-color: #f87171; }
[data-theme="dark"] .btn-outline-danger:hover  { background: rgba(239,68,68,0.2); color: #fca5a5; }
[data-theme="dark"] .btn-outline-warning  { color: #fbbf24; border-color: #fbbf24; }
[data-theme="dark"] .btn-outline-light    { color: #cbd5e1; border-color: rgba(255,255,255,0.2); }
[data-theme="dark"] .btn-light {
    background: rgba(255,255,255,0.08) !important;
    border-color: rgba(255,255,255,0.1) !important;
    color: #e2e8f0 !important;
}

/* ── Select2 / Tom Select ────────────────────────────── */
[data-theme="dark"] .ts-wrapper .ts-control {
    background: rgba(15,23,42,0.6);
    border-color: rgba(255,255,255,0.15);
    color: #e2e8f0;
}
[data-theme="dark"] .ts-dropdown {
    background: #1e293b;
    border-color: rgba(255,255,255,0.1);
    color: #e2e8f0;
}
[data-theme="dark"] .ts-dropdown .option:hover,
[data-theme="dark"] .ts-dropdown .option.active { background: rgba(59,130,246,0.2); }

/* ── Quill editor ────────────────────────────────────── */
[data-theme="dark"] .ql-toolbar {
    background: rgba(15,23,42,0.6);
    border-color: rgba(255,255,255,0.15) !important;
}
[data-theme="dark"] .ql-toolbar .ql-stroke { stroke: #94a3b8; }
[data-theme="dark"] .ql-toolbar .ql-fill   { fill: #94a3b8; }
[data-theme="dark"] .ql-container {
    background: rgba(15,23,42,0.4);
    border-color: rgba(255,255,255,0.15) !important;
    color: #e2e8f0;
}
[data-theme="dark"] .ql-editor.ql-blank::before { color: #475569; }

/* ── Placeholder / skeleton ──────────────────────────── */
[data-theme="dark"] .placeholder { background: rgba(255,255,255,0.1); }
[data-theme="dark"] .placeholder-glow .placeholder { background: rgba(255,255,255,0.08); }

/* ── Visitor / misc custom ───────────────────────────── */
[data-theme="dark"] .visitor-photo-placeholder {
    background: rgba(255,255,255,0.04);
    border-color: rgba(255,255,255,0.1);
    color: #64748b;
}

/* ── Footer copyright text ───────────────────────────── */
[data-theme="dark"] .footer-copyright { color: #475569; }

/* ── Scrollbars (webkit) ─────────────────────────────── */
[data-theme="dark"] ::-webkit-scrollbar-track { background: rgba(15,23,42,0.3); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(59,130,246,0.35); }

/* ── Mobile: table-actions sticky column dark bg ─────── */
@media (max-width: 576px) {
    [data-theme="dark"] .table-actions {
        background: rgba(15,23,42,0.97) !important;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }
}

/* ── Pagination bar text (dark mode) ─────────────────── */
[data-theme="dark"] .pagination-bar-summary { color: #64748b; }
[data-theme="dark"] .pagination-bar-links a,
[data-theme="dark"] .pagination-bar-links span { color: #94a3b8; }

/* ── Table toolbar dark mode ─────────────────────────── */
[data-theme="dark"] .table-toolbar {
    background: rgba(15,23,42,0.6);
    border-color: rgba(255,255,255,0.07);
    color: #cbd5e1;
}
[data-theme="dark"] .table-toolbar .form-control,
[data-theme="dark"] .table-toolbar .form-select {
    background: rgba(15,23,42,0.7);
    border-color: rgba(255,255,255,0.12);
    color: #e2e8f0;
}

/* ── Disabled pagination item (pagination-global) ───── */
[data-theme="dark"] .pagination-global .page-item.disabled .page-link {
    background: rgba(15,23,42,0.5);
    border-color: rgba(255,255,255,0.06);
    color: #475569;
}

/* ── Table card dark bg ─────────────────────────────── */
[data-theme="dark"] .table-card {
    background: rgba(30,41,59,0.85);
    border-color: rgba(255,255,255,0.08);
}

/* ── Glass table dark variant ───────────────────────── */
[data-theme="dark"] .glass-table {
    background: rgba(30,41,59,0.85);
    border-color: rgba(255,255,255,0.08);
}
