/* Mobile-first styling for the field observation tool. Big thumb targets,
   high-contrast color-coded states, one-hand reachability. Follows the
   dashboard's system-font + flat-color spirit (scripts/dashboard/assets). */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, system-ui, "Segoe UI", sans-serif;
  color: #222;
  background: #f7f7fa;
  -webkit-tap-highlight-color: transparent;
}

.view {
  max-width: 540px;
  margin: 0 auto;
  padding: 12px 14px 40px;
}

.hidden { display: none !important; }
.muted { color: #777; font-size: 13px; margin: 6px 0; }

h1 { font-size: 22px; margin: 8px 0 16px; }
h2 { font-size: 18px; margin: 4px 0 12px; }

/* ------------------------------------------------------------- controls */

button {
  font: inherit;
  border: 1px solid #bbb;
  border-radius: 10px;
  background: #fff;
  padding: 12px 16px;
  font-size: 16px;
  cursor: pointer;
  touch-action: manipulation;
}
button:active { filter: brightness(0.92); }

button.primary {
  background: #1a73e8;
  border-color: #1a73e8;
  color: #fff;
  width: 100%;
  margin: 8px 0;
}
button.big { padding: 18px; font-size: 19px; font-weight: 600; }
button.danger {
  background: #c62828;
  border-color: #c62828;
  color: #fff;
  width: 100%;
  margin-top: 18px;
}

.field { display: block; margin: 10px 0; }
.field span { display: block; font-size: 13px; color: #555; margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%;
  font: inherit;
  font-size: 16px; /* prevents iOS zoom-on-focus */
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #fff;
}
.check { display: flex; gap: 8px; align-items: center; font-size: 15px; margin: 10px 0; }
.check input { width: 22px; height: 22px; }

details { margin-top: 22px; }
details summary { font-size: 14px; color: #666; padding: 8px 0; cursor: pointer; }

/* ----------------------------------------------------------- setup lists */

.card-list { margin: 10px 0; }
.card-list .card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 13px 14px;
  margin: 6px 0;
}
.card .title { font-weight: 600; font-size: 15px; }
.card .sub { color: #777; font-size: 13px; }
.card .right { text-align: right; white-space: nowrap; font-size: 14px; color: #1a73e8; font-weight: 600; }
.card.selected { border-color: #1a73e8; box-shadow: 0 0 0 2px #1a73e833; }

.bus-card {
  background: #e8f0fe;
  border: 1px solid #1a73e8;
  border-radius: 10px;
  padding: 14px;
  margin: 10px 0;
  font-size: 15px;
  line-height: 1.5;
}

/* ------------------------------------------------------------ status bar */

#status-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  gap: 12px;
  align-items: center;
  background: #1a1a2e;
  color: #eee;
  font-size: 13px;
  padding: 9px 12px;
  margin: -12px -14px 10px;
  font-variant-numeric: tabular-nums;
}
#st-elapsed { font-weight: 700; font-size: 15px; }
#st-gps { color: #888; }
#st-gps.ok { color: #4caf50; }
#st-gps.bad { color: #ff5252; }
.rec {
  margin-left: auto;
  color: #ff5252;
  font-weight: 700;
  animation: blink 1.6s infinite;
}
@keyframes blink { 50% { opacity: 0.25; } }
#st-sync { font-size: 12px; }

/* ------------------------------------------------------------- next stop */

.next-stop { font-size: 13px; color: #555; margin: 4px 0 8px; }
.next-stop strong { font-size: 14px; color: #222; }
.badge {
  background: #fff3cd;
  border: 1px solid #e0a800;
  color: #8a6d00;
  font-size: 11px;
  font-weight: 700;
  border-radius: 6px;
  padding: 2px 6px;
  margin-left: 6px;
}
.badge.unknown { background: #eee; border-color: #bbb; color: #777; }

/* ------------------------------------------------------------- map panel */

.map-panel {
  height: 220px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #ccc;
  margin-bottom: 6px;
  transition: height 0.2s;
}
.map-panel.collapsed { height: 0; border: none; margin: 0; }
#map { width: 100%; height: 100%; }
.map-toggle {
  width: 100%;
  font-size: 13px;
  padding: 7px;
  color: #555;
  background: #eee;
  border-color: #ddd;
  margin-bottom: 10px;
}

/* ---------------------------------------------------------- active banner */

.active-banner {
  border-radius: 12px;
  padding: 16px 14px;
  margin: 4px 0 12px;
  color: #fff;
  text-align: center;
  transition: background 0.15s;
}
.active-banner.moving { background: #2e7d32; }
#active-label { font-size: 21px; font-weight: 800; letter-spacing: 0.5px; }
#active-duration { font-size: 15px; margin-top: 2px; font-variant-numeric: tabular-nums; }

.signal-buttons {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  margin-top: 12px;
}
.signal-hint { font-size: 13px; opacity: 0.85; }
button.sig {
  border: 2px solid #fff;
  color: #fff;
  font-weight: 800;
  padding: 10px 18px;
  border-radius: 24px;
}
button.sig.red { background: #b71c1c; }
button.sig.green { background: #1b5e20; }
.signal-last { font-size: 12px; opacity: 0.9; }

/* ------------------------------------------------------------ event grid */

.event-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.event-grid button {
  min-height: 62px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  border: none;
  line-height: 1.25;
}
.event-grid button.active-type {
  outline: 3px solid #222;
  outline-offset: 2px;
}
.event-grid button.span2 { grid-column: span 2; }

.moving-btn {
  width: 100%;
  min-height: 58px;
  margin-top: 8px;
  background: #2e7d32;
  border-color: #2e7d32;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
}

#other-note-row { grid-column: span 2; }
#other-note-row input {
  width: 100%;
  font-size: 16px;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
}

/* ------------------------------------------------------------ event list */

.events-header {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 700;
  color: #555;
  margin: 18px 0 6px;
}
.event-list { max-height: 300px; overflow-y: auto; }
.event-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid #e2e2e2;
  border-radius: 10px;
  padding: 10px 12px;
  margin: 5px 0;
}
.event-row .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.event-row .what { flex: 1; min-width: 0; }
.event-row .what .type { font-weight: 600; font-size: 14px; }
.event-row .what .note {
  font-size: 12px; color: #777;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.event-row .when { font-size: 12px; color: #777; text-align: right; white-space: nowrap; }

/* ---------------------------------------------------------------- summary */

.summary-stats {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 6px 14px;
  margin-bottom: 14px;
}
.summary-stats .row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 14px;
}
.summary-stats .row:last-child { border-bottom: none; }
.export-buttons button { margin: 5px 0; }

/* ------------------------------------------------------------ bottom sheet */

.backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 40;
}
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 24px rgba(0,0,0,0.25);
  max-width: 540px;
  margin: 0 auto;
}
.sheet-buttons { display: flex; gap: 10px; margin-top: 12px; }
.sheet-buttons button { flex: 1; }
