/* Dark Mode Variables and Core Setup */
body.dark-mode {
    background-color: #101924 !important;
    color: #7bafd4 !important;
    color-scheme: dark;
}

body.dark-mode .bg-light, 
body.dark-mode .bg-white {
    background-color: #141c26 !important;
}

body.dark-mode .text-dark {
    color: #c7d2fe !important;
}

/* Cards & Modals */
body.dark-mode .card,
body.dark-mode .modal-content,
body.dark-mode .bg-header {
    background-color: #141c26 !important;
    border-color: #3d444d !important;
    box-shadow: 0px 4px 15px rgba(0, 0, 0, 0.3);
}

body.dark-mode .card-header,
body.dark-mode .modal-header,
body.dark-mode .modal-footer {
    background-color: #182034 !important;
    border-color: #3d444d !important;
    color: #b6c6e3;
}

body.dark-mode h1, 
body.dark-mode h2, 
body.dark-mode h3, 
body.dark-mode h4, 
body.dark-mode h5, 
body.dark-mode h6,
body.dark-mode .card-title,
body.dark-mode .modal-title {
    color: #b6c6e3 !important;
}

body.dark-mode label {
    color: #5a7a99 !important;
}

/* Form Controls & Inputs */
body.dark-mode .form-control,
body.dark-mode .custom-select,
body.dark-mode .custom-file-label {
    background-color: #101924 !important;
    border: 1px solid #3d444d !important;
    color: #b6c6e3 !important;
}

body.dark-mode .form-control:focus {
    background-color: #182034 !important;
    border-color: #6576ff !important;
    color: #fff !important;
}

body.dark-mode .form-control::placeholder {
    color: #5a7a99 !important;
}

body.dark-mode textarea:focus,
body.dark-mode input:not(.product_item_total_class, .search-pos):focus,
body.dark-mode select:not(.search-pos):focus,
body.dark-mode input[type]:not(.product_item_total_class, .search-pos):focus,
body.dark-mode .uneditable-input:focus {
    border-color: #ccc !important;
    box-shadow: 0 1px 1px rgba(204, 204, 204, 0.075) inset, 0 0 8px rgba(204, 204, 204, 0.6) !important;
}

body.dark-mode .input-group-text,
body.dark-mode .custom-file-label::after {
    background-color: #3d444d !important;
    border-color: #3d444d !important;
    color: #5a7a99 !important;
}

body.dark-mode .form-control:disabled, 
body.dark-mode .form-control[readonly] {
    background-color: #141c26 !important;
    opacity: 1;
}

/* Tables */
body.dark-mode .table, body.dark-mode .table-striped tbody tr:nth-of-type(odd) { background-color: transparent !important;
    color: #8094ae !important;
}

body.dark-mode .table th,
body.dark-mode .table td {
    border-color: #3d444d !important;
    color: #8094ae !important;
}

body.dark-mode .table thead th { background-color: transparent !important;
    border-bottom: 2px solid #3d444d !important;
    color: #7bafd4 !important;
}

body.dark-mode .table-hover tbody tr:hover {
    background-color: #253245 !important;
}

/* User Dropdown Profile Menu */
body.dark-mode .dropdown-menu {
    background-color: #141c26 !important;
    border: 1px solid #3d444d !important;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3) !important;
}

body.dark-mode .dropdown-menu .d-flex.align-items-center.p-3 {
    background-color: #182034 !important;
    border-bottom: 1px solid #3d444d !important;
}

body.dark-mode .dropdown-menu .d-flex.align-items-center.p-3 div[style*="color: #364a63"] {
    color: #b6c6e3 !important;
}

body.dark-mode .dropdown-divider {
    border-top-color: #3d444d !important;
}

body.dark-mode .dropdown-item {
    color: #8094ae !important;
}

body.dark-mode .dropdown-item:hover,
body.dark-mode .dropdown-item:active,
body.dark-mode .dropdown-item:focus {
    background-color: #3d444d !important;
    color: #fff !important;
}

body.dark-mode .dropdown-item i,
body.dark-mode .dropdown-item span[style*="color: #526484"] {
    color: #5a7a99 !important;
}

body.dark-mode .dropdown-item:hover i,
body.dark-mode .dropdown-item:hover span,
body.dark-mode .dropdown-item:active i,
body.dark-mode .dropdown-item:active span,
body.dark-mode .dropdown-item:focus i,
body.dark-mode .dropdown-item:focus span {
    color: #fff !important;
}

/* Select2 Dropdowns */
body.dark-mode .select2-container--default .select2-selection--single {
    background-color: #101924 !important;
    border: 1px solid #3d444d !important;
}

body.dark-mode .select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #b6c6e3 !important;
}

body.dark-mode .select2-dropdown {
    background-color: #141c26 !important;
    border: 1px solid #3d444d !important;
}

body.dark-mode .select2-results__option[aria-selected=true] {
    background-color: #3d444d !important;
}

body.dark-mode .select2-results__option--highlighted[aria-selected] {
    background-color: #6576ff !important;
    color: white !important;
}

body.dark-mode .select2-search--dropdown .select2-search__field {
    background-color: #101924 !important;
    border: 1px solid #3d444d !important;
    color: #b6c6e3 !important;
}

/* Buttons */
body.dark-mode .btn-light {
    background-color: #3d444d !important;
    border-color: #3d444d !important;
    color: #b6c6e3 !important;
}
body.dark-mode .btn-light:hover {
    background-color: #3a3a52 !important;
}

/* List Groups */
body.dark-mode .list-group-item {
    background-color: #141c26 !important;
    border-color: #3d444d !important;
    color: #8094ae !important;
}

/* DataTables pagination */
body.dark-mode .page-item.disabled .page-link {
    background-color: #182034 !important;
    border-color: #3d444d !important;
    color: #64748b !important;
}
body.dark-mode .page-link {
    background-color: #141c26 !important;
    border-color: #3d444d !important;
    color: #8094ae !important;
}
body.dark-mode .page-item.active .page-link {
    background-color: #6576ff !important;
    border-color: #6576ff !important;
}

/* POS specific overrides */
body.dark-mode .pos-stat-chip {
    background-color: #182034 !important;
    border: 1px solid #3d444d !important;
}
body.dark-mode .pos-chip-label {
    color: #5a7a99 !important;
}
body.dark-mode .pos-chip-value {
    color: #b6c6e3 !important;
}
body.dark-mode .pos-product-card {
    background-color: #101924 !important;
    border-color: #3d444d !important;
}

/* Google Drive Backup */
body.dark-mode #google-drive-card {
    background-color: #141c26 !important;
    border: 1px solid #3d444d !important;
    box-shadow: 0px 10px 30px rgba(0, 0, 0, 0.5) !important;
}
body.dark-mode #google-drive-card h1#card-title {
    color: #b6c6e3 !important;
}
body.dark-mode #google-drive-card .info-item {
    background: #1a2330;
    border-color: #2f3a48;
}
body.dark-mode #google-drive-card .info-label {
    color: #8b97a7;
}
body.dark-mode #google-drive-card .info-value {
    color: #e3e8ee;
}

/* DataTables Hover specific overrides */
body.dark-mode table.dataTable.hover tbody tr:hover,
body.dark-mode table.dataTable.hover tbody tr:hover > td,
body.dark-mode table.dataTable.display tbody tr:hover,
body.dark-mode table.dataTable.display tbody tr:hover > td,
body.dark-mode table.dataTable tbody tr:hover,
body.dark-mode table.dataTable tbody tr:hover > td,
body.dark-mode table.dataTable tbody tr:hover > .sorting_1,
body.dark-mode table.dataTable.display tbody tr:hover > .sorting_1 {
    background-color: #253245 !important; /* Lighter grey for better visibility */
}
body.dark-mode table.dataTable tbody tr.odd,
body.dark-mode table.dataTable tbody tr.even,
body.dark-mode table.dataTable.display tbody tr.odd > .sorting_1, 
body.dark-mode table.dataTable.display tbody tr.even > .sorting_1 {
    background-color: #101924 !important;
}

/* Cashier POS Panels */
body.dark-mode .pos-total-bar,
body.dark-mode .pos-cost-row,
body.dark-mode .pos-totals-panel {
    background-color: #141c26 !important;
    border-color: #3d444d !important;
}
body.dark-mode .pos-total-amount,
body.dark-mode .pos-cost-item .pos-chip-value {
    color: #b6c6e3 !important;
}
body.dark-mode .pos-cost-divider {
    background-color: #3d444d !important;
}

/* SweetAlert2 Dark Mode */
body.dark-mode .swal2-popup {
    background-color: #141c26 !important;
    color: #b6c6e3 !important;
    border: 1px solid #3d444d !important;
}
body.dark-mode .swal2-title,
body.dark-mode .swal2-content,
body.dark-mode .swal2-html-container {
    color: #b6c6e3 !important;
}
body.dark-mode .swal2-icon.swal2-success [class^=swal2-success-line] {
    background-color: #a5dc86 !important;
}
body.dark-mode .swal2-icon.swal2-success .swal2-success-ring {
    border-color: rgba(165, 220, 134, 0.3) !important;
}
body.dark-mode .swal2-icon.swal2-warning {
    border-color: #f8bb86 !important;
    color: #f8bb86 !important;
}
body.dark-mode .swal2-icon.swal2-error {
    border-color: #f27474 !important;
    color: #f27474 !important;
}
body.dark-mode .swal2-icon.swal2-error [class^=swal2-x-mark-line] {
    background-color: #f27474 !important;
}

/* Calculator and Baqy Modal Dark Mode */
body.dark-mode #baqy_modal_create .modal-content,
body.dark-mode #baqy_modal_create .calculator.card,
body.dark-mode #baqy_modal_create .inputs-section {
    background-color: #141c26 !important;
    border-color: #3d444d !important;
}
body.dark-mode #baqy_modal_create .currency-container,
body.dark-mode #baqy_modal_create div[style*="background-color: #f8f9fa"] {
    background-color: #182034 !important;
    border-color: #3d444d !important;
    color: #b6c6e3 !important;
}
body.dark-mode #baqy_modal_create input#currency_input {
    color: #b6c6e3 !important;
}
body.dark-mode #baqy_modal_create .bg-dark {
    background-color: #101924 !important;
    color: #b6c6e3 !important;
}
body.dark-mode #baqy_modal_create .bg-success {
    background-color: #12402b !important;
    color: #a5dc86 !important;
}
body.dark-mode #baqy_modal_create .bg-secondary {
    background-color: #3d444d !important;
    color: #b6c6e3 !important;
}
body.dark-mode #baqy_modal_create .number-btn {
    background-color: #182034 !important;
    border-color: #3d444d !important;
    color: #b6c6e3 !important;
}
body.dark-mode #baqy_modal_create .number-btn:hover {
    background-color: #253245 !important;
}
body.dark-mode #baqy_modal_create .numeric-huge-text {
    color: #8094ae !important;
}

body.dark-mode table td.bg-danger,
body.dark-mode table td.bg-inventory-danger {
    color: white !important;
}

body.dark-mode table td.bg-warning,
body.dark-mode table td.bg-inventory-warning {
    color: black !important;
}

/* Ensure datatable hover does not override bg-inventory states */
body.dark-mode table.dataTable tbody tr:hover > td.bg-inventory-danger,
body.dark-mode table.dataTable.hover tbody tr:hover > td.bg-inventory-danger,
body.dark-mode table.dataTable.display tbody tr:hover > td.bg-inventory-danger {
    background-color: #e85347 !important;
    color: white !important;
}

body.dark-mode table.dataTable tbody tr:hover > td.bg-inventory-warning,
body.dark-mode table.dataTable.hover tbody tr:hover > td.bg-inventory-warning,
body.dark-mode table.dataTable.display tbody tr:hover > td.bg-inventory-warning {
    background-color: rgb(244, 189, 14) !important;
    color: black !important;
}

/* Theme Aware Images */
body.dark-mode .theme-light-img {
    display: none !important;
}
body.dark-mode .theme-dark-img {
    display: inline-block !important;
}

/* POS Note Button Hover */
body.dark-mode .pos-note-btn:hover {
    color: #b6c6e3 !important;
    border-color: #6576ff !important;
    background: #3d444d !important;
}

/* Remove Borders on Structural Elements */
body.dark-mode .card,
body.dark-mode .modal-content,
body.dark-mode .bg-header,
body.dark-mode .list-group-item,
body.dark-mode .pos-product-card,
body.dark-mode .pos-cost-row,
body.dark-mode .pos-totals-panel,
body.dark-mode .card-footer {
    border-color: #3d444d !important;
}

/* POS quick-sale card: image area (light grey in light mode) */
body.dark-mode .pos-card-img-bg {
    background-color: transparent;
}

/* Mobile POS Text Colors */
body.dark-mode .product-title a,
body.dark-mode .product-card-pos h6 {
    color: #b6c6e3 !important;
}

/* Autocomplete Dropdowns */
body.dark-mode .ui-autocomplete {
    background-color: #141c26 !important;
    border: 1px solid #3d444d !important;
    color: #8094ae !important;
}
body.dark-mode .ui-menu-item .ui-menu-item-wrapper {
    color: #8094ae !important;
}
body.dark-mode .ui-menu-item .ui-menu-item-wrapper.ui-state-active,
body.dark-mode .ui-menu-item .ui-menu-item-wrapper:hover {
    background-color: #3d444d !important;
    color: #fff !important;
}

/* Dark mode toggle switch fix */
body.dark-mode .toggle-label {
    background-color: #2b3748;
}
body.dark-mode .toggle-label .toggle-slider {
    background-color: #8094ae;
    box-shadow: none;
}
body.dark-mode .toggle-input:checked + .toggle-label {
    background-color: #4577f6;
}
body.dark-mode .toggle-input:checked + .toggle-label .toggle-slider {
    background-color: #fff;
}

body.dark-mode .price-toggle-slider {
    background-color: #2b3748;
}
body.dark-mode .price-toggle-slider::before {
    background-color: #8094ae;
}

body.dark-mode .custom-control-label::before {
    background-color: #1c2635;
    border-color: #4a5568;
}
body.dark-mode .custom-switch .custom-control-label::after {
    background-color: #8094ae;
}
body.dark-mode .custom-control-input:checked ~ .custom-control-label::before,
body.dark-mode .custom-control-input:indeterminate ~ .custom-control-label::before {
    background-color: #4577f6;
    border-color: #4577f6;
}
body.dark-mode .custom-switch .custom-control-input:checked ~ .custom-control-label::after {
    background-color: #fff;
}
body.dark-mode .custom-control-input:focus:not(:checked) ~ .custom-control-label::before {
    border-color: #4577f6;
}
body.dark-mode .custom-control-input:disabled ~ .custom-control-label::before {
    background-color: #253245;
    border-color: #3d444d;
}
body.dark-mode input[type="checkbox"]:not(.custom-control-input),
body.dark-mode input[type="radio"]:not(.custom-control-input) {
    color-scheme: dark;
}
body.dark-mode .price-toggle-switch input:checked + .price-toggle-slider {
    background-color: #4cafee;
}
body.dark-mode .price-toggle-switch input:checked + .price-toggle-slider::before {
    background-color: #fff;
}

body.dark-mode .price-toggle-label-outside {
    color: #fff;
}

/* Expire Warning Banner Dark Mode */
body.dark-mode .expire-warning-banner {
    background: linear-gradient(135deg, rgba(220, 53, 69, 0.15) 0%, rgba(220, 53, 69, 0.05) 100%);
    border-color: rgba(220, 53, 69, 0.3) !important;
}
body.dark-mode .expire-warning-banner::before {
    background: linear-gradient(180deg, #ff8a9b, #dc3545);
}
body.dark-mode .expire-warning-banner .banner-text {
    color: #a6b0cf;
}
body.dark-mode .expire-warning-banner .date-badge {
    background: rgba(220, 53, 69, 0.2);
    color: #ffb3bd;
}
body.dark-mode .expire-warning-banner .expire-phone {
    color: #ffb3bd;
}
body.dark-mode .expire-warning-banner .phone-separator {
    color: #475569;
}
body.dark-mode .backup-warning-banner {
    background: linear-gradient(135deg, rgba(220, 53, 69, 0.15) 0%, rgba(220, 53, 69, 0.05) 100%);
    border-color: rgba(220, 53, 69, 0.3) !important;
}
body.dark-mode .backup-warning-banner .banner-text {
    color: #a6b0cf;
}

/* Contact modal (follows the app's dark mode toggle) */
body.dark-mode .action-modal {
    background: #141c26;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
}
body.dark-mode .action-modal .modal-header {
    border-bottom-color: #3d444d;
}
body.dark-mode .action-modal .modal-title {
    color: #ffffff;
}
body.dark-mode .action-modal .close-modal {
    color: #a0a0a0;
}
body.dark-mode .icon-btn {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

/* Price change, discount and offer pages */
body.dark-mode .price-fieldset {
    border-color: #3d444d;
}
body.dark-mode .price-table thead th {
    background: #182034;
}
body.dark-mode .price-table tfoot td {
    background: #141c26;
}

/* POS product discount */
body.dark-mode .pos-old-total {
    color: #6b7a90;
}

/* first balance item with 0 total / 0 price */
body.dark-mode #product_body_result tr.balance-row-zero,
body.dark-mode #product_body_result tr.balance-row-zero td {
    background-color: #a52834 !important;
    color: #fff !important;
}

body.dark-mode #product_body_result input.balance-input-zero,
body.dark-mode #product_body_result input.balance-input-zero:focus {
    border: 1px solid #f87171 !important;
    background-color: #dc3545 !important;
    color: #fff !important;
}

body.dark-mode #product_body_result tr.balance-row-zero input.balance-input-zero {
    border: 2px solid #fff !important;
}

body.dark-mode #product_body_result tr.focused-row {
    background-color: #1e3a2c !important;
}

body.dark-mode .table tbody tr.bg-stock,
body.dark-mode #product_body_result tr.bg-stock {
    background-color: #a52834 !important;
}

body.dark-mode .table tbody tr.bg-stock td,
body.dark-mode .table tbody tr.bg-stock td a,
body.dark-mode .table tbody tr.bg-stock .material-icons,
body.dark-mode .table tbody tr.bg-stock .product_item_total_class {
    color: #fff !important;
}

/* first balance "more than 10 products" warning */
body.dark-mode .items-count-warning {
    background-color: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
}

/* Self-updater banner, progress box and changelog modal */
body.dark-mode .update-modal-content {

    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.4);

}

body.dark-mode .update-modal-body {

    background-color: #2a3042;

}

body.dark-mode .update-modal-header {

    background: #7a2a29; 

}

body.dark-mode .update-version-card {

    background-color: #32394e;

    border-color: #3b435b !important;

}

body.dark-mode .update-version-card:hover {

    box-shadow: 0 12px 28px rgba(0,0,0,0.3), 0 4px 12px rgba(0,0,0,0.2);

    background-color: #3b435b;

}

body.dark-mode .update-version-icon.cur {

    background: #2a3042;

    color: #a6b0cf;

}

body.dark-mode .update-version-icon.new {

    background: rgba(52, 195, 143, 0.2);

    color: #34c38f;

}

body.dark-mode .update-version-label {

    color: #a6b0cf;

}

body.dark-mode .update-version-num {

    color: #f6f6f6;

}

body.dark-mode .update-legend-bar {

    border-bottom: 1px dashed #3b435b;

}

body.dark-mode .update-legend-wrap {

    color: #a6b0cf;

}

body.dark-mode .update-legend-new,

body.dark-mode .update-legend-improve,

body.dark-mode .update-legend-remove {

    color: #a6b0cf;

}

body.dark-mode .update-row.striped {

    background: #32394e;

}

body.dark-mode .update-row:hover {

    background: #3b435b;

}

body.dark-mode .update-row-num {

    color: #a6b0cf;

}

body.dark-mode .update-row-text {

    color: #f6f6f6;

}

body.dark-mode .update-badge-new {

    background: rgba(52, 195, 143, 0.2);

    color: #34c38f;

}

body.dark-mode .update-badge-improve {

    background: rgba(85, 110, 230, 0.2);

    color: #556ee6;

}

body.dark-mode .update-badge-fix {

    background: rgba(241, 180, 76, 0.2);

    color: #f1b44c;

}

body.dark-mode .update-badge-remove {

    background: rgba(244, 106, 106, 0.2);

    color: #f46a6a;

}

body.dark-mode .update-modal-footer {

    background-color: #2a3042 !important;

    border-top: 1px solid #3b435b !important;

}

body.dark-mode .update-changelog-scroll {

    background-color: #2a3042;

    border-radius: 10px;

}

body.dark-mode .update-changelog-scroll::-webkit-scrollbar-track {

    background: #2a3042;

}

body.dark-mode .update-changelog-scroll::-webkit-scrollbar-thumb {

    background: #3b435b;

}

body.dark-mode .update-changelog-scroll .text-muted {

    color: #a6b0cf !important;

}

body.dark-mode .update-modal-body .text-muted {

    color: #a6b0cf !important;

}

/* Forced update banner ("a new version is available"), styled like the dark expire banner */
body.dark-mode .forced-update-banner {
    background: linear-gradient(135deg, rgba(220, 53, 69, 0.15) 0%, rgba(220, 53, 69, 0.05) 100%);
    border-color: rgba(220, 53, 69, 0.3) !important;
}
body.dark-mode .forced-update-banner::before {
    background: linear-gradient(180deg, #ff8a9b, #dc3545);
}
body.dark-mode .forced-update-banner .banner-title {
    color: #ff8a9b;
}
body.dark-mode .forced-update-banner .banner-subtitle {
    color: #c7d2fe;
}
body.dark-mode .forced-update-banner .banner-text {
    color: #a6b0cf;
}
body.dark-mode .forced-update-banner .update-divider {
    border-color: rgba(220, 53, 69, 0.25);
}
body.dark-mode .forced-update-banner .version-current {
    background: rgba(220, 53, 69, 0.2);
    color: #ffb3bd;
}
body.dark-mode .forced-update-banner .version-new {
    background: rgba(46, 156, 79, 0.2);
    color: #7ee2a0;
}
body.dark-mode .forced-update-banner-close {
    background: rgba(220, 53, 69, 0.2) !important;
}
body.dark-mode .forced-update-banner-close i {
    color: #ffb3bd;
}
body.dark-mode .forced-update-banner-close:hover {
    background: rgba(220, 53, 69, 0.35) !important;
}

/* Excel import progress dark mode */
body.dark-mode .excel-progress-phase {
    color: #e5e7eb;
}

body.dark-mode .excel-progress-percent {
    color: #60a5fa;
}

body.dark-mode .excel-progress-track {
    background-color: #222c38;
}

body.dark-mode .excel-progress-bar {
    background-color: #60a5fa;
}

body.dark-mode .excel-progress-count,
body.dark-mode .excel-progress-row span {
    color: #8b97a7;
}

body.dark-mode .excel-progress-summary {
    background-color: #151d28;
    border-color: #2a3441;
}

body.dark-mode .excel-progress-row + .excel-progress-row {
    border-top-color: #222c38;
}

body.dark-mode .excel-progress-row b {
    color: #4ade80;
}

body.dark-mode .excel-progress-row.is-skipped b {
    color: #fbbf24;
}
