/* AppMaps — interface mapa-primeiro.
 *
 * Princípio: o mapa ocupa a tela inteira. Controles flutuam sobre ele,
 * ficam na metade de baixo (alcance do polegar) e têm alvo mínimo de 44px.
 * Nada de painel denso permanentemente aberto. */

:root {
  --bg: #fff;
  --fg: #1a1d21;
  --muted: #6b7280;
  --border: #e3e6ea;
  --accent: #d97706;
  --sombra: 0 2px 14px rgba(0, 0, 0, .16);
  --toque: 44px;              /* alvo mínimo de toque */
  --seguro: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1f24;
    --fg: #e8eaed;
    --muted: #9aa2ad;
    --border: #333940;
    --sombra: 0 2px 14px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--fg);
  overflow: hidden;
  overscroll-behavior: none;
}

#map { position: absolute; inset: 0; }

button { font: inherit; color: inherit; cursor: pointer; }

/* ---- Topo: mínimo possível ---- */
.topbar {
  position: absolute;
  top: 10px; left: 10px;
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  background: var(--bg);
  border-radius: 99px;
  box-shadow: var(--sombra);
  z-index: 10;
}
.brand { font-weight: 650; font-size: 14px; }

.net-status {
  font-size: 11px; font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--border);
  color: var(--muted);
}
.net-status.online  { background: #dcfce7; color: #166534; }
.net-status.offline { background: #fef3c7; color: #92400e; }

/* ---- Filtros: polegar, rolagem horizontal ---- */
.filters {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(14px + var(--seguro));
  display: flex; gap: 8px;
  padding: 4px 10px;
  overflow-x: auto;
  scrollbar-width: none;
  z-index: 10;
}
.filters::-webkit-scrollbar { display: none; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  flex: 0 0 auto;
  min-height: var(--toque);
  padding: 0 16px;
  font-size: 14px; font-weight: 550;
  background: var(--bg);
  border: none;
  border-radius: 99px;
  box-shadow: var(--sombra);
}
.chip[aria-pressed="true"] { background: var(--accent); color: #fff; }
.chip .ic { font-size: 16px; }

/* ---- Aviso discreto ---- */
.aviso {
  position: absolute;
  top: 60px; left: 50%;
  transform: translateX(-50%);
  padding: 7px 14px;
  font-size: 13px;
  color: var(--muted);
  background: var(--bg);
  border-radius: 99px;
  box-shadow: var(--sombra);
  z-index: 10;
  pointer-events: none;
}

/* ---- Botão único de menu ---- */
.fab {
  position: absolute;
  right: 10px;
  bottom: calc(70px + var(--seguro));
  width: var(--toque); height: var(--toque);
  font-size: 19px;
  background: var(--bg);
  border: none;
  border-radius: 50%;
  box-shadow: var(--sombra);
  z-index: 10;
}

/* ---- Botão de rota ---- */
.fab-rota { bottom: calc(124px + var(--seguro)); font-size: 20px; }
.fab-rota.ativo { background: #2563eb; color: #fff; }

/* ---- Painel da rota ---- */
.rota-painel {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-height: 55vh;
  padding: 14px 18px calc(14px + var(--seguro));
  overflow-y: auto;
  background: var(--bg);
  border-radius: 18px 18px 0 0;
  box-shadow: var(--sombra);
  z-index: 25;
  animation: subir .22s ease-out;
}

.rota-resumo {
  display: flex; align-items: baseline; gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.rota-resumo strong { font-size: 22px; color: #2563eb; }
.rota-resumo span { color: var(--muted); }

.rota-passos { margin: 10px 0 0; padding-left: 22px; font-size: 14px; }
.rota-passos li { margin-bottom: 9px; }
.rota-passos small { display: block; color: var(--muted); font-size: 12px; }

@media (min-width: 700px) {
  .rota-painel {
    left: auto; right: 14px; bottom: 14px;
    width: 330px;
    border-radius: 16px;
  }
}

/* ---- Navegação ----
 * Poucos elementos, letras grandes, alto contraste. Quem dirige olha por
 * meio segundo: tudo que exigir leitura atenta é perigoso. */

.btn-navegar {
  display: block;
  width: 100%;
  min-height: 50px;
  margin: 12px 0 4px;
  font-size: 16px; font-weight: 650;
  color: #fff;
  background: #2563eb;
  border: none;
  border-radius: 12px;
}

.nav-tela {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px;
  pointer-events: none;   /* deixa arrastar o mapa por baixo */
  z-index: 40;
}
.nav-tela > * { pointer-events: auto; }

.nav-topo {
  padding: 16px 18px;
  color: #fff;
  background: rgba(20, 24, 30, .92);
  border-radius: 14px;
}
.nav-instrucao { font-size: 21px; font-weight: 600; line-height: 1.3; }
.nav-distancia { margin-top: 6px; font-size: 30px; font-weight: 700; color: #7dd3fc; }

.nav-rodape {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 12px 16px calc(12px + var(--seguro));
  color: #fff;
  background: rgba(20, 24, 30, .92);
  border-radius: 14px;
}
.nav-velocidade strong { font-size: 26px; }
.nav-velocidade small { margin-left: 3px; opacity: .7; font-size: 12px; }
.nav-seguinte { flex: 1; font-size: 12px; opacity: .75; }

.nav-sair {
  min-height: var(--toque);
  padding: 0 16px;
  font-size: 14px; font-weight: 600;
  color: #fff;
  background: #b91c1c;
  border: none;
  border-radius: 10px;
}

/* Durante a navegação, some tudo que não interessa ao motorista */
body.navegando .filters,
body.navegando .fab,
body.navegando .topbar,
body.navegando .aviso { display: none; }

/* ---- Painel que sobe de baixo ---- */
.sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-height: 78vh;
  padding-bottom: var(--seguro);
  background: var(--bg);
  border-radius: 18px 18px 0 0;
  box-shadow: var(--sombra);
  z-index: 30;
  animation: subir .22s ease-out;
}
@keyframes subir { from { transform: translateY(100%); } }

.sheet-grab {
  display: block;
  width: 100%; height: 26px;
  padding: 0; border: none;
  background: none;
}
.sheet-grab::before {
  content: "";
  display: block;
  width: 38px; height: 4px;
  margin: 9px auto;
  background: var(--border);
  border-radius: 99px;
}

.sheet-body { padding: 0 18px 18px; overflow-y: auto; max-height: calc(78vh - 26px); }
.sheet section { margin-bottom: 22px; }

.sheet h2 {
  margin: 0 0 3px;
  font-size: 11px; font-weight: 650;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted);
}
.hint { margin: 0 0 10px; font-size: 13px; color: var(--muted); }

/* ---- Interruptor ---- */
.chave {
  display: flex; align-items: center; gap: 10px;
  min-height: var(--toque);
  margin-bottom: 6px;
  font-size: 14px; font-weight: 550;
  cursor: pointer;
}
.chave input { width: 20px; height: 20px; accent-color: var(--accent); }

/* ---- Regiões ---- */
.region {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  min-height: var(--toque);
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.region:last-child { border-bottom: none; }
.region-name { font-weight: 550; }
.region-size { font-size: 12px; color: var(--muted); }

.btn {
  min-height: 38px;
  padding: 0 16px;
  font-size: 13px; font-weight: 600;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn.done { background: #dcfce7; border-color: #86efac; color: #166534; }

.progress {
  height: 3px; margin-top: 6px;
  background: var(--border);
  border-radius: 99px; overflow: hidden;
}
.progress > i {
  display: block; height: 100%; width: 0;
  background: var(--accent);
  transition: width .18s;
}

/* ---- Veículo ---- */
.vehicle { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.vehicle label {
  display: flex; align-items: center; gap: 5px;
  font-size: 13px; color: var(--muted);
}
.vehicle input {
  width: 60px; min-height: 38px;
  padding: 0 8px;
  font: inherit; font-size: 15px;
  color: var(--fg);
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 8px;
}
.vehicle i { font-style: normal; }

.credit { margin: 0; font-size: 11px; color: var(--muted); text-align: center; }
.credit a { color: inherit; }

/* ---- Ficha do ponto ---- */
.poi-card {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 16px 18px calc(18px + var(--seguro));
  background: var(--bg);
  border-radius: 18px 18px 0 0;
  box-shadow: var(--sombra);
  z-index: 20;
  animation: subir .22s ease-out;
}
.poi-card h3 { margin: 0 0 3px; font-size: 17px; }
.poi-type { font-size: 13px; color: var(--muted); }
.poi-card ul { margin: 10px 0 0; padding-left: 20px; font-size: 14px; }
.poi-card li { margin-bottom: 4px; }
.poi-corpo { margin-top: 10px; font-size: 14px; }
.poi-corpo p { margin: 0 0 8px; }
.poi-corpo small { color: var(--muted); }

.poi-close {
  position: absolute; top: 8px; right: 8px;
  width: var(--toque); height: var(--toque);
  font-size: 22px;
  color: var(--muted);
  background: none; border: none;
}

/* ---- Telas largas: limita a largura, mantém o mesmo desenho ---- */
@media (min-width: 700px) {
  .sheet, .poi-card {
    left: 14px; right: auto; bottom: 14px;
    width: 340px;
    border-radius: 16px;
  }
  .filters { justify-content: center; }
}
