/**
 * ==============================================================================
 * LIQUID GLASS DESIGN SYSTEM (v1.0.0)
 * ==============================================================================
 * Universal, cross-framework stylesheet for Liquid Glass & Fluid UI aesthetics.
 * Framework-agnostic: Drop into Django, Laravel, React, Vue, or static HTML.
 * Standards: 4px grid rhythm, WCAG 2.1 AA contrast, native dark/light support.
 * ==============================================================================
 */

[x-cloak] { display: none !important; }

:root {
  /* Surface Tokens - Light */
  --lg-canvas-bg: #f8fafc;
  --lg-surface-bg: rgba(255, 255, 255, 0.72);
  --lg-surface-hover: rgba(255, 255, 255, 0.88);
  --lg-surface-active: rgba(255, 255, 255, 0.95);
  --lg-nav-bg: rgba(255, 255, 255, 0.80);
  --lg-drawer-bg: rgba(255, 255, 255, 0.92);
  
  /* Border & Rim Light Tokens - Light */
  --lg-border: rgba(226, 232, 240, 0.80);
  --lg-border-subtle: rgba(203, 213, 225, 0.60);
  --lg-specular-rim: inset 0 1px 1.5px 0 rgba(255, 255, 255, 0.65), inset 0 -1px 1px 0 rgba(0, 0, 0, 0.04);
  --lg-specular-rim-strong: inset 0 1px 2px 0 rgba(255, 255, 255, 0.90), inset 0 -1px 1px 0 rgba(0, 0, 0, 0.08);

  /* Shadows - Light */
  --lg-shadow-xs: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
  --lg-shadow-sm: 0 2px 8px -1px rgba(0, 0, 0, 0.08), 0 1px 3px 0 rgba(0, 0, 0, 0.04);
  --lg-shadow-md: 0 8px 24px -4px rgba(0, 0, 0, 0.10), 0 2px 6px -1px rgba(0, 0, 0, 0.04);
  --lg-shadow-lg: 0 20px 40px -8px rgba(0, 0, 0, 0.16), 0 6px 16px -3px rgba(0, 0, 0, 0.06);

  /* Primary Emerald Accent Tokens */
  --lg-primary: #10b981;
  --lg-primary-hover: #059669;
  --lg-primary-active: #047857;
  --lg-primary-tint: rgba(16, 185, 129, 0.10);
  --lg-primary-glow: 0 4px 16px -2px rgba(16, 185, 129, 0.35);

  /* Typography Colors - Light */
  --lg-text-primary: #0f172a;
  --lg-text-secondary: #475569;
  --lg-text-muted: #94a3b8;

  /* Filter Blurs */
  --lg-blur-nav: blur(16px);
  --lg-blur-card: blur(12px);
  --lg-blur-drawer: blur(20px);
}

/* Dark Mode Overrides (Triggered by .dark on <html> or <body>) */
.dark, [data-theme="dark"] {
  /* Surface Tokens - Dark */
  --lg-canvas-bg: #060a08;
  --lg-surface-bg: rgba(11, 17, 14, 0.78);
  --lg-surface-hover: rgba(18, 28, 23, 0.88);
  --lg-surface-active: rgba(22, 36, 29, 0.95);
  --lg-nav-bg: rgba(11, 17, 14, 0.85);
  --lg-drawer-bg: rgba(11, 17, 14, 0.94);

  /* Border & Rim Light Tokens - Dark */
  --lg-border: rgba(39, 58, 48, 0.65);
  --lg-border-subtle: rgba(255, 255, 255, 0.08);
  --lg-specular-rim: inset 0 1px 1px 0 rgba(255, 255, 255, 0.15), inset 0 -1px 1px 0 rgba(0, 0, 0, 0.35);
  --lg-specular-rim-strong: inset 0 1px 1.5px 0 rgba(255, 255, 255, 0.28), inset 0 -1px 1.5px 0 rgba(0, 0, 0, 0.50);

  /* Shadows - Dark */
  --lg-shadow-xs: 0 1px 3px 0 rgba(0, 0, 0, 0.4), 0 1px 2px -1px rgba(0, 0, 0, 0.3);
  --lg-shadow-sm: 0 2px 8px -1px rgba(0, 0, 0, 0.5), 0 1px 3px 0 rgba(0, 0, 0, 0.4);
  --lg-shadow-md: 0 8px 24px -4px rgba(0, 0, 0, 0.6), 0 2px 6px -1px rgba(0, 0, 0, 0.5);
  --lg-shadow-lg: 0 20px 40px -8px rgba(0, 0, 0, 0.8), 0 6px 16px -3px rgba(0, 0, 0, 0.6);

  /* Primary Emerald Accent Tokens - Dark */
  --lg-primary: #10b981;
  --lg-primary-hover: #34d399;
  --lg-primary-active: #059669;
  --lg-primary-tint: rgba(16, 185, 129, 0.18);
  --lg-primary-glow: 0 4px 20px -2px rgba(16, 185, 129, 0.50);

  /* Typography Colors - Dark */
  --lg-text-primary: #e2f0e6;
  --lg-text-secondary: #94a3b8;
  --lg-text-muted: #64748b;
}

/* ==============================================================================
 * CURATED COLOR THEME PRESETS (Activated via data-theme-preset on <html>)
 * ============================================================================== */

/* 1. Obsidian Mint (WhatsApp Native Emerald / Mint) */
html[data-theme-preset="obsidian_mint"],
[data-theme-preset="obsidian_mint"] {
  --lg-primary: #10b981;
  --lg-primary-hover: #059669;
  --lg-primary-tint: rgba(16, 185, 129, 0.12);
  --lg-primary-glow: 0 4px 16px -2px rgba(16, 185, 129, 0.35);
}

html.dark[data-theme-preset="obsidian_mint"],
.dark[data-theme-preset="obsidian_mint"],
.dark [data-theme-preset="obsidian_mint"],
[data-theme-preset="obsidian_mint"].dark,
[data-theme-preset="obsidian_mint"] .dark {
  --lg-canvas-bg: #060a08;
  --lg-surface-bg: rgba(11, 17, 14, 0.85);
  --lg-surface-hover: rgba(18, 28, 23, 0.92);
  --lg-nav-bg: rgba(11, 17, 14, 0.90);
  --lg-drawer-bg: rgba(11, 17, 14, 0.95);
  --lg-border: rgba(39, 58, 48, 0.70);
  --lg-primary: #4fd98a;
  --lg-primary-hover: #9bf2b4;
  --lg-primary-tint: rgba(79, 217, 138, 0.20);
  --lg-primary-glow: 0 4px 20px -2px rgba(79, 217, 138, 0.45);
  --lg-text-primary: #e2f0e6;
  --lg-text-secondary: #94a3b8;
}

/* 2. Mission Slate (Cybernetic Graphite & Icy Cyan / Blue) */
html[data-theme-preset="mission_slate"],
[data-theme-preset="mission_slate"] {
  --lg-primary: #0284c7;
  --lg-primary-hover: #0369a1;
  --lg-primary-tint: rgba(14, 165, 233, 0.14);
  --lg-primary-glow: 0 4px 16px -2px rgba(14, 165, 233, 0.35);
}

html.dark[data-theme-preset="mission_slate"],
.dark[data-theme-preset="mission_slate"],
.dark [data-theme-preset="mission_slate"],
[data-theme-preset="mission_slate"].dark,
[data-theme-preset="mission_slate"] .dark {
  --lg-canvas-bg: #0a0e14;
  --lg-surface-bg: rgba(16, 22, 34, 0.85);
  --lg-surface-hover: rgba(24, 32, 48, 0.92);
  --lg-nav-bg: rgba(16, 22, 34, 0.90);
  --lg-drawer-bg: rgba(16, 22, 34, 0.95);
  --lg-border: rgba(38, 52, 78, 0.70);
  --lg-primary: #38bdf8;
  --lg-primary-hover: #7dd3fc;
  --lg-primary-tint: rgba(56, 189, 248, 0.20);
  --lg-primary-glow: 0 4px 20px -2px rgba(56, 189, 248, 0.45);
  --lg-text-primary: #f0f6fc;
  --lg-text-secondary: #94a3b8;
}

/* 3. Executive Warm (Dual-Tone Warm Amber / Golden Bronze) */
html[data-theme-preset="executive_warm"],
[data-theme-preset="executive_warm"] {
  --lg-canvas-bg: #fdfaf6;
  --lg-surface-bg: rgba(255, 255, 255, 0.82);
  --lg-surface-hover: rgba(255, 255, 255, 0.95);
  --lg-nav-bg: rgba(255, 255, 255, 0.90);
  --lg-drawer-bg: rgba(255, 255, 255, 0.95);
  --lg-border: rgba(231, 229, 228, 0.85);
  --lg-primary: #d97706;
  --lg-primary-hover: #b45309;
  --lg-primary-tint: rgba(217, 119, 6, 0.14);
  --lg-primary-glow: 0 4px 16px -2px rgba(217, 119, 6, 0.35);
  --lg-text-primary: #292524;
  --lg-text-secondary: #57534e;
}

html.dark[data-theme-preset="executive_warm"],
.dark[data-theme-preset="executive_warm"],
.dark [data-theme-preset="executive_warm"],
[data-theme-preset="executive_warm"].dark,
[data-theme-preset="executive_warm"] .dark {
  --lg-canvas-bg: #141210;
  --lg-surface-bg: rgba(28, 25, 23, 0.85);
  --lg-surface-hover: rgba(41, 37, 36, 0.92);
  --lg-nav-bg: rgba(28, 25, 23, 0.90);
  --lg-drawer-bg: rgba(28, 25, 23, 0.95);
  --lg-border: rgba(68, 64, 60, 0.70);
  --lg-primary: #f59e0b;
  --lg-primary-hover: #fbbf24;
  --lg-primary-tint: rgba(245, 158, 11, 0.20);
  --lg-primary-glow: 0 4px 20px -2px rgba(245, 158, 11, 0.45);
  --lg-text-primary: #fafaf9;
  --lg-text-secondary: #a8a29e;
}

/* 4. Zinc Minimalist (Pure Monochromatic Linear Craft) */
html[data-theme-preset="zinc_minimalist"],
[data-theme-preset="zinc_minimalist"] {
  --lg-canvas-bg: #fafafa;
  --lg-surface-bg: rgba(255, 255, 255, 0.80);
  --lg-surface-hover: rgba(255, 255, 255, 0.95);
  --lg-border: rgba(228, 228, 231, 0.80);
  --lg-primary: #27272a;
  --lg-primary-hover: #09090b;
  --lg-primary-tint: rgba(39, 39, 42, 0.12);
  --lg-primary-glow: 0 4px 16px -2px rgba(39, 39, 42, 0.25);
}

html.dark[data-theme-preset="zinc_minimalist"],
.dark[data-theme-preset="zinc_minimalist"],
.dark [data-theme-preset="zinc_minimalist"],
[data-theme-preset="zinc_minimalist"].dark,
[data-theme-preset="zinc_minimalist"] .dark {
  --lg-canvas-bg: #09090b;
  --lg-surface-bg: rgba(24, 24, 27, 0.85);
  --lg-surface-hover: rgba(39, 39, 42, 0.92);
  --lg-nav-bg: rgba(24, 24, 27, 0.90);
  --lg-drawer-bg: rgba(24, 24, 27, 0.95);
  --lg-border: rgba(39, 39, 42, 0.75);
  --lg-primary: #e4e4e7;
  --lg-primary-hover: #fafafa;
  --lg-primary-tint: rgba(228, 228, 231, 0.18);
  --lg-primary-glow: 0 4px 20px -2px rgba(228, 228, 231, 0.35);
  --lg-text-primary: #f4f4f5;
  --lg-text-secondary: #a1a1aa;
}

/* Apply canvas backgrounds smoothly */
body {
  background-color: var(--lg-canvas-bg) !important;
  color: var(--lg-text-primary);
  transition: background-color 0.25s cubic-bezier(0.16, 1, 0.3, 1), color 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==============================================================================
 * UNIVERSAL DARK MODE SHIELD (Guarantees Zero Stark White Leaks)
 * ============================================================================== */
.dark body {
  background-color: var(--lg-canvas-bg) !important;
  color: var(--lg-text-primary) !important;
}

.dark .bg-white {
  background-color: var(--lg-surface-bg) !important;
  color: var(--lg-text-primary) !important;
}

.dark .bg-slate-50,
.dark .bg-slate-50\/50,
.dark .bg-slate-50\/60,
.dark .bg-slate-50\/80,
.dark .bg-slate-100 {
  background-color: rgba(255, 255, 255, 0.04) !important;
  color: var(--lg-text-primary);
}

.dark .border-slate-100,
.dark .border-slate-200,
.dark .border-slate-200\/80,
.dark .border-slate-300 {
  border-color: var(--lg-border) !important;
}

.dark .divide-slate-100 > :not([hidden]) ~ :not([hidden]),
.dark .divide-slate-200 > :not([hidden]) ~ :not([hidden]),
.dark .divide-slate-200\/80 > :not([hidden]) ~ :not([hidden]) {
  border-color: var(--lg-border) !important;
}

.dark .text-slate-900,
.dark .text-slate-800 {
  color: var(--lg-text-primary) !important;
}

.dark .text-slate-700,
.dark .text-slate-600,
.dark .text-slate-500 {
  color: var(--lg-text-secondary) !important;
}

.dark tr.hover\:bg-slate-50\/80:hover,
.dark .hover\:bg-slate-50:hover,
.dark .hover\:bg-slate-100:hover,
.dark .hover\:bg-slate-200:hover {
  background-color: var(--lg-surface-hover) !important;
}

/* ==============================================================================
 * DYNAMIC THEME ACCENT PROPAGATION (Colors components to chosen preset)
 * ============================================================================== */
.liquid-glass-btn-primary,
.btn-primary-dynamic {
  background: linear-gradient(180deg, var(--lg-primary) 0%, var(--lg-primary-hover) 100%) !important;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.25) !important;
  box-shadow: inset 0 1px 1px 0 rgba(255, 255, 255, 0.55), inset 0 -1px 2px 0 rgba(0, 0, 0, 0.2), var(--lg-shadow-sm) !important;
}

.liquid-glass-btn-primary:hover,
.btn-primary-dynamic:hover {
  background: linear-gradient(180deg, var(--lg-primary-hover) 0%, var(--lg-primary) 100%) !important;
  box-shadow: inset 0 1px 1.5px 0 rgba(255, 255, 255, 0.75), var(--lg-primary-glow), var(--lg-shadow-md) !important;
  color: #ffffff !important;
}

.liquid-glass-badge-emerald,
.liquid-glass-badge-primary {
  background: var(--lg-primary-tint) !important;
  color: var(--lg-primary) !important;
  border-color: var(--lg-primary) !important;
}

/* Brand Button Overrides across existing Tailwind templates */
.bg-primary-600,
.bg-wa-600 {
  background-color: var(--lg-primary) !important;
  color: #ffffff !important;
}

.bg-primary-600:hover,
.bg-wa-600:hover,
.hover\:bg-primary-700:hover,
.hover\:bg-wa-700:hover {
  background-color: var(--lg-primary-hover) !important;
}

.text-primary-600,
.text-wa-400,
.text-wa-600,
.text-emerald-500,
.text-emerald-600 {
  color: var(--lg-primary) !important;
}

.border-primary-500,
.border-primary-600,
.border-wa-500,
.border-emerald-500 {
  border-color: var(--lg-primary) !important;
}

.bg-primary-50,
.bg-emerald-50,
.bg-wa-50,
.bg-wa-500\/20,
.bg-emerald-500\/10,
.bg-emerald-500\/20 {
  background-color: var(--lg-primary-tint) !important;
}

/* ==============================================================================
 * CORE COMPONENT CLASSES
 * ============================================================================== */

/**
 * 1. Liquid Glass Navigation & Command Headers
 */
.liquid-glass-nav {
  background: var(--lg-nav-bg);
  backdrop-filter: var(--lg-blur-nav);
  -webkit-backdrop-filter: var(--lg-blur-nav);
  border: 1px solid var(--lg-border);
  box-shadow: var(--lg-specular-rim), var(--lg-shadow-sm);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/**
 * 2. Liquid Glass Card Containers
 */
.liquid-glass-card {
  background: var(--lg-surface-bg);
  backdrop-filter: var(--lg-blur-card);
  -webkit-backdrop-filter: var(--lg-blur-card);
  border: 1px solid var(--lg-border);
  box-shadow: var(--lg-specular-rim), var(--lg-shadow-xs);
  border-radius: 1rem;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.liquid-glass-card-interactive {
  cursor: pointer;
}

.liquid-glass-card-interactive:hover {
  background: var(--lg-surface-hover);
  border-color: rgba(16, 185, 129, 0.4);
  box-shadow: var(--lg-specular-rim-strong), var(--lg-shadow-md), var(--lg-primary-glow);
  transform: translateY(-1px);
}

/**
 * 3. Liquid Glass Buttons
 */
.liquid-glass-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 0.75rem;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.liquid-glass-btn:active {
  transform: scale(0.98);
}

/* Primary Liquid Button (Emerald Specular) */
.liquid-glass-btn-primary {
  background: linear-gradient(180deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: inset 0 1px 1px 0 rgba(255, 255, 255, 0.55), inset 0 -1px 2px 0 rgba(0, 0, 0, 0.2), var(--lg-shadow-sm);
}

.liquid-glass-btn-primary:hover {
  background: linear-gradient(180deg, #34d399 0%, #10b981 100%);
  box-shadow: inset 0 1px 1.5px 0 rgba(255, 255, 255, 0.75), var(--lg-primary-glow), var(--lg-shadow-md);
  color: #ffffff;
}

/* Secondary Liquid Button (Translucent Chrome) */
.liquid-glass-btn-secondary {
  background: var(--lg-surface-bg);
  backdrop-filter: var(--lg-blur-card);
  -webkit-backdrop-filter: var(--lg-blur-card);
  color: var(--lg-text-primary);
  border: 1px solid var(--lg-border);
  box-shadow: var(--lg-specular-rim), var(--lg-shadow-xs);
}

.liquid-glass-btn-secondary:hover {
  background: var(--lg-surface-hover);
  color: var(--lg-text-primary);
  box-shadow: var(--lg-specular-rim-strong), var(--lg-shadow-sm);
}

/**
 * 4. Liquid Glass Status Badges & Pills
 */
.liquid-glass-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 9999px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--lg-specular-rim);
  border: 1px solid transparent;
  line-height: 1;
}

.liquid-glass-badge-emerald {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
  border-color: rgba(16, 185, 129, 0.35);
}

.dark .liquid-glass-badge-emerald {
  background: rgba(16, 185, 129, 0.20);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.45);
}

.liquid-glass-badge-amber {
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
  border-color: rgba(245, 158, 11, 0.35);
}

.dark .liquid-glass-badge-amber {
  background: rgba(245, 158, 11, 0.20);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.45);
}

.liquid-glass-badge-sky {
  background: rgba(14, 165, 233, 0.12);
  color: #0284c7;
  border-color: rgba(14, 165, 233, 0.35);
}

.dark .liquid-glass-badge-sky {
  background: rgba(14, 165, 233, 0.20);
  color: #38bdf8;
  border-color: rgba(14, 165, 233, 0.45);
}

/**
 * 5. Liquid Glass Form Inputs
 */
.liquid-glass-input {
  background: var(--lg-surface-bg);
  backdrop-filter: var(--lg-blur-card);
  -webkit-backdrop-filter: var(--lg-blur-card);
  border: 1px solid var(--lg-border);
  box-shadow: inset 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  border-radius: 0.75rem;
  color: var(--lg-text-primary);
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  outline: none;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.liquid-glass-input:focus {
  border-color: var(--lg-primary);
  box-shadow: 0 0 0 3px var(--lg-primary-tint), var(--lg-specular-rim);
  background: var(--lg-surface-active);
}

/**
 * 6. Slide-Out Context Drawer
 */
.liquid-glass-drawer {
  background: var(--lg-drawer-bg);
  backdrop-filter: var(--lg-blur-drawer);
  -webkit-backdrop-filter: var(--lg-blur-drawer);
  border-left: 1px solid var(--lg-border);
  box-shadow: -8px 0 32px -4px rgba(0, 0, 0, 0.15), var(--lg-specular-rim);
}

