/* =========================
   GLOBAL
========================= */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: #f7fbfd;
  color: #2c3e50;
}

/* =========================
   TOPBAR
========================= */
.topbar {
  background: #019EDF;
  padding: 10px 16px;
}

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

.brand-logo {
  width: 45px;
  height: auto;
}

.brand-name {
  color: white;
  font-weight: 600;
  font-size: 16px;
}

.brand-subtitle {
  color: rgba(255,255,255,0.9);
  font-size: 12px;
}

/* =========================
   HERO
========================= */
.hero {
  background: #eef7fc;
  padding: 12px 16px;
  border-bottom: 1px solid #dfe6e9;
}

.hero h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

/* =========================
   LAYOUT - CRITICAL FIXES
========================= */
.page {
  display: flex;
  height: calc(100vh - 95px); /* adjust for topbar+hero */
  overflow: hidden; /* prevents page scroll */
}

.sidebar {
  width: 300px;
  flex-shrink: 0; /* prevents sidebar from shrinking */
  background: #f9fcfe;
  border-right: 1px solid #dfe6e9;
  overflow-y: auto;
  padding: 12px;
  z-index: 1;
}

.map-section {
  flex: 1;
  position: relative;
  min-width: 0; /* critical for flex child to respect parent width */
}

#map {
  height: 100%;
  width: 100%;
}

/* =========================
   PANELS & DROPDOWNS
========================= */
.panel {
  background: white;
  padding: 12px;
  margin-bottom: 12px;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.dropdown {
  width: 100%;
  padding: 6px;
  margin-bottom: 8px;
  border-radius: 4px;
  border: 1px solid #ccc;
}

/* =========================
   MARKERS
========================= */
.marker {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
  border: 2px solid white;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.marker:hover {
  transform: scale(1.15);
  box-shadow: 0 4px 10px rgba(0,0,0,0.35);
}

.marker.good { background: #27ae60; }
.marker.average { background: #f39c12; }
.marker.poor { background: #c0392b; }
.marker.unknown { background: #7f8c8d; }

/* =========================
   CLUSTERS
========================= */
.cluster {
  background: rgba(1, 158, 223, 0.9);
  color: white;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* =========================
   LEGEND - NOW INSIDE MAP AREA
========================= */
.legend {
  position: absolute;
  bottom: 20px;
  right: 20px;
  background: white;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  line-height: 1.6;
  z-index: 1000;
  pointer-events: none; /* allows clicking through to map */
}

.legend h4 {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 600;
}

.legend .box {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  border-radius: 2px;
}

.box.good { background:#27ae60; }
.box.average { background:#f39c12; }
.box.poor { background:#c0392b; }
.box.unknown { background:#7f8c8d; }

/* =========================
   POPUPS
========================= */
.popup img {
  width: 100%;
  border-radius: 6px;
  margin-bottom: 6px;
}

.popup h4 {
  margin: 4px 0;
  font-size: 14px;
}

.popup p {
  margin: 2px 0;
  font-size: 12px;
}

/* =========================
   FOOTER
========================= */
.footer {
  background: #16354b;
  color: #ffffff;
  font-size: 12px;
  border-top: 3px solid #019EDF;
}

.footer-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}

.footer-left,
.footer-center,
.footer-right {
  flex: 1;
  min-width: 220px;
}

.footer-center {
  text-align: center;
}

.footer-right {
  text-align: right;
}

.footer a {
  color: #4fc3f7;
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

.footer-disclaimer {
  text-align: center;
  padding: 8px 15px;
  background: #0f2635;
  font-size: 11px;
  opacity: 0.9;
}

/* =========================
   RESPONSIVE
========================= */
@media (max-width: 900px) {
  .page {
    flex-direction: column;
    height: auto;
    overflow: auto;
  }
  .sidebar {
    width: 100%;
    height: auto;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid #ddd;
  }
  .map-section {
    height: 60vh;
  }
  .legend {
    bottom: 10px;
    right: 10px;
    font-size: 11px;
    padding: 8px 10px;
  }
  .footer-inner {
    flex-direction: column;
    text-align: center;
    gap: 10px;
  }
  .footer-right {
    text-align: center;
  }
}
