/* ==========================================================================
   NaviGo Multi-Agent System - Enterprise UI/UX Theme Engine
   Supports: Night (Dark) Mode & Light (Day) Mode
   Features: Hardware-accelerated transitions, WCAG AA contrast, 
             responsive mobile navigation drawer, polished glassmorphism,
             adaptive banners, accessible badges & clean card elevations.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CSS Custom Properties / Design Tokens
   -------------------------------------------------------------------------- */
:root {
  /* Brand Accents */
  --brand-primary: #6366f1;
  --brand-hover: #4f46e5;
  --brand-active: #4338ca;
  --brand-light: #e0e7ff;
  --brand-glow: rgba(99, 102, 241, 0.25);

  /* NIGHT / DARK VIEW (Executive Obsidian Palette) */
  --bg-body: #090d16;
  --bg-viewport: #060911;
  --bg-surface-950: #080d1a;
  --bg-surface-900: #0f172a;
  --bg-surface-850: #172033;
  --bg-surface-800: #1e293b;
  --bg-surface-750: #26354d;

  --border-subtle: #1e293b;
  --border-medium: #334155;
  --border-card: rgba(30, 41, 59, 0.8);
  --border-focus: #6366f1;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --input-bg: #090f1d;
  --input-border: #1e293b;
  --input-text: #f8fafc;
  --input-placeholder: #64748b;

  --sidebar-bg: #0b1120;
  --sidebar-border: #1e293b;
  --header-bg: rgba(15, 23, 42, 0.8);
  --header-border: #1e293b;

  --card-bg: #0f172a;
  --card-inner-bg: #172033;
  --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
  --modal-bg: #0f172a;
  --modal-backdrop: rgba(4, 7, 14, 0.8);

  --table-header-bg: #172033;
  --table-row-hover: rgba(30, 41, 59, 0.5);

  --scrollbar-track: #090d16;
  --scrollbar-thumb: #334155;
  --scrollbar-thumb-hover: #475569;

  --chat-assistant-bg: #172033;
  --chat-assistant-text: #f1f5f9;
  --chat-assistant-border: #1e293b;

  --toggle-btn-bg: #1e293b;
  --toggle-btn-border: #334155;
  --toggle-btn-text: #f8fafc;
}

/* DAY / LIGHT VIEW (Clean High-Contrast Enterprise Palette) */
html.light {
  --bg-body: #f8fafc;
  --bg-viewport: #f1f5f9;
  --bg-surface-950: #f1f5f9;
  --bg-surface-900: #ffffff;
  --bg-surface-850: #f8fafc;
  --bg-surface-800: #edf2f7;
  --bg-surface-750: #e2e8f0;

  --border-subtle: #e2e8f0;
  --border-medium: #cbd5e1;
  --border-card: #e2e8f0;
  --border-focus: #4f46e5;

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-dim: #94a3b8;

  --input-bg: #ffffff;
  --input-border: #cbd5e1;
  --input-text: #0f172a;
  --input-placeholder: #94a3b8;

  --sidebar-bg: #ffffff;
  --sidebar-border: #e2e8f0;
  --header-bg: rgba(255, 255, 255, 0.88);
  --header-border: #e2e8f0;

  --card-bg: #ffffff;
  --card-inner-bg: #f8fafc;
  --card-shadow: 0 4px 14px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
  --modal-bg: #ffffff;
  --modal-backdrop: rgba(15, 23, 42, 0.45);

  --table-header-bg: #f8fafc;
  --table-row-hover: #f1f5f9;

  --scrollbar-track: #f1f5f9;
  --scrollbar-thumb: #cbd5e1;
  --scrollbar-thumb-hover: #94a3b8;

  --chat-assistant-bg: #f1f5f9;
  --chat-assistant-text: #1e293b;
  --chat-assistant-border: #e2e8f0;

  --toggle-btn-bg: #f1f5f9;
  --toggle-btn-border: #cbd5e1;
  --toggle-btn-text: #0f172a;
}

/* --------------------------------------------------------------------------
   2. Base Transitions & Typography
   -------------------------------------------------------------------------- */
* {
  box-sizing: border-box;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  transition: background-color 0.25s ease, color 0.2s ease;
  min-height: 100%;
}

/* Selection Highlights */
html.light ::selection {
  background-color: #c7d2fe !important;
  color: #1e1b4b !important;
}

html.dark ::selection {
  background-color: #4f46e5 !important;
  color: #ffffff !important;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* --------------------------------------------------------------------------
   3. Light Mode Theme Overrides
   -------------------------------------------------------------------------- */

html.light,
html.light body {
  background-color: var(--bg-body) !important;
  color: var(--text-secondary) !important;
}

/* Main Viewport & Layout */
html.light main,
html.light #appScreen {
  background-color: var(--bg-body) !important;
}

/* Sidebar in Light Mode */
html.light aside {
  background-color: var(--sidebar-bg) !important;
  border-right-color: var(--sidebar-border) !important;
  box-shadow: 1px 0 3px 0 rgba(0, 0, 0, 0.03);
}

html.light aside .border-b,
html.light aside .border-t {
  border-color: var(--border-subtle) !important;
}

html.light aside .bg-surface-950\/60 {
  background-color: #f8fafc !important;
}

/* Navigation Tabs */
html.light .nav-tab {
  color: #475569 !important;
  transition: all 0.15s ease;
}

html.light .nav-tab:hover {
  background-color: #f1f5f9 !important;
  color: #0f172a !important;
}

html.light .nav-tab.active,
html.light .nav-tab.bg-surface-850 {
  background-color: #eef2ff !important;
  color: #4338ca !important;
  font-weight: 600 !important;
  box-shadow: 0 1px 2px rgba(99, 102, 241, 0.1) !important;
}

html.light .nav-tab.active i,
html.light .nav-tab.bg-surface-850 i {
  color: #4f46e5 !important;
}

/* Topbar Header */
html.light header {
  background-color: var(--header-bg) !important;
  border-bottom-color: var(--header-border) !important;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.04) !important;
}

/* Surface Classes */
html.light .bg-surface-950,
html.light .bg-slate-950 {
  background-color: var(--bg-surface-950) !important;
}

html.light .bg-surface-900,
html.light .bg-slate-900 {
  background-color: var(--bg-surface-900) !important;
}

html.light .bg-surface-850,
html.light .bg-slate-850 {
  background-color: var(--bg-surface-850) !important;
}

html.light .bg-surface-800,
html.light .bg-slate-800 {
  background-color: var(--bg-surface-800) !important;
}

/* Borders */
html.light .border-slate-800,
html.light .border-slate-800\/80,
html.light .border-slate-800\/60,
html.light .border-slate-800\/40,
html.light .border-slate-700,
html.light .border-slate-700\/80,
html.light .border-slate-700\/60 {
  border-color: var(--border-subtle) !important;
}

/* Typography Hierarchy in Light Mode */
html.light h1:not([class*="text-indigo-"]):not([class*="text-brand-"]):not([class*="text-emerald-"]):not([class*="text-rose-"]):not([class*="text-amber-"]):not([class*="text-sky-"]):not(button *),
html.light h2:not([class*="text-indigo-"]):not([class*="text-brand-"]):not([class*="text-emerald-"]):not([class*="text-rose-"]):not([class*="text-amber-"]):not([class*="text-sky-"]):not(button *),
html.light h3:not([class*="text-indigo-"]):not([class*="text-brand-"]):not([class*="text-emerald-"]):not([class*="text-rose-"]):not([class*="text-amber-"]):not([class*="text-sky-"]):not(button *),
html.light h4:not([class*="text-indigo-"]):not([class*="text-brand-"]):not([class*="text-emerald-"]):not([class*="text-rose-"]):not([class*="text-amber-"]):not([class*="text-sky-"]):not(button *) {
  color: var(--text-primary) !important;
}

/* Text white overrides (Carefully excluding primary solid buttons & gradients) */
html.light .text-white:not(button):not(button *):not(.keep-white):not([class*="bg-brand-600"]):not([class*="bg-brand-600"] *):not([class*="bg-emerald-600"]):not([class*="bg-emerald-600"] *):not([class*="bg-indigo-600"]):not([class*="bg-indigo-600"] *):not([class*="bg-rose-600"]):not([class*="bg-rose-600"] *):not([class*="bg-teal-600"]):not([class*="bg-teal-600"] *):not([class*="bg-gradient-"]):not([class*="bg-gradient-"] *):not(.badge-solid):not(.badge-solid *) {
  color: var(--text-primary) !important;
}

html.light .text-slate-100:not(button *):not([class*="bg-brand-600"] *):not([class*="bg-emerald-600"] *) {
  color: var(--text-primary) !important;
}

html.light .text-slate-200:not(button *):not([class*="bg-brand-600"] *):not([class*="bg-emerald-600"] *) {
  color: var(--text-primary) !important;
}

html.light .text-slate-300:not(button *):not([class*="bg-brand-600"] *):not([class*="bg-emerald-600"] *) {
  color: var(--text-secondary) !important;
}

html.light .text-slate-400:not(button *):not([class*="bg-brand-600"] *):not([class*="bg-emerald-600"] *) {
  color: var(--text-muted) !important;
}

html.light .text-slate-500 {
  color: var(--text-dim) !important;
}

/* Primary and Accent Buttons Guarantee */
html.light button.bg-brand-600,
html.light button.bg-brand-600 *,
html.light button.bg-emerald-600,
html.light button.bg-emerald-600 *,
html.light button.bg-indigo-600,
html.light button.bg-indigo-600 *,
html.light [class*="bg-gradient-to-r from-brand-600"],
html.light [class*="bg-gradient-to-r from-brand-600"] *,
html.light [class*="bg-gradient-to-r from-emerald-600"],
html.light [class*="bg-gradient-to-r from-emerald-600"] *,
html.light .btn-solid-accent,
html.light .btn-solid-accent * {
  color: #ffffff !important;
}

/* Inputs, Textareas, Selects */
html.light input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
html.light textarea,
html.light select {
  background-color: var(--input-bg) !important;
  border-color: var(--input-border) !important;
  color: var(--input-text) !important;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

html.light input:focus,
html.light textarea:focus,
html.light select:focus {
  border-color: var(--border-focus) !important;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15) !important;
}

html.light input::placeholder,
html.light textarea::placeholder {
  color: var(--input-placeholder) !important;
}

/* Cards & Elevated Containers */
html.light .rounded-2xl,
html.light .rounded-3xl,
html.light .shadow-2xl,
html.light .shadow-xl {
  box-shadow: var(--card-shadow) !important;
}

/* Subtle Hero Card Gradients in Light Mode */
html.light [class*="from-brand-950"] {
  background: linear-gradient(135deg, #eef2ff 0%, #ffffff 50%, #e0e7ff 100%) !important;
  border-color: #c7d2fe !important;
}

html.light [class*="from-emerald-950"] {
  background: linear-gradient(135deg, #ecfdf5 0%, #ffffff 50%, #d1fae5 100%) !important;
  border-color: #a7f3d0 !important;
}

html.light [class*="from-purple-950"] {
  background: linear-gradient(135deg, #faf5ff 0%, #ffffff 50%, #f3e8ff 100%) !important;
  border-color: #e9d5ff !important;
}

html.light [class*="from-amber-950"] {
  background: linear-gradient(135deg, #fffbeb 0%, #ffffff 50%, #fef3c7 100%) !important;
  border-color: #fde68a !important;
}

html.light [class*="from-sky-950"] {
  background: linear-gradient(135deg, #f0f9ff 0%, #ffffff 50%, #e0f2fe 100%) !important;
  border-color: #bae6fd !important;
}

html.light [class*="from-rose-950"] {
  background: linear-gradient(135deg, #fff1f2 0%, #ffffff 50%, #ffe4e6 100%) !important;
  border-color: #fecdd3 !important;
}

html.light [class*="from-teal-950"] {
  background: linear-gradient(135deg, #f0fdfa 0%, #ffffff 50%, #ccfbf1 100%) !important;
  border-color: #99f6e4 !important;
}

/* Badges & Status Chips in Light Mode */
html.light .badge-high {
  background-color: #ecfdf5 !important;
  color: #047857 !important;
  border-color: #a7f3d0 !important;
}

html.light .badge-medium {
  background-color: #fffbeb !important;
  color: #b45309 !important;
  border-color: #fde68a !important;
}

html.light .badge-low {
  background-color: #fff1f2 !important;
  color: #be123c !important;
  border-color: #fecdd3 !important;
}

html.light .badge-review {
  background-color: #eff6ff !important;
  color: #1d4ed8 !important;
  border-color: #bfdbfe !important;
}

/* Dynamic Tailwind Badge classes in Light Mode */
html.light [class*="bg-emerald-500/10"],
html.light [class*="bg-emerald-500/20"] {
  background-color: #ecfdf5 !important;
  color: #047857 !important;
  border-color: #a7f3d0 !important;
}

html.light [class*="bg-amber-500/10"],
html.light [class*="bg-amber-500/20"] {
  background-color: #fffbeb !important;
  color: #b45309 !important;
  border-color: #fde68a !important;
}

html.light [class*="bg-blue-500/10"],
html.light [class*="bg-blue-500/20"],
html.light [class*="bg-sky-500/10"],
html.light [class*="bg-sky-500/20"] {
  background-color: #eff6ff !important;
  color: #0369a1 !important;
  border-color: #bae6fd !important;
}

html.light [class*="bg-purple-500/10"],
html.light [class*="bg-purple-500/20"] {
  background-color: #f5f3ff !important;
  color: #6d28d9 !important;
  border-color: #ddd6fe !important;
}

html.light [class*="bg-brand-500/10"],
html.light [class*="bg-brand-500/20"],
html.light [class*="bg-brand-950/40"] {
  background-color: #eef2ff !important;
  color: #4338ca !important;
  border-color: #c7d2fe !important;
}

/* Modals & Dialogs */
html.light [id*="Modal"] {
  background-color: var(--modal-backdrop) !important;
  backdrop-filter: blur(8px) !important;
}

html.light [id*="Modal"] > div {
  background-color: var(--modal-bg) !important;
  border-color: var(--border-subtle) !important;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.15) !important;
}

/* Tables and Data Rows */
html.light table th,
html.light .table-header {
  background-color: var(--table-header-bg) !important;
  color: #475569 !important;
  border-bottom: 1px solid var(--border-subtle) !important;
}

html.light table tr:hover,
html.light .data-row:hover {
  background-color: var(--table-row-hover) !important;
}

/* Auth / Login Screen */
html.light #loginScreen {
  background-color: #f1f5f9 !important;
}

html.light #loginScreen > div {
  background-color: #ffffff !important;
  border-color: #e2e8f0 !important;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04) !important;
}

/* Booking / Concierge Chat Page (book.html) */
html.light .chat-bubble.assistant-bubble,
html.light #chatMessageStream .bg-surface-850,
html.light #chatMessageStream .bg-surface-950 {
  background-color: var(--chat-assistant-bg) !important;
  color: var(--chat-assistant-text) !important;
  border-color: var(--chat-assistant-border) !important;
}

html.light .quick-chip,
html.light #quickChipsContainer button {
  background-color: #f1f5f9 !important;
  color: #334155 !important;
  border-color: #cbd5e1 !important;
}

html.light .quick-chip:hover,
html.light #quickChipsContainer button:hover {
  background-color: #e2e8f0 !important;
  color: #0f172a !important;
  border-color: #94a3b8 !important;
}

/* --------------------------------------------------------------------------
   4. Theme Switcher Component & UX Micro-interactions
   -------------------------------------------------------------------------- */
.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  border-radius: 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  background-color: var(--toggle-btn-bg);
  border: 1px solid var(--toggle-btn-border);
  color: var(--toggle-btn-text);
  user-select: none;
}

.theme-toggle-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.theme-toggle-btn:active {
  transform: scale(0.97);
}

.theme-toggle-icon {
  font-size: 0.875rem;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.theme-toggle-btn:hover .theme-toggle-icon {
  transform: rotate(20deg);
}

/* Responsive Mobile Drawer */
@media (max-width: 768px) {
  #sidebarDrawer {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    height: 100vh !important;
    z-index: 50 !important;
    transform: translateX(-100%) !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: 10px 0 25px -5px rgba(0, 0, 0, 0.3) !important;
  }
  
  #sidebarDrawer.drawer-open {
    transform: translateX(0) !important;
  }

  #sidebarBackdrop {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 40;
  }

  #sidebarBackdrop.backdrop-open {
    display: block !important;
  }
}
