/*
 * Truck Route Planner - mobile layout.
 * Single column, large touch targets, bottom tab navigation.
 *
 * created by Gabor Gasko
 */

:root { --header-h: 54px; --nav-h: 62px; }

html, body { height: 100%; }
body {
  background: var(--bg);
  overscroll-behavior-y: contain;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* --------------------------------------------------------------- header */

.app-header {
  height: var(--header-h);
  padding: 0 12px;
  gap: 10px;
  position: sticky;
  top: 0;
  padding-top: env(safe-area-inset-top);
  height: calc(var(--header-h) + env(safe-area-inset-top));
}
.brand__mark { width: 30px; height: 30px; border-radius: 8px; }
.brand__mark svg { width: 17px; height: 17px; }
.brand__title { font-size: 14.5px; white-space: nowrap; }
.brand__tagline { display: none; }
.brand { min-width: 0; overflow: hidden; }
.header-meta { gap: 6px; flex: none; }
.chip { display: none; }

/* The header has to fit a 375 px phone: mark, product name, language and
   theme. The author credit lives in the Plan footer and on the Info tab. */
.app-header .author-link { display: none; }

.icon-btn, .lang-select { height: 32px; }
.icon-btn { width: 32px; }
.lang-select { padding: 0 6px; font-size: 12.5px; }

/* ---------------------------------------------------------------- views */

.views {
  flex: 1;
  min-height: 0;
  position: relative;
}
.view {
  padding: 14px 12px calc(var(--nav-h) + env(safe-area-inset-bottom) + 18px);
}
.view[hidden] { display: none; }
.view--map {
  padding: 0;
  position: absolute;
  inset: 0;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
.view--map .map-shell,
.view--map .map-canvas { border-radius: 0; }

/* ----------------------------------------------------------- bottom nav */

.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  z-index: 900;
}
.nav-btn {
  border: 0; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; font-family: inherit; font-size: 11px; font-weight: 500;
  color: var(--muted); position: relative; padding: 0;
  -webkit-tap-highlight-color: transparent;
  transition: color .15s;
}
.nav-btn__icon { width: 22px; height: 22px; display: grid; place-items: center; }
.nav-btn__icon svg { width: 22px; height: 22px; }
.nav-btn[aria-selected="true"] { color: var(--accent); font-weight: 600; }
.nav-btn:disabled { opacity: .35; }

/* ------------------------------------------------- mobile-tuned widgets */

.card { padding: 16px; }

input[type="text"], input[type="number"], input[type="datetime-local"], select {
  height: 44px;
  font-size: 16px; /* prevents iOS zoom on focus */
  border-radius: 10px;
}

.btn { height: 46px; font-size: 15px; border-radius: 10px; }

.swap-row { display: flex; justify-content: center; margin: -4px 0 10px; }
.swap-btn {
  border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); border-radius: 999px;
  width: 36px; height: 36px; cursor: pointer;
  display: grid; place-items: center;
  box-shadow: var(--shadow-xs);
}
.swap-btn svg { width: 16px; height: 16px; }
.swap-btn:active { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }

.stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { padding: 12px 14px; }
.stat__value { font-size: 20px; }

.data-table { min-width: 460px; font-size: 12.5px; }

.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 4px 0 12px;
}
.section-head h2 { font-size: 16px; margin: 0; }

.collapse {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  margin-bottom: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.collapse > summary {
  cursor: pointer; list-style: none;
  padding: 14px 16px;
  font-size: 14px; font-weight: 600; color: var(--ink);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.collapse > summary::-webkit-details-marker { display: none; }
.collapse > summary::after {
  content: ""; width: 8px; height: 8px; flex: none; margin-right: 4px;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg); transition: transform .15s;
}
.collapse[open] > summary::after { transform: rotate(-135deg); }
.collapse__body { padding: 0 16px 16px; }

.map-floating-actions {
  position: absolute; z-index: 600; left: 10px; bottom: 12px; right: 10px;
  display: flex; gap: 8px;
}
.map-floating-actions .btn { flex: 1; height: 42px; padding: 0 12px; font-size: 13.5px; box-shadow: var(--shadow-lg); }

.toast-host { bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px); }

.report { min-height: 300px; font-size: 11px; }

.app-footer {
  font-size: 12px;
  padding: 14px 14px calc(14px + var(--nav-h) + env(safe-area-inset-bottom));
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
.app-footer .spacer { margin-left: 0; }

/* Wide phones / small tablets get a two column stat grid with more room. */
@media (min-width: 520px) {
  .stat-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .field-row--3 { grid-template-columns: 1fr 1fr 1fr; }
}

/* Compact in-view footer (the disclaimer lives in full on the Info tab). */
.view-footer {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}
.view-footer strong { color: var(--ink-soft); font-weight: 600; }
