/* ═══════════════════════════════════════════════════════════════════════════
   Tidepool Dashboard v2.0 — Deep ocean theme
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --bg-deep:      #071e3d;
  --bg-card:      #0d2f5e;
  --bg-card-alt:  #0a2850;
  --bg-header:    #0a2a52;
  --accent:       #4fc3f7;
  --accent-dim:   rgba(79,195,247,0.15);
  --accent-glow:  rgba(79,195,247,0.08);
  --text:         #e0e8f0;
  --text-dim:     #7bafd4;
  --text-muted:   #4a7da8;
  --border:       rgba(79,195,247,0.15);
  --border-strong:rgba(79,195,247,0.3);
  --danger:       #ff8a80;
  --success:      #69f0ae;
  --warning:      #ffab40;
  --radius:       10px;
  --radius-sm:    6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-deep);
  color: var(--text);
  line-height: 1.5;
}

/* ── Header image ─────────────────────────────────────────────────────────── */
.header-image-wrap {
  position: relative;
  width: 100%;
  background: #000;
  overflow: hidden;
  line-height: 0;
}

.header-img {
  display: block;
  width: 100%;
  max-width: 1100px;
  height: auto;
  margin: 0 auto;
}

.header-image-wrap::before,
.header-image-wrap::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  pointer-events: none;
  z-index: 1;
}

.header-image-wrap::before {
  top: 0;
  height: 30px;
  background: linear-gradient(to bottom, var(--bg-deep), transparent);
}

.header-image-wrap::after {
  bottom: 0;
  height: 48px;
  background: linear-gradient(to bottom, transparent, var(--bg-deep));
}

/* ── Location bar ─────────────────────────────────────────────────────────── */
.location-bar {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  position: sticky;
  top: 0;
  z-index: 1000;
  backdrop-filter: blur(10px);
}

.location-controls {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.btn-primary {
  background: linear-gradient(135deg, #1565c0, #1e88e5);
  color: #fff;
}
.btn-primary:hover { background: linear-gradient(135deg, #1e88e5, #42a5f5); }

.btn-ghost {
  background: transparent;
  color: var(--accent);
}
.btn-ghost:hover { background: var(--accent-dim); }

.location-display {
  margin-left: auto;
  font-size: 13px;
  color: var(--text-dim);
  font-family: 'SF Mono', 'Fira Code', monospace;
}

/* Legacy inline-style button compat */
.location-controls button:hover {
  filter: brightness(1.15);
}

#useSelectedBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#useSelectedBtn:not(:disabled):hover {
  background: #81d4fa !important;
}

/* ── Info strip ───────────────────────────────────────────────────────────── */
#locationStrip {
  max-width: 1100px;
  margin: 0 auto;
}

/* ── Tile grid ────────────────────────────────────────────────────────────── */
.tile-stack {
  max-width: 1100px;
  margin: 16px auto;
  padding: 0 16px;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

@media (min-width: 900px) {
  .tile-stack {
    grid-template-columns: 1fr 1fr;
  }
  .tile-full { grid-column: 1 / -1; }
}

/* ── Tile card ────────────────────────────────────────────────────────────── */
.tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  overflow: hidden;
  transition: border-color 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.tile:hover { border-color: var(--border-strong); }

/* ── Tile ordering ────────────────────────────────────────────────────────── */
#weather             { order: 1; }
#warnings            { order: 2; }
#wind                { order: 3; }
#tides               { order: 4; }
#tides_extended      { order: 5; }
#overview_map        { order: 6; }
#buoy                { order: 7; }
#swell               { order: 8; }
#surface_temp        { order: 9; }
#inat                { order: 10; }
#forecast_discussion { order: 11; }

/* ── Collapsible tiles ────────────────────────────────────────────────────── */
.tile-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  background: linear-gradient(135deg, var(--accent-glow), transparent);
  border-bottom: 1px solid var(--border);
}
.tile-header:hover { background: rgba(79,195,247,0.08); }

.tile-title {
  font-weight: 600;
  font-size: 14px;
  flex: 1;
}

.tile-toggle {
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.tile-toggle:hover { background: rgba(79,195,247,0.25); }

/* ── Chart mode toggle button ─────────────────────────────────────────── */
.chart-mode-btn {
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 2px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  font-family: inherit;
}
.chart-mode-btn:hover { background: rgba(79,195,247,0.25); }

.tile-body {
  padding: 12px 14px;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  max-height: 5000px;
  opacity: 1;
}

.tile-body.collapsed {
  max-height: 0;
  opacity: 0;
  padding: 0 14px;
}

/* ── Tile badge ───────────────────────────────────────────────────────────── */
.tile-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}
.badge-live {
  background: rgba(105,240,174,0.15);
  color: var(--success);
}
.badge-warn {
  background: rgba(255,138,128,0.15);
  color: var(--danger);
}

/* ── Stat cards ───────────────────────────────────────────────────────────── */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin: 8px 0;
}

.stat-card {
  background: rgba(0,0,0,0.15);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}
.stat-unit {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 400;
}
.stat-sub {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ── Extremes ribbon ──────────────────────────────────────────────────────── */
.extremes-ribbon {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-dim) transparent;
}

.extreme-chip {
  flex-shrink: 0;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.extreme-high {
  background: rgba(105,240,174,0.1);
  border: 1px solid rgba(105,240,174,0.2);
  color: var(--success);
}
.extreme-low {
  background: rgba(79,195,247,0.1);
  border: 1px solid rgba(79,195,247,0.2);
  color: var(--accent);
}
.extreme-neg {
  background: rgba(255,138,128,0.1);
  border: 1px solid rgba(255,138,128,0.2);
  color: var(--danger);
}

/* ── Warning banner ───────────────────────────────────────────────────────── */
.warning-banner {
  background: rgba(255,138,128,0.08);
  border: 1px solid rgba(255,138,128,0.25);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin: 4px 0;
}
.warning-type {
  color: var(--danger);
  font-weight: 700;
  font-size: 12px;
}
.warning-banner p {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ── Forecast sections ────────────────────────────────────────────────────── */
.forecast-section {
  background: rgba(0,0,0,0.12);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 6px 0;
  font-size: 13px;
  line-height: 1.6;
}
.forecast-section h4 {
  color: var(--accent);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 6px 0;
}

/* ── Buoy station cards ───────────────────────────────────────────────────── */
.buoy-station {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.buoy-station:last-child { border-bottom: none; }

/* ── iNat species grid ────────────────────────────────────────────────────── */
.species-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin: 8px 0;
}
.species-card {
  background: rgba(0,0,0,0.15);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.15s;
}
.species-card:hover { border-color: var(--accent); }
.species-card a { text-decoration: none; color: inherit; }
.species-photo {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: rgba(0,0,0,0.3);
}
.species-info {
  padding: 6px 8px;
}
.species-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.species-sci {
  font-size: 10px;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Section labels ───────────────────────────────────────────────────────── */
.section-label {
  grid-column: 1 / -1;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 8px 0 0 4px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

/* ── Skeleton loading pulse ───────────────────────────────────────────────── */
@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50%       { opacity: 0.9; }
}

.tile-loading {
  animation: pulse 1.4s ease-in-out infinite;
  color: var(--text-dim);
  font-size: 0.9em;
  padding: 6px 0;
  display: block;
}

/* ── Legacy compat ────────────────────────────────────────────────────────── */
.tile strong { font-size: 1em; }
.tile br { line-height: 1.5; }

/* ── Overview map tile ────────────────────────────────────────────────────── */
#overviewMapContainer .leaflet-control-layers {
  background: rgba(11, 61, 145, 0.92);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: 4px;
}
#overviewMapContainer .leaflet-control-layers label { color: #fff; }
#overviewMapContainer .leaflet-control-layers-separator {
  border-top-color: var(--border-strong);
}

.leaflet-velocity-details {
  background: rgba(11, 61, 145, 0.85) !important;
  color: #fff !important;
  border: 1px solid var(--accent) !important;
  border-radius: 4px !important;
  font-size: 11px !important;
}
