/* FloodWatch Thailand — mobile-first styles */
:root {
  --fw-primary: #0b5ed7;
  --fw-surface: #ffffff;
  --fw-ink: #1f2937;
  --fw-muted: #6b7280;
  --fw-radius: 16px;
  --fw-safe-bottom: env(safe-area-inset-bottom, 0px);
  --fw-touch: 48px;
  --fw-topbar-h: 64px;
  --bs-font-sans-serif: "Noto Sans Thai", "Sarabun", "Leelawadee UI", "Thonburi", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

html, body { height: 100%; }
body { color: var(--fw-ink); background: #f5f7fa; -webkit-tap-highlight-color: transparent; }
.min-w-0 { min-width: 0; }
.fw-skip-link { position: absolute; z-index: 2000; top: 8px; left: 8px; background: #fff; padding: 8px 12px; border-radius: 8px; }

/* ---------- Map page layout ---------- */
.fw-map-page { overflow: hidden; overscroll-behavior: none; }
.fw-app { position: fixed; inset: 0; }
.fw-map { position: absolute; inset: 0; z-index: 1; background: #dfe7ef; }

.fw-topbar { position: absolute; z-index: 1000; top: 0; left: 0; right: 0; padding: max(8px, env(safe-area-inset-top)) 8px 0; pointer-events: none; }
.fw-topbar > * { pointer-events: auto; }
.fw-topbar-inner { display: flex; align-items: center; gap: 6px; max-width: 920px; margin: 0 auto; }
.fw-brand img { display: block; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.2); }

.fw-icon-btn { width: var(--fw-touch); height: var(--fw-touch); display: inline-flex; align-items: center; justify-content: center; border-radius: 14px; box-shadow: 0 1px 4px rgba(0,0,0,.18); font-size: 1.25rem; flex: 0 0 auto; }
.fw-icon-btn.active { color: var(--fw-primary); }

.fw-search .form-control { height: var(--fw-touch); padding-left: 2.6rem; border-radius: 14px; border: 0; box-shadow: 0 1px 4px rgba(0,0,0,.18); font-size: 1rem; }
.fw-search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--fw-muted); z-index: 2; }
.fw-search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; max-height: 60vh; overflow-y: auto; border-radius: 14px; z-index: 1100; }
.fw-search-item { display: flex; align-items: center; min-height: var(--fw-touch); cursor: pointer; }

/* ---------- Banners ---------- */
.fw-banners { max-width: 920px; margin: 8px auto 0; display: grid; gap: 6px; }
.fw-banner { border-radius: 14px; padding: 10px 12px; box-shadow: 0 2px 8px rgba(0,0,0,.18); font-size: .9rem; }
.fw-banner-official { background: #0b3d91; color: #fff; border-left: 6px solid #ffd43b; }
.fw-banner-official[data-severity="Emergency"] { background: #7f1d1d; }
.fw-banner-official .fw-banner-link { color: #ffe066; }
.fw-banner-community { background: #fff7e6; color: #5c3b00; border: 1px dashed #f59f00; }
.fw-banner-kicker { font-size: .75rem; font-weight: 600; text-transform: none; opacity: .9; }
.fw-banner-title { font-weight: 700; }
.fw-banner-sub { font-size: .85rem; }
.fw-banner-disclaimer { font-size: .72rem; opacity: .85; margin-top: 2px; }
.fw-banner .btn-close { padding: .6rem; margin: -.4rem -.3rem 0 0; }
@media (max-width: 575.98px) {
  /* Compact on phones so the map stays visible */
  .fw-banner { padding: 8px 10px; font-size: .8rem; }
  .fw-banner .bi.fs-5 { font-size: 1rem !important; }
  .fw-banner-kicker { font-size: .68rem; }
  .fw-banner-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .fw-banner-sub { display: none; }
  .fw-banner-disclaimer { font-size: .66rem; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
}

/* ---------- Map controls ---------- */
.fw-map-controls { position: absolute; z-index: 900; right: 10px; bottom: calc(150px + var(--fw-safe-bottom)); display: grid; gap: 8px; }
.fw-fab-mini { width: 52px; height: 52px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 1.35rem; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.leaflet-top.leaflet-right { top: calc(var(--fw-topbar-h) + 8px); }
.leaflet-control-attribution { font-size: 10px; }
.leaflet-bottom.leaflet-right { bottom: calc(118px + var(--fw-safe-bottom)); }
@media (max-width: 575.98px) { .leaflet-control-zoom { display: none; } }

.fw-loading { position: absolute; z-index: 950; left: 50%; top: calc(var(--fw-topbar-h) + 16px); transform: translateX(-50%); background: rgba(17,24,39,.85); color: #fff; padding: 6px 14px; border-radius: 999px; font-size: .85rem; }

/* ---------- Bottom: FAB + summary ---------- */
.fw-bottom { position: absolute; z-index: 950; left: 0; right: 0; bottom: 0; padding: 0 10px calc(10px + var(--fw-safe-bottom)); display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.fw-bottom > * { pointer-events: auto; }
.fw-fab { border-radius: 999px; padding: 14px 26px; font-weight: 700; font-size: 1.1rem; min-height: 56px; box-shadow: 0 6px 18px rgba(11,94,215,.45) !important; }
.fw-summary { width: 100%; max-width: 560px; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--fw-surface); border-radius: var(--fw-radius); padding: 8px 4px; }
.fw-summary-item { display: flex; flex-direction: column; align-items: center; line-height: 1.15; color: inherit; }
.fw-summary-value { font-size: 1.2rem; font-weight: 700; }
.fw-summary-label { font-size: .7rem; color: var(--fw-muted); }

/* ---------- Markers ---------- */
.fw-marker-wrap { background: none; border: 0; }
.fw-marker { position: relative; width: 40px; height: 40px; border-radius: 50%; background: var(--fw-c); color: var(--fw-t); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; transition: transform .12s; }
.fw-marker:hover { transform: scale(1.1); }
.fw-marker.is-stale { border-style: dashed; border-color: #6b7280; }
.fw-marker-trend { position: absolute; top: -8px; right: -8px; background: #fff; color: #111; width: 18px; height: 18px; border-radius: 50%; font-size: 12px; line-height: 18px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.fw-marker-warn { position: absolute; bottom: -6px; right: -6px; background: #ffc107; color: #000; width: 16px; height: 16px; border-radius: 50%; font-size: 11px; line-height: 16px; text-align: center; font-weight: 900; }
.fw-cluster-wrap { background: none; border: 0; }
.fw-cluster { width: 100%; height: 100%; border-radius: 50%; background: var(--fw-c); color: var(--fw-t); display: flex; align-items: center; justify-content: center; font-weight: 800; border: 4px solid rgba(255,255,255,.85); box-shadow: 0 0 0 4px color-mix(in srgb, var(--fw-c) 35%, transparent), 0 2px 6px rgba(0,0,0,.3); }
.fw-probe-wrap { background: none; border: 0; }
.fw-probe { font-size: 32px; color: #dc3545; filter: drop-shadow(0 2px 2px rgba(0,0,0,.4)); }

/* ---------- Pin mode ---------- */
.fw-pin-overlay { position: absolute; z-index: 960; left: 50%; top: 50%; transform: translate(-50%, -100%); pointer-events: none; text-align: center; }
.fw-pin-icon { font-size: 48px; color: #dc3545; filter: drop-shadow(0 3px 3px rgba(0,0,0,.4)); display: block; }
.fw-pin-shadow { display: block; width: 14px; height: 6px; margin: -6px auto 0; background: rgba(0,0,0,.35); border-radius: 50%; }
.fw-pin-bar { position: absolute; z-index: 1001; left: 10px; right: 10px; bottom: calc(10px + var(--fw-safe-bottom)); max-width: 560px; margin: 0 auto; background: #fff; border-radius: var(--fw-radius); padding: 12px; box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.fw-pinning .fw-bottom, .fw-pinning .fw-map-controls, .fw-pinning .fw-banners { display: none; }

/* ---------- Bottom sheets ---------- */
.fw-sheet.offcanvas-bottom { height: auto; max-height: 82vh; border-top-left-radius: 20px; border-top-right-radius: 20px; padding-bottom: var(--fw-safe-bottom); }
.fw-sheet.fw-sheet-tall { max-height: 92vh; }
.fw-sheet .offcanvas-body { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.fw-sheet-handle { width: 44px; height: 5px; border-radius: 3px; background: #ced4da; margin: 8px auto 0; }
@media (min-width: 768px) {
  .fw-sheet.offcanvas-bottom { left: auto; right: 16px; bottom: 16px; width: 440px; max-height: calc(100vh - 110px); border-radius: 20px; border: 0; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
  .fw-sheet-handle { display: none; }
  .fw-map-controls { bottom: 130px; }
}

.fw-section-title { font-size: .95rem; font-weight: 700; margin: 0 0 .5rem; }
.fw-choice { display: flex; align-items: center; gap: 14px; text-align: left; padding: 14px 16px; border-radius: 14px; }

/* chips (quick select) */
.fw-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.fw-chip { min-height: 44px; padding: 8px 14px; border-radius: 999px; border: 1px solid #ced4da; background: #fff; color: var(--fw-ink); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.fw-chip.is-active { border-color: var(--fw-primary); background: #e7f0ff; color: var(--fw-primary); box-shadow: inset 0 0 0 1px var(--fw-primary); }
.fw-chip-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--fw-c); border: 1px solid rgba(0,0,0,.15); }
.fw-chip-sm { min-height: 36px; padding: 4px 12px; font-weight: 500; font-size: .85rem; }
.fw-stepper .btn { min-width: 56px; }
.fw-stepper input { font-size: 1.5rem; font-weight: 700; }
.fw-location-chip { background: #f1f3f5; border-radius: 12px; padding: 10px 12px; font-size: .9rem; }
.fw-sticky-actions { position: sticky; bottom: 0; background: var(--bs-body-bg); padding-top: 8px; padding-bottom: 4px; }

/* depth/severity badges */
.fw-depth-pill { display: inline-block; background: var(--fw-c); color: var(--fw-t); border-radius: 999px; padding: 4px 12px; font-weight: 700; font-size: .85rem; white-space: nowrap; }
.fw-detail-head { display: flex; gap: 14px; align-items: center; }
.fw-depth-badge { flex: 0 0 auto; width: 84px; height: 84px; border-radius: 20px; background: var(--fw-c); color: var(--fw-t); display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.fw-depth-value { font-size: 2rem; font-weight: 800; line-height: 1; }
.fw-depth-unit { font-size: .8rem; font-weight: 600; }
.fw-severity-label { font-weight: 700; font-size: 1.05rem; }
.fw-trend { font-weight: 600; }
.fw-trend-symbol { font-size: 1.3rem; margin-right: 2px; }
.fw-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin: 0 0 12px; }
.fw-facts dt { font-size: .75rem; color: var(--fw-muted); font-weight: 500; }
.fw-facts dd { margin: 0; font-weight: 600; font-size: .92rem; }
.fw-note { background: #f8f9fa; border-left: 4px solid #adb5bd; border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; white-space: pre-line; overflow-wrap: anywhere; }
.fw-detail-actions { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 400px) { .fw-detail-actions { grid-template-columns: 1fr 1fr; } .fw-detail-actions > :first-child { grid-column: 1 / -1; } }
.fw-panel { border-top: 1px solid #dee2e6; padding-top: 12px; margin-top: 4px; }
.fw-verify-option { display: block; }

/* sparkline */
.fw-spark svg { width: 100%; height: 64px; display: block; }
.fw-spark-base { stroke: #dee2e6; stroke-width: 1; }
.fw-spark-line { fill: none; stroke: #2563eb; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.fw-spark-dot { fill: #2563eb; stroke: #fff; stroke-width: 2; }

/* vehicle risk */
.fw-risk { background: #f8f9fa; border-radius: 14px; padding: 12px; }
.fw-risk-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid #e9ecef; }
.fw-risk-row:last-child { border-bottom: 0; }
.fw-risk-icon { font-size: 1.4rem; width: 32px; text-align: center; color: #495057; }
.fw-risk-name { font-weight: 600; }
.fw-risk-advice { font-size: .78rem; color: var(--fw-muted); }
.fw-risk-badge { flex: 0 0 auto; background: var(--fw-c); color: #fff; border-radius: 10px; padding: 4px 10px; font-weight: 700; font-size: .82rem; text-align: center; line-height: 1.15; }
.fw-risk-badge small { display: block; font-weight: 500; font-size: .68rem; opacity: .9; }
.fw-disclaimer { font-size: .78rem; color: #664d03; background: #fff3cd; border-radius: 10px; padding: 8px 10px; }

/* legend */
.fw-legend-item { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 10px; padding: 6px 0; }
.fw-legend-swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #ced4da; display: inline-flex; align-items: center; justify-content: center; }
.fw-legend-stale { background: #adb5bd; opacity: .5; border-style: dashed; color: #000; font-weight: 900; }

/* ---------- Content pages ---------- */
.fw-page { padding-bottom: 4rem; }
.fw-prose { max-width: 760px; }
.fw-kpi { background: #fff; border-radius: var(--fw-radius); padding: 14px 16px; height: 100%; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.fw-kpi-label { font-size: .78rem; color: var(--fw-muted); font-weight: 600; }
.fw-kpi-value { font-size: 2rem; font-weight: 800; line-height: 1.1; color: var(--fw-ink); font-variant-numeric: tabular-nums; }
.fw-kpi-sub { font-size: .75rem; color: var(--fw-muted); }
.fw-card { background: #fff; border-radius: var(--fw-radius); padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.06); height: 100%; }
.fw-card-title { font-size: 1rem; font-weight: 700; margin-bottom: 12px; }
.fw-chart { position: relative; height: 260px; }
.fw-chart-tall { height: 340px; }
.fw-toasts { z-index: 2000; }

/* ---------- Geolocation loading overlay ---------- */
.fw-geo-loading { position: fixed; inset: 0; z-index: 1990; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(17, 24, 39, .45); backdrop-filter: blur(2px); animation: fw-fade-in .15s ease-out; }
.fw-geo-card { width: 100%; max-width: 360px; background: #fff; border-radius: 20px; padding: 24px 20px 20px; text-align: center; box-shadow: 0 12px 32px rgba(0,0,0,.3); }
.fw-geo-pulse { position: relative; width: 72px; height: 72px; margin: 0 auto 14px; border-radius: 50%; background: #e7f0ff; color: var(--fw-primary); display: flex; align-items: center; justify-content: center; font-size: 2rem; }
.fw-geo-pulse::before, .fw-geo-pulse::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 3px solid var(--fw-primary); opacity: 0; animation: fw-pulse 1.6s ease-out infinite; }
.fw-geo-pulse::after { animation-delay: .8s; }
.fw-geo-title { font-weight: 700; font-size: 1.1rem; }
.fw-geo-sub { font-size: .88rem; color: var(--fw-muted); margin-top: 4px; min-height: 1.3em; }
.fw-geo-hint { font-size: .82rem; color: #664d03; background: #fff3cd; border-radius: 10px; padding: 8px 10px; margin-top: 12px; }
.fw-locating #btn-locate, .fw-locating #loc-current { pointer-events: none; opacity: .6; }
@keyframes fw-pulse { 0% { transform: scale(1); opacity: .7; } 100% { transform: scale(1.9); opacity: 0; } }
@keyframes fw-fade-in { from { opacity: 0; } to { opacity: 1; } }
.fw-copyright { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; padding: 16px 12px calc(16px + var(--fw-safe-bottom)); font-size: .8rem; color: var(--fw-muted); text-align: center; }
.offcanvas .fw-copyright { padding: 12px 0 0; justify-content: flex-start; text-align: left; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
