/* shared.css — Common styles for all Bowker Creek pages */

/* Reset */
* { margin: 0; padding: 0; box-sizing: border-box; }
/* Hide zoom buttons — scroll wheel, trackpad, and pinch all work */
.leaflet-control-zoom { display: none !important; }
html { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Header / Nav bar */
#header {
  background: #1a3a2a; color: #e8f0ea;
  padding: 0.8rem 1.5rem; display: flex;
  align-items: center; justify-content: space-between;
  position: relative; z-index: 1000;
}
#header h1 { font-size: 1.2rem; font-weight: 600; white-space: nowrap; }
#header nav { display: flex; gap: 1rem; align-items: center; }
#header a { color: #7ecf9a; text-decoration: none; font-size: 0.9rem; }
#header a:hover { text-decoration: underline; }

/* Hamburger menu button — hidden on desktop */
#nav-toggle {
  display: none;
  background: none; border: none; color: #e8f0ea;
  font-size: 1.6rem; cursor: pointer; padding: 4px 8px;
  min-width: 44px; min-height: 44px;
  line-height: 1;
}

/* Map container */
#map { height: calc(100vh - 52px); width: 100%; }

/* Popup shared styles */
.popup-title { font-weight: 700; font-size: 1rem; margin-bottom: 4px; color: #1a3a2a; }
.popup-sub { font-size: 0.8rem; color: #666; margin-bottom: 6px; }
.popup-range { font-size: 0.8rem; color: #666; margin-bottom: 8px; }
.popup-readings { font-size: 0.85rem; margin-bottom: 8px; }
.popup-readings div { padding: 2px 0; }
.popup-readings .label { color: #555; }
.popup-readings .value { font-weight: 600; color: #1a3a2a; }
.popup-sparkline { margin: 8px 0; }
.popup-btn {
  display: inline-block; background: #2d7a4f; color: #fff;
  padding: 5px 14px; border-radius: 4px; font-size: 0.85rem;
  cursor: pointer; border: none; text-decoration: none;
}
.popup-btn:hover { background: #246840; }

/* Popup table (surveys, fielddata, overview) */
.popup-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; margin-top: 6px; }
.popup-table th { background: #e8f0ea; text-align: left; padding: 3px 6px; color: #1a3a2a; }
.popup-table td { padding: 3px 6px; border-bottom: 1px solid #eee; }

/* Detail panel (map, overview, fielddata, weather, waterrangers) */
#detail-panel {
  display: none; position: absolute; top: 52px; right: 0; bottom: 0;
  width: 420px; background: #fff; z-index: 999;
  box-shadow: -3px 0 12px rgba(0,0,0,0.15);
  overflow-y: auto;
}
#detail-panel.open { display: block; }
#detail-header {
  padding: 16px 20px; border-bottom: 1px solid #e0e0e0;
  display: flex; justify-content: space-between; align-items: center;
}
#detail-header h2 { font-size: 1.1rem; color: #1a3a2a; }
#detail-close {
  background: none; border: none; font-size: 1.4rem;
  cursor: pointer; color: #888; padding: 4px 8px;
}
#detail-close:hover { color: #333; }
#detail-controls { padding: 12px 20px; border-bottom: 1px solid #eee; }
#detail-controls select {
  padding: 6px 10px; border: 1px solid #ccc; border-radius: 4px;
  font-size: 0.9rem; margin-right: 12px;
}
.range-btns { display: inline-flex; gap: 4px; margin-top: 6px; }
.range-btn {
  padding: 4px 10px; border: 1px solid #ccc; border-radius: 4px;
  background: #fff; cursor: pointer; font-size: 0.8rem;
}
.range-btn.active { background: #2d7a4f; color: #fff; border-color: #2d7a4f; }
#chart-container { padding: 16px 20px; background: #f8f8f8; }
#chart-container canvas { width: 100% !important; height: 300px !important; }
#detail-info { padding: 12px 20px; font-size: 0.85rem; color: #666; }
#detail-info a { color: #2d7a4f; }

/* Data note (waterrangers) */
.data-note {
  position: absolute; bottom: 10px; right: 10px; z-index: 800;
  background: rgba(255,255,255,0.92); padding: 6px 12px; border-radius: 6px;
  font-size: 0.75rem; color: #888; box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  max-width: 280px;
}

/* ==============================
   Responsive: Mobile (<= 768px)
   ============================== */
@media (max-width: 768px) {
  #header {
    flex-wrap: wrap;
    padding: 0.6rem 1rem;
  }
  #header h1 {
    white-space: normal;
    word-wrap: break-word;
    flex: 1;
  }

  /* Show hamburger button */
  #nav-toggle { display: block; }

  /* Hide nav by default, show as dropdown when open */
  #header nav {
    display: none;
    flex-direction: column;
    width: 100%;
    gap: 0;
    order: 3; /* push below the h1 + hamburger row */
  }
  #header nav.open { display: flex; }

  #header nav a,
  #header nav span {
    display: block;
    padding: 12px 16px;
    min-height: 48px;
    line-height: 24px;
    font-size: 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
  }
  #header nav span {
    color: #fff;
    font-weight: 600;
    background: rgba(255,255,255,0.08);
  }
  #header nav a:hover {
    background: rgba(255,255,255,0.05);
    text-decoration: none;
  }

  #map { height: calc(100vh - 90px); }
  /* Mobile bottom sheet pattern — !important overrides desktop base styles */
  #detail-panel,
  #detail-panel.open {
    position: fixed !important;
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: 55vh !important;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
    z-index: 1001;
    display: block;
    transition: transform 0.3s ease;
  }
  #detail-panel {
    transform: translateY(100%);
  }
  #detail-panel.open {
    transform: translateY(0);
  }
  #detail-header {
    flex-direction: column;
    align-items: stretch;
    padding-top: 8px;
  }
  #detail-header::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: #ccc;
    border-radius: 2px;
    margin: 0 auto 8px;
    flex-shrink: 0;
  }
  #detail-header h2 {
    flex: 1;
  }
  #detail-close {
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 1.8rem;
    padding: 8px 12px;
    min-width: 44px;
    min-height: 44px;
    z-index: 1100;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    color: #333;
  }
}

/* ==============================
   Responsive: Phone (<= 480px)
   ============================== */
@media (max-width: 480px) {
  #map { height: calc(100vh - 110px); }
  #header {
    padding: 0.5rem 0.7rem;
  }
  #header h1 { font-size: 1rem; }
  #detail-controls {
    padding: 10px 14px;
  }
  #detail-controls select {
    font-size: 0.82rem;
    margin-right: 6px;
  }
  .range-btn {
    padding: 3px 7px;
    font-size: 0.72rem;
  }
  #chart-container {
    padding: 10px 12px;
  }
  #detail-header {
    padding: 12px 14px;
  }
  #detail-info {
    padding: 10px 14px;
  }
  .data-note {
    max-width: 200px;
    font-size: 0.68rem;
    padding: 4px 8px;
  }
}
