/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w: 320px;
  --bg: #ffffff;
  --bg-translucent: rgba(255, 255, 255, 0.96);
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;
  --excellent: #059669;
  --good: #10b981;
  --adequate: #f59e0b;
  --poor: #ef4444;
  --unknown: #9ca3af;
  --radius: 8px;
}

html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--text); }

/* ── Map ─────────────────────────────────────────────────── */
#map {
  position: absolute;
  inset: 0;
  z-index: 0;
}

/* ── Sidebar ─────────────────────────────────────────────── */
#sidebar {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100%;
  background: var(--bg-translucent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-right: 1px solid var(--border);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: transform 0.3s ease;
}

#sidebar.collapsed {
  transform: translateX(calc(-1 * var(--sidebar-w)));
}

.sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sidebar-header .subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.sidebar-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-section h2 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* Stats */
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
}

.stat-label { font-size: 0.85rem; color: var(--text-muted); }
.stat-value { font-size: 0.85rem; font-weight: 600; }
.stat-time  { font-size: 0.75rem; font-weight: 500; }

/* Conditions grid */
.conditions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.condition-card {
  background: #f8fafc;
  border-radius: var(--radius);
  padding: 10px 8px;
  text-align: center;
}

.condition-icon { font-size: 1.2rem; margin-bottom: 2px; }
.condition-value { font-size: 0.95rem; font-weight: 700; line-height: 1.2; }
.condition-label { font-size: 0.68rem; color: var(--text-muted); margin-top: 1px; }

.conditions-note {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 6px;
  font-style: italic;
}

/* Legend */
.legend { display: flex; flex-direction: column; gap: 6px; }

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-excellent { background: var(--excellent); }
.dot-good      { background: var(--good); }
.dot-adequate  { background: var(--adequate); }
.dot-poor      { background: var(--poor); }
.dot-unknown   { background: var(--unknown); }

/* Alerts */
#alerts-list {
  list-style: none;
  max-height: 200px;
  overflow-y: auto;
}

#alerts-list li {
  padding: 8px 10px;
  margin-bottom: 4px;
  background: #fef2f2;
  border-left: 3px solid var(--poor);
  border-radius: 4px;
  font-size: 0.82rem;
}

#alerts-list li .alert-beach {
  font-weight: 600;
  display: block;
  margin-bottom: 2px;
}

/* Filters */
.filter-group {
  margin-bottom: 8px;
}

.filter-group label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  margin-right: 12px;
  cursor: pointer;
}

.filter-group input[type="text"] {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.82rem;
  outline: none;
}

.filter-group input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

/* Footer */
.sidebar-footer {
  margin-top: auto;
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

.sidebar-footer a { color: var(--accent); text-decoration: none; }
.sidebar-footer a:hover { text-decoration: underline; }

#sidebar-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Sidebar reopen button */
#sidebar-open {
  display: none;
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1001;
  background: var(--bg-translucent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  transition: opacity 0.3s ease;
}

#sidebar-open.visible {
  display: block;
}

/* ── Leaflet popup ───────────────────────────────────────── */
.beach-popup { min-width: 220px; max-width: 300px; }

.beach-popup h3 {
  font-size: 0.95rem;
  margin-bottom: 6px;
}

.beach-popup .meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.beach-popup .classification {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 6px;
}

/* Popup weather/UV/sea blocks */
.popup-weather, .popup-sea {
  background: #f8fafc;
  border-radius: 6px;
  padding: 6px 8px;
  margin: 6px 0;
  font-size: 0.8rem;
}

.pw-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 1px 0;
}

.pw-row span:first-child { width: 20px; text-align: center; flex-shrink: 0; }

.popup-uv {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0;
}

.uv-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
}

.uv-time { font-size: 0.7rem; color: var(--text-muted); }

.uv-low       { background: #059669; }
.uv-moderate  { background: #f59e0b; }
.uv-high      { background: #f97316; }
.uv-very-high { background: #ef4444; }
.uv-extreme   { background: #7c3aed; }
.uv-na        { background: var(--unknown); }

.beach-popup .badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.beach-popup .badge {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 8px;
  background: #f3f4f6;
  color: var(--text-muted);
}

.beach-popup a {
  color: var(--accent);
  font-size: 0.78rem;
  text-decoration: none;
}

.beach-popup a:hover { text-decoration: underline; }

/* ── Marker cluster overrides ────────────────────────────── */
.marker-cluster-small  { background-color: rgba(5, 150, 105, 0.25); }
.marker-cluster-small div  { background-color: rgba(5, 150, 105, 0.6); color: #fff; }
.marker-cluster-medium { background-color: rgba(245, 158, 11, 0.25); }
.marker-cluster-medium div { background-color: rgba(245, 158, 11, 0.6); color: #fff; }
.marker-cluster-large  { background-color: rgba(239, 68, 68, 0.25); }
.marker-cluster-large div  { background-color: rgba(239, 68, 68, 0.6); color: #fff; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 640px) {
  :root { --sidebar-w: 100vw; }

  #sidebar {
    height: 50vh;
    width: 100vw;
    top: auto;
    bottom: 0;
    border-right: none;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
  }

  #sidebar.collapsed {
    transform: translateY(100%);
  }

  #sidebar-open.visible {
    top: auto;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
  }

  #map { height: 100%; }
}

/* ── Advisory / closure badges in popup ──────────────────── */
.advisory {
  margin-top: .5rem;
  padding: .4rem .6rem;
  border-radius: var(--radius);
  font-size: .82rem;
  font-weight: 600;
}
.advisory-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.advisory-closed  { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* ── Alert list items ────────────────────────────────────── */
#alerts-list { list-style: none; padding: 0; margin: 0; }
.alert-item {
  display: block;
  padding: .55rem .7rem;
  margin-bottom: .4rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: .85rem;
  background: #fafafa;
}
.alert-item.clickable { cursor: pointer; transition: background .15s; }
.alert-item.clickable:hover { background: #f3f4f6; border-color: #d1d5db; }
.alert-item .alert-beach { display: block; font-weight: 600; color: var(--text); }
.alert-item .alert-msg { display: block; color: var(--text-muted); margin-top: .15rem; }
.alert-warning { border-left: 3px solid var(--adequate); }
.alert-danger  { border-left: 3px solid var(--poor); }
.alert-info    { border-left: 3px solid var(--accent); }
