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

/* ── Base ─────────────────────────────────────────────────────────────────── */
body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.95rem;
  background: #0f1117;
  color: #cdd9e5;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
header {
  background: #161b22;
  color: #e6edf3;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid #2d333b;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.info-btn {
  background: none;
  border: 1px solid #373e47;
  border-radius: 50%;
  color: #768390;
  font-size: 1.15rem;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
}

.info-btn:hover {
  color: #58a6ff;
  border-color: #58a6ff;
}

.live-data-btn {
  background: none;
  border: 1px solid #373e47;
  border-radius: 0.375rem;
  color: #768390;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.35rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

.live-data-btn:hover {
  color: #58a6ff;
  border-color: #58a6ff;
}

/* ── Info modal ───────────────────────────────────────────────────────────── */
.info-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.info-modal {
  background: #1c2128;
  border: 1px solid #373e47;
  border-radius: 8px;
  width: min(680px, 90vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

.info-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid #2d333b;
  flex-shrink: 0;
}

.info-modal-title {
  font-size: 1rem;
  font-weight: 600;
  color: #e6edf3;
}

.info-close {
  background: none;
  border: none;
  color: #768390;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.2rem;
  transition: color 0.15s;
}

.info-close:hover {
  color: #e6edf3;
}

.info-body {
  padding: 1.25rem;
  overflow-y: auto;
  color: #cdd9e5;
  font-size: 0.9rem;
  line-height: 1.65;
}

.info-body h2 {
  font-size: 1rem;
  font-weight: 700;
  color: #e6edf3;
  margin: 1.25rem 0 0.4rem;
}

.info-body h2:first-child {
  margin-top: 0;
}

.info-body p {
  margin-bottom: 0.6rem;
}

.info-body ul {
  padding-left: 1.4rem;
  margin-bottom: 0.6rem;
}

.info-body li {
  margin-bottom: 0.25rem;
}

.info-body strong {
  color: #e6edf3;
}

/* ── Layout: sidebar | hodograph | right column ───────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) minmax(0, 1.4fr);
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  background: #161b22;
  border-right: 1px solid #2d333b;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
}

.sidebar-logo {
  width: 100%;
  display: block;
  filter: invert(1);
}

.sidebar-logo--natural {
  filter: none;
}

.logo-block {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid #2d333b;
}

.logo-powered-by {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #545d68;
  text-align: center;
}

.logo-times {
  display: block;
  text-align: center;
  font-size: 2rem;
  color: #e6edf3;
}

.sidebar h2 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #768390;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.control-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #adbac7;
}

.control-group select {
  width: 100%;
  padding: 0.35rem 0.5rem;
  border: 1px solid #373e47;
  border-radius: 4px;
  font-size: 0.85rem;
  background: #22272e;
  color: #cdd9e5;
  cursor: pointer;
}

.control-group select:disabled {
  background: #1c2128;
  color: #545d68;
  cursor: not-allowed;
}

/* ── Status message ───────────────────────────────────────────────────────── */
.status {
  font-size: 0.8rem;
  color: #ff7b72;
  line-height: 1.4;
}

/* ── Centre: hodograph / PPI panel ────────────────────────────────────────── */
.plot-area {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid #2d333b;
}

/* Tab bar shared between Hodograph and PPI tabs */
.center-tabs {
  display: flex;
  background: #161b22;
  border-bottom: 1px solid #2d333b;
  flex-shrink: 0;
}

.center-tab-btn {
  padding: 0.55rem 1rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #768390;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.center-tab-btn:hover {
  color: #cdd9e5;
}

.center-tab-btn[aria-selected="true"] {
  color: #58a6ff;
  border-bottom-color: #58a6ff;
}

/* Content area shared by both panels */
.center-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  overflow: auto;
  min-height: 0;
}

#hodograph-img,
#skewt-img,
#skewt-low-img,
#ppi-img {
  max-width: 100%;
  max-height: 100%;
  border: 1px solid #2d333b;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Panels with nav arrows stack image-wrap + nav row vertically */
#hodo-content,
#skewt-content,
#skewt-low-content {
  flex-direction: column;
  align-items: stretch;
  padding: 0;
}

/* Inner image area — retains the original centering + padding */
.center-image-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  overflow: auto;
  min-height: 0;
}

/* Skew-T fills the full image-wrap height; object-fit maintains aspect ratio */
#skewt-content .center-image-wrap,
#skewt-low-content .center-image-wrap {
  align-items: stretch;
  padding: 0.75rem;
}

.skewt-image-stack {
  position: relative;
  width: 100%;
  height: 100%;
}

/* Hodograph stack fills the image-wrap; image remains centered inside */
.hodo-image-stack {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Overlay is centered absolutely to match wherever the base image renders */
.hodo-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 100%;
  max-height: 100%;
  pointer-events: none;
}

#skewt-img,
#skewt-low-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.skewt-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.model-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: #cdd9e5;
  cursor: pointer;
  margin-left: 0.75rem;
  user-select: none;
}

.model-toggle input[type="checkbox"] {
  accent-color: #4fc3f7;
  cursor: pointer;
  width: 14px;
  height: 14px;
}

/* Nav arrow row shared by hodograph and Skew-T panels */
.nav-arrows {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.4rem 1rem;
  background: #161b22;
  border-top: 1px solid #2d333b;
  flex-shrink: 0;
}

.nav-btn {
  padding: 0.25rem 0.7rem;
  background: #22272e;
  border: 1px solid #373e47;
  border-radius: 4px;
  color: #cdd9e5;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.nav-btn:hover:not(:disabled) {
  background: #2d333b;
  border-color: #58a6ff;
}

.nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.nav-counter {
  font-size: 0.82rem;
  color: #768390;
  min-width: 3.5rem;
  text-align: center;
}

/* ── PPI panel (replaces center-content when PPI tab is active) ───────────── */
.ppi-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.ppi-image-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1.5rem 0.75rem;
  overflow: auto;
  min-height: 0;
}

.ppi-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.5rem 1rem;
  background: #161b22;
  border-top: 1px solid #2d333b;
  flex-shrink: 0;
}

.ppi-ctrl-btn {
  padding: 0.25rem 0.7rem;
  background: #22272e;
  border: 1px solid #373e47;
  border-radius: 4px;
  color: #cdd9e5;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.ppi-ctrl-btn:hover {
  background: #2d333b;
  border-color: #58a6ff;
}

.ppi-counter {
  font-size: 0.82rem;
  color: #768390;
  min-width: 3.5rem;
  text-align: center;
}

/* ── Right column ─────────────────────────────────────────────────────────── */
.right-column {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Shared window tabs */
.window-tabs {
  display: flex;
  background: #161b22;
  border-bottom: 1px solid #2d333b;
  flex-shrink: 0;
}

.win-tab-btn {
  padding: 0.55rem 1rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #768390;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.win-tab-btn:hover {
  color: #cdd9e5;
}

.win-tab-btn[aria-selected="true"] {
  color: #58a6ff;
  border-bottom-color: #58a6ff;
}

/* ── Time-height panel (top half of right column) ─────────────────────────── */
.th-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* Variable toggle (Wind Speed / Wind Direction) */
.var-toggle {
  display: flex;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  background: #161b22;
  border-bottom: 1px solid #2d333b;
  flex-shrink: 0;
}

.var-btn {
  padding: 0.2rem 0.65rem;
  background: #22272e;
  border: 1px solid #373e47;
  border-radius: 3px;
  color: #768390;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.var-btn:hover {
  color: #cdd9e5;
}

.var-btn[aria-selected="true"] {
  background: rgba(88, 166, 255, 0.1);
  border-color: #58a6ff;
  color: #58a6ff;
}

.th-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  overflow: auto;
}

#timeheight-img {
  max-width: 100%;
  max-height: 100%;
  border: 1px solid #2d333b;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* ── Panel divider ────────────────────────────────────────────────────────── */
.panel-divider {
  height: 1px;
  background: #2d333b;
  flex-shrink: 0;
}

/* ── Bottom panel (SRH / Bulk Shear, bottom half of right column) ─────────── */
.bottom-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* Product tabs within the bottom panel */
.bottom-tabs {
  display: flex;
  background: #161b22;
  border-bottom: 1px solid #2d333b;
  flex-shrink: 0;
}

.bottom-tab-btn {
  padding: 0.45rem 0.9rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #768390;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.bottom-tab-btn:hover {
  color: #cdd9e5;
}

.bottom-tab-btn[aria-selected="true"] {
  color: #58a6ff;
  border-bottom-color: #58a6ff;
}

.bottom-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  overflow: auto;
  min-height: 0;
}

#timeseries-img,
#bulkshear-img,
#cape-img,
#cin-img {
  max-width: 100%;
  max-height: 100%;
  border: 1px solid #2d333b;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* ── Shared placeholder text ──────────────────────────────────────────────── */
.placeholder {
  color: #545d68;
  font-size: 0.95rem;
  text-align: center;
}

/* ── Footer ───────────────────────────────────────────────────────────────── */
footer {
  background: #161b22;
  border-top: 1px solid #2d333b;
  padding: 0.45rem 1.25rem;
  font-size: 0.75rem;
  color: #545d68;
  text-align: center;
  flex-shrink: 0;
}

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

/* ── Hamburger menu button (desktop: hidden) ──────────────────────────────── */
.menu-btn {
  display: none;
  background: none;
  border: 1px solid #373e47;
  border-radius: 4px;
  color: #768390;
  font-size: 1.1rem;
  width: 2rem;
  height: 2rem;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
}

.menu-btn:hover {
  color: #58a6ff;
  border-color: #58a6ff;
}

/* ── Mobile layout ────────────────────────────────────────────────────────── */
@media (max-width: 768px) {

  body {
    height: auto;
    min-height: 100dvh;
    overflow-y: auto;
  }

  /* Show hamburger, shrink title so all three header items fit */
  .menu-btn {
    display: flex;
  }

  header h1 {
    font-size: 0.9rem;
    text-align: center;
    flex: 1;
    padding: 0 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Collapse the link to an icon so all header items still fit */
  .live-data-btn {
    width: 2rem;
    height: 2rem;
    padding: 0;
    font-size: 0;
    border-radius: 50%;
  }

  .live-data-btn::before {
    content: "\1F4E1";
    font-size: 1rem;
  }

  /* Single-column stacking layout */
  .layout {
    grid-template-columns: 1fr;
    overflow: visible;
    flex: none;
  }

  /* Sidebar: collapsed by default, shown when toggled */
  .sidebar {
    display: none;
    border-right: none;
    border-bottom: 1px solid #2d333b;
    overflow: visible;
  }

  .sidebar.sidebar--open {
    display: flex;
  }

  /* Hide logos on mobile to save space */
  .logo-block {
    display: none !important;
  }

  /* Center panel: natural flow, fixed height for image area */
  .plot-area {
    overflow: visible;
    border-right: none;
    border-bottom: 1px solid #2d333b;
  }

  #hodo-content,
  #skewt-content,
  #skewt-low-content {
    height: 380px;
    flex: none;
    overflow: hidden;
  }

  .ppi-panel {
    height: 380px;
    flex: none;
    overflow: hidden;
  }

  /* Tab bars: scroll horizontally if tabs overflow */
  .center-tabs,
  .window-tabs,
  .var-toggle,
  .bottom-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
  }

  /* Right column: natural flow */
  .right-column {
    overflow: visible;
  }

  .th-panel {
    overflow: visible;
    flex: none;
  }

  .th-content {
    height: 280px;
    overflow: hidden;
  }

  .bottom-panel {
    overflow: visible;
    flex: none;
  }

  .bottom-content {
    height: 220px;
    overflow: hidden;
  }

  /* Images: fill width, respect container height */
  #hodograph-img,
  #timeheight-img,
  #timeseries-img,
  #bulkshear-img,
  #cape-img,
  #cin-img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
  }

  /* Skewt images must keep width/height 100% so the overlay stacks correctly */
  #skewt-img,
  #skewt-low-img {
    width: 100%;
    height: 100%;
  }

  /* Reduce padding in image wrappers */
  .center-image-wrap {
    padding: 0.75rem;
  }

  /* Taller touch targets for nav buttons */
  .nav-btn,
  .ppi-ctrl-btn {
    padding: 0.4rem 1rem;
  }
}

/* ── Date selection / generation status ───────────────────────────────────── */

.gen-status {
  font-size: 0.8rem;
  line-height: 1.4;
  margin-top: 0.15rem;
}

.gen-status.running { color: #79c0ff; }
.gen-status.done    { color: #56d364; }
.gen-status.error   { color: #ff7b72; }
