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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  background: #f5f5f5;
  color: #222;
}

/* Navbar */
.navbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: #1a2a4a;
  color: #fff;
  padding: 0.5rem 1rem;
}
.brand { font-weight: 700; font-size: 1.1rem; margin-right: 1rem; }
.nav-tabs { display: flex; list-style: none; gap: 0.25rem; }
.nav-link {
  display: block;
  padding: 0.4rem 0.8rem;
  color: #ccd;
  text-decoration: none;
  border-radius: 4px;
}
.nav-link:hover, .nav-link.active { background: #2a4a8a; color: #fff; }
.nav-user { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }
.username { color: #aab; font-size: 0.85rem; }

/* Buttons */
.btn-primary {
  background: #1a5fb4;
  color: #fff;
  border: none;
  padding: 0.4rem 0.9rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
}
.btn-primary:hover { background: #1450a0; }
.btn-logout {
  background: transparent;
  border: 1px solid #556;
  color: #aab;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  text-decoration: none;
  font-size: 0.8rem;
}
.btn-logout:hover { background: #2a3a5a; }
.btn-danger {
  background: #c01;
  color: #fff;
  border: none;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}
.btn-danger:hover { background: #a00; }

/* Login */
.login-container {
  max-width: 360px;
  margin: 5rem auto;
  background: #fff;
  border-radius: 8px;
  padding: 2rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  text-align: center;
}
.login-container h1 { margin-bottom: 0.25rem; }
.subtitle { color: #888; margin-bottom: 1.5rem; }
.field { text-align: left; margin-bottom: 1rem; }
.field label { display: block; font-size: 0.85rem; color: #555; margin-bottom: 0.25rem; }
.field input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.95rem;
}
.login-container .btn-primary { width: 100%; padding: 0.6rem; }
.error { background: #fee; border: 1px solid #fcc; padding: 0.5rem; border-radius: 4px; margin-bottom: 1rem; color: #c00; }

/* Main content */
main { padding: 1rem; }
.hint { color: #888; }

/* Tabs */
.tabs-container { background: #fff; border-radius: 6px; padding: 1rem; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.tab-bar { display: flex; gap: 0.25rem; border-bottom: 2px solid #ddd; margin-bottom: 1rem; }
.tab-btn {
  background: none;
  border: none;
  padding: 0.5rem 1.2rem;
  font-size: 0.95rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: #555;
}
.tab-btn.active { border-bottom-color: #1a5fb4; color: #1a5fb4; font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Controls row */
.controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.controls label { font-size: 0.85rem; color: #555; }
.controls input[type="date"],
.controls input[type="time"] {
  padding: 0.35rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.9rem;
}

/* Location selector in tab bar */
.location-selector {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: #555;
}
.location-selector select {
  padding: 0.3rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.85rem;
}

/* Navigation buttons */
.btn-nav {
  background: #e8eef6;
  color: #1a5fb4;
  border: 1px solid #b0c4de;
  padding: 0.4rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
}
.btn-nav:hover { background: #d0ddf0; }

/* Location label */
.location-label {
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 0.5rem;
  min-height: 1.2em;
}

/* Observed wind tile */
.observed-wind-tile {
  background: #f8fbff;
  border: 1px solid #c8d8ec;
  border-radius: 6px;
  padding: 0.6rem 0.85rem;
  margin-bottom: 0.75rem;
  font-size: 0.82rem;
}
.observed-title {
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: #1a2a4a;
}
.observed-fetched {
  font-weight: normal;
  color: #888;
  font-size: 0.76rem;
  margin-left: 0.5rem;
}
.observed-stations {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.observed-station {
  border: 1px solid #dde8f4;
  border-radius: 4px;
  padding: 0.3rem 0.6rem;
  background: #fff;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  min-width: 200px;
}
.obs-name { font-weight: 600; color: #334; white-space: nowrap; }
.obs-reading { color: #222; }
.obs-time { color: #999; font-size: 0.75rem; margin-left: auto; }

/* Wind table */
.wind-table-wrap { overflow-x: auto; }
.wind-table {
  border-collapse: collapse;
  font-size: 0.82rem;
  min-width: 600px;
}
.wind-table th, .wind-table td {
  border: 1px solid #ddd;
  padding: 0.3rem 0.5rem;
  text-align: center;
  white-space: nowrap;
}
.wind-table th { background: #f0f4fa; font-weight: 600; }
.wind-table td:first-child {
  text-align: left;
  background: #fafafa;
  font-weight: 600;
  min-width: 120px;
  position: sticky;
  left: 0;
  z-index: 1;
}
.wind-table th.row-label-cell {
  text-align: left;
  min-width: 120px;
  position: sticky;
  left: 0;
  z-index: 3;
}
.date-header { background: #dce8f8; font-weight: 700; }
.hour-col { font-size: 0.78rem; }
.row-gust td, .row-dir td { background: #fdfdfd; font-size: 0.78rem; color: #555; }
.row-gust td:first-child, .row-dir td:first-child { background: #fafafa; font-weight: normal; }

/* Sunrise/sunset strip */
.sun-strip { display: flex; gap: 0.75rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.sun-card {
  background: #fffdf0;
  border: 1px solid #e8d880;
  border-radius: 6px;
  padding: 0.4rem 0.85rem;
  font-size: 0.82rem;
  min-width: 130px;
}
.sun-card-date { font-weight: 600; margin-bottom: 0.15rem; }
.sun-card-times { color: #555; }
.sun-daylight { display: block; color: #888; font-size: 0.76rem; margin-top: 0.1rem; }

/* Ensemble aggregate rows */
.row-agg td { border-bottom: 2px solid #bbb; }
.row-agg td:first-child { background: #eceef8 !important; font-weight: 700; border-right: 2px solid #bbb; }
.row-agg.row-speed td { background: #f4f5fc; }
.row-agg.row-gust td, .row-agg.row-dir td { background: #f0f1f8; font-size: 0.78rem; }
.row-agg.row-dir { border-bottom: 3px solid #999; }
.agg-cell { padding: 0.2rem 0.4rem !important; vertical-align: top; }
.agg-mean { font-weight: 700; font-size: 0.82rem; }
.agg-range { font-size: 0.7rem; color: #666; line-height: 1.1; white-space: nowrap; }

/* Wind speed colour bands */
.w-light    { background: #cde6ff !important; }
.w-moderate { background: #d4f0d0 !important; }
.w-fresh    { background: #ffe0a8 !important; }
.w-strong   { background: #ffcccc !important; }

/* Tides info header */
.tide-hw-row {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding: 0.75rem 0 1rem;
  border-bottom: 2px solid #e8eef4;
}
.tide-hw-card {
  text-align: center;
  background: #f4f8ff;
  border: 1px solid #c8d8ec;
  border-radius: 10px;
  padding: 1rem 1.5rem;
  min-width: 200px;
}
.hw-time-large {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 0.25rem;
  color: #1a2a4a;
}
.hw-height {
  font-size: 1.2rem;
  color: #334;
  margin-bottom: 0.25rem;
}
.hw-coeff {
  font-size: 1rem;
  color: #445;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.sn-badge {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
}
.coeff-springs { background: #d0eeff; color: #0060a0; }
.coeff-average { background: #e8f5e0; color: #3a7020; }
.coeff-neaps   { background: #fff0d0; color: #a06000; }
.hw-turn {
  font-size: 0.95rem;
  color: #556;
  margin-top: 0.2rem;
}

/* Tides carousel */
.tides-carousel { display: flex; flex-direction: column; gap: 0.75rem; }
.carousel-hw-info {
  font-size: 0.85rem;
  color: #555;
  padding: 0.4rem 0;
  border-bottom: 1px solid #eee;
}
.carousel-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.carousel-arrow {
  font-size: 1.2rem;
  padding: 0.5rem 1.1rem;
  flex-shrink: 0;
}
.carousel-arrow:disabled { opacity: 0.3; cursor: default; }
.carousel-slot-info {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex: 1;
}
.carousel-counter { font-size: 0.85rem; color: #999; }
.carousel-title {
  text-align: center;
  margin: 0.5rem 0 0.25rem;
}
.carousel-title-label {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.1;
}
.carousel-title-time {
  font-size: 1.3rem;
  color: #444;
  margin-top: 0.1rem;
}
.carousel-image {
  text-align: center;
}
.carousel-image img {
  width: 100%;
  max-width: 960px;
  height: auto;
  display: block;
  margin: 0 auto;
  border: 1px solid #ddd;
  border-radius: 4px;
}

/* Admin */
.admin-container { max-width: 800px; margin: 0 auto; }
.admin-container h2 { margin-bottom: 1.5rem; }
.admin-section { background: #fff; border-radius: 6px; padding: 1.2rem; margin-bottom: 1.5rem; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.admin-section h3 { margin-bottom: 1rem; font-size: 1rem; }
.field-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.field-row label { font-size: 0.85rem; color: #555; }
.field-row input[type="text"],
.field-row input[type="password"] {
  padding: 0.35rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.9rem;
}
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { border: 1px solid #ddd; padding: 0.5rem 0.75rem; text-align: left; }
.admin-table th { background: #f0f4fa; }
.muted { color: #aaa; font-size: 0.85rem; }
