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

:root {
  --bg: #1a1f2e;
  --bg-card: #242a3a;
  --bg-card2: #2d3448;
  --accent: #4a9eff;
  --accent2: #7bc8ff;
  --text: #e8edf8;
  --text-muted: #8892b0;
  --text-dim: #5a6480;
  --border: #333d56;
  --danger: #ff6b6b;
  --success: #4ddbaa;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --font: 'Segoe UI', Calibri, system-ui, sans-serif;
  --font-emoji: 'Segoe UI Emoji', 'Apple Color Emoji', sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

/* ── App layout ───────────────────────────────────────────── */
#app {
  max-width: none;
  margin: 0 auto;
  padding: 0 16px 80px;
  min-height: 100vh;
}

/* ── Header ───────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-icon { font-size: 26px; font-family: var(--font-emoji); }

.app-header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--accent2);
}

.header-controls { display: flex; gap: 8px; }

/* ── Icon buttons ─────────────────────────────────────────── */
.btn-icon {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 18px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-icon:hover { background: var(--border); border-color: var(--accent); }

/* ── Language dropdown ────────────────────────────────────── */
.lang-dropdown {
  position: relative;
}
.lang-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  height: 40px;
  padding: 0 10px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.lang-btn:hover { background: var(--border); border-color: var(--accent); }
.lang-btn:focus { outline: none; border-color: var(--accent); }
.lang-btn-arrow { font-size: 10px; color: var(--text-muted); margin-left: 2px; }
.lang-list {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  list-style: none;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  min-width: 130px;
  z-index: 200;
  overflow: hidden;
}
.lang-dropdown.open .lang-list { display: block; }
.lang-dropdown.open .lang-btn { border-color: var(--accent); }
.lang-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.12s;
}
.lang-option:hover { background: var(--border); }
.lang-option.selected { color: var(--accent2); }

/* ── Station section ──────────────────────────────────────── */
.station-section {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.station-section label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
}

.station-select {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  padding: 10px 14px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M6 8L0 0h12z' fill='%234a9eff'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  transition: border-color 0.15s;
}
.station-select:focus { outline: none; border-color: var(--accent); }

.station-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.station-row .station-select { flex: 1; }

.station-search-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  font-size: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
}

.station-search-input {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  padding: 10px 12px;
  width: 100%;
  transition: border-color 0.15s;
}
.station-search-input:focus { outline: none; border-color: var(--accent); }

.station-search-results {
  list-style: none;
  max-height: 50vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
}

.station-search-results li {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 15px;
  transition: background 0.1s;
}
.station-search-results li:hover,
.station-search-results li:focus {
  background: var(--bg-card2);
  outline: none;
}
.station-search-results li.search-no-results {
  color: var(--text-muted);
  font-size: 13px;
  cursor: default;
}
.station-search-results li mark {
  background: none;
  color: var(--accent);
  font-weight: 700;
}

/* ── Error banner ─────────────────────────────────────────── */
.error-banner {
  background: rgba(255,107,107,0.12);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  color: var(--danger);
  padding: 10px 16px;
  font-size: 14px;
  font-style: italic;
  margin-bottom: 16px;
}

/* ── Weather card ─────────────────────────────────────────── */
.weather-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.obs-time-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  background: var(--bg-card2);
  border-bottom: 1px solid var(--border);
}

/* ── Symbol ───────────────────────────────────────────────── */
.symbol-row {
  display: flex;
  justify-content: center;
  padding: 20px 0 8px;
  border-bottom: 1px solid var(--border);
}

.symbol-large {
  font-size: 72px;
  font-family: var(--font-emoji);
  line-height: 1;
  filter: drop-shadow(0 2px 8px rgba(74,158,255,0.3));
}

/* ── Data grid ────────────────────────────────────────────── */
.data-grid {
  padding: 8px 0;
}

.data-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 20px;
  border-bottom: 1px solid rgba(51,61,86,0.5);
}
.data-row:last-child { border-bottom: none; }

.field-label {
  font-size: 14px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.field-value {
  font-size: 18px;
  font-weight: 600;
  text-align: right;
  color: var(--text);
}

.field-value--large {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent2);
}

/* ── Forecast ─────────────────────────────────────────────── */
.forecast-section {
  border-top: 1px solid var(--border);
  padding: 16px 20px;
  background: var(--bg-card2);
}

.forecast-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.forecast-carousel {
  display: flex;
  align-items: center;
  gap: 4px;
}

.forecast-nav-btn {
  flex: 0 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.forecast-nav-btn:hover { background: var(--bg-card2); }
.forecast-nav-btn:disabled { opacity: 0.25; cursor: default; }

.forecast-items {
  display: flex;
  flex: 1;
  gap: 12px;
}

.forecast-item {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.forecast-item--daily {
  border-style: dashed;
  opacity: 0.85;
}

.forecast-time {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.forecast-symbol {
  font-size: 36px;
  font-family: var(--font-emoji);
  line-height: 1;
}

.forecast-temp {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent2);
}

/* ── History trend section ────────────────────────────────── */
.trend-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 16px 16px;
}

.trend-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.trend-canvas-wrap {
  position: relative;
  height: 190px;
}

.trend-canvas-wrap canvas {
  display: block;
}

/* ── Footer ───────────────────────────────────────────────── */.app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.btn-refresh {
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  padding: 9px 20px;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.btn-refresh:hover { background: var(--accent2); }
.btn-refresh:disabled { opacity: 0.5; cursor: default; }

.next-update {
  font-size: 13px;
  color: var(--text-muted);
  text-align: right;
}

/* ── Modal ────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.65);
}

.modal-dialog {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: min(440px, calc(100vw - 32px));
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card2);
}

.modal-header h2 { font-size: 18px; font-weight: 700; }

.modal-close {
  width: 32px;
  height: 32px;
  font-size: 16px;
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-body label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.api-key-input {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: monospace;
  font-size: 14px;
  padding: 10px 12px;
  width: 100%;
  transition: border-color 0.15s;
}
.api-key-input:focus { outline: none; border-color: var(--accent); }

.settings-hint {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.6;
}

.camera-setting {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.camera-setting label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0;
}

.camera-setting input[type="checkbox"] {
  cursor: pointer;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.history-hours-setting {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.history-hours-setting label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0;
}

.history-hours-input {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 5px 8px;
  width: 64px;
  text-align: center;
  transition: border-color 0.15s;
}
.history-hours-input:focus { outline: none; border-color: var(--accent); }
.history-hours-input:disabled { opacity: 0.4; cursor: not-allowed; }

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-card2);
}

.btn-primary {
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  padding: 8px 20px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent2); }

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 14px;
  padding: 8px 20px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-secondary:hover { border-color: var(--text-muted); color: var(--text); }

/* ── Content layout (weather + camera) ───────────────────── */
.content-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-start;
}

.content-layout > #weather-card {
  flex: 1 1 340px;
  min-width: 280px;
}

/* ── Camera column (camera panel + trend chart, right side) ── */
.camera-column {
  flex: 1 1 320px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Camera panel ─────────────────────────────────────────── */
.camera-panel {
  min-width: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.camera-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-card2);
  border-bottom: 1px solid var(--border);
}

.camera-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #fff;
}

.camera-distance {
  font-size: 12px;
  color: #fff;
}

/* ── Carousel ─────────────────────────────────────────────── */
.carousel {
  position: relative;
  display: flex;
  align-items: center;
  background: #000;
}

.carousel-track-wrap {
  flex: 1 1 0;
  overflow: hidden;
}

.carousel-track {
  display: flex;
  transition: transform 0.3s ease;
}

.carousel-slide {
  flex: 0 0 100%;
  position: relative;
}

.carousel-slide img {
  width: 100%;
  display: block;
}

.carousel-slide-label {
  display: none;
}

.carousel-slide-loading,
.carousel-slide-error {
  width: 100%;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.carousel-slide-loading {
  font-size: 28px;
  font-family: var(--font-emoji);
}

.carousel-slide-error {
  font-size: 13px;
  color: var(--danger);
  padding: 16px;
}

.carousel-btn {
  flex: 0 0 auto;
  background: rgba(0,0,0,0.45);
  border: none;
  color: #fff;
  font-size: 28px;
  line-height: 1;
  width: 36px;
  padding: 0;
  cursor: pointer;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  z-index: 1;
}
.carousel-btn:hover { background: rgba(0,0,0,0.75); }
.carousel-btn:disabled { opacity: 0.25; cursor: default; }

.camera-updated {
  padding: 8px 16px;
  font-size: 11px;
  color: #fff;
  text-align: right;
  border-top: 1px solid var(--border);
}

.carousel-slide img { cursor: zoom-in; }

/* ── Camera lightbox ───────────────────────────────────────── */
.camera-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
}
.camera-lightbox.hidden { display: none; }

.lightbox-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  font-size: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: background 0.15s;
}
.lightbox-close:hover { background: rgba(255,255,255,0.28); }

.lightbox-fullscreen {
  position: absolute;
  top: 14px;
  right: 62px;
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  font-size: 18px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: background 0.15s;
}
.lightbox-fullscreen:hover { background: rgba(255,255,255,0.28); }

.camera-lightbox.is-fullscreen {
  width: var(--fs-w, 100vw);
  height: var(--fs-h, 100vh);
}

.camera-lightbox.is-fullscreen .lightbox-track-wrap {
  flex: 1 1 0;
  height: var(--fs-h, 100vh);
  max-width: none;
  max-height: none;
}

.camera-lightbox.is-fullscreen .lightbox-track {
  height: var(--fs-h, 100vh);
}

.camera-lightbox.is-fullscreen .lightbox-slide {
  flex: 0 0 100%;
  width: 100%;
  height: var(--fs-h, 100vh);
}

.camera-lightbox.is-fullscreen .lightbox-slide img {
  width: 100%;
  height: var(--fs-h, 100vh);
  max-width: none;
  max-height: none;
  object-fit: contain;
}

.lightbox-track-wrap {
  flex: 1 1 0;
  overflow: hidden;
  max-width: 100vw;
  max-height: 100vh;
}

.lightbox-track {
  display: flex;
  transition: transform 0.3s ease;
}

.lightbox-slide {
  flex: 0 0 100vw;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.lightbox-slide img {
  max-width: 100vw;
  max-height: 100vh;
  object-fit: contain;
  display: block;
}

.lightbox-slide-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px 12px;
  background: rgba(0,0,0,0.6);
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  text-align: center;
}

.lightbox-nav {
  flex: 0 0 auto;
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  font-size: 40px;
  line-height: 1;
  width: 52px;
  padding: 0;
  cursor: pointer;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  z-index: 1;
}
.lightbox-nav:hover { background: rgba(255,255,255,0.22); }
.lightbox-nav:disabled { opacity: 0.2; cursor: default; }


/* ── Loading state ────────────────────────────────────────── */
body.loading,
body.loading * { cursor: wait !important; }

.weather-card.loading { opacity: 0.55; transition: opacity 0.15s; }

/* ── Utility ──────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 480px) {
  .forecast-items { gap: 8px; }
  .forecast-item { padding: 10px 4px; }
  .forecast-symbol { font-size: 28px; }
  .data-row { padding: 8px 14px; }
  .obs-time-row { padding: 12px 14px; }
}

/* ── Cookie consent banner ────────────────────────────────── */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card2);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 300;
  font-size: 0.875rem;
  color: var(--text-muted);
}
.cookie-banner.hidden { display: none; }
.cookie-banner-text { flex: 1; margin: 0; }
.cookie-banner-btn { white-space: nowrap; flex-shrink: 0; }
