/**
 * Central Builders — Dark mode overrides
 * Activated via html[data-bs-theme="dark"] (Bootstrap 5.3 color mode)
 */

html[data-bs-theme="dark"] {
  color-scheme: dark;
  --central-builders-red: #ef5350;
  --central-builders-red-dark: #e53935;
  --central-builders-red-light: #3a1c1c;
  --central-builders-yellow: #fdd835;
  --central-builders-green: #66bb6a;
  --central-builders-green-light: #1b3320;
  --central-builders-dark: #e8eaed;
  --central-builders-gray: #9aa3b2;
  --central-builders-light-bg: #0f1218;
  --central-builders-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  --central-builders-shadow-hover: 0 10px 25px rgba(239, 83, 80, 0.18);
  --admin-primary: #ff4d4d;
  --admin-primary-dark: #e10600;
  --admin-dark: #e8eaed;
  --admin-bg: #0f1218;
  --admin-border: #2a303c;
  --cb-surface: #171a21;
  --cb-surface-2: #1e232c;
  --cb-border: #2a303c;
  --cb-muted: #9aa3b2;
  --cb-text: #e8eaed;
}

/* Bootstrap utility patches used heavily across PHP views */
html[data-bs-theme="dark"] .bg-white,
html[data-bs-theme="dark"] .bg-light {
  background-color: var(--cb-surface) !important;
}

html[data-bs-theme="dark"] .text-dark {
  color: var(--cb-text) !important;
}

html[data-bs-theme="dark"] .text-muted,
html[data-bs-theme="dark"] .text-secondary {
  color: var(--cb-muted) !important;
}

html[data-bs-theme="dark"] .border,
html[data-bs-theme="dark"] .border-bottom,
html[data-bs-theme="dark"] .border-top,
html[data-bs-theme="dark"] .border-start,
html[data-bs-theme="dark"] .border-end {
  border-color: var(--cb-border) !important;
}

html[data-bs-theme="dark"] .shadow-sm,
html[data-bs-theme="dark"] .shadow,
html[data-bs-theme="dark"] .shadow-lg {
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45) !important;
}

html[data-bs-theme="dark"] .table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--cb-text);
  --bs-table-border-color: var(--cb-border);
  --bs-table-striped-bg: rgba(255, 255, 255, 0.03);
  --bs-table-hover-bg: rgba(255, 255, 255, 0.05);
  color: var(--cb-text);
}

html[data-bs-theme="dark"] .dropdown-menu {
  background-color: var(--cb-surface-2);
  border-color: var(--cb-border);
}

html[data-bs-theme="dark"] .dropdown-item {
  color: var(--cb-text);
}

html[data-bs-theme="dark"] .dropdown-item:hover,
html[data-bs-theme="dark"] .dropdown-item:focus {
  background-color: rgba(255, 255, 255, 0.06);
  color: #fff;
}

html[data-bs-theme="dark"] .dropdown-divider {
  border-color: var(--cb-border);
}

html[data-bs-theme="dark"] .list-group-item {
  background-color: var(--cb-surface);
  border-color: var(--cb-border);
  color: var(--cb-text);
}

html[data-bs-theme="dark"] .badge.bg-light {
  background-color: var(--cb-surface-2) !important;
  color: var(--cb-text) !important;
}

/* Theme toggle */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  background: rgba(127, 127, 127, 0.14);
  outline: none;
}

[data-theme-toggle] .theme-icon-sun {
  display: none;
}

html[data-bs-theme="dark"] [data-theme-toggle] .theme-icon-moon {
  display: none;
}

html[data-bs-theme="dark"] [data-theme-toggle] .theme-icon-sun {
  display: inline-block;
}

.theme-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  min-height: 44px;
  padding: 0.65rem 0.85rem;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.theme-toggle-label:hover,
.theme-toggle-label:focus-visible {
  background: rgba(127, 127, 127, 0.1);
  outline: none;
}

/* Customer storefront */
html[data-bs-theme="dark"] body.customer-layout {
  color: var(--cb-text);
  background-color: var(--central-builders-light-bg);
}

html[data-bs-theme="dark"] .top-announcement-bar {
  background-color: #2a1515;
  border-bottom-color: #4a2222;
  color: #f0c9c9;
}

html[data-bs-theme="dark"] .central-builders-main-nav,
html[data-bs-theme="dark"] .store-navbar.bg-white,
html[data-bs-theme="dark"] .navbar.bg-white {
  background-color: var(--cb-surface) !important;
}

html[data-bs-theme="dark"] .store-navbar {
  border-bottom-color: var(--cb-border);
}

html[data-bs-theme="dark"] .store-navbar .navbar-nav .nav-link {
  color: #c5cad3;
}

html[data-bs-theme="dark"] .store-navbar .navbar-nav .nav-link:hover,
html[data-bs-theme="dark"] .store-navbar .navbar-nav .nav-link.active {
  color: var(--central-builders-red);
}

html[data-bs-theme="dark"] .store-search .input-group-text,
html[data-bs-theme="dark"] .store-search .form-control,
html[data-bs-theme="dark"] .central-builders-search-input {
  background: var(--cb-surface-2) !important;
  border-color: var(--cb-border) !important;
  color: var(--cb-text) !important;
}

html[data-bs-theme="dark"] .store-header-tools .store-bell-btn,
html[data-bs-theme="dark"] .store-header-tools .store-header-cart,
html[data-bs-theme="dark"] .store-header-tools .theme-toggle {
  color: var(--cb-text);
}

.store-header-tools .theme-toggle {
  color: #263238;
}

html[data-bs-theme="dark"] .store-header-tools .store-bell-btn:hover,
html[data-bs-theme="dark"] .store-header-tools .store-bell-btn:focus,
html[data-bs-theme="dark"] .store-header-tools .store-header-cart:hover,
html[data-bs-theme="dark"] .store-header-tools .store-header-cart:focus,
html[data-bs-theme="dark"] .store-header-tools .theme-toggle:hover,
html[data-bs-theme="dark"] .store-header-tools .theme-toggle:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

html[data-bs-theme="dark"] .store-bell-btn .notification-badge,
html[data-bs-theme="dark"] .store-header-cart .cart-badge-count {
  border-color: var(--cb-surface);
}

html[data-bs-theme="dark"] .store-account-icon,
html[data-bs-theme="dark"] .account-icon-wrapper.bg-light {
  background: var(--cb-surface-2) !important;
  color: var(--cb-muted) !important;
}

html[data-bs-theme="dark"] .navbar-toggler-icon {
  filter: invert(1) grayscale(100%);
}

html[data-bs-theme="dark"] .central-builders-hero-section {
  background: radial-gradient(circle at 10% 20%, #1a1d24 0%, #12151b 100%);
}

html[data-bs-theme="dark"] .hero-curve-decoration {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.18) 0%, rgba(245, 158, 11, 0.12) 100%);
}

html[data-bs-theme="dark"] .hero-badge-pill {
  background-color: #3a1c1c;
  color: #ff8a80;
}

html[data-bs-theme="dark"] .hero-title {
  color: #f3f4f6;
}

html[data-bs-theme="dark"] .hero-subtext {
  color: #a0a8b5;
}

html[data-bs-theme="dark"] .category-quick-card,
html[data-bs-theme="dark"] .store-product-card,
html[data-bs-theme="dark"] .shop-product-card,
html[data-bs-theme="dark"] .product-card,
html[data-bs-theme="dark"] .card {
  background: var(--cb-surface);
  border-color: var(--cb-border);
  color: var(--cb-text);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.28);
}

html[data-bs-theme="dark"] .category-quick-card:hover,
html[data-bs-theme="dark"] .store-product-card:hover {
  border-color: #5a3030;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4);
  color: var(--central-builders-red);
}

html[data-bs-theme="dark"] .store-product-visual,
html[data-bs-theme="dark"] .store-product-photo,
html[data-bs-theme="dark"] .catalog-photo,
html[data-bs-theme="dark"] .line-product img {
  background: #12151b;
  border-color: var(--cb-border);
}

html[data-bs-theme="dark"] .account-panel-link {
  border-bottom-color: var(--cb-border);
  color: var(--cb-text);
}

html[data-bs-theme="dark"] .account-panel-link.is-active {
  color: #fff;
}

html[data-bs-theme="dark"] .central-builders-notify-modal .modal-content,
html[data-bs-theme="dark"] .central-builders-auth-modal .modal-content,
html[data-bs-theme="dark"] .login-required-modal .modal-content,
html[data-bs-theme="dark"] .modal-content,
html[data-bs-theme="dark"] .offcanvas {
  background-color: var(--cb-surface);
  border-color: var(--cb-border);
  color: var(--cb-text);
}

html[data-bs-theme="dark"] .central-builders-notify-modal .modal-header,
html[data-bs-theme="dark"] .central-builders-notify-modal .modal-footer,
html[data-bs-theme="dark"] .central-builders-cart-modal .offcanvas-header,
html[data-bs-theme="dark"] .central-builders-account-modal .offcanvas-header,
html[data-bs-theme="dark"] .modal-header,
html[data-bs-theme="dark"] .modal-footer,
html[data-bs-theme="dark"] .offcanvas-header {
  border-color: var(--cb-border);
}

html[data-bs-theme="dark"] .central-builders-notify-modal .modal-title,
html[data-bs-theme="dark"] .login-required-modal .modal-title,
html[data-bs-theme="dark"] .central-builders-auth-modal .modal-title {
  color: var(--cb-text);
}

html[data-bs-theme="dark"] .btn-close {
  filter: invert(1) grayscale(100%);
  opacity: 0.75;
}

html[data-bs-theme="dark"] .form-control,
html[data-bs-theme="dark"] .form-select,
html[data-bs-theme="dark"] .input-group-text {
  background-color: var(--cb-surface-2);
  border-color: var(--cb-border);
  color: var(--cb-text);
}

html[data-bs-theme="dark"] .form-control:focus,
html[data-bs-theme="dark"] .form-select:focus {
  background-color: var(--cb-surface-2);
  border-color: var(--central-builders-red);
  color: var(--cb-text);
  box-shadow: 0 0 0 0.25rem rgba(239, 83, 80, 0.2);
}

html[data-bs-theme="dark"] .form-control::placeholder {
  color: #7d8696;
}

html[data-bs-theme="dark"] .central-builders-perks-bar {
  background: var(--cb-surface);
  border-color: var(--cb-border);
}

html[data-bs-theme="dark"] .central-builders-perks-mobile li {
  background: var(--cb-surface-2);
  border-color: var(--cb-border);
  color: var(--cb-text);
}

html[data-bs-theme="dark"] .central-builders-perks-mobile small {
  color: var(--cb-muted);
}

html[data-bs-theme="dark"] .coupon-menu,
html[data-bs-theme="dark"] .stat-kpi-card,
html[data-bs-theme="dark"] .rider-page .stat-kpi-card {
  background: var(--cb-surface);
  border-color: var(--cb-border);
  color: var(--cb-text);
}

/* Rider */
html[data-bs-theme="dark"] .rider-topbar {
  background: var(--cb-surface);
  border-bottom-color: var(--cb-border);
}

html[data-bs-theme="dark"] .rider-nav a {
  color: #c5cad3;
}

html[data-bs-theme="dark"] .rider-nav a.active {
  color: var(--central-builders-red);
}

html[data-bs-theme="dark"] .rider-bell {
  background: #3a1c1c;
  color: #ff8a80;
}

html[data-bs-theme="dark"] .rider-duty {
  background: #2a1515;
  color: #f0c9c9;
}

html[data-bs-theme="dark"] .rider-duty.on {
  background: #16301f;
  color: #8fd6ae;
}

/* Admin */
html[data-bs-theme="dark"] body.admin-layout,
html[data-bs-theme="dark"] body.admin-layout.bg-light {
  color: var(--cb-text);
  background-color: var(--admin-bg) !important;
}

html[data-bs-theme="dark"] .admin-sidebar {
  background: var(--cb-surface);
  border-right-color: var(--cb-border);
  color: var(--cb-text);
  box-shadow: 8px 0 30px rgba(0, 0, 0, 0.28);
}

html[data-bs-theme="dark"] .admin-sidebar .sidebar-link,
html[data-bs-theme="dark"] .admin-sidebar .nav-link {
  color: #c5cad3;
}

html[data-bs-theme="dark"] .admin-sidebar .nav-link:hover,
html[data-bs-theme="dark"] .admin-sidebar .sidebar-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

html[data-bs-theme="dark"] .admin-sidebar .nav-link.active,
html[data-bs-theme="dark"] .admin-sidebar .sidebar-link.active {
  background: rgba(255, 77, 77, 0.14);
  color: #ff8a80;
}

html[data-bs-theme="dark"] .admin-topbar,
html[data-bs-theme="dark"] .admin-topbar.bg-white {
  background: var(--cb-surface) !important;
  border-bottom-color: var(--cb-border) !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
  color: var(--cb-text);
}

html[data-bs-theme="dark"] .stat-kpi-card {
  background: var(--cb-surface);
  border-color: var(--cb-border);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
}

html[data-bs-theme="dark"] .admin-sidebar-footer,
html[data-bs-theme="dark"] .cg-side-user,
html[data-bs-theme="dark"] .cg-wave-link {
  color: var(--cb-text);
}

html[data-bs-theme="dark"] .cg-wave-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

html[data-bs-theme="dark"] .admin-content-body .card,
html[data-bs-theme="dark"] .admin-content-body .table-responsive,
html[data-bs-theme="dark"] .cg-panel,
html[data-bs-theme="dark"] .cg-card {
  background-color: var(--cb-surface);
  border-color: var(--cb-border);
  color: var(--cb-text);
}

html[data-bs-theme="dark"] .admin-menu-toggle {
  background: var(--cb-surface);
  color: var(--cb-text);
  border-color: var(--cb-border);
}

html[data-bs-theme="dark"] .admin-header-bell {
  background: var(--cb-surface-2);
  color: var(--cb-text);
}

/* Auth / misc soft pink panels used in custom CSS */
html[data-bs-theme="dark"] .auth-visual-footer,
html[data-bs-theme="dark"] [class*="bg-light"],
html[data-bs-theme="dark"] .alert-light {
  color: var(--cb-text);
}

html[data-bs-theme="dark"] .alert-light {
  background-color: var(--cb-surface-2);
  border-color: var(--cb-border);
}

@keyframes liveFlashDark {
  from { background-color: rgba(239, 83, 80, 0.28); }
  to { background-color: transparent; }
}

html[data-bs-theme="dark"] .live-updated {
  animation-name: liveFlashDark;
}
