/* EuroGas Web · sistema visual heredado del prototipo aprobado */

:root {
  --bg: #070b0a;
  --surface: #101715;
  --raised: #18211e;
  --raised-2: #202a27;
  --line: #2a3632;

  --accent: #2fd07e;
  --accent-strong: #36ed94;
  --accent-soft: rgba(47, 208, 126, .10);
  --accent-line: rgba(47, 208, 126, .24);
  --grad-accent: linear-gradient(135deg, #16ad70, #2fd07e);

  --text: #f2f5f4;
  --text-muted: #9eaaa6;
  --text-dim: #6f7b77;
  --danger: #ff6471;
  --warn: #ffb545;

  --screen-x: 16px;
  --card-pad: 14px;
  --gap-sm: 8px;
  --gap: 12px;
  --gap-lg: 20px;

  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 20px;
  --r-pill: 999px;

  --card-bg: linear-gradient(145deg, rgba(28, 38, 35, .96), rgba(18, 25, 23, .96));
  --cta-shadow: 0 12px 28px rgba(47, 208, 126, .20);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 12%, rgba(47, 208, 126, .10), transparent 27rem),
    radial-gradient(circle at 82% 76%, rgba(47, 208, 126, .09), transparent 29rem),
    linear-gradient(145deg, #07100e 0%, #050807 48%, #0a1311 100%);
  background-attachment: fixed;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }

.app { max-width: 560px; margin: 0 auto; padding: 0 var(--screen-x); }

/* — Cabecera ————————————————————————— */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--gap); padding: calc(14px + env(safe-area-inset-top)) 0 10px;
}
.topbar h1 { font-size: 21px; font-weight: 800; margin: 0; letter-spacing: -.02em; }
.badge {
  font-size: 11px; font-weight: 600; padding: 5px 10px; border-radius: var(--r-pill);
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-line);
  white-space: nowrap;
}
.badge.muted { background: rgba(255,255,255,.05); color: var(--text-muted); border-color: var(--line); }
.badge.warn { background: rgba(255,181,69,.10); color: var(--warn); border-color: rgba(255,181,69,.28); }

/* — Tarjetas ——————————————————————————— */
.card {
  background: var(--card-bg); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: var(--card-pad); margin-bottom: var(--gap);
}
.card h2 { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--text-muted); letter-spacing: .02em; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: var(--gap-lg) 0 var(--gap-sm); }
.section-head h2 { margin: 0; font-size: 15px; font-weight: 600; }

/* — Contador principal ————————————————— */
.hero { text-align: center; padding: 22px var(--card-pad); }
.hero .figure {
  font-size: clamp(46px, 16vw, 66px); font-weight: 800; line-height: 1;
  letter-spacing: -.035em; font-variant-numeric: tabular-nums;
  background: var(--grad-accent); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero .caption { color: var(--text-muted); font-size: 13px; margin-top: 8px; }

.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap-sm); }
.metric {
  background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 10px 8px; text-align: center;
}
.metric .value { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.metric .label { font-size: 10px; color: var(--text-dim); margin-top: 3px; text-transform: uppercase; letter-spacing: .04em; }
.metric.wide { grid-column: span 3; }

/* — Aceleración en vivo ————————————————— */
.accel-meter { height: 8px; border-radius: var(--r-pill); background: var(--raised-2); position: relative; overflow: hidden; margin-top: 6px; }
.accel-meter .zero { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--line); }
.accel-meter .fill { position: absolute; top: 0; bottom: 0; background: var(--accent); transition: all .18s ease-out; }
.accel-meter .fill.brake { background: var(--warn); }

/* — Desglose ——————————————————————————— */
.breakdown { display: flex; flex-direction: column; gap: 9px; }
.bd-row { display: grid; grid-template-columns: 92px 1fr auto; align-items: center; gap: 10px; font-size: 12px; }
.bd-row .name { color: var(--text-muted); }
.bd-row .track { display: block; height: 7px; border-radius: var(--r-pill); background: var(--raised-2); overflow: hidden; }
.bd-row .bar { display: block; height: 100%; border-radius: var(--r-pill); background: var(--grad-accent); transition: width .3s ease; }
.bd-row .amount { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 52px; text-align: right; }
.bd-row[data-kind="inercia"] .bar { background: linear-gradient(135deg, #ff9f43, #ffc078); }
.bd-row[data-kind="aire"] .bar { background: linear-gradient(135deg, #3ba5f0, #7cc6f7); }
.bd-row[data-kind="rodadura"] .bar { background: linear-gradient(135deg, #8b7ff0, #b3a9f7); }
.bd-row[data-kind="pendiente"] .bar { background: linear-gradient(135deg, #e86ba8, #f3a3c9); }
.bd-row[data-kind="motor"] .bar { background: linear-gradient(135deg, #5c6b66, #8b9a94); }

/* — Controles ——————————————————————————— */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 15px 18px; border-radius: var(--r-lg);
  font-weight: 700; font-size: 16px; letter-spacing: -.01em;
  background: var(--raised-2); border: 1px solid var(--line); color: var(--text);
  transition: transform .12s ease, opacity .12s ease;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .4; }
.btn.primary { background: var(--grad-accent); color: #04140c; border: 0; box-shadow: var(--cta-shadow); }
.btn.danger { background: rgba(255,100,113,.12); border-color: rgba(255,100,113,.3); color: var(--danger); }
.btn.small { padding: 10px 14px; font-size: 14px; border-radius: var(--r-sm); width: auto; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap-sm); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--gap); }
.field label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.field input, .field select {
  background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 12px 13px; font-size: 16px; width: 100%; outline: none;
}
.field input:focus, .field select:focus { border-color: var(--accent-line); }
.field .hint { font-size: 11px; color: var(--text-dim); line-height: 1.45; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap-sm); }

.stepper { display: flex; align-items: center; gap: var(--gap-sm); }
.stepper button {
  width: 42px; height: 42px; border-radius: var(--r-sm); background: var(--raised);
  border: 1px solid var(--line); font-size: 20px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.stepper .count { flex: 1; text-align: center; font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 4px; }
.segmented button { padding: 9px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.segmented button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

/* — Listas ——————————————————————————————— */
.trip {
  display: flex; align-items: center; gap: var(--gap); width: 100%; text-align: left;
  background: var(--card-bg); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 13px var(--card-pad); margin-bottom: var(--gap-sm);
}
.trip .main { flex: 1; min-width: 0; }
.trip .title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trip .meta { font-size: 12px; color: var(--text-dim); margin-top: 3px; }
.trip .cost { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 16px; }

.empty { text-align: center; padding: 48px 24px; color: var(--text-dim); }
.empty .icon { font-size: 34px; margin-bottom: 12px; opacity: .5; }
.empty p { margin: 6px 0 0; font-size: 14px; line-height: 1.5; }

.note { font-size: 12px; color: var(--text-dim); line-height: 1.55; margin: 10px 0 0; }
.note strong { color: var(--text-muted); font-weight: 600; }

.pill-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pill { font-size: 11px; padding: 5px 9px; border-radius: var(--r-pill); background: var(--raised-2); color: var(--text-muted); border: 1px solid var(--line); }
.pill.hot { background: rgba(255,159,67,.12); color: #ff9f43; border-color: rgba(255,159,67,.28); }

/* — Navegación inferior ————————————————— */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: rgba(10, 16, 14, .92); backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
}
.tabbar button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px; font-size: 10px; font-weight: 600; color: var(--text-dim); }
.tabbar button[aria-selected="true"] { color: var(--accent); }
.tabbar .glyph { font-size: 19px; line-height: 1; }

.screen { display: none; animation: rise .22s ease-out; }
.screen.active { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* — Avisos ——————————————————————————————— */
.alert {
  border-radius: var(--r-sm); padding: 11px 13px; font-size: 13px; line-height: 1.5;
  background: rgba(255,181,69,.10); border: 1px solid rgba(255,181,69,.26); color: #ffce8a;
  margin-bottom: var(--gap);
}
.alert.bad { background: rgba(255,100,113,.10); border-color: rgba(255,100,113,.26); color: #ff9aa3; }
.alert.ok { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }

details.advanced { border-top: 1px solid var(--line); padding-top: var(--gap); margin-top: var(--gap); }
details.advanced summary { font-size: 13px; color: var(--text-muted); font-weight: 600; cursor: pointer; list-style: none; }
details.advanced summary::-webkit-details-marker { display: none; }
details.advanced summary::before { content: '▸ '; color: var(--accent); }
details.advanced[open] summary::before { content: '▾ '; }
details.advanced > div { padding-top: var(--gap); }

dialog {
  border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface);
  color: var(--text); padding: 0; width: min(520px, calc(100vw - 32px)); max-height: 86vh;
}
dialog::backdrop { background: rgba(0,0,0,.66); backdrop-filter: blur(3px); }
dialog .sheet { padding: 20px; overflow-y: auto; max-height: 86vh; }
dialog h2 { margin: 0 0 var(--gap); font-size: 19px; font-weight: 800; color: var(--text); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Sugerencias de destino */
.destination-box { position: relative; }
.suggestions {
  list-style: none; margin: 0; padding: 4px; position: absolute; left: 0; right: 0; top: 70px; z-index: 20;
  background: var(--raised-2); border: 1px solid var(--line); border-radius: var(--r-sm);
  box-shadow: 0 16px 36px rgba(0, 0, 0, .45); max-height: 320px; overflow-y: auto;
}
.suggestions[hidden] { display: none; }
.suggestions [role=option] {
  display: flex; flex-direction: column; gap: 2px; padding: 10px 11px; border-radius: 9px; cursor: pointer;
}
.suggestions [role=option]:hover, .suggestions [role=option].active { background: var(--accent-soft); }
.suggestions .s-name { font-size: 14px; font-weight: 600; color: var(--text); }
.suggestions .s-detail { font-size: 12px; color: var(--text-muted); }
.suggestions .s-head { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-dim); padding: 8px 11px 4px; }
.suggestions .s-msg { font-size: 12px; line-height: 1.5; color: var(--text-muted); padding: 10px 11px; }
