/* Option A: Dark Gradient + Neon Accent (scoped by .theme-dark) */

.theme-dark {
  --bg-1: #0B1020;
  --bg-2: #0E1A35;
  --surface: rgba(17, 25, 40, 0.65);
  --surface-solid: #101726;
  --surface-2: rgba(12, 18, 32, 0.9);
  --surface-border: rgba(255, 255, 255, 0.08);
  --text: #E6EAF2;
  --text-muted: #A9B4CE;
  --primary: #00E0FF;
  --primary-700: #00B3CC;
  --secondary: #7C4DFF;
  --accent: #00E0FF;
  --success: #22D3A8;
  --warning: #F59E0B;
  --danger: #EF4444;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --ring-color: rgba(0, 224, 255, 0.35);

  /* Bootstrap CSS variables */
  --bs-body-bg: #0E1A35;
  --bs-body-color: var(--text);
  --bs-border-color: var(--surface-border);
  --bs-card-bg: var(--surface);
  --bs-card-color: var(--text);
  --bs-dropdown-bg: var(--surface-2);
  --bs-dropdown-color: var(--text);
  --bs-dropdown-link-hover-bg: rgba(255,255,255,0.06);
  --bs-modal-bg: var(--surface);
  --bs-modal-color: var(--text);
  --bs-popover-bg: var(--surface);
  --bs-popover-body-color: var(--text);
  --bs-tooltip-bg: rgba(0,0,0,.85);
  --bs-tooltip-color: #fff;
  --bs-table-bg: transparent;
  --bs-table-color: var(--text);
  --bs-table-border-color: var(--surface-border);
  --bs-link-color: var(--primary);
  --bs-link-hover-color: var(--primary-700);
  --bs-primary: var(--primary);
  --bs-secondary: var(--secondary);
  --bs-success: var(--success);
  --bs-warning: var(--warning);
  --bs-danger: var(--danger);
  --bs-info: #38bdf8;
  --bs-heading-color: var(--text);
  --bs-secondary-color: var(--text-muted);
}

.theme-dark {
  color: var(--text);
  background: radial-gradient(1000px 600px at 80% -10%, rgba(0, 224, 255, 0.15), transparent 60%),
              radial-gradient(800px 500px at 10% 120%, rgba(124, 77, 255, 0.18), transparent 60%),
              linear-gradient(180deg, var(--bg-1), var(--bg-2));
}

.theme-dark a { color: var(--text); }
.theme-dark .text-muted { color: var(--text-muted) !important; }
.theme-dark .text-dark { color: var(--text) !important; }

/* Headings and common text elements */
.theme-dark h1, .theme-dark h2, .theme-dark h3, .theme-dark h4, .theme-dark h5, .theme-dark h6,
.theme-dark .card-title, .theme-dark .modal-title,
.theme-dark label, .theme-dark .form-label { color: var(--text) !important; }
.theme-dark p, .theme-dark small, .theme-dark .small, .theme-dark .kpi-label,
.theme-dark .stat-label, .theme-dark .image-card-meta { color: var(--text-muted) !important; }
.theme-dark .stat-value, .theme-dark .image-card-title { color: var(--text) !important; }

/* Navbar */
.theme-dark .navbar.navbar-light.bg-white {
  background: linear-gradient(180deg, rgba(11, 16, 32, 0.75), rgba(11, 16, 32, 0.35)) !important;
  border-bottom: 1px solid var(--surface-border);
}
.theme-dark .navbar .navbar-toggler { border-color: rgba(255,255,255,0.35); }
.theme-dark .navbar .navbar-toggler-icon { filter: invert(1) brightness(1.2); }
.theme-dark .navbar .navbar-brand,
.theme-dark .navbar .nav-link { color: var(--text) !important; }
.theme-dark .navbar .nav-link:hover { background: rgba(255,255,255,0.06); border-radius: 8px; }
.theme-dark .dropdown-menu {
  background: var(--surface-2);
  border: 1px solid var(--surface-border);
}
.theme-dark .dropdown-item { color: var(--text); }
.theme-dark .dropdown-item:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.theme-dark .dropdown-divider { border-top-color: var(--surface-border); }

/* Footer */
.theme-dark footer.footer,
.theme-dark footer.border-top { border-top-color: var(--surface-border) !important; background: transparent; color: var(--text-muted); }

/* Cards, panels, modals */
.theme-dark .card,
.theme-dark .modal-content,
.theme-dark .dropdown-menu,
.theme-dark .list-group-item,
.theme-dark .offcanvas {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  color: var(--text);
  backdrop-filter: blur(8px);
}
.theme-dark .card-header,
.theme-dark .modal-header,
.theme-dark .card-footer,
.theme-dark .modal-footer { border-color: var(--surface-border); }

/* Tables */
.theme-dark .table { color: var(--text); }
.theme-dark .table thead th { color: var(--text-muted); border-bottom-color: var(--surface-border); }
.theme-dark .table td, .theme-dark .table th { border-color: var(--surface-border); }
.theme-dark .table-striped > tbody > tr:nth-of-type(odd) { --bs-table-accent-bg: rgba(255,255,255,0.03); color: var(--text); }
.theme-dark .table > :not(caption) > * > * { background-color: transparent; }
.theme-dark .table-hover > tbody > tr:hover,
.theme-dark .table-hover > tbody > tr:hover td,
.theme-dark .table-hover > tbody > tr:hover th,
.theme-dark .table-hover > tbody > tr:hover > * {
  background-color: rgba(255,255,255,0.06) !important;
  color: var(--text) !important;
}
.theme-dark .table-hover > tbody > tr:hover a:not(.btn),
.theme-dark .table-hover > tbody > tr:hover .btn-link {
  color: var(--text) !important;
}
.theme-dark .table-hover > tbody > tr:hover .text-muted { color: var(--text) !important; }

/* Delete confirmation (danger emphasis) */
.theme-dark .modal-danger .modal-content,
.theme-dark .card.border-danger { border-color: rgba(239,68,68,0.6) !important; }
.theme-dark .text-danger { color: #FCA5A5 !important; }

/* Tabs, pagination, badges */
.theme-dark .nav-tabs { border-bottom-color: var(--surface-border); }
.theme-dark .nav-tabs .nav-link { color: var(--text-muted); }
.theme-dark .nav-tabs .nav-link.active { color: var(--text); background: rgba(255,255,255,0.04); border-color: var(--surface-border); }
.theme-dark .nav-pills .nav-link { color: var(--text-muted); background: transparent; }
.theme-dark .nav-pills .nav-link:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.theme-dark .nav-pills .nav-link.active, .theme-dark .nav-pills .show>.nav-link { color: #00151A; background-color: var(--primary); }
.theme-dark .pagination .page-link { background: transparent; border-color: var(--surface-border); color: var(--text); }
.theme-dark .pagination .page-link:hover { background: rgba(255,255,255,0.06); }
.theme-dark .badge { filter: saturate(1.1); }

/* Badges neutral background */
.theme-dark .badge.bg-secondary { background-color: rgba(255,255,255,0.12) !important; color: var(--text) !important; }

/* Forms */
.theme-dark .form-control,
.theme-dark .form-select,
.theme-dark textarea,
.theme-dark input[type="text"],
.theme-dark input[type="email"],
.theme-dark input[type="password"],
.theme-dark input[type="number"],
.theme-dark input[type="search"] {
  color: var(--text);
  background-color: rgba(255,255,255,0.04);
  border: 1px solid var(--surface-border);
}
.theme-dark .form-floating > label { color: var(--text-muted); }
.theme-dark .form-floating > .form-control:focus ~ label,
.theme-dark .form-floating > .form-control:not(:placeholder-shown) ~ label { color: var(--text); }
.theme-dark .form-control:focus,
.theme-dark .form-select:focus,
.theme-dark textarea:focus,
.theme-dark input:focus { box-shadow: 0 0 0 3px var(--ring-color); border-color: transparent; }
.theme-dark ::placeholder { color: #9BA6BF; opacity: 1; }

/* Buttons */
.theme-dark .btn-primary { color: #00151A; background-color: var(--primary); border-color: var(--primary); box-shadow: 0 6px 20px rgba(0, 224, 255, 0.25); }
.theme-dark .btn-primary:hover { background-color: var(--primary-700); border-color: var(--primary-700); }
.theme-dark .btn-secondary { background-color: var(--secondary); border-color: var(--secondary); color: #fff; }
.theme-dark .btn-light { color: var(--text); background-color: rgba(255,255,255,0.06); border-color: var(--surface-border); }
.theme-dark .btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.theme-dark .btn-outline-primary:hover { background: rgba(0,224,255,0.12); }
.theme-dark .btn-outline-secondary { color: var(--text); border-color: var(--surface-border); }
.theme-dark .btn-outline-secondary:hover { background: rgba(255,255,255,0.06); border-color: var(--surface-border); }

/* Outline-danger and outline-warning contrasts */
.theme-dark .btn-outline-danger { color: var(--danger); border-color: var(--danger); }
.theme-dark .btn-outline-danger:hover { background: rgba(239,68,68,0.12); }
.theme-dark .btn-outline-warning { color: #FACC15; border-color: #FACC15; }
.theme-dark .btn-outline-warning:hover { background: rgba(250,204,21,0.15); color: #1a1a1a; }
/* Ensure filled warning styles are dark-mode friendly if used */
.theme-dark .btn.btn-warning { color: #1a1a1a; background-color: #FACC15; border-color: #FACC15; }
.theme-dark .btn.btn-warning:hover { background-color: #eab308; border-color: #eab308; }
.theme-dark .bg-warning { background-color: rgba(250,204,21,0.15) !important; }
.theme-dark .text-warning { color: #FACC15 !important; }

/* Alerts */
.theme-dark .alert { color: var(--text); border: 1px solid var(--surface-border); background: rgba(255,255,255,0.04); }
.theme-dark .alert-success { border-left: 4px solid var(--success); }
.theme-dark .alert-warning { border-left: 4px solid var(--warning); }
.theme-dark .alert-danger { border-left: 4px solid var(--danger); }

/* Identity pages cards and headings */
.theme-dark .card .form-label, .theme-dark .card h1, .theme-dark .card h2, .theme-dark .card h3 { color: var(--text); }
.theme-dark .card .text-danger { color: #FFB4B4 !important; }

/* Utilities */
.theme-dark .bg-white { background-color: rgba(255,255,255,0.06) !important; }
.theme-dark .bg-light { background-color: rgba(255,255,255,0.04) !important; }
.theme-dark .bg-body { background-color: var(--bs-body-bg) !important; }
.theme-dark .border-bottom { border-bottom-color: var(--surface-border) !important; }
.theme-dark .border-top { border-top-color: var(--surface-border) !important; }

/* Home/Index marketing jumbotron adjustments */
.theme-dark .jumbotron.bg-light { background: rgba(255,255,255,0.06) !important; color: var(--text); }
.theme-dark .jumbotron .display-4 i { color: var(--primary); }
.theme-dark .card .fa, .theme-dark .card .fas { filter: none; opacity: .95; }

/* Admin panel adjustments */
.theme-dark .admin-wrapper { background: linear-gradient(180deg, var(--bg-1), var(--bg-2)); }
.theme-dark .admin-topbar { background: var(--surface-solid); border-bottom: 1px solid var(--surface-border); color: var(--text); }
.theme-dark .kpi-card { background: var(--surface); border: 1px solid var(--surface-border); color: var(--text); }
.theme-dark .kpi-card .kpi-label { color: var(--text-muted) !important; }
.theme-dark .kpi-card .kpi-bg-icon { color: #23304a; }

/* Workspace layout specifics */
.theme-dark .workspace-sidebar { background: var(--surface-solid); border-right: 1px solid var(--surface-border); }
.theme-dark .workspace-topbar { background: var(--surface-solid); border-bottom: 1px solid var(--surface-border); color: var(--text); }
.theme-dark .sidebar-brand { color: var(--text); border-bottom: 1px solid var(--surface-border); }
.theme-dark .sidebar-nav .nav-link { color: var(--text); }
.theme-dark .sidebar-nav .nav-link:hover { background: rgba(255,255,255,0.06); border-radius: 8px; }
/* Ensure mobile slide-in sidebar uses dark background */
.theme-dark .workspace-sidebar.show { background: var(--surface-solid); }

/* Dark-friendly icons in navbar/nav links */
.theme-dark .navbar .nav-link i,
.theme-dark .workspace-topbar .nav-link i { color: var(--text) !important; opacity: .95; }
.theme-dark .workspace-topbar .btn i { color: var(--text) !important; }

/* Headings and body font */
.theme-dark, .theme-dark h1, .theme-dark h2, .theme-dark h3, .theme-dark h4, .theme-dark h5, .theme-dark h6 {
  font-family: 'Poppins', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}


/* Selection clarity for list groups and active items (e.g., GenerateV4 settings) */
.theme-dark .list-group-item,
.theme-dark .list-group-item-action {
  background: rgba(255,255,255,0.03);
  color: var(--text);
  border: 1px solid var(--surface-border);
}
.theme-dark .list-group-item-action:hover,
.theme-dark .list-group-item:hover {
  background: rgba(255,255,255,0.06);
}
.theme-dark .list-group-item-action.active,
.theme-dark .list-group-item.active,
.theme-dark .list-group-item-action.active:hover {
  background: rgba(0,224,255,0.12);
  color: var(--text);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,224,255,0.15) inset;
}

/* Image radio selection outlines (e.g., GenerateV3 base image, GenerateV4 base image) */
.theme-dark label input[type="radio"] { position: absolute; opacity: 0; }
.theme-dark label input[type="radio"] + img {
  outline: 2px solid transparent;
  transition: outline-color .15s ease, box-shadow .15s ease;
}
.theme-dark label input[type="radio"]:checked + img {
  outline-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(0,224,255,0.12);
}

/* Alerts in dark mode for better contrast */
.theme-dark .alert-primary,
.theme-dark .alert-info {
  background: rgba(0,224,255,0.10);
  border-color: rgba(0,224,255,0.20);
  color: var(--text);
}
.theme-dark .alert-light {
  background: rgba(255,255,255,0.06);
  border-color: var(--surface-border);
  color: var(--text);
}

/* Progress bars */
.theme-dark .progress { background-color: rgba(255,255,255,0.08); }
.theme-dark .progress-bar { background-color: var(--primary); }

/* Range inputs (advanced settings sliders) */
.theme-dark .form-range::-webkit-slider-runnable-track { background: rgba(255,255,255,0.15); }
.theme-dark .form-range::-moz-range-track { background: rgba(255,255,255,0.15); }
.theme-dark .form-range::-webkit-slider-thumb { background: var(--primary); box-shadow: 0 0 0 2px #00151A; }
.theme-dark .form-range::-moz-range-thumb { background: var(--primary); border: none; }

/* Card headers/footers subtle separation */
.theme-dark .card-header,
.theme-dark .card-footer { background-color: rgba(255,255,255,0.03); }

/* Form checks (gallery selection checkboxes) */
.theme-dark .form-check-input { background-color: rgba(255,255,255,0.12); border-color: var(--surface-border); }
.theme-dark .form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }

/* Pagination active state */
.theme-dark .page-item.active .page-link { background: var(--primary); border-color: var(--primary); color: #00151A; }

/* Additional dark-mode refinements for contrast on specific views */
.theme-dark .table-hover > tbody > tr:hover { --bs-table-accent-bg: rgba(255,255,255,0.06); color: var(--text); }

/* Dark buttons on image overlays (e.g., Outlet Photos ellipsis) */
.theme-dark .btn-dark { background-color: rgba(255,255,255,0.12); color: var(--text); border-color: var(--surface-border); }
.theme-dark .btn-dark:hover { background-color: rgba(255,255,255,0.18); }

/* Stronger readable alert backgrounds for warning/danger/success */
.theme-dark .alert-success { background: rgba(34,211,168,0.12); border-color: rgba(34,211,168,0.25); }
.theme-dark .alert-warning { background: rgba(245,158,11,0.12); border-color: rgba(245,158,11,0.25); }
.theme-dark .alert-danger { background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.25); }

/* Primary badge readability on dark */
.theme-dark .badge.bg-primary { color: #00151A !important; }

/* Address autocomplete dropdowns (Outlet/BusinessProfile forms) */
.theme-dark .address-suggestions { background: var(--surface); border-color: var(--surface-border); color: var(--text); box-shadow: 0 6px 18px rgba(0,0,0,0.4); }
.theme-dark .address-suggestion { border-bottom: 1px solid var(--surface-border); }
.theme-dark .address-suggestion:hover,
.theme-dark .address-suggestion.active { background-color: rgba(255,255,255,0.06); }
.theme-dark .address-main { color: var(--text); }
.theme-dark .address-secondary { color: var(--text-muted); }

/* Dark-mode toast styling (video creation complete) */
.theme-dark .toast.text-bg-primary {
  background: linear-gradient(180deg, rgba(0,224,255,0.18), rgba(0,224,255,0.12));
  color: #00151A;
}
.theme-dark .toast .btn-close {
  filter: invert(0); /* keep dark close icon visible on light-ish bg */
}
.theme-dark .toast .btn.btn-light {
  background: #fff;
  color: #0b1220;
  border-color: rgba(0,0,0,0.05);
}
.theme-dark .toast .btn.btn-outline-light {
  color: #E6EAF2;
  border-color: rgba(230,234,242,0.35);
}
.theme-dark .toast .btn.btn-outline-light:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(230,234,242,0.5);
}
.theme-dark #pvs-toast-container { z-index: 1100; }


/* Brand Guidelines - dark theme fixes */
.theme-dark .brand-colors-container,
.theme-dark .brand-fonts-container {
  background-color: var(--surface);
  border: 1px solid var(--surface-border);
  color: var(--text);
}

.theme-dark .color-chip {
  border-color: rgba(255,255,255,0.85);
  box-shadow: 0 2px 4px rgba(0,0,0,0.35);
}

.theme-dark .font-chip {
  background-color: rgba(255,255,255,0.06);
  border: 1px solid var(--surface-border);
  color: var(--text);
}

.theme-dark .form-control-color {
  background-color: rgba(255,255,255,0.06);
  border-color: var(--surface-border);
}

/* Autocomplete/suggestion dropdowns within Brand Guidelines */
.theme-dark .font-suggestions {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  color: var(--text);
  box-shadow: 0 6px 18px rgba(0,0,0,0.4);
}
.theme-dark .font-suggestion { border-bottom: 1px solid var(--surface-border); }
.theme-dark .font-suggestion:hover,
.theme-dark .font-suggestion.active { background-color: rgba(255,255,255,0.06); }