/*
 * 13/11/2026 — Giao diện tối cho admin (bản tối thiểu).
 * Bật bằng class "dark-mode" trên <html> (script trong components/header.html đọc localStorage
 * "hx-admin-theme" trước khi vẽ trang, nút đổi ở components/topNavBar.html).
 * AdminLTE 3.2 đã có sẵn quy tắc ".dark-mode ..." cho menu, thẻ, bảng, form, modal, select2;
 * file này đổi bảng màu sang tông xanh đen (giống trang theo dõi dự án) và vá các chỗ admin tự
 * viết màu sáng. Mọi quy tắc đều bắt đầu bằng html.dark-mode nên chế độ sáng không bị ảnh hưởng.
 */
html.dark-mode {
    --hx-bg: #0b1220;
    --hx-surface: #131c2e;
    --hx-surface-2: #1a2538;
    --hx-surface-3: #223049;
    --hx-border: #263247;
    --hx-text: #e5e9f0;
    --hx-muted: #9aa4b2;
    --hx-primary: #4f8cff;
    --hx-primary-hover: #6a9dff;
    --hx-success: #22c55e;
    --hx-warning: #f59e0b;
    --hx-danger: #f05252;

    /* Bootstrap 5.3 (nạp sau AdminLTE) dùng biến CSS */
    --bs-body-bg: var(--hx-bg);
    --bs-body-color: var(--hx-text);
    --bs-border-color: var(--hx-border);
    --bs-secondary-color: var(--hx-muted);
    --bs-tertiary-bg: var(--hx-surface-2);
    --bs-emphasis-color: #ffffff;
    --bs-heading-color: var(--hx-text);
    --bs-link-color: var(--hx-primary);
    --bs-link-hover-color: var(--hx-primary-hover);
    color-scheme: dark;
    background-color: var(--hx-bg);
}

html.dark-mode body,
html.dark-mode .wrapper,
html.dark-mode .content-wrapper {
    background-color: var(--hx-bg) !important;
    color: var(--hx-text);
}

html.dark-mode h1, html.dark-mode h2, html.dark-mode h3,
html.dark-mode h4, html.dark-mode h5, html.dark-mode h6,
html.dark-mode label, html.dark-mode legend {
    color: var(--hx-text);
}

html.dark-mode a { color: var(--hx-primary); }
html.dark-mode a:hover { color: var(--hx-primary-hover); }
html.dark-mode .text-muted, html.dark-mode small.text-muted, html.dark-mode .form-text { color: var(--hx-muted) !important; }
html.dark-mode .text-dark { color: var(--hx-text) !important; }
html.dark-mode hr { border-color: var(--hx-border); }
/* Link chữ tối viết sẵn trong thẻ (vd "Sales by state" ở Dashboard); link đã có màu riêng (text-*, badge, nút) giữ nguyên */
html.dark-mode .bg-white a:not(.btn):not(.nav-link):not(.dropdown-item):not(.badge):not([class*="text-"]) { color: var(--hx-primary) !important; }
html.dark-mode .form-control-plaintext { color: var(--hx-text) !important; }

/* ---- Thanh trên cùng, menu trái, chân trang ---- */
html.dark-mode .main-header.navbar {
    background-color: var(--hx-surface) !important;
    border-bottom: 1px solid var(--hx-border) !important;
}
html.dark-mode .main-header .nav-link,
html.dark-mode .main-header h4 { color: var(--hx-text) !important; }
html.dark-mode .main-header .nav-link:hover { color: #ffffff !important; }
html.dark-mode .main-sidebar,
html.dark-mode .main-sidebar .brand-link { background-color: #0d1526 !important; }
html.dark-mode .main-sidebar .brand-link { border-bottom-color: var(--hx-border) !important; }
html.dark-mode .nav-sidebar .nav-link { color: #c7d0dc !important; }
html.dark-mode .nav-sidebar .nav-link.active,
html.dark-mode .nav-sidebar > .nav-item > .nav-link.active {
    background-color: var(--hx-primary) !important;
    color: #ffffff !important;
}
html.dark-mode .nav-sidebar .nav-treeview .nav-link.active { background-color: var(--hx-surface-3) !important; }
html.dark-mode .main-footer {
    background-color: var(--hx-surface) !important;
    border-top-color: var(--hx-border) !important;
    color: var(--hx-muted);
}

/* ---- Thẻ, khung ---- */
html.dark-mode .card,
html.dark-mode .info-box,
html.dark-mode .small-box,
html.dark-mode .callout,
html.dark-mode .jumbotron,
html.dark-mode .bg-white,
html.dark-mode .bg-light {
    background-color: var(--hx-surface) !important;
    color: var(--hx-text) !important;
    border-color: var(--hx-border) !important;
}
html.dark-mode .card { border: 1px solid var(--hx-border); box-shadow: none; }
html.dark-mode .card-header,
html.dark-mode .card-footer {
    background-color: var(--hx-surface-2) !important;
    border-color: var(--hx-border) !important;
    color: var(--hx-text);
}
html.dark-mode .border, html.dark-mode .border-top, html.dark-mode .border-bottom,
html.dark-mode .border-left, html.dark-mode .border-right { border-color: var(--hx-border) !important; }

/* ---- Bảng (gồm DataTables) ---- */
html.dark-mode .table {
    color: var(--hx-text);
    background-color: transparent;
    --bs-table-bg: transparent;
    --bs-table-color: var(--hx-text);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.03);
    --bs-table-striped-color: var(--hx-text);
    --bs-table-hover-bg: rgba(79, 140, 255, 0.10);
    --bs-table-hover-color: #ffffff;
    --bs-table-border-color: var(--hx-border);
}
html.dark-mode .table td,
html.dark-mode .table th { border-color: var(--hx-border) !important; }
html.dark-mode .table thead th,
html.dark-mode .table thead td,
html.dark-mode .thead-light th {
    background-color: var(--hx-surface-2) !important;
    color: var(--hx-text) !important;
}
html.dark-mode .table-striped tbody tr:nth-of-type(odd) { background-color: rgba(255, 255, 255, 0.03); }
html.dark-mode .table-hover tbody tr:hover { background-color: rgba(79, 140, 255, 0.10); color: #ffffff; }
html.dark-mode .table tr.table-active, html.dark-mode .table-active > td { background-color: var(--hx-surface-3) !important; }
/* 13/11/2026: dòng bảng tô màu kiểu Bootstrap (table-light / -warning / -danger / -success / -info / -secondary / -primary)
   — trước còn nền trắng / vàng sáng (vd. AI Assistant › Rules, Handoffs, Island / Room drawing đang sửa) */
html.dark-mode .table-light, html.dark-mode .table-light > td, html.dark-mode .table-light > th { background-color: var(--hx-surface-3) !important; color: var(--hx-text) !important; }
html.dark-mode .table-warning, html.dark-mode .table-warning > td, html.dark-mode .table-warning > th { background-color: rgba(245, 158, 11, 0.16) !important; color: #fcd9a0 !important; }
html.dark-mode .table-danger, html.dark-mode .table-danger > td, html.dark-mode .table-danger > th { background-color: rgba(240, 82, 82, 0.18) !important; color: #ffc4c4 !important; }
html.dark-mode .table-success, html.dark-mode .table-success > td, html.dark-mode .table-success > th { background-color: rgba(34, 197, 94, 0.16) !important; color: #b8f0cb !important; }
html.dark-mode .table-info, html.dark-mode .table-info > td, html.dark-mode .table-info > th,
html.dark-mode .table-primary, html.dark-mode .table-primary > td, html.dark-mode .table-primary > th { background-color: rgba(79, 140, 255, 0.16) !important; color: #c7dbff !important; }
html.dark-mode .table-secondary, html.dark-mode .table-secondary > td, html.dark-mode .table-secondary > th { background-color: rgba(148, 163, 184, 0.14) !important; color: var(--hx-text) !important; }
html.dark-mode .dataTables_wrapper,
html.dark-mode .dataTables_info,
html.dark-mode .dataTables_length,
html.dark-mode .dataTables_filter { color: var(--hx-muted) !important; }

/* ---- Form ---- */
html.dark-mode .form-control,
html.dark-mode .custom-select,
html.dark-mode .form-select,
html.dark-mode select,
html.dark-mode textarea,
html.dark-mode input[type="text"],
html.dark-mode input[type="number"],
html.dark-mode input[type="email"],
html.dark-mode input[type="password"],
html.dark-mode input[type="search"],
html.dark-mode input[type="date"],
html.dark-mode input[type="url"] {
    background-color: var(--hx-surface-2) !important;
    color: var(--hx-text) !important;
    border-color: var(--hx-border) !important;
}
html.dark-mode .form-control:focus,
html.dark-mode .custom-select:focus,
html.dark-mode select:focus,
html.dark-mode textarea:focus {
    border-color: var(--hx-primary) !important;
    box-shadow: 0 0 0 0.15rem rgba(79, 140, 255, 0.25) !important;
}
html.dark-mode .form-control::placeholder,
html.dark-mode textarea::placeholder,
html.dark-mode input::placeholder { color: #6b7686 !important; }
html.dark-mode .form-control:disabled,
html.dark-mode .form-control[readonly],
html.dark-mode select:disabled,
html.dark-mode select[multiple]:disabled {
    background-color: #151f31 !important;
    color: var(--hx-muted) !important;
}
html.dark-mode select option { background-color: var(--hx-surface-2); color: var(--hx-text); }
html.dark-mode .input-group-text {
    background-color: var(--hx-surface-3) !important;
    color: var(--hx-text) !important;
    border-color: var(--hx-border) !important;
}
/* select2 */
html.dark-mode .select2-container--default .select2-selection--single,
html.dark-mode .select2-container--default .select2-selection--multiple,
html.dark-mode .select2-container--bootstrap4 .select2-selection,
html.dark-mode .select2-dropdown {
    background-color: var(--hx-surface-2) !important;
    border-color: var(--hx-border) !important;
    color: var(--hx-text) !important;
}
html.dark-mode .select2-container .select2-selection__rendered { color: var(--hx-text) !important; }
html.dark-mode .select2-results__option { color: var(--hx-text); }
html.dark-mode .select2-container--default .select2-results__option--highlighted[aria-selected],
html.dark-mode .select2-container--default .select2-results__option--highlighted {
    background-color: var(--hx-primary) !important;
    color: #ffffff !important;
}
html.dark-mode .select2-search__field { background-color: var(--hx-surface) !important; color: var(--hx-text) !important; }
html.dark-mode .select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: var(--hx-surface-3) !important;
    border-color: var(--hx-border) !important;
    color: var(--hx-text) !important;
}

/* ---- Nút ---- */
html.dark-mode .btn-default,
html.dark-mode .btn-light,
html.dark-mode .btn-outline-secondary,
html.dark-mode .btn-outline-dark,
html.dark-mode .btn-secondary {
    background-color: var(--hx-surface-3) !important;
    border-color: var(--hx-border) !important;
    color: var(--hx-text) !important;
}
html.dark-mode .btn-default:hover,
html.dark-mode .btn-light:hover,
html.dark-mode .btn-outline-secondary:hover,
html.dark-mode .btn-outline-dark:hover,
html.dark-mode .btn-secondary:hover { background-color: #2b3b58 !important; color: #ffffff !important; }
html.dark-mode .btn-default:disabled,
html.dark-mode .btn-outline-secondary:disabled,
html.dark-mode .btn-light:disabled { opacity: 0.45; }
html.dark-mode .btn-primary { background-color: var(--hx-primary) !important; border-color: var(--hx-primary) !important; }
html.dark-mode .btn-outline-primary { color: var(--hx-primary) !important; border-color: var(--hx-primary) !important; }
html.dark-mode .btn-outline-primary:hover { background-color: var(--hx-primary) !important; color: #ffffff !important; }
html.dark-mode .btn-tool { color: var(--hx-muted) !important; }
html.dark-mode .badge-light { background-color: var(--hx-surface-3) !important; color: var(--hx-text) !important; }

/* ---- Modal, menu thả xuống, thông báo ---- */
html.dark-mode .modal-content {
    background-color: var(--hx-surface) !important;
    color: var(--hx-text) !important;
    border: 1px solid var(--hx-border) !important;
}
html.dark-mode .modal-header,
html.dark-mode .modal-footer { border-color: var(--hx-border) !important; }
html.dark-mode .close, html.dark-mode .btn-close { color: var(--hx-text) !important; text-shadow: none; opacity: 0.8; }
html.dark-mode .btn-close { filter: invert(1); }
html.dark-mode .dropdown-menu {
    background-color: var(--hx-surface-2) !important;
    border-color: var(--hx-border) !important;
    color: var(--hx-text) !important;
}
html.dark-mode .dropdown-item,
html.dark-mode .dropdown-header { color: var(--hx-text) !important; }
html.dark-mode .dropdown-item:hover,
html.dark-mode .dropdown-item:focus { background-color: var(--hx-surface-3) !important; color: #ffffff !important; }
html.dark-mode .dropdown-divider { border-top-color: var(--hx-border) !important; }
html.dark-mode .list-group-item {
    background-color: var(--hx-surface) !important;
    border-color: var(--hx-border) !important;
    color: var(--hx-text) !important;
}
html.dark-mode .list-group-item-action:hover { background-color: var(--hx-surface-3) !important; }
html.dark-mode .popover, html.dark-mode .popover-body { background-color: var(--hx-surface-2); color: var(--hx-text); }

/* ---- Tab, phân trang, breadcrumb ---- */
html.dark-mode .nav-tabs { border-bottom-color: var(--hx-border) !important; }
html.dark-mode .nav-tabs .nav-link { color: var(--hx-muted) !important; }
html.dark-mode .nav-tabs .nav-link.active,
html.dark-mode .nav-tabs .nav-item.show .nav-link {
    background-color: var(--hx-surface) !important;
    border-color: var(--hx-border) var(--hx-border) var(--hx-surface) !important;
    color: var(--hx-text) !important;
}
html.dark-mode .nav-pills .nav-link { color: var(--hx-muted); }
html.dark-mode .nav-pills .nav-link.active { background-color: var(--hx-primary) !important; color: #ffffff !important; }
html.dark-mode .page-link {
    background-color: var(--hx-surface-2) !important;
    border-color: var(--hx-border) !important;
    color: var(--hx-text) !important;
}
html.dark-mode .page-item.active .page-link {
    background-color: var(--hx-primary) !important;
    border-color: var(--hx-primary) !important;
    color: #ffffff !important;
}
html.dark-mode .page-item.disabled .page-link { color: #5d6878 !important; }
html.dark-mode .breadcrumb { background-color: transparent; }
html.dark-mode .breadcrumb-item, html.dark-mode .breadcrumb-item.active { color: var(--hx-muted); }

/* ---- Thông báo nền sáng nhạt của Bootstrap → bản tối ---- */
html.dark-mode .alert-info { background-color: rgba(79, 140, 255, 0.12) !important; border-color: rgba(79, 140, 255, 0.35) !important; color: #c8dbff !important; }
html.dark-mode .alert-warning { background-color: rgba(245, 158, 11, 0.12) !important; border-color: rgba(245, 158, 11, 0.35) !important; color: #fcd9a0 !important; }
html.dark-mode .alert-success { background-color: rgba(34, 197, 94, 0.12) !important; border-color: rgba(34, 197, 94, 0.35) !important; color: #b8f0cb !important; }
html.dark-mode .alert-danger { background-color: rgba(240, 82, 82, 0.12) !important; border-color: rgba(240, 82, 82, 0.35) !important; color: #ffc4c4 !important; }
html.dark-mode .alert-secondary, html.dark-mode .alert-light { background-color: var(--hx-surface-2) !important; border-color: var(--hx-border) !important; color: var(--hx-text) !important; }

/* ---- Trình soạn thảo, ô tải file ---- */
html.dark-mode .note-editor .note-toolbar,
html.dark-mode .note-editor .note-statusbar { background-color: var(--hx-surface-2) !important; border-color: var(--hx-border) !important; }
html.dark-mode .note-editor .note-editing-area .note-editable { background-color: var(--hx-surface) !important; color: var(--hx-text) !important; }
html.dark-mode .note-btn { background-color: var(--hx-surface-3) !important; color: var(--hx-text) !important; border-color: var(--hx-border) !important; }
html.dark-mode .ck.ck-editor__main > .ck-editor__editable { background-color: var(--hx-surface) !important; color: var(--hx-text) !important; }
html.dark-mode .ck.ck-toolbar { background-color: var(--hx-surface-2) !important; border-color: var(--hx-border) !important; }
html.dark-mode .ck.ck-button, html.dark-mode .ck.ck-toolbar .ck-button { color: var(--hx-text) !important; }
html.dark-mode .ck.ck-button:hover { background-color: var(--hx-surface-3) !important; }
html.dark-mode .dropzone { background-color: var(--hx-surface-2) !important; border-color: var(--hx-border) !important; color: var(--hx-text) !important; }

/* ---- Form sản phẩm / tủ: accordion (Bootstrap 5), ô giữ chỗ PDF, vùng kéo-thả file ---- */
html.dark-mode .accordion {
    --bs-accordion-bg: var(--hx-surface);
    --bs-accordion-color: var(--hx-text);
    --bs-accordion-border-color: var(--hx-border);
    --bs-accordion-btn-bg: var(--hx-surface-2);
    --bs-accordion-btn-color: var(--hx-text);
    --bs-accordion-active-bg: var(--hx-surface-3);
    --bs-accordion-active-color: #ffffff;
    background-color: var(--hx-surface) !important;
}
html.dark-mode .accordion-item,
html.dark-mode .accordion-body { background-color: var(--hx-surface) !important; color: var(--hx-text) !important; border-color: var(--hx-border) !important; }
html.dark-mode .custom-accordion-button,
html.dark-mode .accordion-button {
    background-color: var(--hx-surface-2) !important;
    border-color: var(--hx-border) !important;
    color: var(--hx-text) !important;
}
html.dark-mode .accordion-button::after { filter: invert(1) brightness(1.6); }
html.dark-mode .texture-pdf-placeholder { background-color: var(--hx-surface-2) !important; border-color: var(--hx-border) !important; }
html.dark-mode .dz-button,
html.dark-mode .dz-message { color: var(--hx-muted) !important; }

/* ---- Vá màu viết thẳng trong HTML (style="...") ở các trang hay dùng ---- */
html.dark-mode [style*="background-color: #fff"],
html.dark-mode [style*="background-color:#fff"],
html.dark-mode [style*="background: #fff"],
html.dark-mode [style*="background:#fff"],
html.dark-mode [style*="background-color: white"],
html.dark-mode [style*="background: white"],
html.dark-mode [style*="background-color: #f8f9fa"],
html.dark-mode [style*="background: #f8f9fa"],
html.dark-mode [style*="background-color: #f8fafc"],
html.dark-mode [style*="background: #f8fafc"],
html.dark-mode [style*="background-color: #f5f5f5"],
html.dark-mode [style*="background: #f5f5f5"],
html.dark-mode [style*="background-color: #f1f5f9"],
html.dark-mode [style*="background: #f1f5f9"] {
    background-color: var(--hx-surface-2) !important;
    color: var(--hx-text) !important;
}
html.dark-mode [style*="color: #333"],
html.dark-mode [style*="color:#333"],
html.dark-mode [style*="color: #000"],
html.dark-mode [style*="color:#000"],
html.dark-mode [style*="color: black"],
html.dark-mode [style*="color: #212529"],
html.dark-mode [style*="color: #1a2b3d"],
html.dark-mode [style*="color: #111827"] {
    color: var(--hx-text) !important;
}
html.dark-mode [style*="color: #6c757d"],
html.dark-mode [style*="color: #666"],
html.dark-mode [style*="color: #6b7280"] { color: var(--hx-muted) !important; }

/* ---- Trang chi tiết đơn hàng (static/extend/css/order.css, class od-*) ---- */
html.dark-mode .od-page-wrap,
html.dark-mode .od-shell-body { background: var(--hx-bg) !important; }
html.dark-mode .od-card,
html.dark-mode .od-advanced,
html.dark-mode .od-status-banner,
html.dark-mode .od-bank-strip,
html.dark-mode .od-activity-log,
html.dark-mode .od-status-summary-card,
html.dark-mode .od-side-card,
html.dark-mode .od-admin-panel,
html.dark-mode .od-email-card,
html.dark-mode .od-support-card {
    background: var(--hx-surface) !important;
    border-color: var(--hx-border) !important;
    color: var(--hx-text);
}
html.dark-mode .od-code-box,
html.dark-mode .od-process-box,
html.dark-mode .od-btn-muted,
html.dark-mode .od-proof-frame__img-wrap,
html.dark-mode .od-proof-btn--mismatch,
html.dark-mode #orderTabPaymentProof .od-quick-verification-card {
    background: var(--hx-surface-2) !important;
    border-color: var(--hx-border) !important;
    color: var(--hx-text) !important;
}
html.dark-mode .od-btn-outline,
html.dark-mode .od-order-pill,
html.dark-mode .od-btn-icon,
html.dark-mode .od-btn-white {
    background: var(--hx-surface-2) !important;
    border-color: var(--hx-border) !important;
    color: var(--hx-text) !important;
}
html.dark-mode .od-btn-outline:hover:not(:disabled),
html.dark-mode .od-btn-white:hover,
html.dark-mode .od-proof-btn--mismatch:hover:not(:disabled) { background: var(--hx-surface-3) !important; color: #ffffff !important; }
html.dark-mode .od-order-pill--primary { background: var(--hx-primary) !important; color: #ffffff !important; border-color: var(--hx-primary) !important; }
html.dark-mode .od-toolbar__title,
html.dark-mode .od-value,
html.dark-mode .od-timeline__label,
html.dark-mode .od-summary-list,
html.dark-mode .od-mini-check,
html.dark-mode .od-bank-page-title,
html.dark-mode .od-form-title,
html.dark-mode .od-activity-label,
html.dark-mode .od-checklist .custom-control-label,
html.dark-mode .od-proof-btn--request,
html.dark-mode #orderTabPaymentProof .od-quick-verification-card__title { color: var(--hx-text) !important; }
html.dark-mode .od-label,
html.dark-mode .od-last-updated,
html.dark-mode .od-timeline__time,
html.dark-mode .od-activity-time { color: var(--hx-muted) !important; }
html.dark-mode .od-back,
html.dark-mode .od-value--lg,
html.dark-mode .od-status-banner__value,
html.dark-mode .od-link-ghost,
html.dark-mode .od-nav-tabs .nav-link:hover,
html.dark-mode .od-nav-tabs .nav-link.active { color: var(--hx-primary) !important; }
html.dark-mode .od-badge-soft,
html.dark-mode .od-delivery-icon,
html.dark-mode .od-pill-info,
html.dark-mode .od-activity-icon {
    background: rgba(79, 140, 255, 0.15) !important;
    color: #9cc0ff !important;
    border-color: var(--hx-surface) !important;
}
html.dark-mode .od-pill-status { background: rgba(34, 197, 94, 0.15) !important; color: #86efac !important; }
html.dark-mode .od-notify-strip { background: rgba(79, 140, 255, 0.10) !important; border-color: rgba(79, 140, 255, 0.30) !important; color: #c8dbff !important; }
html.dark-mode .od-proof-frame { background: rgba(79, 140, 255, 0.08) !important; border-color: rgba(79, 140, 255, 0.30) !important; }
html.dark-mode .od-refund-summary,
html.dark-mode .od-refund-box,
html.dark-mode .od-support-reply--internal { background: rgba(245, 158, 11, 0.10) !important; border-color: rgba(245, 158, 11, 0.35) !important; }
html.dark-mode .od-refund-summary__title,
html.dark-mode .od-refund-box__title { color: #fcd34d !important; }
html.dark-mode .od-bank-actions .btn-danger-soft { background: rgba(240, 82, 82, 0.12) !important; border-color: rgba(240, 82, 82, 0.35) !important; color: #fca5a5 !important; }
html.dark-mode .od-tabs-head,
html.dark-mode .od-proof-footer,
html.dark-mode .od-activity-log__head,
html.dark-mode .od-activity-item,
html.dark-mode .od-timeline__item::after,
html.dark-mode .od-proof-thumb,
html.dark-mode .od-support-thumb,
html.dark-mode .od-input-grid .form-control { border-color: var(--hx-border) !important; }
html.dark-mode .od-timeline__item::after { background: var(--hx-border) !important; }
html.dark-mode .kpi-action-required-badge { background: rgba(245, 158, 11, 0.15) !important; color: #fcd34d !important; border-color: rgba(245, 158, 11, 0.4) !important; }

/* =====================================================================================
 * Bản đầy đủ (13/11/2026): màn hình phụ — trang tạo / sửa / upload, hộp thoại, bảng phụ.
 * Mỗi nhóm ghi file gốc để khi sửa CSS gốc thì sửa luôn ở đây.
 * ===================================================================================== */

/* Màu nhạt cho trạng thái: nền trong suốt pha màu + chữ sáng cùng tông */
html.dark-mode {
    --hx-tint-green: rgba(34, 197, 94, 0.16);
    --hx-tint-yellow: rgba(245, 158, 11, 0.16);
    --hx-tint-red: rgba(240, 82, 82, 0.18);
    --hx-tint-orange: rgba(249, 115, 22, 0.16);
    --hx-tint-blue: rgba(79, 140, 255, 0.16);
    --hx-tint-purple: rgba(167, 139, 250, 0.18);
    --hx-tint-grey: rgba(148, 163, 184, 0.14);
}

/* --- static/css/style.css: trang đăng nhập / đặt lại mật khẩu --- */
html.dark-mode .login-page,
html.dark-mode .register-page,
html.dark-mode .reset-password-wrapper { background-color: var(--hx-bg) !important; }
html.dark-mode .login-logo a,
html.dark-mode .login-box .card-header a,
html.dark-mode .login-box-msg { color: var(--hx-text) !important; }
html.dark-mode .error-details,
html.dark-mode .success-details { color: var(--hx-muted) !important; }

/* --- style.css: hộp thoại tự viết (upload / xoá / xác nhận / trạng thái), tab, gallery --- */
html.dark-mode .modal-content-upload,
html.dark-mode .modal-content-delete,
html.dark-mode .modal-content-confirm,
html.dark-mode .status-popup,
html.dark-mode datalist {
    background-color: var(--hx-surface) !important;
    color: var(--hx-text) !important;
    border-color: var(--hx-border) !important;
}
html.dark-mode .modal-footer { background-color: var(--hx-surface) !important; }
html.dark-mode .status-btn:hover { background-color: var(--hx-surface-3) !important; }
html.dark-mode .tab-nav button { background-color: var(--hx-surface-2) !important; color: var(--hx-muted) !important; border-color: var(--hx-border) !important; }
html.dark-mode .tab-nav button.active { background-color: var(--hx-surface) !important; color: var(--hx-text) !important; }
html.dark-mode .media-gallery-modal-image,
html.dark-mode .media-gallery-modal-thumbnail,
html.dark-mode .media-gallery-modal-delete-image { background-color: var(--hx-surface-2) !important; }
html.dark-mode .media-gallery-modal-image::-webkit-scrollbar-track,
html.dark-mode .media-gallery-modal-thumbnail::-webkit-scrollbar-track,
html.dark-mode .media-gallery-modal-delete-image::-webkit-scrollbar-track { background: var(--hx-surface-3) !important; }

/* --- style.css: cây danh mục (Category), accordion, vùng kéo-thả --- */
html.dark-mode .tree-panel,
html.dark-mode .wj-treeview,
html.dark-mode .custom-accordion-item { background-color: var(--hx-surface) !important; color: var(--hx-text) !important; border-color: var(--hx-border) !important; }
html.dark-mode .wj-treeview .wj-node { color: var(--hx-text) !important; }
html.dark-mode .wj-treeview .wj-node.wj-state-selected { background-color: var(--hx-surface-3) !important; }
html.dark-mode .category-actions i:hover { color: var(--hx-primary-hover) !important; }
html.dark-mode .dropzone,
html.dark-mode .dropzone-sm,
html.dark-mode .custom-dropzone { background-color: var(--hx-surface-2) !important; border-color: var(--hx-border) !important; color: var(--hx-muted) !important; }
html.dark-mode .dropzone .dz-preview .dz-details { background-color: var(--hx-surface) !important; color: var(--hx-text) !important; }
html.dark-mode .dropzone .dz-message { color: var(--hx-muted) !important; }

/* --- style.css: danh sách sản phẩm dạng lưới (nút sửa / xoá nổi trên ảnh) --- */
html.dark-mode .cabinetry-item > .cabinetry-actions,
html.dark-mode .component-item > .component-actions,
html.dark-mode .product-item > .product-actions { background-color: var(--hx-surface-2) !important; }

/* --- style.css: Island Drawing — ô trạng thái --- */
html.dark-mode .island-cell.island-OK { background: var(--hx-tint-green) !important; color: #b8f0cb !important; }
html.dark-mode .island-cell.island-UNLINKED { background: var(--hx-tint-yellow) !important; color: #fcd9a0 !important; }
html.dark-mode .island-cell.island-MISSING { background: var(--hx-tint-red) !important; color: #ffc4c4 !important; }
html.dark-mode .island-cell.island-INACTIVE { background: var(--hx-tint-orange) !important; color: #fdc9a0 !important; }
html.dark-mode .island-cell.island-EMPTY { background: var(--hx-tint-grey) !important; color: var(--hx-muted) !important; }
html.dark-mode #islandGoVariants { color: var(--hx-primary) !important; }

/* --- style.css: Room Drawing — bảng vật thể, chú thích màu --- */
html.dark-mode .room-object-table tr.room-cat-row td { background: var(--hx-surface-2) !important; color: var(--hx-text) !important; }
html.dark-mode .room-key-room { color: var(--hx-text) !important; }
html.dark-mode .room-key-base { background: var(--hx-tint-blue) !important; color: #c8dbff !important; }
html.dark-mode .room-key-tall { background: var(--hx-tint-purple) !important; color: #d9ccff !important; }
html.dark-mode .room-key-island { background: var(--hx-tint-green) !important; color: #b8f0cb !important; }
html.dark-mode .room-key-appliance { background: var(--hx-tint-grey) !important; color: var(--hx-text) !important; }

/* --- style.css: Room Shapes, Face Styles, Cabinet Types, Box style spec --- */
html.dark-mode .shape-card .shape-thumb img,
html.dark-mode .shape-layout .layout-thumb img,
html.dark-mode .shape-preview,
html.dark-mode #faceStyleTable .face-thumb,
html.dark-mode #bssStyles .bss-thumb { background-color: #e9edf3 !important; } /* ảnh / bản vẽ nền trong: giữ nền sáng nhẹ để nhìn rõ nét */
html.dark-mode .shape-off.shape-layout,
html.dark-mode #faceStyleTable tr.face-off td,
html.dark-mode #cabTypeTable tr.cabtype-off td,
html.dark-mode #bssSections .bss-section.bss-off { background: #10192a !important; color: var(--hx-muted) !important; }
html.dark-mode #faceStyleTable tr.face-highlight td,
html.dark-mode #cabTypeTable tr.cabtype-highlight td { background: var(--hx-tint-yellow) !important; }
html.dark-mode #cabTypeTable tr.cabtype-group td { background: var(--hx-surface-3) !important; color: var(--hx-text) !important; }
html.dark-mode #cabTypeTable code { color: #c8dbff !important; background: transparent; }
html.dark-mode #cabTypeTable tr.cabtype-filter-row th { background: var(--hx-surface-2) !important; }
html.dark-mode .cabtype-column-panel,
html.dark-mode .bss-preview-item { background: var(--hx-surface) !important; color: var(--hx-text) !important; border-color: var(--hx-border) !important; }

/* --- cabinetry.css, component.css: bảng chọn cột, hàng bộ lọc --- */
html.dark-mode .cabinetry-column-panel,
html.dark-mode .cabinetry-column-panel-header,
html.dark-mode .component-column-panel,
html.dark-mode .component-column-panel-header { background-color: var(--hx-surface) !important; color: var(--hx-text) !important; border-color: var(--hx-border) !important; }
html.dark-mode #cabinetryColumnSelector .form-check:hover,
html.dark-mode #componentColumnSelector .form-check:hover,
html.dark-mode .cabinetry-selected-column,
html.dark-mode .component-selected-column { background-color: var(--hx-surface-2) !important; }
html.dark-mode .cabinetry-draggable-column.sortable-chosen,
html.dark-mode .cabinetry-draggable-column.sortable-ghost,
html.dark-mode .component-draggable-column.sortable-chosen,
html.dark-mode .component-draggable-column.sortable-ghost { background-color: var(--hx-tint-blue) !important; }
html.dark-mode .cabinetry-filter-row th,
html.dark-mode .component-filter-row th { background-color: var(--hx-surface-2) !important; }

/* --- import-excel.css: trang nhập Excel (bảng xem trước, ô sửa được, dòng lỗi) --- */
/* import-excel.css viết "th { background: #f0f0f0 }" và ".modal-header { background: #fff }" cho cả trang */
html.dark-mode th { background-color: var(--hx-surface-2); color: var(--hx-text); }
html.dark-mode .modal-header { background-color: transparent; }
html.dark-mode td[contenteditable="true"] { background-color: var(--hx-surface-2) !important; color: var(--hx-text) !important; }
html.dark-mode td[contenteditable="true"]:focus { outline: 1px solid var(--hx-primary); }
html.dark-mode .sort-arrow.active { color: var(--hx-text) !important; }
html.dark-mode .row-error td { background-color: var(--hx-tint-red) !important; }

/* --- room-default.css: bảng Room Default --- */
html.dark-mode .rd-cell:hover { background-color: var(--hx-surface-3) !important; }
html.dark-mode .rd-cell-selected { background-color: var(--hx-tint-blue) !important; }
html.dark-mode .rd-cell-add { background-color: var(--hx-tint-green) !important; }
html.dark-mode .rd-cell-remove { background-color: var(--hx-tint-red) !important; }
html.dark-mode .rd-cell-state { color: var(--hx-muted) !important; }
html.dark-mode .rd-cell-same-type:not(.rd-cell-add):not(.rd-cell-remove):not(.rd-cell-selected),
html.dark-mode .rd-legend-same { background-color: var(--hx-tint-yellow) !important; }
html.dark-mode .rd-table th, html.dark-mode .rd-header { background-color: var(--hx-surface-2) !important; color: var(--hx-text) !important; }

/* --- order.css: hộp thoại báo giá (Quotation) trong chi tiết đơn --- */
html.dark-mode #quotationDetailModal .quotation-modal-header,
html.dark-mode #quotationDetailModal .qr-card,
html.dark-mode #quotationDetailModal .qr-source-table,
html.dark-mode #quotationDetailModal .qr-oth-table { background: var(--hx-surface) !important; color: var(--hx-text) !important; border-color: var(--hx-border) !important; }
html.dark-mode #quotationDetailModal .qr-source-box { background: var(--hx-surface-2) !important; border-color: var(--hx-border) !important; }
html.dark-mode #quotationDetailModal .qr-source-table th,
html.dark-mode #quotationDetailModal .qr-oth-table th { background: var(--hx-surface-2) !important; color: var(--hx-text) !important; }
html.dark-mode #quotationDetailModal .quotation-modal-header .modal-title,
html.dark-mode #quotationDetailModal .qr-section-heading { color: var(--hx-text) !important; }
html.dark-mode #quotationDetailModal .qr-price { color: #86efac !important; }

/* --- <style> trong templates/pages/order/support-inbox.html --- */
html.dark-mode #supportInboxPage tr.si-row-open { background: var(--hx-tint-purple) !important; }
html.dark-mode #siDetailModal .si-entry-customer { background: var(--hx-surface-2) !important; color: var(--hx-text) !important; }
html.dark-mode #siDetailModal .si-entry-internal { background: var(--hx-tint-yellow) !important; color: var(--hx-text) !important; }

/* --- màu viết thẳng còn lại trong HTML / JS --- */
html.dark-mode [style*="background:#fff8e1"], html.dark-mode [style*="background: #fff8e1"],
html.dark-mode [style*="background:#fff8e6"], html.dark-mode [style*="background: #fff8e6"] { background: var(--hx-tint-yellow) !important; color: var(--hx-text) !important; }
html.dark-mode [style*="background:#f3eefc"], html.dark-mode [style*="background: #f3eefc"] { background: var(--hx-tint-purple) !important; color: var(--hx-text) !important; }
html.dark-mode [style*="background:#f8f9fa"] { background: var(--hx-surface-2) !important; color: var(--hx-text) !important; }

/* --- thanh cuộn của trình duyệt cho khớp nền tối --- */
html.dark-mode ::-webkit-scrollbar { width: 10px; height: 10px; }
html.dark-mode ::-webkit-scrollbar-track { background: var(--hx-bg); }
html.dark-mode ::-webkit-scrollbar-thumb { background: #2b3953; border-radius: 6px; border: 2px solid var(--hx-bg); }
html.dark-mode ::-webkit-scrollbar-thumb:hover { background: #3a4b6b; }

/* ---- Nút đổi sáng / tối trên thanh trên cùng ---- */
.hx-theme-toggle { cursor: pointer; }
.hx-theme-toggle .fa-sun { display: none; }
html.dark-mode .hx-theme-toggle .fa-sun { display: inline-block; color: #fbbf24; }
html.dark-mode .hx-theme-toggle .fa-moon { display: none; }
