/* Avemaria — dark / light theme (maps Elite pourpos-theme to layout classes) */

html[data-theme="dark"] {
  --body-bg: #020617;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --sidebar-bg: #0f172a;
  --sidebar-border: rgba(255, 255, 255, 0.1);
  --sidebar-hover: rgba(255, 255, 255, 0.08);
  --sidebar-active-bg: rgba(255, 255, 255, 0.12);
  --sidebar-active-text: #fbbf24;
  --light-color: #1e293b;
}

html[data-theme="light"] {
  --body-bg: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --sidebar-bg: #2D2D4D;
}

body.dark-mode {
  background: var(--body-bg);
  color: var(--text-primary);
}

body.dark-mode .top-navbar {
  background: var(--sidebar-bg);
  border-bottom-color: var(--sidebar-border);
}

body.dark-mode .business-title {
  color: var(--text-primary);
}

body.dark-mode .sidebar {
  background: var(--sidebar-bg);
}

body.dark-mode .sidebar-header {
  border-bottom-color: var(--sidebar-border);
}

body.dark-mode .content {
  background: var(--body-bg);
}

body.dark-mode .site-footer {
  background: #0f172a;
  border-top-color: rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
}

body.dark-mode .site-footer a {
  color: #93c5fd;
}

body.dark-mode .card,
body.dark-mode .modal-content {
  background: #0f172a;
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

body.dark-mode .card-header,
body.dark-mode .modal-header {
  background: rgba(255, 255, 255, 0.05);
  border-bottom-color: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

body.dark-mode .dropdown-menu {
  background: #0f172a;
  border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .dropdown-item {
  color: var(--text-primary);
}

body.dark-mode .dropdown-item:hover,
body.dark-mode .dropdown-item:focus {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

body.dark-mode .dropdown-header {
  color: var(--text-secondary);
}

body.dark-mode .text-muted {
  color: var(--text-secondary) !important;
}

body.dark-mode .table {
  color: var(--text-primary);
  --bs-table-bg: transparent;
  --bs-table-color: var(--text-primary);
  --bs-table-border-color: rgba(255, 255, 255, 0.08);
}

body.dark-mode .table thead th {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
}

body.dark-mode .table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

body.dark-mode .dash-date-filter,
body.dark-mode .insight-card,
body.dark-mode .welcome-empty {
  background: #0f172a;
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

body.dark-mode .dash-date-filter .form-control {
  background: #1e293b;
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
}

body.dark-mode .dash-date-filter-label,
body.dark-mode .dash-section-title {
  color: var(--text-primary);
}

body.dark-mode .insight-head {
  background: rgba(255, 255, 255, 0.03);
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

body.dark-mode .insight-head h3,
body.dark-mode .tp-name,
body.dark-mode .bv-row-label {
  color: var(--text-primary);
}

body.dark-mode .bv-total .bv-amount {
  color: #fff;
}

body.dark-mode .insight-pill {
  background: #1e293b;
  color: var(--text-secondary);
}

body.dark-mode .top-products li,
body.dark-mode .bv-total {
  border-color: rgba(255, 255, 255, 0.08);
}

body.dark-mode .welcome-empty h2 {
  color: var(--text-primary);
}

body.dark-mode .login-card {
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
}

body.dark-mode .login-body {
  background: #0f172a;
}

body.dark-mode .login-header h1 {
  color: #e2e8f0;
}

body.dark-mode .login-body .form-label {
  color: #e2e8f0;
}

body.dark-mode .login-body .form-control {
  background: #1e293b;
  border-color: rgba(255, 255, 255, 0.15);
  color: #e2e8f0;
}

body.dark-mode .login-copyright {
  border-top-color: rgba(255, 255, 255, 0.1);
  color: #94a3b8;
}

body.dark-mode .idle-warning-card {
  background: #0f172a;
  color: var(--text-primary);
}

html[data-theme="dark"] .topbar-icon-btn {
  color: rgba(255, 255, 255, 0.95);
}

html[data-theme="dark"] .topbar-icon-btn:hover {
  opacity: 0.85;
}

/* ── Global form controls ── */
body.dark-mode .form-control,
body.dark-mode .form-select,
body.dark-mode .form-control-custom,
body.dark-mode textarea.form-control {
  background: #1e293b;
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
}

body.dark-mode .form-control:focus,
body.dark-mode .form-select:focus,
body.dark-mode .form-control-custom:focus {
  background: #1e293b;
  border-color: rgba(251, 191, 36, 0.45);
  color: var(--text-primary);
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.12);
}

body.dark-mode .form-control::placeholder {
  color: #64748b;
}

body.dark-mode .input-group-text {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--text-secondary);
}

body.dark-mode .form-label,
body.dark-mode label.form-label {
  color: var(--text-primary);
}

body.dark-mode .form-check-label {
  color: var(--text-primary);
}

body.dark-mode .form-text {
  color: var(--text-secondary) !important;
}

/* ── Layout surfaces (inline styles in layout.html) ── */
body.dark-mode .card-header {
  background: rgba(255, 255, 255, 0.04) !important;
  border-bottom-color: rgba(255, 255, 255, 0.1) !important;
  color: var(--text-primary) !important;
}

body.dark-mode .low-stock-list li,
body.dark-mode .pending-pickup-list li,
body.dark-mode .credit-due-list li {
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

body.dark-mode .low-stock-list .ls-name,
body.dark-mode .pending-pickup-list .pp-customer,
body.dark-mode .credit-due-list .cd-customer {
  color: var(--text-primary);
}

body.dark-mode .low-stock-list .ls-code,
body.dark-mode .pending-pickup-list .pp-meta,
body.dark-mode .credit-due-list .cd-meta {
  color: var(--text-secondary);
}

body.dark-mode .idle-warning-card p {
  color: var(--text-secondary);
}

/* ── Bootstrap utility overrides ── */
body.dark-mode .bg-light {
  background-color: rgba(255, 255, 255, 0.06) !important;
  color: var(--text-primary) !important;
}

body.dark-mode .bg-white {
  background-color: #0f172a !important;
  color: var(--text-primary) !important;
}

body.dark-mode .border,
body.dark-mode .border-top,
body.dark-mode .border-bottom {
  border-color: rgba(255, 255, 255, 0.1) !important;
}

body.dark-mode .list-group-item {
  background: #0f172a;
  border-color: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

body.dark-mode .list-group-item-action:hover,
body.dark-mode .list-group-item-action:focus {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

body.dark-mode .btn-outline-secondary {
  color: var(--text-secondary);
  border-color: rgba(255, 255, 255, 0.2);
}

body.dark-mode .btn-outline-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.25);
}

body.dark-mode .pagination .page-link {
  background: #0f172a;
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

body.dark-mode .pagination .page-item.active .page-link {
  background: #213752;
  border-color: #213752;
}

/* ── Dashboard (inline styles in dashboard/index.html) ── */
body.dark-mode .dash-section-title {
  color: #e2e8f0;
  border-left-color: #fbbf24;
}

body.dark-mode .insight-head {
  background: rgba(255, 255, 255, 0.03);
}

body.dark-mode .tp-bar {
  background: rgba(255, 255, 255, 0.1);
}

body.dark-mode .bv-row-sub {
  color: var(--text-secondary);
}

body.dark-mode .welcome-empty .we-icon {
  -webkit-text-fill-color: #fbbf24;
}

/* ── Product list & similar list pages ── */
body.dark-mode .product-card-grid .product-card,
body.dark-mode .product-list-card {
  background: #0f172a;
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

body.dark-mode .product-card-grid .product-card:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(251, 191, 36, 0.35);
}

body.dark-mode .product-card-grid .product-card .product-name,
body.dark-mode .product-card-grid .product-card .product-meta {
  color: var(--text-primary);
}

body.dark-mode .product-card-grid .product-card .product-code,
body.dark-mode .product-card-grid .product-card .text-muted {
  color: var(--text-secondary) !important;
}

body.dark-mode .filter-bar,
body.dark-mode .page-toolbar,
body.dark-mode .detail-card,
body.dark-mode .detail-section,
body.dark-mode .info-panel {
  background: #0f172a !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  color: var(--text-primary);
}

body.dark-mode .detail-row,
body.dark-mode .info-row {
  border-color: rgba(255, 255, 255, 0.08);
}

body.dark-mode .detail-row:nth-child(even),
body.dark-mode .info-row:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

/* ── Permissions page ── */
body.dark-mode .permission-item .card {
  background: #0f172a;
  border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .permission-item .card:hover {
  border-color: rgba(251, 191, 36, 0.35);
}

body.dark-mode .user-permissions .stat-card,
body.dark-mode .permissions-page .stat-card {
  background: #0f172a !important;
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-mode .app-icon {
  color: #fbbf24;
}

body.dark-mode .toggle-slider {
  background: #475569;
}

body.dark-mode .toggle-slider:after {
  background: #e2e8f0;
}

/* ── POS / sales / avema pages with inline light panels ── */
body.dark-mode .sale-payment-card,
body.dark-mode .store-usage-card,
body.dark-mode .purchase-detail-card,
body.dark-mode .finished-product-card,
body.dark-mode .avema-pos-panel {
  background: #0f172a !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  color: var(--text-primary);
}

body.dark-mode .avema-pos-item {
  background: #0f172a;
  border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .avema-pos-item:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(251, 191, 36, 0.35);
}

body.dark-mode .avema-pos-item.is-out {
  background: rgba(255, 255, 255, 0.02);
}

body.dark-mode .create-user-section,
body.dark-mode .user-form-section {
  background: #0f172a;
  border-color: rgba(255, 255, 255, 0.1);
}

/* ── Alerts & badges on dark backgrounds ── */
body.dark-mode .alert-light {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

body.dark-mode hr {
  border-color: rgba(255, 255, 255, 0.1);
  opacity: 1;
}

/* ── Global dark fixes (override layout + page inline styles) ── */
html[data-theme="dark"] body.dark-mode .table,
body.dark-mode .table {
  background: var(--table-bg, #0f172a) !important;
  color: var(--text-primary) !important;
  --bs-table-bg: #0f172a;
  --bs-table-color: #e2e8f0;
  --bs-table-border-color: rgba(255, 255, 255, 0.08);
  --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
  --bs-table-hover-bg: rgba(255, 255, 255, 0.03);
}

html[data-theme="dark"] body.dark-mode .table thead,
html[data-theme="dark"] body.dark-mode .table thead th,
body.dark-mode .table thead,
body.dark-mode .table thead th,
body.dark-mode .table-light,
body.dark-mode thead.table-light th {
  background: rgba(255, 255, 255, 0.04) !important;
  color: #94a3b8 !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
}

html[data-theme="dark"] body.dark-mode .table td,
html[data-theme="dark"] body.dark-mode .table th,
body.dark-mode .table td,
body.dark-mode .table th {
  border-color: rgba(255, 255, 255, 0.08) !important;
  color: #e2e8f0 !important;
}

html[data-theme="dark"] body.dark-mode .table tbody td,
body.dark-mode .table tbody td {
  background: transparent !important;
}

html[data-theme="dark"] body.dark-mode .table-hover tbody tr:hover,
body.dark-mode .table-hover tbody tr:hover {
  background: rgba(255, 255, 255, 0.03) !important;
}

html[data-theme="dark"] body.dark-mode .table strong,
body.dark-mode .table strong {
  color: #f8fafc !important;
}

html[data-theme="dark"] body.dark-mode .card,
body.dark-mode .card {
  background: #0f172a !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  color: #e2e8f0 !important;
}

html[data-theme="dark"] body.dark-mode .card-body,
body.dark-mode .card-body {
  background: transparent !important;
  color: #e2e8f0 !important;
}

html[data-theme="dark"] body.dark-mode .nav-tabs,
body.dark-mode .nav-tabs {
  border-bottom-color: rgba(255, 255, 255, 0.1) !important;
}

html[data-theme="dark"] body.dark-mode .nav-tabs .nav-link,
body.dark-mode .nav-tabs .nav-link {
  color: #94a3b8 !important;
  border-color: transparent !important;
}

html[data-theme="dark"] body.dark-mode .nav-tabs .nav-link:hover,
body.dark-mode .nav-tabs .nav-link:hover {
  color: #e2e8f0 !important;
  border-color: rgba(255, 255, 255, 0.1) rgba(255, 255, 255, 0.1) transparent !important;
}

html[data-theme="dark"] body.dark-mode .nav-tabs .nav-link.active,
body.dark-mode .nav-tabs .nav-link.active {
  background: #0f172a !important;
  color: #fbbf24 !important;
  border-color: rgba(255, 255, 255, 0.1) rgba(255, 255, 255, 0.1) #0f172a !important;
}

html[data-theme="dark"] body.dark-mode .dash-date-filter,
html[data-theme="dark"] body.dark-mode .insight-card,
html[data-theme="dark"] body.dark-mode .welcome-empty,
body.dark-mode .dash-date-filter,
body.dark-mode .insight-card,
body.dark-mode .welcome-empty {
  background: #0f172a !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  color: #e2e8f0 !important;
}

html[data-theme="dark"] body.dark-mode .dash-date-filter .form-control,
body.dark-mode .dash-date-filter .form-control {
  background: #1e293b !important;
  border-color: rgba(255, 255, 255, 0.15) !important;
  color: #e2e8f0 !important;
}

html[data-theme="dark"] body.dark-mode .insight-head,
body.dark-mode .insight-head {
  background: rgba(255, 255, 255, 0.03) !important;
  border-bottom-color: rgba(255, 255, 255, 0.08) !important;
}

html[data-theme="dark"] body.dark-mode .product-card-grid .product-card,
html[data-theme="dark"] body.dark-mode .product-stat-card,
body.dark-mode .product-card-grid .product-card {
  background: #0f172a !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  color: #e2e8f0 !important;
}

html[data-theme="dark"] body.dark-mode .page-toolbar,
html[data-theme="dark"] body.dark-mode .filter-bar,
html[data-theme="dark"] body.dark-mode .detail-card,
html[data-theme="dark"] body.dark-mode .detail-section,
html[data-theme="dark"] body.dark-mode .info-panel,
html[data-theme="dark"] body.dark-mode .sale-payment-card,
html[data-theme="dark"] body.dark-mode .store-usage-card,
html[data-theme="dark"] body.dark-mode .purchase-detail-card,
body.dark-mode .page-toolbar,
body.dark-mode .filter-bar,
body.dark-mode .detail-card,
body.dark-mode .detail-section,
body.dark-mode .info-panel,
body.dark-mode .sale-payment-card,
body.dark-mode .store-usage-card,
body.dark-mode .purchase-detail-card {
  background: #0f172a !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  color: #e2e8f0 !important;
}

html[data-theme="dark"] body.dark-mode .pwa-install-card,
body.dark-mode .pwa-install-card {
  background: #0f172a !important;
  color: #e2e8f0 !important;
}

html[data-theme="dark"] body.dark-mode .pwa-install-footer,
body.dark-mode .pwa-install-footer {
  border-top-color: rgba(255, 255, 255, 0.1) !important;
}

html[data-theme="dark"] body.dark-mode .modal-content,
body.dark-mode .modal-content {
  background: #0f172a !important;
  color: #e2e8f0 !important;
}

html[data-theme="dark"] body.dark-mode .btn-close,
body.dark-mode .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

html[data-theme="dark"] body.dark-mode .product-card-grid .product-card,
body.dark-mode .product-card-grid .product-card {
  background: #0f172a !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  color: #e2e8f0 !important;
}

html[data-theme="dark"] body.dark-mode .product-card-name,
html[data-theme="dark"] body.dark-mode .product-card-code,
body.dark-mode .product-card-name,
body.dark-mode .product-card-code {
  color: #e2e8f0 !important;
}

body.dark-mode .product-card-code {
  color: #94a3b8 !important;
}

html[data-theme="dark"] body.dark-mode .product-metric,
body.dark-mode .product-metric {
  background: rgba(255, 255, 255, 0.05) !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
}

html[data-theme="dark"] body.dark-mode .product-metric .metric-label,
body.dark-mode .product-metric .metric-label {
  color: #94a3b8 !important;
}

html[data-theme="dark"] body.dark-mode .product-metric .metric-value,
body.dark-mode .product-metric .metric-value {
  color: #e2e8f0 !important;
}

html[data-theme="dark"] body.dark-mode .product-card-footer,
body.dark-mode .product-card-footer {
  border-top-color: rgba(255, 255, 255, 0.1) !important;
}

html[data-theme="dark"] ::-webkit-scrollbar-track,
body.dark-mode ::-webkit-scrollbar-track {
  background: #0f172a;
}

html[data-theme="dark"] ::-webkit-scrollbar-thumb,
body.dark-mode ::-webkit-scrollbar-thumb {
  background: #475569;
}
