/* ══════════════════════════════════════════════════════════
   main.css — FIFA 2026 Stadium Hub Design System
   Updated: Warm off-white surface, pitch green/coral accent
══════════════════════════════════════════════════════════ */

:root {
  /* Core Palette (World Stage Theme) */
  --color-bg-base:      #F9F6EE; /* Cream */
  --color-bg-surface:   #EAE6DC; /* Chalk */
  --color-bg-alt:       #dcd7cc;
  --color-header-bg:    #0D1F17; /* Deep stadium night */
  
  --color-text-main:    #17211D;
  --color-text-muted:   #647067;
  --color-text-dim:     #8b968e;
  --color-text-inv:     #ffffff;

  /* Accents */
  --color-pitch-green:  #0D1F17; /* Pitch */
  --color-field-green:  #1A3D2B; /* Field */
  --color-coral:        #E8531A; /* Ember / Alert */
  --color-gold:         #F5C518; /* Gold / Premium */
  --color-ai-teal:      #7ED56F; /* Lime / AI */
  --color-sky:          #C8E6FF; /* Transport / Info */
  
  /* Semantic */
  --color-error:        #E8531A;
  --color-success:      #7ED56F;

  /* Typography */
  --font-display:       'Bebas Neue', sans-serif;
  --font-body:          'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono:          'JetBrains Mono', monospace;
  
  /* Spacing */
  --sp-xs: 4px; --sp-sm: 8px; --sp-md: 16px; --sp-lg: 24px; --sp-xl: 32px;

  /* Borders & Shadows */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-pill: 9999px;
  
  --shadow-flat: 0 4px 0 rgba(13, 31, 23, 0.05);
  --shadow-card: 0 4px 24px rgba(13, 31, 23, 0.07);
  --glass-blur: blur(16px);
}

/* ─── Command Center (Dark Mode) ───────────────────────── */
[data-theme="dark"] {
  --color-bg-base:      #0A1810; /* Pure deep green-black */
  --color-bg-surface:   #122A1C; /* Slightly lighter for cards */
  --color-bg-alt:       #1A3D2B;
  --color-header-bg:    #050C08;
  --color-text-main:    #F9F6EE;
  --color-text-muted:   #a5b3ab;
  --color-text-dim:     #7a8780;
  --color-text-inv:     #17211D;
  --shadow-flat:        0 4px 0 rgba(0,0,0,0.4);
  --shadow-card:        0 8px 32px rgba(0,0,0,0.5);
  --color-pitch-green:  #7ED56F; /* Lime readable against dark surface */
}

/* ─── High Contrast Mode ───────────────────────────────── */
[data-contrast="high"] {
  --color-bg-base:      #ffffff;
  --color-bg-surface:   #ffffff;
  --color-text-main:    #000000;
  --color-text-muted:   #1a1a1a;
  --color-text-dim:     #333333;
  --color-pitch-green:  #005a00;
  --color-coral:        #b30000;
  --shadow-flat:        0 4px 0 rgba(0,0,0,0.2);
}
[data-contrast="high"] .card-flat,
[data-contrast="high"] .card-glass { border: 2px solid #000 !important; }
[data-contrast="high"] .tab-btn.active { outline: 3px solid #005a00; }

/* ─── Large Text Mode ──────────────────────────────────── */
[data-large-text="true"] { font-size: 112% !important; }
[data-large-text="true"] .section-title { font-size: 2.4rem; }
[data-large-text="true"] .message-bubble { font-size: 1.08rem; }

/* ─── Base ────────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { direction: ltr; } /* Always LTR layout — RTL applies to text only */
html {
  background-color: #14171c; /* Match footer bottom for overscroll */
}
body {
  font-family: var(--font-body);
  background-color: var(--color-bg-base);
  color: var(--color-text-main);
  line-height: 1.5;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s, color 0.3s;
}
h1, h2, h3, .logo-title, .section-title {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.1;
}

/* RTL text support: only text content flips, not layout */
[dir="rtl"] [data-i18n],
[dir="rtl"] .message-bubble,
[dir="rtl"] .chat-title,
[dir="rtl"] .section-title,
[dir="rtl"] p,
[dir="rtl"] label,
[dir="rtl"] .form-hint,
[dir="rtl"] .logo-sub {
  direction: rtl;
  text-align: right;
}
/* Keep all layout containers LTR regardless */
.app-header, .tab-nav, .main-content, .app-footer,
.grid-2, .grid-3, .card-flat, .card-glass, .chat-container,
.chat-input-area, .message, .modal-box, .modal-overlay,
.header-inner, .footer-inner, .chat-messages, .quick-prompts,
#floating-chat-container, #floating-chat-panel,
.toast-container, .lang-dropdown, .heatmap-wrapper {
  direction: ltr !important;
}

/* ─── Header ──────────────────────────────────────────── */
.app-header {
  background: var(--color-header-bg);
  color: var(--color-text-inv);
  padding: var(--sp-md) var(--sp-lg);
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 2px solid var(--color-gold);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-md);
}
.logo-block { display: flex; align-items: center; gap: 12px; }
.logo-icon { font-size: 1.8rem; }
.logo-title { font-size: 1.8rem; letter-spacing: 0.05em; color: var(--color-gold); }
.logo-sub { font-size: 0.75rem; color: #a1a5ab; text-transform: uppercase; letter-spacing: 0.05em; font-family: var(--font-body); }
.header-actions { display: flex; gap: var(--sp-md); align-items: center; }

/* ─── Tabs ────────────────────────────────────────────── */
.tab-nav {
  display: flex;
  gap: var(--sp-md);
  padding: 0 var(--sp-lg);
  background-color: var(--color-header-bg); /* Match header for seamless look */
  border-bottom: 1px solid rgba(255,255,255,0.1);
  overflow-x: auto;
  position: relative;
  scrollbar-width: none; /* Hide scrollbar Firefox */
}
.tab-nav::-webkit-scrollbar { display: none; }
.tab-btn {
  background: none;
  border: none;
  color: #a1a5ab;
  padding: var(--sp-md) var(--sp-md);
  font-size: 1rem;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  transition: all 0.2s;
  white-space: nowrap;
  border-radius: var(--radius-pill);
}
.tab-btn:hover { color: var(--color-text-inv); background: rgba(255,255,255,0.05); }
.tab-btn.active { color: var(--color-pitch-green); background: var(--color-gold); }

/* Sliding Indicator (Hidden now in favor of pill background) */
.tab-indicator { display: none; }
.tab-icon svg { opacity: 0.8; transition: opacity 0.2s; }
.tab-btn.active .tab-icon svg { opacity: 1; stroke: var(--color-pitch-green); }

/* ─── Main Content & Panels ───────────────────────────── */
.main-content {
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  padding: var(--sp-xl) var(--sp-lg);
}
.tab-panel {
  display: none;
  /* GSAP controls entrance — CSS just ensures hidden state */
}
.tab-panel.active {
  display: block;
  /* Scale+fade+blur entrance driven by GSAP in app.js */
}
/* Fallback for no-GSAP environments */
@keyframes fadeSlide {
  from { opacity: 0; transform: scale(0.97); filter: blur(4px); }
  to   { opacity: 1; transform: scale(1);    filter: blur(0px); }
}
.tab-panel.entering-fallback { animation: fadeSlide 0.22s ease-out forwards; }

.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 2rem;
  margin-bottom: var(--sp-xl);
  color: var(--color-text-main);
}
.section-title-icon { font-size: 2rem; }
.text-accent  { color: var(--color-pitch-green); }
.text-gold    { color: var(--color-gold); }
.text-ai-teal { color: var(--color-ai-teal); }

/* ─── Layout Grids ────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-xl); align-items: start; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--sp-lg); }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ─── Cards (Flat vs Frosted) ─────────────────────────── */
/* Flat data cards (zone lists, tables) */
.card-flat {
  background: var(--color-bg-surface);
  border: 1px solid rgba(20, 23, 28, 0.08);
  border-radius: var(--radius-md);
  padding: var(--sp-lg);
  box-shadow: var(--shadow-flat);
}
/* Glass AI surfaces — teal identity distinguishes AI layer from data layer */
.card-glass {
  background: rgba(126, 213, 111, 0.05); /* lime tint */
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(126, 213, 111, 0.15);
  border-top: 3px solid var(--color-ai-teal);
  border-radius: var(--radius-lg);
  padding: var(--sp-lg);
  box-shadow: 0 8px 32px rgba(126, 213, 111, 0.05);
}
[data-theme="dark"] .card-glass {
  background: rgba(126, 213, 111, 0.05);
  border-color: rgba(126, 213, 111, 0.1);
  border-top-color: var(--color-ai-teal);
}

/* ─── Chat System ─────────────────────────────────────── */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 550px;
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.chat-header {
  padding: var(--sp-md);
  border-bottom: 1px solid rgba(126, 213, 111, 0.15);
  background: linear-gradient(180deg, rgba(126, 213, 111, 0.08) 0%, transparent 100%);
}
.chat-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ai-badge {
  font-family: var(--font-body);
  font-size: 0.65rem;
  background: var(--color-ai-teal);
  color: #17211D;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
  letter-spacing: 0.05em;
  animation: badgePulse 2s infinite;
}
@keyframes badgePulse {
  0% { box-shadow: 0 0 0 0 rgba(126, 213, 111, 0.4); }
  70% { box-shadow: 0 0 0 4px rgba(126, 213, 111, 0); }
  100% { box-shadow: 0 0 0 0 rgba(126, 213, 111, 0); }
}
.chat-messages {
  flex: 1;
  padding: var(--sp-md);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
}
.message { display: flex; gap: 12px; max-width: 85%; }
.message.user { align-self: flex-end; flex-direction: row-reverse; }
.message.bot { align-self: flex-start; }
.message.system { align-self: center; max-width: 100%; color: var(--color-error); font-size: 0.9rem; }

.message-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--color-bg-alt);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.bot-avatar {
  background: var(--color-pitch-green);
  color: var(--color-gold);
  font-weight: 700;
  font-size: 0.7rem;
  position: relative;
}
.bot-avatar::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(126,213,111,0.4), transparent);
  animation: avatarPulse 3s ease-in-out infinite;
}
.ai-dot { width: 6px; height: 6px; background: var(--color-gold); border-radius: 50%; display: inline-block; margin-right: 3px; animation: dotBlink 2s ease-in-out infinite; }

.message-bubble {
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  line-height: 1.6;
  box-shadow: 0 3px 12px rgba(0,0,0,0.05);
  transition: box-shadow 0.25s, opacity 0.25s;
}
/* AI message settle animation — soft lime glow pulse on new bot bubble */
.message.bot .message-bubble.settling {
  animation: aiSettle 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes aiSettle {
  0%   { box-shadow: 0 0 0 0 rgba(126,213,111,0.5); transform: scale(0.98); }
  50%  { box-shadow: 0 0 0 8px rgba(126,213,111,0.15); transform: scale(1.01); }
  100% { box-shadow: 0 3px 12px rgba(0,0,0,0.05); transform: scale(1); }
}
.user .message-bubble {
  background: var(--color-gold);
  color: #17211D;
  border-top-right-radius: 4px;
}
.bot .message-bubble {
  background: var(--color-bg-surface);
  border: 1px solid rgba(126, 213, 111, 0.2);
  border-top-left-radius: 4px;
  border-left: 3px solid var(--color-ai-teal);
}
[data-theme="dark"] .bot .message-bubble { background: var(--color-bg-alt); }

.message-meta { font-size: 0.7rem; color: var(--color-text-dim); margin-top: 4px; }
.user .message-meta { text-align: right; }

/* Input area */
.chat-input-area {
  padding: var(--sp-md);
  background: transparent;
  border-top: 1px solid rgba(20, 23, 28, 0.08);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  background: var(--color-bg-surface);
  border: 1px solid rgba(20, 23, 28, 0.15);
  border-radius: var(--radius-pill);
  padding: 12px 20px;
  color: var(--color-text-main);
  font-family: inherit;
  font-size: 0.95rem;
  resize: none;
  min-height: 46px;
  max-height: 150px;
  transition: border-color 0.2s;
}
.chat-input:focus { outline: none; border-color: var(--color-ai-teal); box-shadow: 0 0 0 2px rgba(126, 213, 111, 0.2); }
.btn-send {
  background: var(--color-gold);
  color: #17211D;
  border: none;
  border-radius: 50%;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  flex-shrink: 0;
}
.btn-send:hover {
  background: #d6b36e;
  transform: scale(1.1) rotate(-5deg);
  box-shadow: 0 4px 12px rgba(198, 161, 91, 0.4);
}
.btn-send:active { transform: scale(0.95); }

/* Quick prompts */
.quick-prompts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: var(--sp-sm); }
.quick-prompt-btn {
  background: rgba(126, 213, 111, 0.1);
  border: 1px solid rgba(126, 213, 111, 0.25);
  color: var(--color-ai-teal);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
}
.quick-prompt-btn:hover {
  background: rgba(126, 213, 111, 0.2);
  color: var(--color-ai-teal);
  border-color: var(--color-ai-teal);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(126, 213, 111, 0.2);
}

/* Explain Simply Toggle */
.explain-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}
.toggle-switch {
  width: 32px; height: 18px;
  background: #ccc;
  border-radius: var(--radius-pill);
  position: relative;
  transition: background 0.2s;
}
.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle-switch.on { background: var(--color-field-green); }
.toggle-switch.on::after { transform: translateX(14px); }

/* ─── Buttons & Inputs ────────────────────────────────── */
.btn {
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  font-family: var(--font-body);
}
.btn-primary { background: var(--color-gold); color: #17211D; }
.btn-primary:hover { background: #d6b36e; }
.btn-ghost { background: transparent; color: inherit; border: 1px solid rgba(255,255,255,0.2); }
.btn-ghost:hover { background: rgba(255,255,255,0.1); }

/* Language switcher dropdown */
.lang-switcher { position: relative; }
.lang-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--color-header-bg);
  border-radius: var(--radius-md);
  box-shadow: 0 20px 60px rgba(0,0,0,0.4), 0 0 0 1px rgba(245, 197, 24, 0.3);
  padding: 8px;
  min-width: 180px;
  display: none;
  flex-direction: column;
  gap: 2px;
  z-index: 200;
  border: 1px solid rgba(245, 197, 24, 0.2);
  max-height: 0;
  overflow: hidden;
  opacity: 0;
}
.lang-dropdown.open {
  display: flex;
  max-height: 400px;
  opacity: 1;
  animation: dropdownIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.lang-dropdown-item {
  padding: 10px 14px;
  background: transparent;
  border: none;
  border-radius: 8px;
  text-align: left;
  display: flex;
  gap: 10px;
  align-items: center;
  cursor: pointer;
  color: #c8cdd6;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.18s ease;
  border-left: 3px solid transparent;
}
.lang-dropdown-item:hover {
  background: rgba(245, 197, 24, 0.15);
  border-left-color: var(--color-gold);
  color: #fff;
  padding-left: 18px;
}
.lang-dropdown-item .lang-flag-text { flex: 1; }

/* ─── Rate Badge ──────────────────────────────────────── */
.rate-badge {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--radius-pill);
  background: rgba(255,255,255,0.1); font-size: 0.75rem;
  border: 1px solid rgba(255,255,255,0.2);
}
.rate-badge .dot { width: 6px; height: 6px; border-radius: 50%; background: #00e676; }
.rate-badge.warning .dot { background: #ff9100; }
.rate-badge.danger .dot { background: #ff5252; }
.rate-badge.danger { color: #ff5252; border-color: #ff5252; }

/* ─── Settings Modal ──────────────────────────────────── */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(20, 23, 28, 0.6);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal-box {
  background: var(--color-bg-surface);
  border-radius: var(--radius-lg);
  padding: var(--sp-lg);
  width: 90%; max-width: 500px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.15);
  transform: translateY(20px); transition: transform 0.3s;
}
.modal-overlay.open .modal-box { transform: translateY(0); }
.modal-title { font-family: var(--font-display); font-size: 1.5rem; margin-bottom: var(--sp-md); display: flex; align-items: center; gap: 8px; }

.form-group { margin-bottom: var(--sp-md); }
.form-label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 0.9rem; }
.form-input {
  width: 100%; padding: 10px 14px;
  border: 1px solid rgba(20,23,28,0.2); border-radius: var(--radius-sm);
  background: var(--color-bg-base); font-family: monospace; font-size: 0.95rem;
}
.form-input:focus { outline: none; border-color: var(--color-pitch-green); }
.form-hint { font-size: 0.8rem; color: var(--color-text-dim); margin-top: 6px; line-height: 1.4; }
.visibility-btn {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 1rem; opacity: 0.7;
}

/* ─── Footer ──────────────────────────────────────────── */
.app-footer {
  background: linear-gradient(135deg, #0e1117 0%, #14171c 100%);
  color: #7a8190;
  padding: var(--sp-lg) var(--sp-lg) var(--sp-md);
  margin-top: auto;
  border-top: 2px solid transparent;
  background-clip: padding-box;
  position: relative;
  font-size: 0.85rem;
}
.app-footer::before {
  content: '';
  position: absolute;
  top: -2px; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--color-pitch-green), var(--color-coral), var(--color-gold));
}
.footer-inner {
  max-width: 1400px; margin: 0 auto;
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: var(--sp-md);
}
.footer-stats {
  display: flex; gap: 12px; flex-wrap: wrap; margin: var(--sp-sm) auto;
  justify-content: center;
}
.footer-stat-pill {
  background: rgba(45,92,52,0.15);
  border: 1px solid rgba(45,92,52,0.25);
  color: #9be3a8;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.footer-bottom {
  text-align: center;
  margin-top: var(--sp-sm);
  font-size: 0.75rem;
  color: #4a515c;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: var(--sp-sm);
}
.footer-left strong { color: #e0e4ea; }
.footer-credits-note { font-style: italic; margin-top: 4px; }
.footer-right { display: flex; gap: var(--sp-md); align-items: center; }
.footer-right a, .btn-link { color: inherit; text-decoration: none; cursor: pointer; border: none; background: none; }
.footer-right a:hover, .btn-link:hover { color: var(--color-text-inv); }

/* ─── Alerts ──────────────────────────────────────────── */
.no-key-banner {
  background: #fff3e0; color: #e65100;
  padding: 12px 16px; border-radius: var(--radius-md); border-left: 4px solid #ff9800;
  margin-bottom: var(--sp-lg); display: flex; align-items: center; gap: 12px;
}
.no-key-banner.hidden { display: none; }
.inline-btn-link { background: none; border: none; color: inherit; text-decoration: underline; font-weight: bold; cursor: pointer; }

/* ─── Custom Select Dropdowns ──────────────────────────── */
/* Remove native appearance, apply FIFA design system treatment */
.stadium-select, select.custom-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--color-bg-surface);
  border: 1.5px solid rgba(20,23,28,0.15);
  border-radius: var(--radius-sm);
  padding: 10px 40px 10px 14px;
  font-size: 0.9rem;
  font-family: var(--font-body);
  color: var(--color-text-main);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  /* Custom chevron using CSS — avoids SVG data-URI encoding issues */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2317211D' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  width: 100%;
}
.stadium-select:focus, select.custom-select:focus {
  outline: none;
  border-color: var(--color-ai-teal);
  box-shadow: 0 0 0 3px rgba(126, 213, 111, 0.15);
}
[data-theme="dark"] .stadium-select, [data-theme="dark"] select.custom-select {
  background-color: var(--color-bg-alt);
  color: var(--color-text-main);
  border-color: rgba(126, 213, 111, 0.2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237ED56F' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
}
.divider { height: 1px; background: rgba(20,23,28,0.1); margin: var(--sp-lg) 0; }
[data-tooltip] { position: relative; }
[data-tooltip]:hover::after {
  content: attr(data-tooltip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  background: #14171c; color: white; padding: 4px 8px; border-radius: 4px; font-size: 0.75rem; white-space: nowrap; pointer-events: none;
}

/* ─── Stats & Missing Classes ─────────────────────────── */
.stat-card {
  background: var(--color-bg-surface);
  border: 1px solid rgba(20, 23, 28, 0.08);
  border-radius: var(--radius-md);
  padding: var(--sp-md);
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-flat);
}
.stat-icon { font-size: 1.5rem; }
.stat-label { font-size: 0.75rem; color: var(--color-text-dim); text-transform: uppercase; font-weight: 600; }
.stat-value { font-weight: 700; color: var(--color-text-main); }
/* Replaced generic hover-lift with settle-in micro-interaction */
.hover-lift { transition: box-shadow 0.25s ease; }
.hover-lift:hover { box-shadow: 0 8px 24px rgba(40,124,124,0.12); }

.lang-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; }
.lang-btn { display: flex; align-items: center; gap: 8px; }
.lang-flag { font-size: 1.1rem; }

/* ─── Floating Chat ───────────────────────────────────── */
#floating-chat-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
/* Floating chat — AI Teal identity */
#floating-chat-btn {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: var(--color-ai-teal);
  color: #17211D;
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(126, 213, 111, 0.45), 0 0 0 0 rgba(126, 213, 111, 0.3);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s;
  position: relative;
}
#floating-chat-btn::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(126, 213, 111, 0.35);
  animation: ringBreath 3s ease-in-out infinite;
}
#floating-chat-btn:hover {
  transform: scale(1.12) rotate(-6deg);
  box-shadow: 0 12px 40px rgba(126, 213, 111, 0.65), 0 0 50px rgba(126, 213, 111, 0.2);
}
#floating-chat-btn.pulse { animation: floatBtnGlow 2.5s ease-in-out infinite; }
@keyframes floatBtnGlow {
  0%, 100% { box-shadow: 0 8px 32px rgba(126, 213, 111, 0.45), 0 0 0 0 rgba(126, 213, 111, 0); }
  50%       { box-shadow: 0 12px 48px rgba(126, 213, 111, 0.7), 0 0 0 16px rgba(126, 213, 111, 0); }
}
@keyframes ringBreath {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50%       { transform: scale(1.18); opacity: 0; }
}
#floating-chat-panel {
  width: 360px;
  height: 480px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  /* Corner-anchor entrance — GSAP animates from bottom-right */
  transform-origin: bottom right;
  padding: 0;
  overflow: hidden;
  /* Teal identity for the AI surface */
  border-top-color: var(--color-ai-teal);
}
#floating-chat-panel.hide { opacity: 0; transform: scale(0.6); pointer-events: none; display: none; }
@media (max-width: 600px) {
  #floating-chat-container { bottom: 16px; right: 16px; left: 16px; }
  #floating-chat-panel { width: 100%; height: 60vh; margin-bottom: 16px; }
}

/* ─── A11y & Sustainability Cards ──────────────────────── */
.a11y-card, .waste-card {
  background: var(--color-bg-surface);
  border: 1px solid rgba(20,23,28,0.08);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
}
.a11y-card:hover, .waste-card:hover {
  transform: translateY(-5px) scale(1.01);
  box-shadow: 0 12px 28px rgba(20,23,28,0.1);
}
.a11y-card .icon, .waste-card .icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}

/* Accessibility toggle rows */
.a11y-toggle {
  padding: 14px 16px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--color-bg-base);
  border: 1px solid rgba(20,23,28,0.07);
  transition: background 0.2s, box-shadow 0.2s;
}
.a11y-toggle:hover {
  background: rgba(126, 213, 111, 0.05);
  box-shadow: 0 4px 14px rgba(126, 213, 111, 0.1);
}
.a11y-toggle[aria-checked="true"] {
  background: rgba(126, 213, 111, 0.08);
  border-color: rgba(126, 213, 111, 0.25);
}

/* keep the app shell always LTR regardless of content language */
.app-shell, .nav-tabs, .header-bar { direction: ltr !important; }

/* ─── Global Toasts ────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}
.toast {
  background: var(--color-bg-surface);
  border-left: 4px solid var(--color-accent);
  padding: 16px;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  width: 320px;
  transform: translateX(120%);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: auto;
  color: var(--color-text);
}
.toast.show { transform: translateX(0); }
.toast-critical { border-left-color: var(--color-error); }
.toast-success { border-left-color: var(--color-pitch-green); }

/* ─── Reasoning Trace ──────────────────────────────────────── */
.reasoning-trace {
  margin-top: 12px;
  font-size: 0.75rem;
  background: rgba(0,0,0,0.03);
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.05);
  overflow: hidden;
}
.reasoning-trace summary {
  padding: 8px 10px;
  font-weight: 600;
  color: var(--color-text-dim);
  cursor: pointer;
  user-select: none;
  list-style: none; /* Hide default arrow in webkit */
}
.reasoning-trace summary::-webkit-details-marker { display: none; }
.reasoning-trace summary::before {
  content: '▶';
  display: inline-block;
  margin-right: 6px;
  font-size: 0.6rem;
  transition: transform 0.2s;
}
.reasoning-trace[open] summary::before { transform: rotate(90deg); }
.reasoning-trace .trace-content {
  padding: 0 10px 10px;
  color: var(--color-text-muted);
}
.reasoning-trace ul {
  margin: 0; padding-left: 20px;
}
.reasoning-trace li {
  margin-bottom: 4px;
}

/* ─── Alert Banners ─────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  line-height: 1.5;
  border-left: 4px solid;
}
.alert-success {
  background: rgba(45, 92, 52, 0.1);
  border-left-color: var(--color-pitch-green);
  color: var(--color-pitch-green);
  font-weight: 600;
}
.alert-warning {
  background: rgba(201, 162, 39, 0.1);
  border-left-color: var(--color-gold);
  color: #7a5f10;
}
.alert-error {
  background: rgba(217, 93, 57, 0.1);
  border-left-color: var(--color-coral);
  color: var(--color-coral);
}

/* ─── WebGL / Canvas Particle Background ────────────────────── */
#webgl-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
}
.app-header, .tab-nav, .main-content, .app-footer {
  position: relative;
  z-index: 1;
}

/* ─── Dark Mode Card Adjustments ────────────────────────────── */
[data-theme="dark"] .card-flat {
  background: var(--color-bg-surface);
  border-color: rgba(111,207,151,0.08);
}
/* card-glass dark already handled inline above */
[data-theme="dark"] .tab-btn.active { color: var(--color-gold); }
[data-theme="dark"] .tab-indicator { background: linear-gradient(90deg, var(--color-gold), #6FCF97); }
[data-theme="dark"] .no-key-banner {
  background: rgba(201,162,39,0.1);
  color: #e8c040;
  border-left-color: var(--color-gold);
}
[data-theme="dark"] .alert-success {
  background: rgba(45,92,52,0.2);
  color: #7fd490;
}
[data-theme="dark"] .app-header {
  background: linear-gradient(135deg, #090c11 0%, #0d1118 100%);
}
[data-theme="dark"] .tab-nav {
  background: #090c11;
}
[data-theme="dark"] .chat-input {
  background: var(--color-bg-alt);
  border-color: rgba(255,255,255,0.1);
  color: var(--color-text-main);
}
[data-theme="dark"] .modal-box {
  background: var(--color-bg-surface);
}
[data-theme="dark"] .stadium-select {
  background-color: var(--color-bg-alt);
  color: var(--color-text-main);
  border-color: rgba(255,255,255,0.1);
}
[data-theme="dark"] .lang-dropdown {
  background: linear-gradient(145deg, #1a1f2b, #0e1117);
}
[data-theme="dark"] .quick-prompt-btn {
  background: rgba(40,124,124,0.15);
  border-color: rgba(40,124,124,0.3);
  color: #6FCF97;
}

/* ─── Heatmap / Map Legend Fix ──────────────────────────────── */
.heatmap-wrapper { overflow: hidden; }
.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  padding: 8px;
  background: rgba(255,255,255,0.85);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
}
[data-theme="dark"] .map-legend { background: rgba(26,31,43,0.9); }
.map-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

/* ─── Input sanity / Select security  ───────────────────────── */
/* autocomplete="off" is set directly on HTML elements. */
