/* =============================================================
   MCM Live Meteogram — style.css
   Light theme, WordPress 2024 compatible, no external fonts
   ============================================================= */

/* --- Tokens -------------------------------------------------- */
:root {
  --bg: #f8f8f7;
  --surface: #ffffff;
  --border: #e0ddd8;
  --border-light: #ece9e4;
  --text-primary: #1a1917;
  --text-secondary: #5a574f;
  --text-muted: #8a877f;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #eff6ff;
  --danger: #dc2626;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  /* station color palette — 16 accessible colors matching shared.js */
  --s0: #0c8599;
  --s1: #e03131;
  --s2: #2f9e44;
  --s3: #7048e8;
  --s4: #e8590c;
  --s5: #c2255c;
  --s6: #f08c00;
  --s7: #495057;
  --s8: #7d4037;
  --s9: #5c940d;
  --s10: #087f5b;
  --s11: #5f3dc4;
  --s12: #1971c2;
  --s13: #a61e4d;
  --s14: #9c36b5;
  --s15: #d6336c;
}

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

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg);
  line-height: 1.5;
}

/* --- App shell ---------------------------------------------- */
#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 20px 40px;
}

/* --- Page nav (Met / Lake) & Button groups ------------------ */
#page-nav,
.button-group {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.nav-link,
.preset-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: none;
  border-right: 1px solid var(--border);
  padding: 6px 12px;
  font-size: 12px;
  font-family: var(--font);
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
  line-height: normal;
  box-sizing: border-box;
}

.nav-link:last-child,
.preset-btn:last-child {
  border-right: none;
}

.nav-link:hover,
.preset-btn:hover {
  background: var(--accent-light);
  color: var(--accent);
}

.nav-link.active,
.preset-btn.active {
  background: var(--accent);
  color: #fff;
}

/* --- Controls bar ------------------------------------------- */
#controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-group>label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

/* --- Station dropdown --------------------------------------- */
#station-selector-wrapper {
  position: relative;
}

#station-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text-primary);
  cursor: pointer;
  min-width: 180px;
  transition: border-color 0.15s;
}

#station-dropdown-btn:hover {
  border-color: var(--accent);
}

#station-dropdown-btn[aria-expanded="true"] {
  border-color: var(--accent);
}

#station-dropdown-btn .chevron {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.15s;
}

#station-dropdown-btn[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
}

#station-dropdown-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#station-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 180px;
  max-height: 300px;
  overflow-y: auto;
  list-style: none;
  padding: 4px 0;
}

#station-dropdown li {
  padding: 7px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-family: var(--mono);
  transition: background 0.1s;
}

#station-dropdown li:hover {
  background: var(--accent-light);
}

#station-dropdown li[aria-selected="true"] {
  background: var(--accent-light);
  color: var(--accent);
}

#station-dropdown li .check {
  width: 14px;
  text-align: center;
  flex-shrink: 0;
}

#station-dropdown li.no-data {
  color: var(--text-muted);
  font-style: italic;
  cursor: not-allowed;
}

#station-dropdown li.no-data:hover {
  background: none;
}



/* --- Custom range ------------------------------------------- */
#custom-range-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

#custom-range-inputs input[type="datetime-local"] {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 8px;
  font-size: 12px;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--surface);
}

.range-sep {
  color: var(--text-muted);
  font-size: 12px;
}

#apply-range-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 6px 12px;
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.12s;
}

#apply-range-btn:hover {
  background: var(--accent-hover);
}

/* --- Panel toggles ------------------------------------------ */
.toggle-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.toggle-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  color: var(--text-secondary);
  background: var(--surface);
}

.toggle-pill:has(input:checked) {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

.toggle-pill input {
  display: none;
}

/* --- Legend ------------------------------------------------- */
#legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 12px;
  min-height: 24px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text-secondary);
}

.legend-swatch {
  width: 24px;
  height: 3px;
  border-radius: 2px;
}

/* --- Status bar --------------------------------------------- */
#status-bar {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  min-height: 18px;
}

#status-bar.error {
  color: var(--danger);
}

/* --- Chart panels ------------------------------------------- */
#charts {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chart-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.chart-panel.hidden {
  display: none;
}

.panel-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 10px 16px 4px;
  border-bottom: 1px solid var(--border-light);
}

.panel-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.panel-unit {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--mono);
}

.y-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-secondary);
}

.y-controls input {
  width: 40px;
  font-size: 11px;
  padding: 2px 4px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text-primary);
  appearance: textfield;
  -moz-appearance: textfield;
  /* Hide arrows in Firefox */
}

.y-controls input::-webkit-outer-spin-button,
.y-controls input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  /* Hide arrows in Safari/Chrome */
  margin: 0;
}

.y-auto-btn {
  font-size: 10px;
  padding: 2px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-secondary);
}

.y-auto-btn:hover {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent);
}

.no-data-msg {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  padding: 12px 16px;
  text-align: center;
}

.panel-svg-container {
  width: 100%;
}

/* --- SVG elements ------------------------------------------- */
.axis path,
.axis line {
  stroke: var(--border);
  stroke-width: 1;
}

.axis text {
  fill: var(--text-muted);
  font-size: 11px;
  font-family: var(--font);
}

.grid-line {
  stroke: var(--border-light);
  stroke-dasharray: 2, 4;
  stroke-width: 1;
}

.data-line {
  fill: none;
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.data-dot {
  stroke: #fff;
  stroke-width: 1;
  r: 2.5;
}


.zoom-overlay {
  fill: none;
  pointer-events: all;
  cursor: crosshair;
}

/* --- Tooltip ----------------------------------------------- */
#tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 8px 12px;
  font-size: 12px;
  line-height: 1.6;
  z-index: 1000;
  max-width: 280px;
  opacity: 0;
  transition: opacity 0.1s;
}

#tooltip.visible {
  opacity: 1;
}

.tooltip-time {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.tooltip-label {
  color: var(--text-secondary);
  white-space: nowrap;
}

.tooltip-value {
  font-family: var(--mono);
  font-weight: 600;
  white-space: nowrap;
}

/* --- Responsive -------------------------------------------- */
@media (max-width: 700px) {
  #controls {
    flex-direction: column;
  }

  #custom-range-inputs {
    flex-direction: column;
    align-items: flex-start;
  }

  #app {
    padding: 10px 12px 30px;
  }
}