/* =========================================================
   LakeFishFinder  |  style.css
   ========================================================= */

/* ── Reset & base ─────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Core Palette */
  --bg-dark: #0A1A3F;       /* Primary: Navy */
  --bg-panel: #13254d;      /* Elevated Navy */
  --bg-card: #1c305a;       /* Card/Surface Navy */
  --border: rgba(242, 242, 242, 0.15); /* Neutral Soft Gray (Alpha) */
  --bathy: #dfff00;   /* Accent: Chartreuse */
  
  /* Primary Actions & Highlights */
  --accent: #233fca;        /* Secondary: Royal Blue */
  --accent-hover: #0047FF;  /* Highlight: Cobalt */
  
  /* Typography & Interaction */
  --text-main: #F2F2F2;     /* Neutral: Soft Gray */
  --text-muted: #afb8c1;    /* Mid Gray */
  --text-label: #8b949e;
  
  /* System */
  --danger: #ff4d4d;
  --header-h: 64px;
  --status-h: 28px;
  --panel-w: 380px;
  --radius: 8px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --search-bg: #ffffff;
}

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: Verdana, Geneva, sans-serif;
  background: var(--bg-dark);
  color: var(--text-main);
  font-size: 14px;
}

/* ── Header ───────────────────────────────────────────── */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  z-index: 1100;
  display: flex;
  align-items: center;
  padding: 0 16px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  overflow: visible;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 16px;
  width: 100%;
  flex: 1;
  line-height: 1;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  height: 100%;
}
.brand-icon {
  height: 40px;
  width: auto;
  align-self: center;
}
.brand h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  line-height: 1;
  margin: 0;
}
.subtitle {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}

.menu-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 6px 10px;  /* Reduced padding for consistency */
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 18px;
  height: 40px;  /* Fixed height */
  width: 40px;   /* Fixed width */
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .2s, background .2s;
  margin-left: auto;
  flex-shrink: 0;
  line-height: 1;
}

.menu-toggle:hover {
  border-color: var(--accent);
  background: rgba(31, 142, 241, 0.12);
}

/* Main Menu Dropdown */
.main-menu {
  position: absolute;
  top: 100%;
  right: 12px;
  width: 320px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: calc(100vh - var(--header-h) - 24px);
  overflow-y: auto;
  transition:
    opacity 0.2s,
    transform 0.2s;
  z-index: 1200;
}

.main-menu.hidden {
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
}

/* Menu Sections */
.menu-section {
  border-bottom: 1px solid var(--border);
}

.menu-section:last-of-type {
  border-bottom: none;
}

.menu-section-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: transparent;
  border: none;
  color: var(--text-main);
  padding: 12px 16px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.2s;
  text-align: left;
}

.menu-section-header:hover {
  background: var(--bg-panel);
}

.menu-arrow {
  color: var(--text-muted);
  font-size: 12px;
  transition: transform 0.2s;
}

.menu-section-header.expanded .menu-arrow {
  transform: rotate(-180deg);
}

.menu-section-content {
  max-height: 0;
  overflow: hidden;
  transition:
    max-height 0.3s ease,
    padding 0.3s ease;
  padding: 0 16px;
}

.menu-section-content.expanded {
  max-height: 400px;
  padding: 0 16px 12px;
}

.menu-placeholder {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  padding: 8px 0;
}

/* Toggle switches */
.toggle-group {
  margin-bottom: 12px;
}

.toggle-group:last-child {
  margin-bottom: 0;
}

.toggle-item {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.toggle-item input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition:
    background 0.2s,
    border-color 0.2s;
  flex-shrink: 0;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  top: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition:
    transform 0.2s,
    background 0.2s;
}

.toggle-item input:checked + .toggle-slider {
  background: rgba(31, 142, 241, 0.2);
  border-color: var(--accent);
}

.toggle-item input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: var(--accent);
}

.toggle-item:hover .toggle-slider {
  border-color: var(--accent);
}

.toggle-label {
  font-size: 13px;
  color: var(--text-main);
  flex: 1;
}

/* Filter groups within menu */
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.filter-group:last-child {
  margin-bottom: 0;
}

.filter-group label {
  font-size: 12px;
  color: var(--text-label);
  font-weight: 500;
}

/* Menu Footer */
.menu-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
}

.menu-footer .btn-reset {
  width: 100%;
}

/* ── Search ───────────────────────────────────────────── */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-wrap input#lake-search {
  flex: 1 1 auto;
  min-width: 0; /* allow shrinking in narrow layouts */
  padding: 8px 10px;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  font-size: 14px;
  box-sizing: border-box;
}

.search-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background-color: #0b74de; /* accent color — change as needed */
  color: #ffffff;            /* white magnifying glass */
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  transition: background-color 120ms ease, transform 120ms ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

/* Hover / active states */
.search-btn:hover { background-color: #095fb3; transform: translateY(-1px); }
.search-btn:active { transform: translateY(0); }

/* Focus outline for accessibility */
.search-btn:focus {
  outline: 3px solid rgba(11,116,222,0.18);
  outline-offset: 2px;
  border-radius: 8px;
}

/* Small screens: reduce spacing if needed */
@media (max-width: 420px) {
  .search-btn { width: 36px; height: 36px; font-size: 16px; }
}

.search-results {
  position: fixed;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 240px;
  overflow-y: auto;
  z-index: 9999;
  box-shadow: var(--shadow);
}
.search-results.hidden {
  display: none;
}

.search-result-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
  font-size: 13px;
}
.search-result-item:last-child {
  border-bottom: none;
}
.search-result-item:hover {
  background: var(--bg-panel);
}
.search-result-item .result-county {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}


/* Make the button exactly the same height as the input */
.search-btn {
  height: 40px;
  min-width: 40px;
  padding: 0;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--accent);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
  color: var(--search-bg);    /* SVG uses currentColor; this sets the silhouette color */
}

/* Ensure the SVG scales and uses the color */
.search-btn svg {
  width: 18px;
  height: 18px;
  display: block;
  stroke: currentColor;
  fill: none;
}

/* Hover / focus polish */
.search-btn:hover { background-color: var(--accent-hover); transform: translateY(-1px); }
.search-btn:focus { outline: 3px solid rgba(31,142,241,0.18); outline-offset: 2px; }

/* On small screens keep proportions */
@media (max-width: 420px) {
  .search-btn { height: 36px; min-width: 36px; }
  .search-btn svg { width: 16px; height: 16px; stroke-width: 1.4; }
}


.btn-reset {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  transition:
    border-color 0.2s,
    color 0.2s;
  flex-shrink: 0;
}
.btn-reset:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* ── Main layout ──────────────────────────────────────── */
.app-main {
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  bottom: var(--status-h);
  display: flex;
}

#map {
  flex: 1;
  height: 100%;
  z-index: 1;
}

/* ── Info Panel ───────────────────────────────────────── */
.info-panel {
  position: absolute;
  top: 0;             /* Aligns to the top of the main area (below header) */
  right: 0;           /* Sticks it to the right edge */
  bottom: 0;          /* Stretches it down to the status bar */
  
  width: var(--panel-w);
  /* Remove max-height to allow it to fill the vertical space */
  background: var(--bg-panel);
  border-left: 1px solid var(--border); /* Only need a border on the left side now */
  z-index: 900;
  overflow-y: auto;
  box-shadow: var(--shadow);
  transition:
    transform 0.3s ease,
    opacity 0.3s ease;
}

/* Update the hidden state to slide off perfectly */
.info-panel.hidden {
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}

.close-panel {
  position: sticky;
  top: 0;
  float: right;
  background: var(--bg-card);
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  padding: 8px 10px;
  cursor: pointer;
  border-radius: 0 var(--radius) 0 var(--radius);
  z-index: 10;
  transition: color 0.2s;
}
.close-panel:hover {
  color: var(--text-main);
}

#panel-content {
  padding: 16px;
}

/* Panel header */
.panel-lake-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
  line-height: 1.25;
}
.panel-county {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.panel-dow {
  font-size: 11px;
  color: var(--text-label);
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.stat-card .stat-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-label);
  margin-bottom: 4px;
}
.stat-card .stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}
.stat-card .stat-unit {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 3px;
}

/* Section headings inside panel */
.panel-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-label);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* Additional attributes list */
.attr-list {
  list-style: none;
  margin-bottom: 20px;
}
.attr-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.attr-list li:last-child {
  border-bottom: none;
}
.attr-list .attr-key {
  color: var(--text-muted);
}
.attr-list .attr-val {
  font-weight: 600;
  color: var(--text-main);
}

/* Fish survey section */
.fish-survey-section {
  margin-bottom: 20px;
}
.fish-loading {
  color: var(--text-muted);
  font-size: 13px;
  padding: 8px 0;
}

.species-tag {
  display: inline-block;
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: var(--bathy);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 600;
  margin: 3px 3px 3px 0;
}

.survey-note {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 8px;
}

.warn-note {
  font-size: 12px;
  color: #f97316;
  font-style: italic;
  margin-top: 8px;
}

.depth-map-section {
  margin-bottom: 20px;
}

.depth-map-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

.depth-map-sheet-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.depth-map-sheet-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
  transition:
    border-color 0.2s,
    color 0.2s,
    background 0.2s;
}

.depth-map-sheet-btn:hover,
.depth-map-sheet-btn.active {
  border-color: var(--accent);
  color: var(--text-main);
  background: rgba(31, 142, 241, 0.12);
}

.depth-map-frame {
  width: 100%;
  height: 245px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.depth-map-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.depth-map-action-link {
  display: block;
  flex: 1 1 160px;
  text-align: center;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 12px;
  transition:
    background 0.2s,
    border-color 0.2s,
    color 0.2s;
}

.depth-map-action-link:hover {
  background: var(--accent-hover);
}

.depth-map-action-link-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-main);
}

.depth-map-action-link-secondary:hover {
  background: var(--bg-panel);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Loading overlay ──────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13, 17, 23, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 3000;
  transition: opacity 0.4s;
}
.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Status bar ───────────────────────────────────────── */
.status-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--status-h);
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
  z-index: 1100;
}
.zoom-level {
  color: var(--text-label);
}
.lake-count {
  margin-left: auto;
  color: var(--text-label);
}

/* ── Leaflet overrides ────────────────────────────────── */
.leaflet-container {
  background: #0d1117;
}

/* Lake polygon tooltip */
.leaflet-tooltip.lake-tooltip {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  font-family: Verdana, Geneva, sans-serif;
  box-shadow: var(--shadow);
}
.leaflet-tooltip.lake-tooltip::before {
  border-top-color: var(--border);
}

.bathy-depth-label {
  overflow: visible;
  background: transparent !important;
  border: none !important;
}

.bathy-depth-pill {
  position: absolute;
  transform: translate(-50%, -50%);
  color: var(--bathy);
  background: rgba(0, 0, 0, 0.2);
  border-radius: 999px;
  padding: 1px 3px;
  font-size: 10px;
  font-weight: 400;
  white-space: nowrap;
  pointer-events: none;
}

.leaflet-tooltip .tt-county {
  font-size: 11px;
  color: var(--text-muted);
}

.location-marker-shell {
  background: transparent;
  border: none;
}

/* Highlighted lake polygon */
.lake-polygon-selected {
  stroke: var(--accent) !important;
  stroke-width: 3 !important;
  fill-opacity: 0.5 !important;
}

/* ── Scrollbar (panel) ─────────────────────────────────  */
.info-panel::-webkit-scrollbar {
  width: 6px;
}
.info-panel::-webkit-scrollbar-track {
  background: var(--bg-dark);
}
.info-panel::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ── Responsive tweaks ─────────────────────────────────  */
@media (max-width: 860px) {
  /* Keep header inline and fixed height on small screens */
  .header-inner {
    flex-direction: row;
    align-items: center;
    padding: 0 16px;
  }
  .app-header {
    height: var(--header-h);
    min-height: var(--header-h);
  }
  .app-main {
    top: var(--header-h);
  }
  .header-controls { gap: 8px; }
  input[type="text"] { width: 150px; }
}

/* Fish survey & lengths tables — vertical column separators */
.fish-survey-table,
.lengths-table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  font-size: 13px;
  table-layout: auto;
}

.fish-survey-table th,
.fish-survey-table td,
.lengths-table th,
.lengths-table td {
  padding: 8px 10px;
  border-right: 1px solid var(--border);
  vertical-align: top;
  color: var(--text-main);
}

.fish-survey-table th,
.lengths-table th {
  text-align: left;
  border-bottom: 2px solid var(--border);
  font-weight: 700;
}

/* Remove the right border on the last column to avoid double lines */
.fish-survey-table tr th:last-child,
.fish-survey-table tr td:last-child,
.lengths-table tr th:last-child,
.lengths-table tr td:last-child {
  border-right: none;
}

/* space between the fish table and the lengths section */
.fish-survey-table-wrap {
  margin-bottom: 12px;
}
.lengths-table-wrap {
  margin-top: 8px;
}

/* Panel adjuster (mobile) */
.info-panel {
  transition: top 0.18s ease;
}
.panel-adjuster {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1200;
  pointer-events: none;
}
.panel-grip {
  pointer-events: auto;
  width: 44px;
  height: 8px;
  border-radius: 6px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.04),
    rgba(0, 0, 0, 0.06)
  );
  border: 1px solid var(--border);
  cursor: grab;
  touch-action: none;
}
.panel-grip:active {
  cursor: grabbing;
}

/* state while dragging (disable transition) */
.info-panel.panel-dragging {
  transition: none !important;
}

/* lowered toggle state */
.info-panel.panel-lowered {
  top: 50% !important;
}

/* Mobile format */
@media (max-width: 860px) {
  .info-panel {
    top: 40vh !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    max-height: none !important;
    border-radius: 12px 12px 0 0;
    transform: none;
  }
}

/* Layer options (radio buttons) */
.layer-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.layer-option {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  transition: background 0.2s;
  user-select: none;
}

.layer-option:hover {
  background: var(--bg-panel);
}

.layer-option input[type="radio"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
  margin: 0;
}

.layer-option-label {
  font-size: 13px;
  color: var(--text-main);
  flex: 1;
}

/* Attribution & Credits */
.panel-attribution {
  margin-top: 24px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  font-size: 11px;
  color: var(--text-label);
  line-height: 1.4;
}
.panel-attribution a {
  color: var(--accent);
  text-decoration: none;
}
.panel-attribution a:hover {
  text-decoration: underline;
}

.survey-source {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  font-style: italic;
}

.status-bar .attribution {
  margin-left: 12px;
  opacity: 0.8;
}
.status-bar .attribution a {
  color: inherit;
  text-decoration: underline;
}




