/* ============================================================
   GoneFishing – Outdoor/nature dark theme
   IBM Plex Sans · Tre fjellvann demo
   ============================================================ */

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

:root {
  --bg:        #0f1a12;
  --surface:   #162118;
  --surface2:  #1e2e21;
  --border:    #2d3f2f;
  --text:      #d4e8d4;
  --muted:     #7a9e7e;
  --accent:    #4caf6e;
  --accent2:   #2e86ab;
  --warn:      #e8a020;
  --danger:    #c0392b;
  --good:      #27ae60;
  --fair:      #e8a020;
  --poor:      #c0392b;
  --info:      #2e86ab;
  --radius:    8px;
  --shadow:    0 2px 8px rgba(0,0,0,0.5);
}

html, body {
  height: 100%;
  font-family: 'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
}

/* ── Header ─────────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-icon { font-size: 1.7rem; line-height: 1; }
header h1 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
}
header .subtitle {
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
}
.lake-chips { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 0.75rem;
  color: var(--accent);
}
.river-chip {
  color: var(--accent2);
  border-color: var(--accent2);
}

/* ── Location selector ───────────────────────────────────── */
#location-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.loc-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 22px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
  font-family: inherit;
}
.loc-btn:hover          { border-color: var(--accent);  color: var(--accent); }
.loc-btn.river-btn:hover{ border-color: var(--accent2); color: var(--accent2); }
.loc-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0f1a12;
  font-weight: 600;
}
.loc-btn.river-btn.active {
  background: var(--accent2);
  border-color: var(--accent2);
  color: #fff;
}
.loc-btn .btn-elev {
  font-size: 0.72rem;
  opacity: 0.75;
  margin-left: 2px;
}
.loc-btn.active .btn-elev { opacity: 0.7; }

/* ── Offline banner ───────────────────────────────────────── */
#offline-banner {
  display: none;
  background: var(--warn);
  color: #1a1000;
  padding: 8px 16px;
  font-size: 0.83rem;
  font-weight: 500;
  text-align: center;
}
#offline-banner.visible { display: block; }
#offline-banner code { background: rgba(0,0,0,.15); border-radius:4px; padding:1px 6px; font-size:.8rem; }

/* ── Main layout ─────────────────────────────────────────── */
#main {
  display: grid;
  grid-template-columns: 1fr 390px;
  height: calc(100vh - 112px);
  gap: 0;
}

/* ── Map ─────────────────────────────────────────────────── */
#map-container {
  grid-column: 1;
  position: relative;
  /* Eksplisitt høyde nødvendig – Leaflet krever dette */
  height: calc(100vh - 112px);
}
#map {
  width: 100%;
  height: 100%;
  min-height: 300px;
}

/* ── Side panel ───────────────────────────────────────────── */
#side-panel {
  grid-column: 2;
  overflow-y: auto;
  background: var(--bg);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* ── Panel cards ─────────────────────────────────────────── */
.panel-card {
  border-bottom: 1px solid var(--border);
  padding: 12px 14px;
}
.panel-card h2 {
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.panel-card h2 .badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge.good  { background: var(--good);   color: #fff; }
.badge.fair  { background: var(--fair);   color: #1a1000; }
.badge.poor  { background: var(--danger); color: #fff; }

/* ── Alert boxes ─────────────────────────────────────────── */
.alert-box {
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 0.8rem;
  margin-bottom: 8px;
  font-weight: 500;
}
.alert-box.danger { background: rgba(192,57,43,.18); border-left:3px solid var(--danger); color: #e08070; }
.alert-box.warn   { background: rgba(232,160,32,.15); border-left:3px solid var(--warn);   color: var(--warn); }
.alert-box.info   { background: rgba(46,134,171,.15); border-left:3px solid var(--info);   color: var(--accent2); }

/* ── Info card ───────────────────────────────────────────── */
#info-card .loc-name {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 2px;
}
#info-card .loc-name.river { color: var(--accent2); }
#info-card .loc-meta {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}
#info-card .loc-desc {
  font-size: 0.86rem;
  color: var(--text);
  margin-bottom: 8px;
}
.meta-link {
  color: var(--accent2);
  font-size: 0.75rem;
  text-decoration: none;
  border: 1px solid var(--accent2);
  padding: 1px 7px;
  border-radius: 10px;
}
.meta-link:hover { background: var(--accent2); color: #fff; }
.info-extra {
  margin: 6px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.info-extra-row {
  font-size: 0.8rem;
  display: flex;
  gap: 6px;
  align-items: flex-start;
}
.info-extra-label {
  color: var(--muted);
  min-width: 90px;
  flex-shrink: 0;
  font-weight: 500;
}

/* ── Inatur fiskekort-knapp ──────────────────────────────── */
.inatur-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--accent);
  color: #0f1a12;
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
  box-shadow: var(--shadow);
}
.inatur-btn:hover { background: #5dcf84; transform: translateY(-1px); }

/* ── Weather panel ───────────────────────────────────────── */
.weather-now {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 10px;
}
.weather-now .temp-big {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  flex-shrink: 0;
}
.weather-now .weather-details {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.75;
}
.forecast-row {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.forecast-hour {
  flex: 0 0 50px;
  text-align: center;
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 5px 3px;
  font-size: 0.72rem;
}
.forecast-hour .fh-time { color: var(--muted); margin-bottom: 1px; }
.forecast-hour .fh-temp { font-weight: 600; color: var(--text); }
.forecast-hour .fh-wind { color: var(--muted); font-size: 0.67rem; }
.forecast-hour .fh-icon { font-size: 1rem; margin: 2px 0; }
.timestamp { font-size: 0.7rem; color: var(--muted); margin-top: 6px; }

/* ── Sunrise / fishing window panel ──────────────────────── */
.sun-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.sun-item {
  flex: 1;
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 8px 6px;
  text-align: center;
}
.sun-icon { font-size: 1.3rem; line-height: 1; margin-bottom: 3px; }
.sun-time { font-size: 1rem; font-weight: 700; color: var(--text); }
.sun-label { font-size: 0.7rem; color: var(--muted); }

.fishing-windows { margin-top: 4px; }
.fw-title {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.fw-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
  flex-wrap: wrap;
  font-size: 0.8rem;
}
.fw-badge {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.fw-badge.morning { background: rgba(76,175,110,.2); color: var(--accent); border: 1px solid var(--accent); }
.fw-badge.evening { background: rgba(232,160,32,.2); color: var(--warn); border: 1px solid var(--warn); }
.fw-time { font-weight: 600; color: var(--text); white-space: nowrap; }
.fw-tip { font-size: 0.75rem; color: var(--muted); }

/* ── Water temperature panel ─────────────────────────────── */
.wt-now {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.wt-val {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}
.wt-info { font-size: 0.82rem; }
.wt-label { font-weight: 600; color: var(--text); margin-bottom: 1px; }
.wt-sub { font-size: 0.75rem; color: var(--muted); }
.wt-trend {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}
.wt-trend-item {
  flex: 1;
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 4px 6px;
  text-align: center;
}
.wt-trend-time { font-size: 0.68rem; color: var(--muted); }
.wt-trend-val { font-size: 0.9rem; font-weight: 600; }
.wt-note { font-size: 0.72rem; color: var(--muted); line-height: 1.5; margin: 4px 0; }

/* ── Water / discharge panel ────────────────────────────── */
.discharge-now {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.discharge-val {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}
.discharge-val.low    { color: var(--accent2); }
.discharge-val.normal { color: var(--accent);  }
.discharge-val.high   { color: var(--warn);    }
.discharge-val.flood  { color: var(--danger);  }
.discharge-label {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.6;
}
.sparkline-wrap {
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 8px;
  margin-bottom: 6px;
}
.sparkline-wrap svg { display: block; width: 100%; overflow: visible; }
.water-advice { margin-top: 2px; }

/* ── 7-day forecast table ────────────────────────────────── */
.fc7-table { display: flex; flex-direction: column; gap: 2px; }
.fc7-row {
  display: grid;
  grid-template-columns: 46px 22px 46px 50px 50px 36px auto;
  align-items: center;
  gap: 4px;
  padding: 5px 6px;
  border-radius: var(--radius);
  background: var(--surface2);
  font-size: 0.78rem;
}
.fc7-today { border-left: 3px solid var(--accent); }
.fc7-day   { color: var(--text); font-weight: 500; white-space: nowrap; }
.fc7-icon  { font-size: 1rem; text-align: center; }
.fc7-temp  { display: flex; gap: 4px; align-items: baseline; }
.fc7-tmax  { color: var(--text); font-weight: 600; }
.fc7-tmin  { color: var(--muted); font-size: .7rem; }
.fc7-precip{ color: var(--accent2); }
.fc7-wind  { color: var(--muted); }
.fc7-uv    { color: var(--warn); font-size: .7rem; }
.fc7-score { display: flex; justify-content: flex-end; }

/* ── Tips panel ──────────────────────────────────────────── */
.tips-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.tips-list li {
  font-size: 0.83rem;
  padding: 6px 10px;
  background: var(--surface2);
  border-radius: var(--radius);
  border-left: 3px solid var(--accent);
  line-height: 1.5;
}
.tips-list li.tip-dynamic { border-left-color: var(--warn); }

/* ── Spots panel ─────────────────────────────────────────── */
.spots-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.spot-item {
  font-size: 0.82rem;
  padding: 7px 10px;
  background: var(--surface2);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.12s;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.spot-item:hover { background: var(--border); }
.spot-item strong { color: var(--accent); font-size: 0.84rem; }
.spot-item span { color: var(--muted); font-size: 0.79rem; line-height: 1.45; }

/* ── Loading spinner ─────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  padding: 8px 0;
}
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Footer ──────────────────────────────────────────────── */
footer {
  padding: 8px 16px;
  font-size: 0.7rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: center;
}
footer a { color: var(--muted); text-decoration: underline; }
footer a:hover { color: var(--accent); }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  #main {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }
  #map-container {
    height: 320px !important;
  }
  #map {
    height: 320px !important;
    min-height: 320px;
  }
  #side-panel {
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: none;
  }
  header h1 { font-size: 1rem; }
  .lake-chips { display: none; }
  .fc7-row {
    grid-template-columns: 40px 20px 40px 44px 44px 32px auto;
    font-size: 0.72rem;
  }
}

/* Ekstra liten skjerm (320–480px) */
@media (max-width: 480px) {
  #map-container {
    height: 260px !important;
  }
  #map {
    height: 260px !important;
    min-height: 260px;
  }
  .weather-now .temp-big { font-size: 1.8rem; }
  .fc7-row { grid-template-columns: 36px 18px 36px 42px 42px 0 auto; }
  .fc7-uv  { display: none; }
}

/* ── Leaflet popup overrides ─────────────────────────────── */
.leaflet-popup-content-wrapper {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.leaflet-popup-tip { background: var(--surface2); }
.leaflet-popup-content { font-size: 0.84rem; line-height: 1.5; }
.leaflet-popup-content strong { color: var(--accent); }
