/* ==========================================================================
   SANA'S POS — Global Dark Mode & Button Variant Compatibility Layer
   Applies consistently across all modules, forms, tables, modals & widgets.
   ========================================================================== */

/* Subtle tinted action buttons (light & dark compatible) */
.btn-light-primary {
    --bs-btn-color: var(--bs-primary);
    --bs-btn-bg: rgba(var(--bs-primary-rgb), 0.12);
    --bs-btn-border-color: transparent;
    --bs-btn-hover-color: #ffffff;
    --bs-btn-hover-bg: var(--bs-primary);
    --bs-btn-hover-border-color: var(--bs-primary);
    --bs-btn-active-color: #ffffff;
    --bs-btn-active-bg: var(--bs-primary);
}

.btn-light-warning {
    --bs-btn-color: var(--bs-warning);
    --bs-btn-bg: rgba(var(--bs-warning-rgb), 0.14);
    --bs-btn-border-color: transparent;
    --bs-btn-hover-color: #111827;
    --bs-btn-hover-bg: var(--bs-warning);
    --bs-btn-hover-border-color: var(--bs-warning);
    --bs-btn-active-color: #111827;
    --bs-btn-active-bg: var(--bs-warning);
}

.btn-light-danger {
    --bs-btn-color: var(--bs-danger);
    --bs-btn-bg: rgba(var(--bs-danger-rgb), 0.14);
    --bs-btn-border-color: transparent;
    --bs-btn-hover-color: #ffffff;
    --bs-btn-hover-bg: var(--bs-danger);
    --bs-btn-hover-border-color: var(--bs-danger);
    --bs-btn-active-color: #ffffff;
    --bs-btn-active-bg: var(--bs-danger);
}

.btn-light-success {
    --bs-btn-color: var(--bs-success);
    --bs-btn-bg: rgba(var(--bs-success-rgb), 0.14);
    --bs-btn-border-color: transparent;
    --bs-btn-hover-color: #ffffff;
    --bs-btn-hover-bg: var(--bs-success);
    --bs-btn-hover-border-color: var(--bs-success);
    --bs-btn-active-color: #ffffff;
    --bs-btn-active-bg: var(--bs-success);
}

/* ==========================================================================
   Dark Theme Overrides ([data-bs-theme="dark"])
   ========================================================================== */

[data-bs-theme="dark"] {
    color-scheme: dark;
    --bs-body-color: rgba(255, 255, 255, 0.82);
    --bs-secondary-color: #98a8be;
    --bs-border-color: #313e54;
}

/* Topbar & navigation chrome */
[data-bs-theme="dark"] .topbar {
    background-color: #1a2537 !important;
    border-bottom: 1px solid #313e54;
}

[data-bs-theme="dark"] .topbar .nav-link,
[data-bs-theme="dark"] .side-mini-panel .sidebartoggler {
    color: rgba(255, 255, 255, 0.85);
}

/* Typography & text contrast */
[data-bs-theme="dark"] body .text-muted {
    color: #98a8be !important;
}

[data-bs-theme="dark"] .text-dark {
    color: rgba(255, 255, 255, 0.92) !important;
}

[data-bs-theme="dark"] .text-dark-light {
    color: rgba(255, 255, 255, 0.78) !important;
}

/* Preserve dark ink on bright yellow/warning surfaces */
[data-bs-theme="dark"] .btn-warning,
[data-bs-theme="dark"] .btn-warning.text-dark,
[data-bs-theme="dark"] .bg-warning,
[data-bs-theme="dark"] .bg-warning.text-dark,
[data-bs-theme="dark"] .bg-warning h1,
[data-bs-theme="dark"] .bg-warning h2,
[data-bs-theme="dark"] .bg-warning h3,
[data-bs-theme="dark"] .bg-warning h4,
[data-bs-theme="dark"] .bg-warning h5,
[data-bs-theme="dark"] .bg-warning h6,
[data-bs-theme="dark"] .bg-warning small,
[data-bs-theme="dark"] .bg-warning .text-dark {
    color: #111827 !important;
}

[data-bs-theme="dark"] .btn-warning .badge.bg-white,
[data-bs-theme="dark"] .bg-warning .badge.bg-white {
    background-color: #1a2537 !important;
    color: #f8fafc !important;
    border-color: rgba(17, 24, 39, 0.25) !important;
}

/* Buttons: .btn-light dark surface */
[data-bs-theme="dark"] .btn-light {
    --bs-btn-color: rgba(255, 255, 255, 0.88);
    --bs-btn-bg: #25334a;
    --bs-btn-border-color: #364766;
    --bs-btn-hover-color: #ffffff;
    --bs-btn-hover-bg: #30425f;
    --bs-btn-hover-border-color: #465c80;
    --bs-btn-active-color: #ffffff;
    --bs-btn-active-bg: #364766;
    --bs-btn-active-border-color: #4b6288;
    --bs-btn-disabled-color: rgba(255, 255, 255, 0.45);
    --bs-btn-disabled-bg: #1f2a3d;
    --bs-btn-disabled-border-color: #2b384f;
}

/* Keep primary welcome card CTA bright white for contrast against gradient */
[data-bs-theme="dark"] .bg-primary-gt .btn-light {
    --bs-btn-color: var(--bs-primary);
    --bs-btn-bg: #ffffff;
    --bs-btn-border-color: #ffffff;
    --bs-btn-hover-color: var(--bs-primary);
    --bs-btn-hover-bg: #eef2ff;
    --bs-btn-hover-border-color: #eef2ff;
}

/* Subtle tinted action buttons in dark mode */
[data-bs-theme="dark"] .btn-light-primary {
    --bs-btn-bg: rgba(var(--bs-primary-rgb), 0.2);
    --bs-btn-color: #a5a1ff;
}

[data-bs-theme="dark"] .btn-light-primary.text-primary {
    color: #a5a1ff !important;
}

[data-bs-theme="dark"] .btn-light-primary:hover {
    color: #ffffff !important;
}

[data-bs-theme="dark"] .btn-light-warning {
    --bs-btn-bg: rgba(var(--bs-warning-rgb), 0.2);
    --bs-btn-color: #fbda6c;
}

[data-bs-theme="dark"] .btn-light-warning.text-warning {
    color: #fbda6c !important;
}

[data-bs-theme="dark"] .btn-light-warning:hover {
    color: #111827 !important;
}

[data-bs-theme="dark"] .btn-light-danger {
    --bs-btn-bg: rgba(var(--bs-danger-rgb), 0.2);
    --bs-btn-color: #ffa3be;
}

[data-bs-theme="dark"] .btn-light-danger.text-danger {
    color: #ffa3be !important;
}

[data-bs-theme="dark"] .btn-light-danger:hover {
    color: #ffffff !important;
}

[data-bs-theme="dark"] .btn-light-success {
    --bs-btn-bg: rgba(var(--bs-success-rgb), 0.2);
    --bs-btn-color: #86dda7;
}

[data-bs-theme="dark"] .btn-light-success.text-success {
    color: #86dda7 !important;
}

[data-bs-theme="dark"] .btn-light-success:hover {
    color: #ffffff !important;
}

[data-bs-theme="dark"] .btn-outline-secondary {
    --bs-btn-color: rgba(255, 255, 255, 0.8);
    --bs-btn-border-color: #465875;
    --bs-btn-hover-bg: #2a3952;
    --bs-btn-hover-border-color: #5b7194;
    --bs-btn-hover-color: #ffffff;
}

/* Badges & surfaces */
[data-bs-theme="dark"] .card-header.bg-primary .badge.bg-white {
    background-color: rgba(255, 255, 255, 0.18) !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .badge.bg-light {
    background-color: #25334a !important;
    color: rgba(255, 255, 255, 0.88) !important;
}

[data-bs-theme="dark"] .badge.bg-light.text-muted {
    color: #a9b8cc !important;
}

/* Forms, selects, inputs & searchable dropdowns */
[data-bs-theme="dark"] .form-label,
[data-bs-theme="dark"] .col-form-label,
[data-bs-theme="dark"] .form-check-label {
    color: rgba(255, 255, 255, 0.85) !important;
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select,
[data-bs-theme="dark"] .form-select:focus {
    background-color: #162030;
    border-color: #364766;
    color: rgba(255, 255, 255, 0.92);
}

[data-bs-theme="dark"] .form-control::placeholder {
    color: #7e90aa;
}

[data-bs-theme="dark"] .form-control.text-primary {
    color: #9e99ff !important;
}

[data-bs-theme="dark"] .form-select option {
    background-color: #1a2537;
    color: #f1f5f9;
}

[data-bs-theme="dark"] .input-group-text {
    background-color: #243247 !important;
    border: 1px solid #364766 !important;
    color: rgba(255, 255, 255, 0.88) !important;
}

[data-bs-theme="dark"] .input-group-text.text-primary {
    color: #9e99ff !important;
}

[data-bs-theme="dark"] .dropdown-menu,
[data-bs-theme="dark"] .position-absolute.bg-white.border.rounded-2 {
    background-color: #1a2537 !important;
    border-color: #364766 !important;
    color: rgba(255, 255, 255, 0.88);
}

[data-bs-theme="dark"] .dropdown-item {
    color: rgba(255, 255, 255, 0.85);
}

[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus {
    background-color: #25334a !important;
    color: #ffffff;
}

[data-bs-theme="dark"] .dropdown-item.active,
[data-bs-theme="dark"] .dropdown-item:active {
    background-color: var(--bs-primary) !important;
    color: #ffffff !important;
}

/* Tables & borders */
[data-bs-theme="dark"] .table > :not(caption) > * > * {
    color: rgba(255, 255, 255, 0.85) !important;
    border-bottom-color: #2d3b52;
}

[data-bs-theme="dark"] .table thead th {
    color: #98a8be !important;
}

[data-bs-theme="dark"] .table-hover > tbody > tr:hover > * {
    --bs-table-bg-state: #223047;
}

[data-bs-theme="dark"] .border,
[data-bs-theme="dark"] .border-top,
[data-bs-theme="dark"] .border-bottom,
[data-bs-theme="dark"] .border-start,
[data-bs-theme="dark"] .border-end {
    border-color: #313e54 !important;
}

/* Modals */
[data-bs-theme="dark"] .modal-content {
    background-color: #1a2537;
    border: 1px solid #313e54 !important;
    color: rgba(255, 255, 255, 0.88);
}

[data-bs-theme="dark"] .modal-header,
[data-bs-theme="dark"] .modal-footer {
    border-color: #313e54 !important;
}

/* Pagination */
[data-bs-theme="dark"] .pagination {
    --bs-pagination-color: rgba(255, 255, 255, 0.82);
    --bs-pagination-bg: #1a2537;
    --bs-pagination-border-color: #313e54;
    --bs-pagination-hover-color: #ffffff;
    --bs-pagination-hover-bg: #25334a;
    --bs-pagination-hover-border-color: #465a7e;
    --bs-pagination-active-color: #ffffff;
    --bs-pagination-active-bg: var(--bs-primary);
    --bs-pagination-active-border-color: var(--bs-primary);
    --bs-pagination-disabled-color: #64748b;
    --bs-pagination-disabled-bg: #151e2d;
    --bs-pagination-disabled-border-color: #273449;
}

/* Alerts */
[data-bs-theme="dark"] .alert-warning {
    color: #fde68a;
    background-color: rgba(248, 194, 10, 0.14);
    border-color: rgba(248, 194, 10, 0.35);
}

[data-bs-theme="dark"] .alert-danger {
    color: #fecdd3;
    background-color: rgba(255, 102, 146, 0.16);
    border-color: rgba(255, 102, 146, 0.35);
}

[data-bs-theme="dark"] .alert-success {
    color: #bbf7d0;
    background-color: rgba(54, 199, 108, 0.15);
    border-color: rgba(54, 199, 108, 0.35);
}

[data-bs-theme="dark"] .alert-info {
    color: #bae6fd;
    background-color: rgba(70, 202, 235, 0.15);
    border-color: rgba(70, 202, 235, 0.35);
}

/* Thermal paper & monochrome logo previews must stay white paper + black ink */
[data-bs-theme="dark"] .thermal-80mm,
[data-bs-theme="dark"] .thermal-80mm.bg-white {
    background-color: #ffffff !important;
    color: #000000 !important;
}

[data-bs-theme="dark"] .thermal-80mm .border-dark {
    border-color: #000000 !important;
}

[data-bs-theme="dark"] .receipt-logo-preview {
    background-color: #ffffff !important;
    border-color: #364766 !important;
}
