/* ========================================================================
   PHAROS — Εμφάνιση
   Ήρεμο, καθαρό, με μεγάλα στοιχεία για να διαβάζονται με μια ματιά
   στο τιμόνι. Χωρίς μαύρο: το σκούρο θέμα είναι βαθύ γκρι-μπλε.
   ======================================================================== */

:root {
  --accent:  #0EA5B7;
  --warn:    #F5A524;
  --danger:  #E5484D;
  --ok:      #30A46C;

  --bg:      #EEF3F6;
  --surface: #FFFFFF;
  --surface-2: #F4F8FA;
  --ink:     #16232E;
  --ink-2:   #5A6C7A;
  --line:    rgba(22,35,46,.10);
  --shadow:  0 8px 28px rgba(16,32,46,.14), 0 2px 6px rgba(16,32,46,.08);
  --radius:  20px;
  --safe-t:  env(safe-area-inset-top, 0px);
  --safe-b:  env(safe-area-inset-bottom, 0px);
}

html[data-theme="night"] {
  --bg:      #0F1922;
  --surface: #17242F;
  --surface-2: #1E2E3B;
  --ink:     #E6EEF4;
  --ink-2:   #93A7B6;
  --line:    rgba(230,238,244,.12);
  --shadow:  0 10px 30px rgba(0,0,0,.45), 0 2px 8px rgba(0,0,0,.3);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Κρίσιμο: τα .sheet / .alert-card ορίζουν display, που αλλιώς νικάει το [hidden]
   και αφήνει αόρατα στοιχεία να «τρώνε» τα πατήματα πάνω από τα κουμπιά. */
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--ink);
  font: 400 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", "Noto Sans", sans-serif;
  overscroll-behavior: none;
}

#map { position: fixed; inset: 0; }
.maplibregl-ctrl-attrib { font-size: 10px; opacity: .75; }

/* ─────────────  ΠΑΝΩ ΜΠΑΡΑ  ───────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(var(--safe-t) + 10px) 12px 10px;
  background: linear-gradient(to bottom, var(--bg) 55%, transparent);
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 22px; height: 22px; border-radius: 7px; display: block; }
.brand-name { font-weight: 700; letter-spacing: .16em; font-size: 13px; }

.chips { display: flex; gap: 6px; margin-left: auto; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); color: var(--ink-2);
  border-radius: 999px; padding: 5px 11px; font-size: 12px; font-weight: 600;
  box-shadow: var(--shadow); white-space: nowrap;
}
.chip .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink-2); transition: background .3s;
}
.chip.live .dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(48,164,108,.22); }
.chip.warn .dot { background: var(--warn); }
.chip.off  .dot { background: var(--danger); }

.icon-btn {
  border: 0; background: var(--surface); color: var(--ink);
  width: 38px; height: 38px; border-radius: 12px; font-size: 17px;
  box-shadow: var(--shadow); cursor: pointer;
}

/* ─────────────  ΚΑΡΤΑ ΕΙΔΟΠΟΙΗΣΗΣ  ───────────── */
.alert-card {
  position: fixed; z-index: 30;
  top: calc(var(--safe-t) + 58px); left: 12px; right: 12px;
  display: grid; grid-template-columns: auto 1fr auto;
  gap: 14px; align-items: center;
  padding: 16px 18px 20px;
  border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
  border-left: 6px solid var(--warn);
  animation: pop .28s cubic-bezier(.2,.9,.3,1.3);
}
@keyframes pop { from { transform: translateY(-14px) scale(.97); opacity: 0 } }
.alert-card.near   { border-left-color: var(--danger); }
.alert-card.over   { background: var(--danger); color: #fff; border-left-color: #fff; }
.alert-card.over .alert-sub, .alert-card.over .alert-limit span { color: rgba(255,255,255,.8); }

.alert-icon { font-size: 30px; line-height: 1; }
.alert-title { font-weight: 700; font-size: 19px; letter-spacing: -.01em; }
.alert-sub { color: var(--ink-2); font-size: 15px; font-variant-numeric: tabular-nums; }
.alert-limit {
  text-align: center; min-width: 58px;
  border: 3px solid var(--danger); border-radius: 50%;
  width: 58px; height: 58px; display: grid; place-content: center;
  background: var(--surface);
}
.alert-limit b { font-size: 21px; line-height: 1; color: var(--ink); }
.alert-limit span { display: block; font-size: 9px; color: var(--ink-2); letter-spacing: .06em; }
.alert-bar {
  grid-column: 1 / -1; height: 5px; border-radius: 999px;
  background: var(--line); overflow: hidden; margin-top: 2px;
}
.alert-bar i { display: block; height: 100%; width: 0;
  background: var(--warn); border-radius: 999px; transition: width .4s linear; }
.alert-card.near .alert-bar i { background: var(--danger); }
.alert-card.over .alert-bar i { background: #fff; }

/* ─────────────  ΖΩΝΗ ΜΕΣΗΣ ΤΑΧΥΤΗΤΑΣ  ───────────── */
.section-card {
  position: fixed; z-index: 29; left: 12px; right: 12px;
  top: calc(var(--safe-t) + 58px);
  padding: 14px 16px 16px; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
  border-left: 6px solid var(--accent);
}
.alert-card:not([hidden]) ~ .section-card { top: calc(var(--safe-t) + 190px); }
.section-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.section-tag {
  font-size: 10px; font-weight: 800; letter-spacing: .12em;
  color: var(--accent); white-space: nowrap;
}
.section-head span:last-child {
  font-size: 14px; color: var(--ink-2); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.section-track { height: 7px; border-radius: 999px; background: var(--line); overflow: hidden; }
.section-track i { display: block; height: 100%; width: 0;
  background: var(--accent); border-radius: 999px; transition: width .5s linear; }
.section-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px; margin-top: 12px; text-align: center;
}
.section-grid b { display: block; font-size: 22px; font-variant-numeric: tabular-nums;
  letter-spacing: -.02em; line-height: 1.1; }
.section-grid span { font-size: 10.5px; color: var(--ink-2); }
.section-card.over { border-left-color: var(--danger); }
.section-card.over .section-track i { background: var(--danger); }
.section-card.over .section-req b { color: var(--danger); }
.section-card.safe .section-req b { color: var(--ok); }

/* ─────────────  HUD  ───────────── */
.hud {
  position: fixed; z-index: 25; left: 12px;
  bottom: calc(var(--safe-b) + 96px);
  background: var(--surface); box-shadow: var(--shadow);
  border-radius: 18px; padding: 10px 18px 8px; text-align: center;
}
.hud .speed b {
  display: block; font-size: 38px; font-weight: 700;
  font-variant-numeric: tabular-nums; letter-spacing: -.03em; line-height: 1;
}
.hud .speed span { font-size: 10px; color: var(--ink-2); letter-spacing: .08em; }
.hud.over b { color: var(--danger); }

/* ─────────────  ΚΟΥΜΠΙΑ  ───────────── */
.dock {
  position: fixed; z-index: 26; left: 12px; right: 12px;
  bottom: calc(var(--safe-b) + 14px);
  display: flex; align-items: center; gap: 8px; justify-content: center;
}
.round {
  flex: 0 0 auto; width: 52px; height: 52px; border-radius: 17px; border: 0;
  background: var(--surface); color: var(--ink); font-size: 20px;
  box-shadow: var(--shadow); cursor: pointer; transition: transform .12s;
}
.round:active { transform: scale(.94); }
.round.accent { background: var(--accent); color: #fff; }
.round.on { background: var(--accent); color: #fff; }

.primary {
  flex: 1 1 auto; min-height: 52px; border: 0; border-radius: 17px;
  background: var(--accent); color: #fff; font-size: 15px; font-weight: 700;
  box-shadow: var(--shadow); cursor: pointer; padding: 0 16px;
  transition: transform .12s, background .2s;
}
.primary:active { transform: scale(.98); }
.primary.stop { background: var(--danger); }
.primary:disabled { opacity: .45; }

.mark-here {
  position: fixed; z-index: 27; right: 12px;
  bottom: calc(var(--safe-b) + 96px);
  width: 92px; height: 92px; border-radius: 30px; border: 0;
  background: var(--accent); color: #fff; font-weight: 800;
  font-size: 13px; letter-spacing: .06em; line-height: 1.25;
  box-shadow: var(--shadow); cursor: pointer;
}
.mark-here:active { transform: scale(.94); }

.hint {
  position: fixed; z-index: 24; left: 12px; right: 12px;
  bottom: calc(var(--safe-b) + 78px);
  margin: 0; padding: 10px 14px; border-radius: 14px;
  background: var(--surface); color: var(--ink-2);
  font-size: 13px; text-align: center; box-shadow: var(--shadow);
}

/* ─────────────  ΦΥΛΛΑ (sheets)  ───────────── */
.scrim {
  position: fixed; inset: 0; z-index: 39;
  background: rgba(10,20,28,.42); backdrop-filter: blur(2px);
}
.sheet {
  position: fixed; z-index: 40; left: 0; right: 0; bottom: 0;
  max-height: 88vh; display: flex; flex-direction: column;
  background: var(--surface); color: var(--ink);
  border-radius: 26px 26px 0 0; box-shadow: var(--shadow);
  animation: rise .3s cubic-bezier(.2,.9,.3,1);
}
@keyframes rise { from { transform: translateY(100%) } }
.sheet.tall { height: 88vh; }
.sheet-inner {
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 8px 20px calc(var(--safe-b) + 24px);
}
.grab { width: 40px; height: 4px; border-radius: 99px; background: var(--line);
  margin: 6px auto 12px; }
.sheet h2 { margin: 0 0 14px; font-size: 20px; letter-spacing: -.02em; }
.sheet h3 { margin: 22px 0 10px; font-size: 12px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-2); }
.lead { margin: -6px 0 16px; color: var(--ink-2); font-size: 14px; }
.list-head { display: flex; align-items: center; justify-content: space-between; }
.list-head h2 { margin-bottom: 8px; }

.field-label { display: block; font-size: 12px; font-weight: 600;
  color: var(--ink-2); margin: 14px 0 6px; }
input[type=text], input[type=search], input[type=number], select, textarea {
  width: 100%; padding: 13px 14px; font-size: 16px; font-family: inherit;
  color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 14px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1.4fr; gap: 12px; }
.coords { font-size: 12px; color: var(--ink-2); margin: 14px 0 0;
  font-variant-numeric: tabular-nums; }
.zone-count { margin: 0; padding: 13px 0; font-weight: 600; color: var(--ink-2); }

.type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.type-btn {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  border-radius: 14px; padding: 12px 6px; font-size: 11.5px; font-weight: 600;
  cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 5px;
  line-height: 1.2; text-align: center; min-height: 74px; justify-content: center;
}
.type-btn i { font-style: normal; font-size: 21px; }
.type-btn.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface-2));
  box-shadow: inset 0 0 0 1px var(--accent); }

.sheet-actions { display: flex; gap: 10px; margin-top: 22px; }
.sheet-actions .primary { flex: 1; }
.ghost {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  border-radius: 15px; padding: 14px 16px; font-size: 14px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.ghost.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-row .ghost { text-align: center; }

.switch { display: flex; align-items: center; gap: 12px; padding: 11px 0;
  font-size: 15px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span {
  flex: 0 0 auto; width: 46px; height: 28px; border-radius: 99px;
  background: var(--line); position: relative; transition: background .2s;
}
.switch span::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%; background: var(--surface);
  box-shadow: 0 1px 4px rgba(0,0,0,.25); transition: transform .2s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }

input[type=range] { width: 100%; accent-color: var(--accent); }
.muted { color: var(--ink-2); font-size: 13px; margin: 6px 0 0; }
.about { color: var(--ink-2); font-size: 11.5px; margin-top: 28px; line-height: 1.6; }

/* ─────────────  ΛΙΣΤΑ  ───────────── */
.filters { display: flex; gap: 6px; overflow-x: auto; padding: 12px 0 4px;
  scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filter {
  flex: 0 0 auto; border: 1px solid var(--line); background: var(--surface-2);
  color: var(--ink-2); border-radius: 99px; padding: 7px 13px;
  font-size: 12.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.filter.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.list { margin-top: 10px; }
.item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 13px 12px; border: 0; border-bottom: 1px solid var(--line);
  background: none; color: var(--ink); text-align: left; cursor: pointer;
  font-family: inherit; font-size: 15px;
}
.item:active { background: var(--surface-2); }
.item i { font-style: normal; font-size: 22px; flex: 0 0 auto; }
.item .meta { flex: 1; min-width: 0; }
.item .meta b { display: block; font-weight: 600; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.item .meta small { color: var(--ink-2); font-size: 12px; }
.item .dist { color: var(--ink-2); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.empty { color: var(--ink-2); text-align: center; padding: 40px 20px; font-size: 14px; }

/* ─────────────  TOAST  ───────────── */
.toast {
  position: fixed; z-index: 60; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-b) + 84px);
  background: var(--ink); color: var(--bg);
  padding: 12px 18px; border-radius: 14px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow); max-width: 88vw; text-align: center;
  animation: pop .25s cubic-bezier(.2,.9,.3,1.3);
}

/* ─────────────  ΛΕΙΤΟΥΡΓΙΑ ΟΔΗΓΗΣΗΣ  ───────────── */
body.driving .topbar { opacity: .55; }
body.driving .round#btn-list, body.driving .round#btn-settings { display: none; }

@media (min-width: 780px) {
  .alert-card, .section-card { left: auto; right: 16px; width: 400px; }
  .dock { left: 50%; transform: translateX(-50%); width: min(520px, 94vw); }
  .sheet { left: 50%; transform: translateX(-50%); width: min(560px, 100vw);
    border-radius: 26px 26px 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
