/* OpenAudit Philippines - LGU Map Styles */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f4f8;
  min-height: 100vh;
}

header {
  background: #1a365d;
  color: white;
  padding: 1rem;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

header nav {
  margin-bottom: 0.75rem;
}

header .nav-link {
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  margin: 0 0.75rem;
  font-size: 0.9rem;
  padding-bottom: 0.25rem;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

header .nav-link:hover,
header .nav-link.active {
  color: white;
  border-bottom-color: white;
}

header .nav-link.logout-link {
  color: rgba(255,200,200,0.9);
}

header .nav-link.logout-link:hover {
  color: #ff6b6b;
  border-bottom-color: #ff6b6b;
}

header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

header p {
  margin: 0.5rem 0 0 0;
  font-size: 0.9rem;
  opacity: 0.9;
}

main {
  position: relative;
  padding: 1rem;
  max-width: 1400px;
  margin: 0 auto;
}

#map-container {
  position: relative;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  overflow: hidden;
}

#map {
  background: #f0f4f8;
  height: 70vh;
  min-height: 500px;
  width: 100%;
}

/* ============================================
   LEAFLET INFO PANEL
   ============================================ */

.info-panel {
  background: white;
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
  min-width: 250px;
  max-width: 300px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  margin-right: 10px;
  margin-top: 10px;
}

.info-panel h4 {
  margin: 0 0 8px 0;
  font-size: 14px;
  font-weight: 600;
  color: #1a365d;
}

.info-score {
  text-align: center;
  margin: 8px 0;
}

.info-score .score-value {
  font-size: 28px;
  font-weight: 700;
  color: #1a365d;
}

.info-score .score-label {
  font-size: 14px;
  color: #718096;
}

.info-risk {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.info-risk.minimal { background: #c6f6d5; color: #22543d; }
.info-risk.low { background: #fefcbf; color: #744210; }
.info-risk.moderate { background: #fed7aa; color: #9c4221; }
.info-risk.high { background: #fed7d7; color: #9b2c2c; }
.info-risk.critical { background: #c53030; color: white; }
.info-risk.no_data { background: #e2e8f0; color: #4a5568; }

.info-details {
  font-size: 12px;
  color: #4a5568;
  border-top: 1px solid #e2e8f0;
  padding-top: 8px;
  margin-top: 8px;
}

.info-details div {
  margin: 3px 0;
}

/* ============================================
   LEAFLET LEGEND PANEL
   ============================================ */

.legend-panel {
  background: white;
  padding: 8px 10px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  max-width: 150px;
}

.legend-panel h4 {
  margin: 0 0 6px 0;
  font-size: 11px;
  font-weight: 600;
  color: #4a5568;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.legend-item {
  display: flex;
  align-items: center;
  margin: 3px 0;
}

.legend-color {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  margin-right: 6px;
  border: 1px solid rgba(0,0,0,0.1);
}

.legend-label {
  font-size: 10px;
  color: #4a5568;
}

/* Leaflet control positioning adjustments */
.leaflet-top.leaflet-right {
  top: 10px;
}

.leaflet-bottom.leaflet-right {
  bottom: 10px;
}

/* ============================================
   CONTROL PANEL STYLES
   ============================================ */

.control-panel {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 1000;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
  padding: 1rem;
  min-width: 200px;
}

.control-group {
  margin-bottom: 1rem;
}

.control-group:last-child {
  margin-bottom: 0;
}

.control-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: #4a5568;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
}

.control-group select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 0.9rem;
  background: white;
  cursor: pointer;
}

.control-group select:focus {
  outline: none;
  border-color: #1a365d;
}

/* View toggle buttons */
.toggle-buttons {
  display: flex;
  gap: 0;
}

.toggle-btn {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid #e2e8f0;
  background: white;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}

.toggle-btn:first-child {
  border-radius: 4px 0 0 4px;
}

.toggle-btn:last-child {
  border-radius: 0 4px 4px 0;
  border-left: none;
}

.toggle-btn:hover {
  background: #f7fafc;
}

.toggle-btn.active {
  background: #1a365d;
  color: white;
  border-color: #1a365d;
}

/* ============================================
   ZOOM CONTROLS
   ============================================ */

.zoom-controls {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: white;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  overflow: hidden;
}

.zoom-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: white;
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1a365d;
  transition: background 0.15s;
}

.zoom-btn:hover {
  background: #f7fafc;
}

.zoom-btn:active {
  background: #e2e8f0;
}

/* ============================================
   MOBILE HINT
   ============================================ */

.mobile-hint {
  display: none;
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.8rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.mobile-hint.visible {
  opacity: 1;
}

/* Loading state */
.loading {
  padding: 3rem;
  text-align: center;
  color: #4a5568;
  font-size: 1rem;
}

/* Error message */
.error-message {
  padding: 2rem;
  text-align: center;
  background: #fed7d7;
  color: #9b2c2c;
  border-radius: 8px;
  margin: 1rem;
}

.error-message h3 {
  margin: 0 0 0.5rem 0;
}

.error-message p {
  margin: 0.25rem 0;
}

/* Tooltip */
.tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.15s ease;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  border: 1px solid #e2e8f0;
  min-width: 200px;
  overflow: hidden;
}

.tooltip-header {
  background: #1a365d;
  color: white;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tooltip-title {
  font-weight: 600;
  font-size: 14px;
}

.tooltip-type {
  font-size: 11px;
  opacity: 0.8;
  background: rgba(255,255,255,0.2);
  padding: 2px 8px;
  border-radius: 10px;
}

.tooltip-body {
  padding: 12px 14px;
}

/* Score display */
.tooltip-score-big {
  text-align: center;
  margin-bottom: 10px;
}

.tooltip-score-big .score-value {
  font-size: 32px;
  font-weight: 700;
  color: #1a365d;
}

.tooltip-score-big .score-label {
  font-size: 14px;
  color: #718096;
  margin-left: 2px;
}

/* Risk level badge */
.tooltip-risk {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.tooltip-risk.minimal {
  background: #c6f6d5;
  color: #22543d;
}

.tooltip-risk.low {
  background: #fefcbf;
  color: #744210;
}

.tooltip-risk.moderate {
  background: #fed7aa;
  color: #9c4221;
}

.tooltip-risk.high {
  background: #fed7d7;
  color: #9b2c2c;
}

.tooltip-risk.critical {
  background: #c53030;
  color: white;
}

.tooltip-risk.no-data {
  background: #e2e8f0;
  color: #4a5568;
}

/* Details section */
.tooltip-details {
  border-top: 1px solid #e2e8f0;
  padding-top: 10px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  font-size: 12px;
}

.detail-label {
  color: #718096;
}

.detail-value {
  color: #2d3748;
  font-weight: 500;
}

/* Trend indicators */
.trend-improving {
  color: #22543d;
}

.trend-worsening {
  color: #c53030;
}

.trend-stable {
  color: #718096;
}

.tooltip-location {
  font-size: 11px;
  color: #718096;
  margin-bottom: 8px;
}

.tooltip-stats {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #e2e8f0;
  font-size: 11px;
  color: #718096;
}

.tooltip-stats span {
  display: block;
  margin-top: 3px;
}

footer {
  text-align: center;
  padding: 1rem;
  color: #718096;
  font-size: 0.8rem;
}

/* Mobile optimizations */
@media (max-width: 768px) {
  header {
    padding: 0.75rem;
  }

  header h1 {
    font-size: 1.25rem;
  }

  main {
    padding: 0.5rem;
  }

  .control-panel {
    position: relative;
    top: 0;
    left: 0;
    margin-bottom: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    min-width: unset;
  }

  .control-group {
    flex: 1;
    min-width: 120px;
    margin-bottom: 0;
  }

  .zoom-controls {
    bottom: 0.5rem;
    right: 0.5rem;
  }

  .zoom-btn {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }

  .mobile-hint {
    display: block;
  }

  #map svg {
    height: 60vh;
    min-height: 400px;
  }

  #map svg path.lgu {
    stroke-width: 0.1 !important;
  }

  .tooltip {
    min-width: 160px;
  }

  .tooltip-header {
    padding: 8px 10px;
  }

  .tooltip-title {
    font-size: 13px;
  }

  .tooltip-body {
    padding: 8px 10px;
  }

  /* Hide legend on mobile - too small */
  #map svg .legend {
    display: none;
  }
}

@media (max-width: 480px) {
  .control-panel {
    flex-direction: column;
  }

  .control-group {
    min-width: 100%;
  }
}

@media (max-width: 400px) {
  header h1 {
    font-size: 1.1rem;
  }

  #map svg path.lgu {
    stroke-width: 0.05 !important;
  }
}
