/* ============================================================================
   Driver Smart Flex — Design System v2
   Sophisticated dark UI · warm amber accent · 8pt grid · Inter type
   ============================================================================ */

:root {
  /* Color — backgrounds */
  --bg:           #0a0c12;
  --surface-1:    #11141c;
  --surface-2:    #181c26;
  --surface-3:    #1f2330;
  --elevated:     #2a2f3d;

  /* Color — text */
  --ink:          #f4f6fa;
  --ink-soft:     #c9cdd6;
  --muted:        #8b919d;
  --dim:          #5a5f6a;

  /* Color — borders */
  --border:        rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.11);
  --border-focus:  rgba(245, 158, 11, 0.45);

  /* Color — semantic */
  --primary:       #10b981;
  --primary-hover: #34d399;
  --primary-soft:  rgba(16, 185, 129, 0.12);
  --primary-line:  rgba(16, 185, 129, 0.32);

  --accent:        #f59e0b;
  --accent-hover:  #fbbf24;
  --accent-soft:   rgba(245, 158, 11, 0.12);
  --accent-line:   rgba(245, 158, 11, 0.34);

  --danger:        #ef4444;
  --danger-hover:  #f87171;
  --danger-soft:   rgba(239, 68, 68, 0.12);
  --danger-line:   rgba(239, 68, 68, 0.32);

  --skip:          #eab308;
  --skip-soft:     rgba(234, 179, 8, 0.12);
  --skip-line:     rgba(234, 179, 8, 0.32);

  /* Type scale */
  --text-micro:    11px;
  --text-tiny:     12px;
  --text-sm:       13px;
  --text-base:     15px;
  --text-md:       17px;
  --text-lg:       20px;
  --text-xl:       24px;
  --text-2xl:      32px;
  --text-3xl:      44px;
  --text-display:  64px;

  /* Radius */
  --r-xs: 4px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-pill: 999px;

  /* Spacing — 8pt grid */
  --s-1: 4px;   --s-2: 8px;   --s-3: 12px;  --s-4: 16px;
  --s-5: 20px;  --s-6: 24px;  --s-8: 32px;  --s-10: 40px;
  --s-12: 48px; --s-16: 64px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.35);
  --shadow:    0 4px 16px rgba(0,0,0,0.35), 0 1px 3px rgba(0,0,0,0.45);
  --shadow-lg: 0 24px 48px rgba(0,0,0,0.45), 0 12px 24px rgba(0,0,0,0.35);

  /* Motion */
  --ease:     cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in:  cubic-bezier(0.4, 0, 0.6, 1);
  --t-snap:   120ms ease-out;
  --t-normal: 200ms var(--ease);
  --t-slow:   400ms var(--ease);
}

/* ────────────────────────── Reset ────────────────────────── */

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

html, body { height: 100%; }

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: var(--text-base);
  font-weight: 400;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
}

button { font: inherit; color: inherit; cursor: pointer; background: none; border: none; }
input, select, textarea { font: inherit; color: inherit; }
input, button, select, textarea { outline: none; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
img, svg { display: block; max-width: 100%; }

::selection { background: var(--accent-soft); color: var(--ink); }

/* Focus ring — accesibilidad sin sacrificar diseño */
:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* Scrollbar — fina, integrada */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--elevated); background-clip: padding-box; }

/* ────────────────────────── Typography utilities ────────────────────────── */

.h-display { font-size: var(--text-display); font-weight: 800; letter-spacing: -0.04em; line-height: 1; }
.h-1       { font-size: var(--text-3xl);     font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; }
.h-2       { font-size: var(--text-2xl);     font-weight: 700; letter-spacing: -0.025em; line-height: 1.15; }
.h-3       { font-size: var(--text-xl);      font-weight: 700; letter-spacing: -0.02em; line-height: 1.25; }
.h-4       { font-size: var(--text-lg);      font-weight: 700; letter-spacing: -0.015em; line-height: 1.3; }
.text-md   { font-size: var(--text-md); }
.text-base { font-size: var(--text-base); }
.text-sm   { font-size: var(--text-sm); }
.text-tiny { font-size: var(--text-tiny); }
.text-micro{ font-size: var(--text-micro); }

.muted     { color: var(--muted); }
.dim       { color: var(--dim); }
.ink-soft  { color: var(--ink-soft); }
.tnum      { font-variant-numeric: tabular-nums; }
.eyebrow   { font-size: var(--text-micro); text-transform: uppercase; letter-spacing: 0.14em; font-weight: 700; color: var(--dim); }

/* ────────────────────────── Buttons ────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: 40px; padding: 0 var(--s-4);
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  font-size: var(--text-sm); font-weight: 600; line-height: 1;
  cursor: pointer; user-select: none; white-space: nowrap;
  transition: background var(--t-snap), border-color var(--t-snap), color var(--t-snap), transform var(--t-snap);
}
.btn:hover:not(:disabled)  { background: var(--elevated); border-color: rgba(255,255,255,0.14); }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled              { opacity: 0.42; cursor: not-allowed; }

.btn--primary {
  background: var(--primary); color: #052e1a;
  border-color: transparent;
}
.btn--primary:hover:not(:disabled) { background: var(--primary-hover); border-color: transparent; }

.btn--accent {
  background: var(--accent); color: #1a0e00;
  border-color: transparent;
}
.btn--accent:hover:not(:disabled) { background: var(--accent-hover); border-color: transparent; }

.btn--ghost { background: transparent; }
.btn--ghost:hover:not(:disabled) { background: var(--surface-2); }

.btn--danger {
  color: var(--danger-hover); border-color: var(--danger-line);
  background: var(--danger-soft);
}
.btn--danger:hover:not(:disabled) { background: rgba(239,68,68,0.20); border-color: rgba(239,68,68,0.45); }

.btn--block { width: 100%; }
.btn--lg    { height: 48px; padding: 0 var(--s-5); font-size: var(--text-base); }
.btn--xl    { height: 56px; padding: 0 var(--s-6); font-size: var(--text-md); }

.btn .icon { width: 16px; height: 16px; flex-shrink: 0; }
.btn--lg .icon { width: 18px; height: 18px; }
.btn--xl .icon { width: 20px; height: 20px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  background: var(--surface-2); color: var(--ink-soft);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  cursor: pointer; transition: background var(--t-snap), color var(--t-snap), border-color var(--t-snap);
}
.icon-btn:hover { background: var(--elevated); color: var(--ink); border-color: rgba(255,255,255,0.14); }
.icon-btn .icon { width: 18px; height: 18px; }

/* ────────────────────────── Cards / panels ────────────────────────── */

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.card--raised { background: var(--surface-2); box-shadow: var(--shadow-sm); }

/* ────────────────────────── Inputs ────────────────────────── */

.input {
  display: flex; align-items: center; gap: var(--s-3);
  height: 44px; padding: 0 var(--s-4);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  transition: border-color var(--t-snap), box-shadow var(--t-snap), background var(--t-snap);
}
.input:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--surface-1);
}
.input input, .input textarea {
  flex: 1; min-width: 0;
  background: transparent; border: none; outline: none;
  color: var(--ink); font-size: var(--text-base);
}
.input input::placeholder, .input textarea::placeholder { color: var(--dim); }
.input .icon { width: 18px; height: 18px; color: var(--dim); flex-shrink: 0; }

.field { display: grid; gap: var(--s-2); }
.field__label {
  font-size: var(--text-micro); text-transform: uppercase; letter-spacing: 0.10em;
  font-weight: 700; color: var(--dim);
}

/* ────────────────────────── Chips / badges ────────────────────────── */

.chip {
  display: inline-flex; align-items: center; gap: var(--s-1);
  height: 24px; padding: 0 var(--s-3);
  font-size: var(--text-tiny); font-weight: 600; line-height: 1;
  background: var(--surface-3); color: var(--ink-soft);
  border: 1px solid var(--border); border-radius: var(--r-pill);
  white-space: nowrap;
}
.chip--accent  { background: var(--accent-soft);  color: var(--accent-hover); border-color: var(--accent-line); }
.chip--primary { background: var(--primary-soft); color: var(--primary-hover); border-color: var(--primary-line); }

/* ────────────────────────── Toasts ────────────────────────── */

.toasts {
  position: fixed; top: var(--s-5); right: var(--s-5);
  display: flex; flex-direction: column; gap: var(--s-2);
  z-index: 10000; pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 240px; max-width: 360px;
  padding: var(--s-3) var(--s-4);
  background: var(--elevated); color: var(--ink);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  border-left: 3px solid var(--ink-soft);
  font-size: var(--text-sm); font-weight: 500;
  box-shadow: var(--shadow);
  transform: translateX(110%);
  transition: transform var(--t-slow), opacity var(--t-normal);
  opacity: 0;
}
.toast.show { transform: translateX(0); opacity: 1; }
.toast--success { border-left-color: var(--primary); }
.toast--error   { border-left-color: var(--danger); }
.toast--info    { border-left-color: var(--ink-soft); }
.toast--warn    { border-left-color: var(--accent); }

/* ────────────────────────── Modals ────────────────────────── */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(5, 7, 12, 0.78); backdrop-filter: blur(6px);
  display: grid; place-items: center;
  padding: var(--s-4); z-index: 1000;
  opacity: 0; pointer-events: none; transition: opacity var(--t-normal);
}
.modal-backdrop.show { opacity: 1; pointer-events: auto; }

.modal {
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: var(--s-6);
  max-width: 460px; width: 100%;
  box-shadow: var(--shadow-lg);
  transform: translateY(8px) scale(0.98);
  transition: transform var(--t-normal);
}
.modal-backdrop.show .modal { transform: translateY(0) scale(1); }
.modal__title { font-size: var(--text-lg); font-weight: 700; letter-spacing: -0.015em; margin-bottom: var(--s-2); }
.modal__body  { color: var(--ink-soft); margin-bottom: var(--s-5); }
.modal__actions { display: flex; gap: var(--s-2); justify-content: flex-end; flex-wrap: wrap; }

/* ────────────────────────── Loading dots ────────────────────────── */

.dots {
  display: inline-flex; gap: 4px;
}
.dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  animation: dots 1.2s infinite ease-in-out both;
}
.dots span:nth-child(1) { animation-delay: -0.32s; }
.dots span:nth-child(2) { animation-delay: -0.16s; }
@keyframes dots {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40%           { opacity: 1; transform: scale(1); }
}

/* ────────────────────────── Common helpers ────────────────────────── */

.flex     { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.grid     { display: grid; }
.gap-1 { gap: var(--s-1); } .gap-2 { gap: var(--s-2); } .gap-3 { gap: var(--s-3); }
.gap-4 { gap: var(--s-4); } .gap-5 { gap: var(--s-5); } .gap-6 { gap: var(--s-6); }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; min-width: 0; }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); border: 0;
}
