/**
 * FireBreak Bacchus Theme
 * Commercial Winery Underwriting Platform
 * Based on: docs/bacchus/pilot/wireframes/PILOT_DESIGN_SYSTEM.md
 */

:root[data-theme="bacchus"],
.theme-bacchus {
  /* ========================================
     PRIMARY BRAND COLORS
     ======================================== */

  /* Primary Blue (Firebreak Blue) - 9 shades */
  --color-primary-50: #eff6ff;
  --color-primary-100: #dbeafe;
  --color-primary-200: #bfdbfe;
  --color-primary-300: #93c5fd;
  --color-primary-400: #60a5fa;
  --color-primary-500: #3b82f6;  /* Base primary */
  --color-primary-600: #2563eb;
  --color-primary-700: #1d4ed8;
  --color-primary-800: #1e40af;
  --color-primary-900: #1e3a8a;

  /* ========================================
     FIRE ALERT COLORS
     ======================================== */

  /* Fire Ember (Orange) - Active fire warnings */
  --color-fire-ember-50: #fff7ed;
  --color-fire-ember-100: #ffedd5;
  --color-fire-ember-200: #fed7aa;
  --color-fire-ember-300: #fdba74;
  --color-fire-ember-400: #fb923c;  /* Base */
  --color-fire-ember-500: #f97316;
  --color-fire-ember-600: #ea580c;
  --color-fire-ember-700: #c2410c;
  --color-fire-ember-800: #9a3412;
  --color-fire-ember-900: #7c2d12;

  /* Fire Flame (Red) - Critical fire alerts */
  --color-fire-flame-50: #fef2f2;
  --color-fire-flame-100: #fee2e2;
  --color-fire-flame-200: #fecaca;
  --color-fire-flame-300: #fca5a5;
  --color-fire-flame-400: #f87171;
  --color-fire-flame-500: #ef4444;  /* Base */
  --color-fire-flame-600: #dc2626;
  --color-fire-flame-700: #b91c1c;
  --color-fire-flame-800: #991b1b;
  --color-fire-flame-900: #7f1d1d;

  /* Fire Smoke (Gray) - Inactive fire */
  --color-fire-smoke-50: #fafafa;
  --color-fire-smoke-100: #f4f4f5;
  --color-fire-smoke-200: #e4e4e7;
  --color-fire-smoke-300: #d4d4d8;
  --color-fire-smoke-400: #a1a1aa;
  --color-fire-smoke-500: #71717a;  /* Base */
  --color-fire-smoke-600: #52525b;
  --color-fire-smoke-700: #3f3f46;
  --color-fire-smoke-800: #27272a;
  --color-fire-smoke-900: #18181b;

  /* ========================================
     STATUS COLORS
     ======================================== */

  --color-status-action-required: #ef4444;  /* Red */
  --color-status-waiting: #f59e0b;           /* Amber */
  --color-status-approved: #10b981;          /* Green */
  --color-status-reviewing: #3b82f6;         /* Blue */

  /* ========================================
     DARK THEME (BASE - DEFAULT)
     ======================================== */

  /* Background Colors */
  --color-bg-base: #0f172a;           /* slate-950 - Page background */
  --color-bg-elevated: #1e293b;       /* slate-900 - Cards, panels */
  --color-bg-elevated-hover: #334155; /* slate-800 - Hover states */
  --color-bg-input: #1e293b;          /* slate-900 - Form inputs */
  --color-bg-overlay: rgba(15, 23, 42, 0.8);  /* Modal backdrop */

  /* Text Colors */
  --color-text-primary: #f1f5f9;      /* slate-100 - Primary text */
  --color-text-secondary: #cbd5e1;    /* slate-300 - Secondary text */
  --color-text-tertiary: #94a3b8;     /* slate-400 - Tertiary text */
  --color-text-disabled: #64748b;     /* slate-500 - Disabled text */
  --color-text-inverse: #0f172a;      /* slate-950 - Text on light backgrounds */

  /* Border Colors */
  --color-border-base: #334155;       /* slate-800 - Default borders */
  --color-border-subtle: #1e293b;     /* slate-900 - Subtle borders */
  --color-border-focus: #3b82f6;      /* primary-500 - Focus state */

  /* ========================================
     GLASSMORPHIC SURFACE TOKENS
     ======================================== */
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-bg-elevated: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(226, 232, 240, 0.5);
  --glass-blur: 12px;
  --color-cta: #f59e0b;
  --color-cta-hover: #d97706;

  /* ========================================
     TYPOGRAPHY
     ======================================== */

  /* Font Families */
  --font-family-base: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  --font-family-mono: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Consolas', monospace;

  /* Font Weights */
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* Font Sizes (Type Scale) */
  --font-size-xs: 0.75rem;    /* 12px */
  --font-size-sm: 0.875rem;   /* 14px */
  --font-size-base: 1rem;     /* 16px */
  --font-size-lg: 1.125rem;   /* 18px */
  --font-size-xl: 1.25rem;    /* 20px */
  --font-size-2xl: 1.5rem;    /* 24px */
  --font-size-3xl: 1.875rem;  /* 30px */
  --font-size-4xl: 2.25rem;   /* 36px */
  --font-size-5xl: 3rem;      /* 48px */
  --font-size-6xl: 3.75rem;   /* 60px */

  /* Line Heights */
  --line-height-none: 1;
  --line-height-tight: 1.25;
  --line-height-snug: 1.375;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.625;
  --line-height-loose: 2;

  /* Letter Spacing */
  --letter-spacing-tighter: -0.05em;
  --letter-spacing-tight: -0.025em;
  --letter-spacing-normal: 0;
  --letter-spacing-wide: 0.025em;
  --letter-spacing-wider: 0.05em;
  --letter-spacing-widest: 0.1em;

  /* ========================================
     SPACING SCALE
     ======================================== */

  --space-0: 0;
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */
  --space-20: 5rem;     /* 80px */
  --space-24: 6rem;     /* 96px */
  --space-32: 8rem;     /* 128px */

  /* ========================================
     BORDER RADIUS
     ======================================== */

  --radius-none: 0;
  --radius-sm: 0.25rem;   /* 4px - Badges */
  --radius-base: 0.375rem; /* 6px - Buttons, inputs */
  --radius-md: 0.5rem;    /* 8px - Cards, panels */
  --radius-lg: 0.75rem;   /* 12px - Modals */
  --radius-xl: 1rem;      /* 16px - Hero sections */
  --radius-full: 9999px;  /* Avatars, pills */

  /* ========================================
     SHADOWS & ELEVATION
     ======================================== */

  /* Box Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);

  /* Focus Rings */
  --shadow-focus: 0 0 0 3px rgba(59, 130, 246, 0.4);  /* 3px blue @ 40% opacity */

  /* Inner Shadows (Depth) */
  --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);

  /* ========================================
     Z-INDEX SYSTEM
     ======================================== */

  --z-base: 0;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-fixed: 300;
  --z-modal-backdrop: 400;
  --z-modal: 500;
  --z-popover: 600;
  --z-tooltip: 700;
  --z-toast: 1600;

  /* ========================================
     ANIMATION
     ======================================== */

  /* Durations */
  --duration-instant: 0ms;
  --duration-fast: 150ms;
  --duration-normal: 300ms;
  --duration-slow: 500ms;
  --duration-slower: 700ms;

  /* Easing Functions */
  --ease-linear: linear;
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.68, -0.55, 0.265, 1.55);

  /* ========================================
     ACCESSIBILITY
     ======================================== */

  /* Touch Targets (Minimum 48px) */
  --touch-target-min: 48px;

  /* Focus Visible */
  --focus-visible-outline: 3px solid var(--color-border-focus);
  --focus-visible-offset: 2px;

  /* ========================================
     COMPONENT-SPECIFIC TOKENS
     ======================================== */

  /* Buttons */
  --btn-padding-sm: var(--space-2) var(--space-3);
  --btn-padding-base: var(--space-3) var(--space-4);
  --btn-padding-lg: var(--space-4) var(--space-6);

  /* Cards */
  --card-bg: var(--color-bg-elevated);
  --card-border: var(--color-border-base);
  --card-padding: var(--space-6);
  --card-radius: var(--radius-md);
  --card-shadow: var(--shadow-md);

  /* Inputs */
  --input-bg: var(--color-bg-input);
  --input-border: var(--color-border-base);
  --input-border-focus: var(--color-border-focus);
  --input-padding: var(--space-3) var(--space-4);
  --input-radius: var(--radius-base);

  /* Modals */
  --modal-bg: var(--color-bg-elevated);
  --modal-backdrop: var(--color-bg-overlay);
  --modal-radius: var(--radius-lg);
  --modal-shadow: var(--shadow-2xl);
}

/* ========================================
   GLOBAL STYLES (Bacchus Theme Active)
   ======================================== */

body[data-theme="bacchus"],
body.theme-bacchus {
  background-color: var(--color-bg-base);
  color: var(--color-text-primary);
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

/* Screen Reader Only (Accessibility) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Focus Visible (Keyboard Navigation) */
.focus-visible:focus-visible {
  outline: var(--focus-visible-outline);
  outline-offset: var(--focus-visible-offset);
}

/* Touch Target Minimum */
.touch-target {
  min-width: var(--touch-target-min);
  min-height: var(--touch-target-min);
}

/* ========================================
   BUTTON STYLES (Bacchus Theme)
   ======================================== */

/* Primary button - Darker amber style (bg-amber-500 hover:bg-amber-600) */
.theme-bacchus .btn-primary,
body[data-theme="bacchus"] .btn-primary {
  background: #f59e0b; /* bg-amber-500 */
  color: white;
  border: none;
  border-radius: 0.5rem; /* rounded-lg */
  padding: 0.75rem 1.5rem; /* px-6 py-3 */
  font-size: 1rem;
  font-weight: 600;
  box-shadow: 0 10px 15px -3px rgba(245, 158, 11, 0.25); /* shadow-lg shadow-amber-500/25 */
  transition: all 0.2s;
  cursor: pointer;
}

.theme-bacchus .btn-primary:hover:not(:disabled),
body[data-theme="bacchus"] .btn-primary:hover:not(:disabled) {
  background: #d97706; /* hover:bg-amber-600 */
  box-shadow: 0 10px 15px -3px rgba(245, 158, 11, 0.35);
  transform: translateY(-1px);
}

.theme-bacchus .btn-primary:disabled,
body[data-theme="bacchus"] .btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* CRITICAL FIX: Autocomplete dropdown base and active states */
/* Base state - collapsed with glassmorphic styling */
.theme-bacchus .autocomplete-dropdown {
  background: rgba(255, 255, 255, 0.95) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  border: 1px solid rgba(226, 232, 240, 0.5) !important;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1) !important;
  max-height: 0 !important;
  overflow: hidden !important;
}

/* Active state - expanded */
body.theme-bacchus .autocomplete-dropdown.active,
.theme-bacchus .autocomplete-dropdown.active,
#autocompleteDropdown.autocomplete-dropdown.active,
#autocompleteDropdown.active {
  max-height: 400px !important;
  opacity: 1 !important;
  overflow-y: auto !important;
  display: flex !important;
  flex-direction: column !important;
  gap: var(--space-sm) !important;
  padding: var(--space-xs) !important;
  min-height: 100px !important;
}
