/* ==========================================================
   STYLING DÙNG CHUNG CHO TOÀN BỘ HỆ THỐNG LIGHT ERP
   ========================================================== */

/* 1. Tùy chỉnh Tabulator Light Theme & Thu nhỏ font chữ gọn gàng */
.tabulator { background-color: #ffffff !important; border: 1px solid #dee2e6 !important; color: #212529 !important; font-size: 11.5px !important; }
.tabulator .tabulator-header { background-color: #f8f9fa !important; border-bottom: 2px solid #dee2e6 !important; color: #212529 !important; font-weight: 600; }
.tabulator .tabulator-header .tabulator-col { background-color: #f8f9fa !important; border-right: 1px solid #dee2e6 !important; }
.tabulator .tabulator-header .tabulator-col-content { padding: 6px 4px !important; }
.tabulator .tabulator-header .tabulator-col-title { color: #212529 !important; font-size: 11.5px !important; font-weight: 700 !important; }
.tabulator .tabulator-row { background-color: #ffffff !important; color: #212529 !important; border-bottom: 1px solid #dee2e6 !important; min-height: 28px !important; }
.tabulator .tabulator-row.tabulator-row-even { background-color: #fcfcfc !important; }
.tabulator .tabulator-row:hover { background-color: #e9ecef !important; color: #000 !important; }
.tabulator .tabulator-cell { padding: 5px 6px !important; }
.tabulator .tabulator-footer { background-color: #f8f9fa !important; border-top: 1px solid #dee2e6 !important; color: #212529 !important; }
.tabulator-page { background-color: #ffffff !important; color: #212529 !important; border: 1px solid #dee2e6 !important; font-size: 11.5px !important; }
.tabulator-page.active { background-color: #0d6efd !important; border-color: #0d6efd !important; color: #fff !important; }

/* 2. Tùy chỉnh Context Menu chuột phải Light */
.tabulator-menu { background-color: #ffffff !important; border: 1px solid #dee2e6 !important; box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important; padding: 4px 0 !important; }
.tabulator-menu .tabulator-menu-item { color: #212529 !important; padding: 6px 12px !important; font-size: 11.5px !important; }
.tabulator-menu .tabulator-menu-item:hover { background-color: #e9ecef !important; color: #0d6efd !important; }
.tabulator-menu .tabulator-menu-separator { border-top: 1px solid #dee2e6 !important; margin: 4px 0 !important; }

/* 3. Tùy chỉnh Select2 chuẩn Light ERP */
.select2-container--default .select2-selection--single { background-color: #ffffff !important; border: 1px solid #dee2e6 !important; color: #212529 !important; height: 31px !important; padding-top: 2px; }
.select2-container--default .select2-selection--single .select2-selection__rendered { color: #212529 !important; line-height: 24px !important; font-size: 12px !important; }
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 29px !important; }
.select2-dropdown { background-color: #ffffff !important; border: 1px solid #dee2e6 !important; color: #212529 !important; font-size: 12px !important; }
.select2-search--dropdown .select2-search__field { background-color: #ffffff !important; border: 1px solid #dee2e6 !important; color: #212529 !important; }
.select2-results__option { background-color: #ffffff !important; color: #212529 !important; }
.select2-results__option--highlighted[aria-selected] { background-color: #0d6efd !important; color: #fff !important; }
.select2-results__option[aria-selected=true] { background-color: #e9ecef !important; color: #212529 !important; }

/* Ép gọn font chữ Select2 cho cả theme Bootstrap 5 */
.select2-container--bootstrap-5 .select2-selection,
.select2-container--bootstrap-5 .select2-selection__rendered,
.select2-container--bootstrap-5 .select2-dropdown .select2-search__field,
.select2-container--bootstrap-5 .select2-results__option {
    font-size: 12px !important;
}
.select2-container--bootstrap-5 .select2-selection {
    min-height: 31px !important;
    padding: 2px 4px !important;
}
.select2-container--bootstrap-5 .select2-dropdown .select2-search { padding: 4px !important; }
.select2-container--bootstrap-5 .select2-dropdown .select2-search__field { padding: 2px 6px !important; height: 28px !important; }


/* ==========================================================
   TRỌN BỘ CSS DARK MODE CHUYÊN SÂU (ĐÃ FIX CHỮ & FORM)
   ========================================================== */

[data-bs-theme="dark"] .card-custom,
[data-bs-theme="dark"] .card,
[data-bs-theme="dark"] .modal-content {
    background-color: var(--bg-card) !important;
    color: var(--text-title) !important;
    border-color: var(--border-color) !important;
}

/* Ép toàn bộ Input, Select, Textarea và văn bản bên trong form ở Dark Mode hiển thị chữ màu trắng rõ nét */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select,
[data-bs-theme="dark"] textarea,
[data-bs-theme="dark"] input[type="text"],
[data-bs-theme="dark"] input[type="number"],
[data-bs-theme="dark"] input[type="search"] {
    background-color: #0f172a !important;
    color: #ffffff !important;
    border-color: var(--border-color) !important;
}

[data-bs-theme="dark"] .form-control::placeholder,
[data-bs-theme="dark"] textarea::placeholder {
    color: #94a3b8 !important;
}

/* Các nhãn (label) và chữ hướng dẫn trong form */
[data-bs-theme="dark"] label,
[data-bs-theme="dark"] .form-label {
    color: #cbd5e1 !important;
}

/* Đồng bộ bảng Tabulator sang tông tối */
[data-bs-theme="dark"] .tabulator,
[data-bs-theme="dark"] .table {
    background-color: var(--bg-card) !important;
    color: #f8fafc !important;
    border-color: var(--border-color) !important;
}

/* Ép tất cả các ô chữ, thẻ span, link bên trong bảng Tabulator phải chuyển sang màu sáng */
[data-bs-theme="dark"] .tabulator-cell,
[data-bs-theme="dark"] .tabulator-cell span,
[data-bs-theme="dark"] .tabulator-cell div,
[data-bs-theme="dark"] .tabulator-cell a {
    color: #f8fafc !important;
}

[data-bs-theme="dark"] .tabulator-row {
    background-color: var(--bg-card) !important;
    color: #f8fafc !important;
    border-bottom-color: var(--border-color) !important;
}

[data-bs-theme="dark"] .tabulator-row.tabulator-row-even {
    background-color: #162032 !important;
}

[data-bs-theme="dark"] .tabulator-row.tabulator-selected {
    background-color: #1d4ed8 !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .tabulator-row.tabulator-selected .tabulator-cell,
[data-bs-theme="dark"] .tabulator-row.tabulator-selected span,
[data-bs-theme="dark"] .tabulator-row.tabulator-selected a {
    color: #ffffff !important;
}

[data-bs-theme="dark"] .tabulator-row:hover {
    background-color: #1e293b !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .tabulator-row:hover .tabulator-cell,
[data-bs-theme="dark"] .tabulator-row:hover span {
    color: #ffffff !important;
}

[data-bs-theme="dark"] .tabulator-header,
[data-bs-theme="dark"] .tabulator-col,
[data-bs-theme="dark"] .tabulator-col-content {
    background-color: #0f172a !important;
    color: #ffffff !important;
    border-color: var(--border-color) !important;
}

[data-bs-theme="dark"] .tabulator-header .tabulator-col-title {
    color: #ffffff !important;
}

/* Xử lý các nút/icon phụ trợ nhỏ bên trong bảng không bị lóe trắng */
[data-bs-theme="dark"] .tabulator-cell button,
[data-bs-theme="dark"] .tabulator-cell .btn,
[data-bs-theme="dark"] .tabulator-cell span[class*="btn"] {
    background-color: #1e293b !important;
    color: #f8fafc !important;
    border-color: #334155 !important;
}

/* Thanh phân trang Tabulator */
[data-bs-theme="dark"] .tabulator-footer,
[data-bs-theme="dark"] .tabulator-paginator {
    background-color: var(--bg-card) !important;
    color: #f8fafc !important;
    border-color: var(--border-color) !important;
}

[data-bs-theme="dark"] .tabulator-page {
    background-color: #1e293b !important;
    color: #f8fafc !important;
    border-color: var(--border-color) !important;
}

[data-bs-theme="dark"] .tabulator-page.active {
    background-color: #0d6efd !important;
    border-color: #0d6efd !important;
    color: #ffffff !important;
}

/* Context Menu chuột phải trong Dark Mode */
[data-bs-theme="dark"] .tabulator-menu {
    background-color: #1e293b !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5) !important;
}
[data-bs-theme="dark"] .tabulator-menu .tabulator-menu-item { color: #f8fafc !important; }
[data-bs-theme="dark"] .tabulator-menu .tabulator-menu-item:hover {
    background-color: rgba(13, 110, 253, 0.2) !important;
    color: #38bdf8 !important;
}
[data-bs-theme="dark"] .tabulator-menu .tabulator-menu-separator { border-top: 1px solid var(--border-color) !important; }

/* Select2 trong Dark Mode */
[data-bs-theme="dark"] .select2-container--default .select2-selection--single {
    background-color: #0f172a !important;
    border-color: var(--border-color) !important;
    color: #f8fafc !important;
}
[data-bs-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__rendered { color: #f8fafc !important; }
[data-bs-theme="dark"] .select2-dropdown {
    background-color: #1e293b !important;
    border-color: var(--border-color) !important;
    color: #f8fafc !important;
}
[data-bs-theme="dark"] .select2-search--dropdown .select2-search__field {
    background-color: #0f172a !important;
    border-color: var(--border-color) !important;
    color: #ffffff !important;
}
[data-bs-theme="dark"] .select2-results__option {
    background-color: #1e293b !important;
    color: #f8fafc !important;
}
[data-bs-theme="dark"] .select2-results__option--highlighted[aria-selected] {
    background-color: #0d6efd !important;
    color: #fff !important;
}


/* Ép toàn bộ các thẻ form trong trạng thái Dark Mode nhận chữ trắng, nền tối tuyệt đối */
[data-bs-theme="dark"] input,
[data-bs-theme="dark"] select,
[data-bs-theme="dark"] textarea,
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select,
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection {
    background-color: #0f172a !important;
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important; /* Chặn trình duyệt đổi màu chữ input */
    border-color: #334155 !important;
}

[data-bs-theme="dark"] input:focus,
[data-bs-theme="dark"] select:focus,
[data-bs-theme="dark"] textarea:focus,
[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    background-color: #0f172a !important;
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
    border-color: #38bdf8 !important;
    box-shadow: 0 0 0 0.25rem rgba(56, 189, 248, 0.25) !important;
}



/* 💡 TÙY CHỈNH LÀM MỜ PLACEHOLDER CHO TẤT CẢ CÁC Ô NHẬP LIỆU */
    ::placeholder {
        color: #94a3b8 !important; /* Màu xám mờ nhẹ */
        opacity: 0.6 !important;   /* Giảm độ đậm */
        font-weight: normal !important;
    }
    ::-webkit-input-placeholder {
        color: #94a3b8 !important;
        opacity: 0.6 !important;
    }
    ::-moz-placeholder {
        color: #94a3b8 !important;
        opacity: 0.6 !important;
    }
    :-ms-input-placeholder {
        color: #94a3b8 !important;
        opacity: 0.6 !important;
    }
    :-moz-placeholder {
        color: #94a3b8 !important;
        opacity: 0.6 !important;
    }