/* ============================================================
   FloodWatch Guwahati — mobile-first styles
   ============================================================ */
:root {
  --bg: #eef4f8;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #5b6b7c;
  --line: #d8e2ea;
  --primary: #0b7285;
  --primary-dark: #0b4f5c;
  --accent: #dc2626;
  --accent-dark: #b91c1c;
  --low: #16a34a;
  --moderate: #eab308;
  --high: #f97316;
  --critical: #dc2626;
  --radius: 16px;
  --shadow: 0 4px 16px rgba(15, 42, 66, 0.08);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  overflow-x: hidden;
  min-height: 100vh;
}

img { max-width: 100%; }
[hidden] { display: none !important; }
a { color: var(--primary); }

:focus-visible {
  outline: 3px solid #38bdf8;
  outline-offset: 2px;
}

/* ---------- Storage banner ---------- */
.storage-banner {
  background: #fef3c7;
  color: #92400e;
  border-bottom: 1px solid #fde68a;
  padding: 10px 16px;
  font-size: 0.9rem;
  text-align: center;
}

/* ---------- Header / navigation ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.05rem;
}

.brand-icon { font-size: 1.3rem; }
.brand-text em { font-style: normal; opacity: 0.85; font-weight: 500; }

.nav-toggle {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 46px;
  height: 44px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  height: 2.5px;
  background: #fff;
  border-radius: 2px;
}

.main-nav {
  display: none;
  flex-basis: 100%;
  flex-direction: column;
  gap: 4px;
  padding: 6px 0 4px;
}

.main-nav.open { display: flex; }

.main-nav a {
  display: block;
  padding: 13px 16px;
  min-height: 48px;
  color: #eaf6f9;
  text-decoration: none;
  font-weight: 600;
  border-radius: 10px;
}

.main-nav a:hover { background: rgba(255, 255, 255, 0.12); }

.main-nav a.active {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.main-nav a.nav-cta {
  background: var(--accent);
  color: #fff;
  text-align: center;
}

.main-nav a.nav-cta:hover { background: var(--accent-dark); }

/* ---------- Layout ---------- */
.app-main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 16px 14px 48px;
}

.view { display: none; }
.view.active { display: block; animation: fadeIn 0.22s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.section-title {
  font-size: 1.05rem;
  margin: 26px 0 12px;
  color: var(--primary-dark);
}

.page-title { font-size: 1.5rem; margin: 6px 0 4px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.link { font-size: 0.92rem; font-weight: 600; text-decoration: none; }

.hint {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 8px 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 20px;
  border: 2px solid transparent;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.06s ease, background 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-lg { min-height: 54px; padding: 14px 24px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-sm { min-height: 40px; padding: 8px 14px; font-size: 0.9rem; }

.btn-danger {
  background: linear-gradient(135deg, var(--accent), #ef4444);
  color: #fff;
  box-shadow: 0 6px 18px rgba(220, 38, 38, 0.35);
}

.btn-danger:hover { background: var(--accent-dark); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
  box-shadow: 0 6px 16px rgba(11, 114, 133, 0.3);
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-outline {
  background: #fff;
  color: var(--primary-dark);
  border-color: var(--primary);
}

.btn-outline:hover { background: #e6f4f7; }

.btn-soft {
  background: #e6f4f7;
  color: var(--primary-dark);
  border-color: transparent;
}

.btn-soft:hover { background: #d2ebf0; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

.btn-ghost:hover { background: #f1f5f9; }

.btn-danger-text { color: var(--accent); border-color: var(--accent); }
.btn-danger-text:hover { background: #fee2e2; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0;
}

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(140deg, var(--primary-dark) 0%, #0e7490 55%, #0891b2 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 26px 20px;
  box-shadow: var(--shadow);
}

.hero-kicker {
  margin: 0 0 6px;
  font-size: 0.78rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  opacity: 0.85;
}

.hero h1 {
  margin: 0 0 10px;
  font-size: 1.85rem;
  line-height: 1.15;
}

.hero h1 span { font-weight: 400; opacity: 0.9; }

.hero-desc {
  margin: 0 0 18px;
  font-size: 0.98rem;
  opacity: 0.95;
  max-width: 52ch;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hero-actions .btn-outline {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.75);
}

.hero-actions .btn-outline:hover { background: rgba(255, 255, 255, 0.22); }

/* ---------- Stats ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px 14px;
  box-shadow: var(--shadow);
  border-left: 5px solid var(--primary);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-total { border-left-color: #0ea5e9; }
.stat-areas { border-left-color: var(--moderate); }
.stat-high  { border-left-color: var(--high); }
.stat-critical { border-left-color: var(--critical); }

.stat-num { font-size: 1.9rem; font-weight: 800; line-height: 1.1; }
.stat-label { font-size: 0.82rem; color: var(--muted); font-weight: 600; }

/* ---------- Cards / report list ---------- */
.cards { display: flex; flex-direction: column; gap: 12px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.report-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  border-left: 5px solid var(--line);
  overflow-wrap: anywhere;
}

.report-card.sev-border-low { border-left-color: var(--low); }
.report-card.sev-border-moderate { border-left-color: var(--moderate); }
.report-card.sev-border-high { border-left-color: var(--high); }
.report-card.sev-border-critical { border-left-color: var(--critical); }

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.card-top time { font-size: 0.8rem; color: var(--muted); }

.card-area {
  margin: 0 0 6px;
  font-size: 1.08rem;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.card-area .approx { font-size: 0.75rem; color: var(--muted); font-weight: 500; }

.card-meta { margin: 3px 0; font-size: 0.92rem; color: #334155; }

.card-desc { margin: 8px 0 0; font-size: 0.93rem; color: #1e293b; }

.card-photo {
  margin-top: 10px;
  border-radius: 10px;
  max-height: 220px;
  width: 100%;
  object-fit: cover;
  cursor: zoom-in;
  border: 1px solid var(--line);
}

.card-actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }

.sev-badge {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.sev-badge.sev-low { background: #dcfce7; color: #166534; }
.sev-badge.sev-moderate { background: #fef9c3; color: #854d0e; }
.sev-badge.sev-high { background: #ffedd5; color: #9a3412; }
.sev-badge.sev-critical { background: #fee2e2; color: #991b1b; }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 18px; }

.field { border: 0; padding: 0; margin: 0; min-width: 0; }

.fieldset { border: 0; padding: 0; margin: 0; }

.field label,
.label-like,
.field legend {
  display: block;
  font-weight: 700;
  font-size: 0.94rem;
  margin-bottom: 7px;
  color: var(--primary-dark);
}

.req { color: var(--accent); }
.opt { color: var(--muted); font-weight: 500; font-size: 0.85rem; }

input[type="text"],
input[type="number"],
input[type="search"],
textarea {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  font-size: 16px;              /* prevents iOS zoom */
  font-family: inherit;
  color: var(--ink);
  background: #f8fafc;
  border: 2px solid var(--line);
  border-radius: 12px;
  transition: border-color 0.15s ease;
}

textarea { resize: vertical; min-height: 90px; }

input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
}

input.invalid, textarea.invalid { border-color: var(--accent); background: #fef2f2; }

.field-error {
  margin: 6px 0 0;
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 600;
}

.file-input {
  width: 100%;
  padding: 12px;
  background: #f8fafc;
  border: 2px dashed var(--line);
  border-radius: 12px;
  font-size: 0.95rem;
}

.photo-preview {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.photo-preview img {
  max-height: 200px;
  border-radius: 10px;
  border: 1px solid var(--line);
}

/* Severity chips (radio inputs styled as big touch chips) */
.sev-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.sev-chip {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  padding: 10px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

.sev-chip input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.sev-chip span { pointer-events: none; }

.sev-chip.sev-chip-low.is-on { border-color: var(--low); background: #dcfce7; color: #166534; }
.sev-chip.sev-chip-moderate.is-on { border-color: var(--moderate); background: #fef9c3; color: #854d0e; }
.sev-chip.sev-chip-high.is-on { border-color: var(--high); background: #ffedd5; color: #9a3412; }
.sev-chip.sev-chip-critical.is-on { border-color: var(--critical); background: #fee2e2; color: #991b1b; }

/* ---------- Search & filter chips ---------- */
.search-wrap { position: relative; margin: 12px 0; }

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: #e2e8f0;
  color: #334155;
  font-size: 1rem;
  cursor: pointer;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.chip {
  min-height: 42px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: #fff;
  color: #334155;
  font-weight: 700;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
}

.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip.chip-low.active { background: var(--low); border-color: var(--low); }
.chip.chip-moderate.active { background: var(--moderate); border-color: var(--moderate); color: #422006; }
.chip.chip-high.active { background: var(--high); border-color: var(--high); }
.chip.chip-critical.active { background: var(--critical); border-color: var(--critical); }

/* ---------- Map ---------- */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 8px 0 10px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #334155;
}

.legend span { display: inline-flex; align-items: center; gap: 6px; }

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.dot-low { background: var(--low); }
.dot-moderate { background: var(--moderate); }
.dot-high { background: var(--high); }
.dot-critical { background: var(--critical); }

.big-map {
  height: 60vh;
  min-height: 320px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  z-index: 1;
}

.picker-map {
  height: 240px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  z-index: 1;
}

.map-fallback {
  background: #fff8e6;
  border: 1px solid #fde68a;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 0.94rem;
}

.map-fallback p { margin: 4px 0; }

.leaflet-container { font: inherit; }

.popup h4 { margin: 0 0 6px; font-size: 1rem; }
.popup p { margin: 5px 0; font-size: 0.88rem; }
.popup-photo { max-width: 220px; max-height: 150px; border-radius: 8px; margin-top: 6px; }
.popup .approx { color: var(--muted); font-size: 0.8rem; }

/* ---------- Dashboard bars ---------- */
.panel { margin-top: 14px; }
.section-title.tight { margin: 0 0 12px; }

.bars { display: flex; flex-direction: column; gap: 10px; }

.bar-row {
  display: grid;
  grid-template-columns: 90px 1fr 40px;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
}

.bar-label { font-weight: 700; color: #334155; overflow-wrap: anywhere; }

.bar-track {
  background: #e9eef3;
  border-radius: 999px;
  height: 14px;
  overflow: hidden;
}

.bar-fill { height: 100%; border-radius: 999px; min-width: 3px; }
.bar-val { text-align: right; font-weight: 800; color: var(--primary-dark); }

/* ---------- Empty states / success / misc ---------- */
.empty-state {
  background: #fff;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 28px 18px;
  text-align: center;
  color: var(--muted);
}

.empty-state p { margin: 0 0 14px; }
.empty-state .big { font-size: 2rem; display: block; margin-bottom: 6px; }

.success { border: 2px solid #bbf7d0; background: #f0fdf4; }
.success h2 { margin: 0 0 6px; font-size: 1.25rem; color: #166534; }
.success p { margin: 0; color: #166534; }

.noscript {
  margin: 20px;
  padding: 16px;
  background: #fee2e2;
  border-radius: 12px;
  color: #991b1b;
  font-weight: 600;
}

.app-footer {
  text-align: center;
  padding: 22px 14px 34px;
  color: var(--muted);
  font-size: 0.85rem;
}

.app-footer p { margin: 0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 3000;
  max-width: min(92vw, 460px);
  padding: 13px 20px;
  border-radius: 12px;
  color: #fff;
  font-weight: 600;
  font-size: 0.93rem;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  animation: toastIn 0.2s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.toast-success { background: #15803d; }
.toast-error { background: #b91c1c; }
.toast-info { background: #0f172a; }

/* ---------- Photo lightbox ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 4000;
  background: rgba(2, 6, 23, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal img {
  max-width: 100%;
  max-height: 84vh;
  border-radius: 10px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
}

/* ---------- Tablet & desktop ---------- */
@media (min-width: 700px) {
  .app-main { padding: 22px 22px 56px; }

  .stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

  .hero { padding: 38px 34px; }
  .hero h1 { font-size: 2.4rem; }

  .sev-group { grid-template-columns: repeat(4, minmax(0, 1fr)); }

  .big-map { height: 66vh; }

  .bar-row { grid-template-columns: 130px 1fr 44px; }
}

@media (min-width: 880px) {
  .nav-toggle { display: none; }

  .main-nav {
    display: flex;
    flex-direction: row;
    flex-basis: auto;
    gap: 4px;
    padding: 0;
  }

  .main-nav a {
    padding: 10px 14px;
    min-height: 42px;
    font-size: 0.95rem;
  }

  .main-nav a.nav-cta { border-radius: 999px; margin-left: 6px; }
}

/* Keep layout safe on very small screens */
@media (max-width: 360px) {
  .hero-actions .btn { width: 100%; }
  .stat-num { font-size: 1.6rem; }
}
