/* ==========================================================================
   ROOMLY SEMANTIC COLOR DESIGN SYSTEM & DESIGN TOKENS
   60-30-10 Principle: 60% Canvas/Surface | 30% Structural | 10% Accent
   WCAG 2.2 AA / AAA Compliant across Dark & Light Modes
   ========================================================================== */

:root {
  color-scheme: dark;
  /* 60% Canvas & Neutral Surfaces (Dark Theme - Default) */
  --color-background: #090A0F;
  --color-background-alt: #0F1118;
  --color-surface: #141722;
  --color-surface-elevated: #1D2130;
  --color-surface-container-lowest: #090A0F;
  --color-surface-container-low: #141722;
  --color-surface-container: #1D2130;
  --color-surface-container-high: #252A3C;
  --color-surface-container-highest: #30364C;

  /* 30% Structural Typography & Borders */
  --color-text-primary: #F4F5F8;
  --color-text-secondary: #9EA3B5;
  --color-text-muted: #6B7285;
  --color-border-subtle: rgba(255, 255, 255, 0.08);
  --color-border: rgba(255, 255, 255, 0.14);
  --color-border-strong: rgba(255, 200, 0, 0.40);

  /* 10% Purposeful Accents */
  --color-primary: #FFC800;
  --color-primary-hover: #E5B400;
  --color-on-primary: #0A0A0A;
  --color-secondary: #8B5CF6;
  --color-secondary-surface: rgba(139, 92, 246, 0.12);
  --color-on-secondary: #FFFFFF;
  --color-tertiary: #10B981;
  --color-tertiary-surface: rgba(16, 185, 129, 0.12);
  --color-on-tertiary: #FFFFFF;
  --color-success: #10B981;
  --color-warning: #F59E0B;
  --color-error: #EF4444;
  --color-error-surface: rgba(239, 68, 68, 0.12);
  --color-focus: #FFC800;

  /* Button Tokens */
  --color-button-primary: #FFC800;
  --color-button-primary-hover: #E5B400;
  --color-button-primary-text: #0A0A0A;
  --color-button-secondary: #1D2130;
  --color-button-secondary-hover: #252A3C;
  --color-button-secondary-text: #F4F5F8;
  --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
   LIGHT MODE DESIGN SYSTEM (Activated when .dark is removed or data-theme="light")
   Calibrated for high contrast, crisp typography, and professional elegance
   ========================================================================== */
html:not(.dark),
[data-theme="light"] {
  color-scheme: light;
  /* 60% Canvas & Neutral Surfaces */
  --color-background: #F8FAFC;
  --color-background-alt: #F1F5F9;
  --color-surface: #FFFFFF;
  --color-surface-elevated: #F8FAFC;
  --color-surface-container-lowest: #FFFFFF;
  --color-surface-container-low: #F8FAFC;
  --color-surface-container: #F1F5F9;
  --color-surface-container-high: #E2E8F0;
  --color-surface-container-highest: #CBD5E1;

  /* 30% Structural Typography & Borders (WCAG AAA / AA compliant) */
  --color-text-primary: #0F172A;       /* Slate 900 - 15.4:1 contrast on white */
  --color-text-secondary: #334155;     /* Slate 700 - 8.2:1 contrast on white */
  --color-text-muted: #64748B;         /* Slate 500 - 4.6:1 contrast on white */
  --color-border-subtle: #E2E8F0;      /* Slate 200 */
  --color-border: #CBD5E1;             /* Slate 300 */
  --color-border-strong: rgba(217, 119, 6, 0.50);

  /* 10% Purposeful Accents (Calibrated for WCAG AA on light mode) */
  --color-primary: #D97706;            /* Amber 600 - High contrast on light surfaces */
  --color-primary-hover: #B45309;      /* Amber 700 */
  --color-on-primary: #FFFFFF;
  --color-secondary: #7C3AED;          /* Violet 600 */
  --color-secondary-surface: rgba(124, 58, 237, 0.08);
  --color-on-secondary: #FFFFFF;
  --color-tertiary: #059669;           /* Emerald 600 */
  --color-tertiary-surface: rgba(5, 150, 105, 0.08);
  --color-on-tertiary: #FFFFFF;
  --color-success: #059669;
  --color-warning: #D97706;
  --color-error: #DC2626;
  --color-error-surface: rgba(220, 38, 38, 0.08);
  --color-focus: #D97706;

  /* Button Tokens */
  --color-button-primary: #D97706;
  --color-button-primary-hover: #B45309;
  --color-button-primary-text: #FFFFFF;
  --color-button-secondary: #F1F5F9;
  --color-button-secondary-hover: #E2E8F0;
  --color-button-secondary-text: #0F172A;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* Global Utility & Resets */
body {
  background-color: var(--color-background);
  color: var(--color-text-primary);
  transition: background-color 0.2s ease, color 0.2s ease;
}

::selection {
  background: var(--color-primary);
  color: var(--color-on-primary);
}

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

/* Form Controls & Native Select Contrast Shield */
select, input, textarea {
  color-scheme: dark;
}
html:not(.dark) select, html:not(.dark) input, html:not(.dark) textarea,
[data-theme="light"] select, [data-theme="light"] input, [data-theme="light"] textarea {
  color-scheme: light;
}

/* Explicit fallback styling for native select options across all platforms */
select option {
  background-color: #141722 !important;
  color: #F4F5F8 !important;
}
html:not(.dark) select option,
[data-theme="light"] select option {
  background-color: #FFFFFF !important;
  color: #0F172A !important;
}

/* ==========================================================================
   CUSTOM DROPDOWN COMPONENT (100% theme-consistent, zero OS rendering quirks)
   ========================================================================== */
.custom-dropdown {
  position: relative;
  display: inline-block;
}
.custom-dropdown-trigger {
  user-select: none;
  cursor: pointer;
}
.custom-dropdown-menu {
  display: none;
  background-color: var(--color-surface-elevated, #1D2130);
  border: 1px solid var(--color-border);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}
.custom-dropdown.open .custom-dropdown-menu {
  display: block;
}
.custom-dropdown.open .dd-chevron {
  transform: rotate(180deg);
}
.custom-dropdown-item {
  color: var(--color-text-primary);
  user-select: none;
}
.custom-dropdown-item:hover {
  background-color: var(--color-surface-container-high, #252A3C);
  color: var(--color-primary);
}
.custom-dropdown-item.selected {
  color: var(--color-primary);
  background-color: var(--color-surface-container, #1D2130);
}
.custom-dropdown-item.selected .dd-item-dot {
  opacity: 1 !important;
}

/* Light mode overrides for custom dropdown */
html:not(.dark) .custom-dropdown-menu,
[data-theme="light"] .custom-dropdown-menu {
  background-color: #FFFFFF !important;
  border-color: #CBD5E1 !important;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12) !important;
}
html:not(.dark) .custom-dropdown-item,
[data-theme="light"] .custom-dropdown-item {
  color: #0F172A !important;
}
html:not(.dark) .custom-dropdown-item:hover,
[data-theme="light"] .custom-dropdown-item:hover {
  background-color: #F1F5F9 !important;
  color: #D97706 !important;
}
html:not(.dark) .custom-dropdown-item.selected,
[data-theme="light"] .custom-dropdown-item.selected {
  background-color: #FEF3C7 !important;
  color: #B45309 !important;
}


/* ==========================================================================
   LIGHT MODE READABILITY & CONTRAST SHIELD
   Ensures WCAG 2.2 AA (4.5:1+) readability across all surfaces in light mode
   ========================================================================== */

/* Universal fallback: text-white on light backgrounds automatically becomes dark text */
html:not(.dark) .text-white,
[data-theme="light"] .text-white {
  color: var(--color-text-primary) !important;
}

/* Preserve pure white text ONLY where it sits on dark overlays or colored buttons */
html:not(.dark) [class*="bg-black"] .text-white,
html:not(.dark) [class*="bg-black\/"] .text-white,
html:not(.dark) [class*="from-black"] .text-white,
html:not(.dark) .bg-primary,
html:not(.dark) .bg-secondary,
html:not(.dark) .bg-tertiary,
html:not(.dark) [class*="bg-primary"] .text-on-primary,
html:not(.dark) .text-on-primary,
html:not(.dark) .text-on-secondary,
html:not(.dark) .text-on-tertiary,
html:not(.dark) .badge-dark,
html:not(.dark) .image-overlay-text,
html:not(.dark) [class*="bg-gradient"] .image-overlay-text,
[data-theme="light"] [class*="bg-black"] .text-white,
[data-theme="light"] [class*="bg-black\/"] .text-white,
[data-theme="light"] [class*="from-black"] .text-white,
[data-theme="light"] .text-on-primary,
[data-theme="light"] .text-on-secondary,
[data-theme="light"] .image-overlay-text {
  color: #FFFFFF !important;
}

/* Secondary, Muted & Grey Typography Mapping in Light Mode */
html:not(.dark) .text-gray-100,
html:not(.dark) .text-gray-200,
html:not(.dark) .text-gray-300,
html:not(.dark) .text-slate-100,
html:not(.dark) .text-slate-200,
html:not(.dark) .text-slate-300,
[data-theme="light"] .text-gray-100,
[data-theme="light"] .text-gray-200,
[data-theme="light"] .text-gray-300 {
  color: var(--color-text-secondary) !important;
}

html:not(.dark) .text-gray-400,
html:not(.dark) .text-slate-400,
html:not(.dark) .text-outline,
[data-theme="light"] .text-gray-400,
[data-theme="light"] .text-outline {
  color: var(--color-text-muted) !important;
}

/* Form Controls & Selectors in Light Mode */
html:not(.dark) input,
html:not(.dark) select,
html:not(.dark) textarea,
[data-theme="light"] input,
[data-theme="light"] select,
[data-theme="light"] textarea {
  color: var(--color-text-primary) !important;
}

html:not(.dark) input::placeholder,
[data-theme="light"] input::placeholder {
  color: var(--color-text-muted) !important;
}

html:not(.dark) select option,
[data-theme="light"] select option {
  background-color: #FFFFFF !important;
  color: var(--color-text-primary) !important;
}

/* Surface Containers & Elevation in Light Mode */
html:not(.dark) [class*="bg-surface-container-lowest"],
[data-theme="light"] [class*="bg-surface-container-lowest"] {
  background-color: #FFFFFF !important;
  border-color: #E2E8F0 !important;
  box-shadow: var(--card-shadow);
}

html:not(.dark) [class*="bg-surface-container-low"],
[data-theme="light"] [class*="bg-surface-container-low"] {
  background-color: #F8FAFC !important;
  border-color: #E2E8F0 !important;
}

html:not(.dark) [class*="bg-surface-container"]:not([class*="bg-surface-container-low"]):not([class*="bg-surface-container-lowest"]),
[data-theme="light"] [class*="bg-surface-container"]:not([class*="bg-surface-container-low"]):not([class*="bg-surface-container-lowest"]) {
  background-color: #F1F5F9 !important;
  border-color: #E2E8F0 !important;
}

/* Borders in Light Mode: Neutral slate borders instead of invisible faint white */
html:not(.dark) [class*="border-white"],
[data-theme="light"] [class*="border-white"] {
  border-color: var(--color-border-subtle) !important;
}

/* Header in Light Mode */
html:not(.dark) header,
[data-theme="light"] header {
  background-color: rgba(255, 255, 255, 0.95) !important;
  border-bottom: 1px solid #E2E8F0 !important;
}

/* Hover States in Light Mode - prevent links from turning white and disappearing */
html:not(.dark) .hover\:text-white:hover,
[data-theme="light"] .hover\:text-white:hover {
  color: var(--color-primary) !important;
}

/* Location chips & filter pills in light mode */
html:not(.dark) .filter-pill,
[data-theme="light"] .filter-pill {
  background-color: #F1F5F9 !important;
  color: var(--color-text-secondary) !important;
  border-color: #CBD5E1 !important;
}

