/* SolarSoiled Homeowner Dashboard — dashboard.css */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

:root {
  /* BBF forest theme (light) — keeps the original light dashboard, on brand.
     --navy is the deep-forest used both for dark chrome (nav/headers) AND as
     dark text on light cards; --gold is the bright forest accent that sits on
     that dark chrome; --gold-dk is the deeper accent for light surfaces. */
  --navy:    #1a2e1a;   /* deep forest — nav, headers, dark chrome + dark text */
  --teal:    #2d7a2d;   /* forest-700 — links / buttons / secondary accent */
  --gold:    #7ec87e;   /* forest-300 — bright accent on dark chrome */
  --gold-dk: #3d9e3d;   /* forest-500 — accent on light surfaces / hover */
  --offwhite:#f1f7f0;   /* warm off-white base */
  --border:  #dce8dc;   /* soft forest border */
  --text:    #1c241c;   /* ink */
  --muted:   #5a6b5a;   /* forest ink-soft */
  --green:   #22c55e;   /* risk traffic-light (kept saturated for the map) */
  --yellow:  #eab308;
  --red:     #ef4444;
  --radius:  8px;
  --shadow:  0 1px 4px rgba(26,46,26,.12);
  --sidebar: 340px;
}

body {
  font-family: 'Geist', system-ui, sans-serif;
  /* BBF warm off-white with faint forest washes for organic depth */
  background:
    radial-gradient(900px 460px at 92% 0%, rgba(126,200,126,.14), transparent 55%),
    radial-gradient(760px 520px at -5% 22%, rgba(61,158,61,.10), transparent 55%),
    var(--offwhite);
  color: var(--text);
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── navbar ── */
.db-nav {
  background: var(--navy);
  padding: 0 1.25rem;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  z-index: 1000;
}
.db-nav .brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  text-decoration: none;
  color: #fff;
  font-family: 'Geist', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
}
.db-nav .brand span.dot { color: var(--gold); }
.db-nav .nav-links { display: flex; gap: 1.2rem; list-style: none; }
.db-nav .nav-links a { color: #cbd5e1; text-decoration: none; font-size: .85rem; }
.db-nav .nav-links a:hover { color: #fff; }
.db-nav .btn-home {
  background: var(--gold);
  color: var(--navy);
  padding: .35rem .9rem;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  font-size: .8rem;
}

/* ── layout ── */
.dashboard-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ── sidebar ── */
.sidebar {
  width: var(--sidebar);
  flex-shrink: 0;
  min-height: 0;
  overflow-y: auto;
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  background: var(--navy);
  color: #fff;
  padding: 1rem 1.25rem .75rem;
}
.sidebar-header h2 {
  font-family: 'Geist', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: .2rem;
}
.sidebar-header p { font-size: .78rem; color: #94a3b8; }

.sidebar-section {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.sidebar-section h3 {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin-bottom: .6rem;
}

/* ── array detail card ── */
#array-detail { display: none; }
#array-detail.visible { display: block; }

.detail-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .2rem .6rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
  margin-bottom: .6rem;
}
.badge-high   { background: #fee2e2; color: #b91c1c; }
.badge-medium { background: #fef9c3; color: #92400e; }
.badge-low    { background: #dcfce7; color: #166534; }

.scores-table { font-size: .8rem; border-collapse: collapse; }
.scores-table td { padding: .15rem .3rem; }
.scores-table .lbl { color: var(--muted); }
.scores-table .val { font-weight: 700; text-align: right; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .45rem .8rem;
  font-size: .82rem;
  margin-bottom: .75rem;
}
.detail-grid .lbl { color: var(--muted); }
.detail-grid .val { font-weight: 600; }

.risk-gauge {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: .4rem;
}
.risk-gauge-fill {
  height: 100%;
  border-radius: 4px;
  transition: width .4s ease;
}

/* ── recalculate form ── */
.recalc-form { display: flex; flex-direction: column; gap: .6rem; }
.recalc-form label { font-size: .8rem; font-weight: 600; color: var(--text); }
.recalc-form input[type="date"],
.recalc-form input[type="range"] {
  width: 100%;
  padding: .4rem .6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .85rem;
}
.recalc-form .threshold-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .8rem;
  color: var(--muted);
}

/* Plain-word readout of the risk-threshold slider (e.g. "Balanced"). */
.threshold-word {
  font-weight: 700;
  color: var(--gold-dk, #D9A020);
}
.btn-recalc {
  background: var(--teal);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: .55rem 1rem;
  font-weight: 600;
  font-size: .85rem;
  cursor: pointer;
  width: 100%;
  transition: background .2s;
}
.btn-recalc:hover { background: var(--navy); }
.btn-recalc:disabled { background: var(--muted); cursor: not-allowed; }

#recalc-result {
  background: #f1f5f9;
  border-radius: 6px;
  padding: .65rem;
  font-size: .8rem;
  color: var(--text);
  display: none;
}
#recalc-result.visible { display: block; }
#recalc-result strong { display: block; margin-bottom: .2rem; }

/* ── calculator (collapsible) ── */
.calc-summary {
  font-size: .75rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: .35rem;
  margin-bottom: 0;
  padding: .1rem 0 .6rem;
  user-select: none;
}
.calc-summary::before { content: '▶'; font-size: .6rem; transition: transform .2s; }
details[open] .calc-summary::before { transform: rotate(90deg); }
.calc-summary::-webkit-details-marker { display: none; }

/* ── sidebar footer ── */
.sidebar-footer {
  padding: .6rem 1.25rem;
  font-size: .7rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: auto;
}
.sidebar-footer a { color: var(--teal); text-decoration: none; }
.sidebar-footer a:hover { text-decoration: underline; }

/* ── calculator ── */
.calc-form { display: flex; flex-direction: column; gap: .7rem; }
.calc-field { display: flex; flex-direction: column; gap: .25rem; }
.calc-field label { font-size: .8rem; font-weight: 600; }
.calc-field .input-row {
  display: flex;
  align-items: center;
  gap: .4rem;
}
.calc-field input[type="number"] {
  flex: 1;
  padding: .4rem .5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .85rem;
}
.calc-field .unit {
  font-size: .78rem;
  color: var(--muted);
  white-space: nowrap;
}

.calc-results {
  background: linear-gradient(135deg, var(--navy) 0%, var(--teal) 100%);
  border-radius: 8px;
  padding: .85rem 1rem;
  color: #fff;
  margin-top: .25rem;
}
.calc-results .result-row {
  display: flex;
  justify-content: space-between;
  font-size: .82rem;
  padding: .2rem 0;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.calc-results .result-row:last-child { border-bottom: none; }
.calc-results .result-row .val {
  font-weight: 700;
  color: var(--gold);
}
.calc-note {
  font-size: .72rem;
  color: var(--muted);
  margin-top: .4rem;
}

/* ── stats overview ── */
.stat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}
.stat-chip {
  background: var(--offwhite);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: .25rem .7rem;
  font-size: .78rem;
  display: flex;
  gap: .35rem;
}
.stat-chip .chip-val { font-weight: 700; color: var(--navy); }
.stat-chip .chip-lbl { color: var(--muted); }

/* ── model tab bar ── */
.model-tabs {
  display: flex;
  background: var(--navy);
  border-bottom: 2px solid var(--teal);
  flex-shrink: 0;
  overflow-x: auto;
}
.model-tab {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  transition: color .15s, border-color .15s;
  font-family: 'Geist', system-ui, sans-serif;
}
.model-tab:hover { color: #e2e8f0; }
.model-tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}
.model-tab .tab-icon { font-size: .95rem; }
.model-tab .tab-sub {
  font-weight: 400;
  color: inherit;
  opacity: .7;
}

/* ── map ── */
#map {
  flex: 1;
  min-height: 0;
  z-index: 1;
}

/* ── loading overlay ── */
#map-loading {
  position: absolute;
  inset: 0;
  background: rgba(15,32,39,.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  z-index: 9999;
  font-size: .9rem;
  gap: .6rem;
  pointer-events: none;
}
#map-loading.hidden { display: none; }
.spinner {
  width: 30px; height: 30px;
  border: 3px solid rgba(255,255,255,.3);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── map legend ── */
.map-legend {
  background: #fff;
  border-radius: 6px;
  padding: .5rem .75rem;
  font-size: .75rem;
  box-shadow: var(--shadow);
  line-height: 1.6;
}
.map-legend h4 { font-size: .72rem; color: var(--muted); margin-bottom: .25rem; text-transform: uppercase; letter-spacing: .05em; }
.legend-row { display: flex; align-items: center; gap: .4rem; }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }

/* ── highlight pulse on QR land ── */
@keyframes pulse-outline {
  0%   { stroke-opacity: 1; stroke-width: 4; }
  50%  { stroke-opacity: .3; stroke-width: 8; }
  100% { stroke-opacity: 1; stroke-width: 4; }
}
.qr-highlight path,
path.qr-highlight { animation: pulse-outline 1.5s ease-in-out 3; }

/* Mailer "my home" marker — continuous pulse so the recipient's house stands out
   against the dimmed background after a postcard QR scan. */
path.mailer-home-pulse { animation: pulse-outline 1.6s ease-in-out infinite; }

/* ── impact card (hero numbers) ── */
#impact-card {
  background: linear-gradient(135deg, var(--navy) 0%, var(--teal) 100%);
  color: #fff;
  padding: 1rem 1.25rem .85rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.impact-header {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  margin-bottom: .6rem;
}
.impact-header #impact-label {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: rgba(255,255,255,.55);
  font-weight: 600;
}
.impact-header #impact-array-tag {
  font-size: .75rem;
  color: var(--gold);
  font-weight: 700;
}
.impact-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: .82rem;
  padding: .22rem 0;
  border-bottom: 1px solid rgba(255,255,255,.08);
  color: rgba(255,255,255,.8);
}
.impact-row:last-of-type { border-bottom: none; }
.impact-row.primary {
  font-size: .9rem;
  font-weight: 600;
  color: #fff;
  padding: .3rem 0 .35rem;
  border-bottom: 1px solid rgba(255,255,255,.15);
  margin-bottom: .1rem;
}
.impact-row .val {
  font-weight: 700;
  color: var(--gold);
  font-size: inherit;
}
.impact-row.primary .val {
  font-size: 1.35rem;
  letter-spacing: -.02em;
}
.impact-note {
  font-size: .7rem;
  color: rgba(255,255,255,.4);
  margin-top: .55rem;
}

/* ── area loss banner ── */
#area-loss-banner { background: #fff; }

.area-loss-agg { display: flex; flex-direction: column; gap: .3rem; }

.area-loss-total {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -.02em;
  line-height: 1.2;
}
.area-loss-total .loss-range { color: var(--red); }
.area-loss-total .loss-per-yr {
  font-size: .72rem;
  font-weight: 400;
  color: var(--muted);
  margin-left: .15rem;
}

.area-loss-sub {
  font-size: .74rem;
  color: var(--muted);
  line-height: 1.45;
}
.area-loss-high-row {
  display: flex;
  align-items: flex-start;
  gap: .35rem;
  font-size: .78rem;
  color: var(--text);
  background: #fee2e2;
  border-radius: 6px;
  padding: .3rem .55rem;
  margin-top: .15rem;
}
.area-loss-cta {
  font-size: .72rem;
  color: var(--muted);
  margin-top: .1rem;
}

.area-loss-array { display: flex; flex-direction: column; gap: .3rem; }
.loss-headline {
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.3;
}
.loss-headline .loss-val { color: var(--red); }
.loss-reco {
  font-size: .76rem;
  color: var(--text);
  line-height: 1.45;
}
.area-loss-back {
  background: none;
  border: none;
  color: var(--teal);
  font-size: .72rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-align: left;
  margin-top: .1rem;
}

/* ── map search bar ── */
#map-search-bar {
  display: flex;
  background: #1e3d20;
  padding: .45rem .75rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
  gap: 0;
  align-items: center;
}
#search-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  min-width: 0;
}
#search-input {
  flex: 1;
  padding: .4rem .7rem;
  font-size: .82rem;
  border: none;
  border-radius: 6px 0 0 6px;
  background: rgba(255,255,255,.13);
  color: #fff;
  outline: none;
  font-family: inherit;
  min-width: 0;
}
#search-input::placeholder { color: #94a3b8; }
#search-input:focus { background: rgba(255,255,255,.22); }

/* suggestions dropdown */
#search-suggestions {
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  right: 0;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,.22);
  list-style: none;
  z-index: 10000;
  overflow: hidden;
}
#search-suggestions li {
  padding: .45rem .75rem;
  font-size: .79rem;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .1s;
}
#search-suggestions li:last-child { border-bottom: none; }
#search-suggestions li:hover,
#search-suggestions li.active { background: var(--offwhite); }
#search-suggestions.hidden { display: none; }
#search-btn {
  padding: .4rem .8rem;
  background: var(--gold);
  color: var(--navy);
  border: none;
  border-radius: 0 6px 6px 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  flex-shrink: 0;
}
#search-btn:hover  { background: #3d9e3d; }
#search-btn:disabled { background: var(--muted); cursor: not-allowed; }
#fit-btn {
  padding: .4rem .7rem;
  background: rgba(255,255,255,.13);
  color: #cbd5e1;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 6px;
  cursor: pointer;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
  font-family: inherit;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
#fit-btn:hover { background: rgba(255,255,255,.22); color: #fff; }

.search-callout {
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
  padding: .4rem .75rem;
  font-size: .78rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  flex-shrink: 0;
}
.search-callout a { color: var(--teal); font-weight: 600; }
.search-callout.hidden { display: none; }
#search-dismiss {
  background: none;
  border: none;
  cursor: pointer;
  font-size: .9rem;
  color: var(--muted);
  padding: 0 .2rem;
  flex-shrink: 0;
  line-height: 1;
}

/* ── search pin marker ── */
.search-pin { background: transparent !important; border: none !important; }
.search-pin-dot {
  width: 18px;
  height: 18px;
  background: #3b82f6;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,.45);
}

/* ── weather widget (Leaflet control) ── */
.weather-widget {
  background: #fff;
  border-radius: 6px;
  padding: .5rem .75rem;
  font-size: .72rem;
  box-shadow: var(--shadow);
  line-height: 1.6;
  min-width: 155px;
}
.ww-title {
  font-weight: 700;
  font-size: .74rem;
  color: var(--navy);
  margin-bottom: .1rem;
}
.ww-loading { font-size: .7rem; color: var(--muted); }
.ww-row {
  display: flex;
  justify-content: space-between;
  gap: .6rem;
  color: var(--text);
}
.ww-advisory { margin-top: .2rem; font-size: .7rem; font-weight: 600; }
.ww-advisory.warn { color: #b45309; }
.ww-advisory.good { color: #166534; }


/* ── responsive ── */
@media (max-width: 768px) {
  .dashboard-layout { flex-direction: column; height: auto; }
  .sidebar { width: 100%; height: auto; overflow-y: visible; }
  #map { height: 60vw; min-height: 300px; }
  .db-nav .nav-links { display: none; }
}
