/* ============================================================
   ROUTE AI — MAIN DESIGN SYSTEM & GLOBAL STYLES
   ============================================================ */

/* --- Design Tokens --- */
:root {
  /* Background stack */
  --bg-base:    #0a0f1d;
  --bg-surface: #111827;
  --bg-raised:  #1f2937;
  --bg-overlay: rgba(17, 24, 39, 0.95);

  /* Glass surfaces */
  --glass:            #1f2937;
  --glass-hover:      #2d3748;
  --glass-active:     #2d3748;
  --glass-strong:     #374151;

  /* Borders */
  --border:       rgba(255, 255, 255, 0.08);
  --border-light: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(37, 99, 235, 0.5);

  /* Brand */
  --primary:        #2563eb;
  --primary-dark:   #1d4ed8;
  --primary-light:  #9ca3af;
  --primary-glow:   rgba(37, 99, 235, 0.12);
  --primary-glow-strong: rgba(37, 99, 235, 0.2);

  --secondary:      #2563eb;
  --secondary-glow: rgba(37, 99, 235, 0.12);

  --accent:         #f59e0b;
  --accent-glow:    rgba(245, 158, 11, 0.22);

  /* Semantic */
  --success:     #10b981;
  --success-bg:  rgba(16, 185, 129, 0.10);
  --success-border: rgba(16, 185, 129, 0.25);

  --warning:     #f59e0b;
  --warning-bg:  rgba(245, 158, 11, 0.10);
  --warning-border: rgba(245, 158, 11, 0.25);

  --danger:      #ef4444;
  --danger-bg:   rgba(239, 68, 68, 0.10);
  --danger-border: rgba(239, 68, 68, 0.25);

  /* Route Colors */
  --route-a:     #2563eb;  /* Fastest — Blue */
  --route-b:     #10b981;  /* Alternative — Green */
  --route-c:     #f59e0b;  /* Eco/Scenic — Amber */

  /* Text */
  --text-1:  #f9fafb;
  --text-2:  #9ca3af;
  --text-3:  #64748b;
  --text-4:  #64748b;

  /* Layout */
  --sidebar-w:  380px;

  /* Radius */
  --r-xs:   4px;
  --r-sm:   6px;
  --r-md:   10px;
  --r-lg:   14px;
  --r-xl:   20px;
  --r-2xl:  28px;
  --r-full: 9999px;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.45);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.45);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.55);
  --shadow-xl:  0 20px 60px rgba(0,0,0,0.65);
  --shadow-primary: 0 4px 16px rgba(0, 0, 0, 0.24);

  /* Easing */
  --ease:        cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out:    cubic-bezier(0, 0, 0.2, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Durations */
  --dur-fast:   120ms;
  --dur-base:   220ms;
  --dur-slow:   380ms;
}

/* --- Reset --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-base);
  color: var(--text-1);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

#slg stop, #esg stop { stop-color: var(--primary); }
.empty-icon circle:first-child { fill: #1e293b; stroke: var(--border); }
.empty-icon circle:nth-of-type(2) { fill: var(--primary); }

button  { cursor: pointer; border: none; background: none; font-family: inherit; color: inherit; }
input   { font-family: inherit; font-size: inherit; color: inherit; }
a       { color: var(--primary-light); text-decoration: none; transition: color var(--dur-fast); }
a:hover { color: var(--primary); text-decoration: underline; }

/* --- App Layout --- */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  position: relative;
}

/* --- Utility --- */
.hidden { display: none !important; }

/* --- Scrollbar --- */
::-webkit-scrollbar        { width: 4px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  { background: var(--border-light); border-radius: var(--r-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-4); }

/* ============================================================
   SETUP MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: var(--bg-base);
}

.modal-bg-glow {
  position: absolute;
  width: 600px;
  height: 600px;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  background: transparent;
  pointer-events: none;
  animation: glowPulse 4s ease-in-out infinite;
}

.modal-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 460px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: modalSlideIn 0.5s var(--ease-bounce) both;
}

/* Modal Header */
.modal-header {
  text-align: center;
  padding: 2.5rem 2rem 1.75rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

.modal-logo-mark {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  filter: none;
  animation: markerBounce 0.8s var(--ease-bounce) 0.2s both;
}

.modal-title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: none;
  color: var(--text-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: currentColor;
  background-clip: text;
}

.modal-subtitle {
  font-size: 0.875rem;
  color: var(--text-2);
  margin-top: 0.375rem;
  line-height: 1.55;
}

.modal-badges {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.625rem;
  border-radius: var(--r-full);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-blue, .badge-purple, .badge-green { background: #1e293b; color: #94a3b8; border: 1px solid var(--border); }

/* Modal Body */
.modal-body {
  padding: 1.75rem 2rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.api-key-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.api-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-1);
}

.api-label-icon { font-size: 1rem; }

.get-key-link {
  margin-left: auto;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--primary-light);
  opacity: 0.75;
  transition: opacity var(--dur-fast);
}

.get-key-link:hover { opacity: 1; text-decoration: underline; }

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.api-input {
  width: 100%;
  padding: 0.75rem 2.75rem 0.75rem 1rem;
  background: var(--glass);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
  color: var(--text-1);
  font-size: 0.875rem;
  outline: none;
  transition: border-color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
}

.api-input::placeholder { color: var(--text-4); }

.api-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.vis-toggle {
  position: absolute;
  right: 0.75rem;
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--dur-fast);
  padding: 0.25rem;
}

.vis-toggle:hover { color: var(--text-2); }
.vis-toggle svg   { width: 16px; height: 16px; }

.modal-note {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.75rem 0.875rem;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 0.775rem;
  color: var(--text-2);
  line-height: 1.55;
}

.note-icon {
  flex-shrink: 0;
  width: 13px;
  height: 13px;
  margin-top: 2px;
  color: var(--primary-light);
}

.modal-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.9rem 1.25rem;
  background: var(--primary);
  background-size: 200% 200%;
  border-radius: var(--r-lg);
  color: white;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: transform var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
  animation: gradientShift 4s ease infinite;
}

.modal-cta:hover {
  transform: translateY(-2px);
  background: var(--primary-dark);
  box-shadow: var(--shadow-md);
}

.modal-cta:active { transform: translateY(0); }

.setup-error {
  text-align: center;
  font-size: 0.8125rem;
  color: var(--danger);
  padding: 0.5rem;
  border-radius: var(--r-sm);
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  animation: fadeIn 0.2s;
}

/* ============================================================
   SHARED COMPONENTS
   ============================================================ */

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  background: var(--glass);
  border: 1px solid var(--border);
  color: var(--text-2);
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast);
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--glass-hover);
  border-color: var(--border-light);
  color: var(--text-1);
}

.section-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-3);
  margin-bottom: 0.625rem;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
  max-width: 340px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.75rem 1rem;
  background: var(--bg-raised);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  font-size: 0.8125rem;
  line-height: 1.45;
  pointer-events: all;
  animation: toastIn 0.3s var(--ease) both;
  color: var(--text-1);
}

.toast.removing { animation: toastOut 0.3s var(--ease) both; }

.toast-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.toast-msg  { flex: 1; }

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--primary); }
.toast.warning { border-left: 3px solid var(--warning); }

/* ============================================================
   LOADING OVERLAY
   ============================================================ */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 15, 29, 0.82);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.2s;
}

.loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  padding: 2rem 2.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
}

.loading-rings {
  position: relative;
  width: 56px;
  height: 56px;
}

.ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid transparent;
}

.ring1 { border-top-color: var(--primary);    animation: spin 1.0s linear infinite; }
.ring2 { border-top-color: var(--secondary);  animation: spin 1.4s linear infinite reverse; inset: 6px; }
.ring3 { border-top-color: var(--accent);     animation: spin 1.8s linear infinite;           inset: 12px; border-width: 2px; }

.loading-text {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-2);
  text-align: center;
}

/* ============================================================
   PICK MODE BANNER
   ============================================================ */
.pick-mode-banner {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  animation: chipSlideUp 0.3s var(--ease-bounce) both;
}

.pick-mode-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.625rem 1.25rem;
  background: var(--bg-raised);
  border: 1px solid var(--border-light);
  border-radius: var(--r-full);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  color: var(--text-1);
  white-space: nowrap;
}

.pick-cancel-btn {
  padding: 0.25rem 0.75rem;
  background: var(--glass-hover);
  border: 1px solid var(--border-light);
  border-radius: var(--r-full);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-2);
  transition: all var(--dur-fast);
}

.pick-cancel-btn:hover {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger);
}
