/* ==========================================================
   DCA Patrol — mobile-first officer app styles
   Design goals: huge touch targets, high contrast (readable in
   sunlight), works one-handed, no framework.
   Swap the brand colors below to match DCA branding.
   ========================================================== */

:root {
  --brand:        #1b3a5c;   /* deep navy */
  --brand-light:  #2e5d8e;
  --accent:       #e8a33d;   /* gold accent */
  --danger:       #b3382e;
  --success:      #2e7d4f;
  --bg:           #f4f5f7;
  --card:         #ffffff;
  --text:         #16202b;
  --muted:        #5b6672;
  --radius:       14px;
  --tap-min:      56px;      /* minimum touch target */
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  line-height: 1.4;
  /* Respect notches / home indicators */
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---------- Header ---------- */

.app-header {
  background: var(--brand);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.app-header img { height: 36px; width: auto; background: #fff; border-radius: 8px; padding: 3px 6px; }
/* The badge carries the shift state and must never wrap or be pushed off the
   screen, so a long officer name truncates instead. */
.app-header h1 {
  font-size: 1.05rem; margin: 0; font-weight: 600;
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.app-header .shift-badge {
  font-size: .8rem;
  background: var(--success);
  padding: 4px 10px;
  border-radius: 99px;
  white-space: nowrap;
  flex: 0 0 auto;
}
.app-header .shift-badge.off { background: var(--muted); }

/* ---------- Icon grid (home) ---------- */

.icon-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  padding: 16px;
  max-width: 560px;
  margin: 0 auto;
}
@media (min-width: 700px) {
  .icon-grid { grid-template-columns: repeat(3, 1fr); }
}

.grid-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--card);
  border: none;
  border-radius: var(--radius);
  padding: 22px 10px 18px;
  min-height: 132px;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
  color: var(--text);
  text-decoration: none;
  text-align: center;
  font-size: .95rem;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
  transition: transform .06s ease;
}
.grid-btn:active { transform: scale(.96); }
.grid-btn svg { width: 52px; height: 52px; }
.grid-btn .ico { color: var(--brand-light); }
.grid-btn.danger .ico { color: var(--danger); }
.grid-btn.accent .ico { color: var(--accent); }
.grid-btn.success .ico { color: var(--success); }
.grid-btn[aria-disabled="true"] { opacity: .4; pointer-events: none; }

/* ---------- Forms ---------- */

.form-page {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px;
}
.form-page h2 { margin: 4px 0 16px; font-size: 1.3rem; }

label { display: block; font-weight: 600; margin: 16px 0 6px; }

input[type="text"], input[type="tel"], input[type="email"],
input[type="time"], input[type="datetime-local"],
select, textarea {
  width: 100%;
  min-height: var(--tap-min);
  padding: 12px 14px;
  font-size: 1.05rem;      /* >=16px prevents iOS zoom-on-focus */
  border: 1.5px solid #c8ced6;
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 3px solid var(--brand-light);
  outline-offset: 1px;
}

/* Big segmented choice buttons (radio replacements) */
.choice-row { display: flex; gap: 10px; flex-wrap: wrap; }
.choice-row input[type="radio"], .choice-row input[type="checkbox"] { position: absolute; opacity: 0; }
.choice-row label.choice {
  flex: 1 1 40%;
  margin: 0;
  min-height: var(--tap-min);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid #c8ced6;
  border-radius: 10px;
  background: var(--card);
  font-weight: 600;
  cursor: pointer;
}
.choice-row input:checked + label.choice {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

/* ---------- Buttons ---------- */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 58px;
  border: none;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 20px;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-ghost   { background: transparent; color: var(--brand); border: 1.5px solid var(--brand); }
.btn:active  { opacity: .85; }
.btn[disabled] { opacity: .5; }
/* Helper action bolted onto a field, e.g. "Use my location" under an address.
   Sits tight against its field but keeps the full touch target. */
.btn-locate { min-height: var(--tap-min); margin-top: 8px; font-size: .95rem; }

/* ---------- Read-only panels (shift summary, shift log) ---------- */

.muted { color: var(--muted); }

.shift-summary {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 8px;
}
.shift-summary h3 { margin: 0 0 4px; font-size: 1.05rem; }
.shift-summary p { margin: 0; font-size: .9rem; }
.shift-summary ul { list-style: none; margin: 12px 0 0; padding: 0; }
.shift-summary li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid #e4e8ed;
}
.shift-summary li strong { font-size: 1.05rem; }

.entry-list { list-style: none; margin: 0; padding: 0; }
.entry-item {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.entry-item .entry-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.entry-item .entry-type {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  background: #e6edf5;
  color: var(--brand);
  font-size: .78rem;
  font-weight: 700;
}
.entry-item .entry-time { color: var(--muted); font-size: .85rem; }
.entry-item .entry-summary { margin: 0; }
.entry-item .entry-address { margin: 4px 0 0; color: var(--muted); font-size: .88rem; }

.empty-state {
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  color: var(--muted);
}

/* ---------- GPS chip ---------- */

.gps-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 8px 14px;
  border-radius: 99px;
  font-size: .85rem;
  font-weight: 600;
  background: #e6edf5;
  color: var(--brand);
}
.gps-chip.ok    { background: #e2f2e8; color: var(--success); }
.gps-chip.error { background: #f9e3e1; color: var(--danger); }

/* ---------- Login ---------- */

.login-wrap {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--brand);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px 22px;
  box-shadow: 0 8px 30px rgba(0,0,0,.25);
}
.login-card img { display: block; margin: 0 auto 8px; height: 64px; }
.login-card h1 { text-align: center; font-size: 1.2rem; margin: 0 0 4px; }
.login-card p.sub { text-align: center; color: var(--muted); margin: 0 0 12px; font-size: .9rem; }

/* ---------- Misc ---------- */

.error-msg { color: var(--danger); font-weight: 600; margin-top: 12px; min-height: 1.2em; }
.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--brand); text-decoration: none; font-weight: 600; padding: 12px 0; }
.toast {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translateX(-50%);
  background: var(--text); color: #fff;
  padding: 12px 22px; border-radius: 99px;
  font-weight: 600;
  opacity: 0; pointer-events: none;
  transition: opacity .25s;
}
.toast.show { opacity: 1; }
