/* ══════════════════════════════════════════════
   PathSense India — Map Styles
   Dark mode default, light mode via layer switch
   ══════════════════════════════════════════════ */

/* ── Map Container ── */
#map {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  background: #0a1128;
}


/* ══════════════════════════════════════════════
   Leaflet Controls — Dark Default
   ══════════════════════════════════════════════ */

.leaflet-control-zoom {
  border: none !important;
  box-shadow: 0 2px 10px rgba(0,0,0,0.35) !important;
  border-radius: 10px !important;
  overflow: hidden;
}

.leaflet-control-zoom a {
  background: rgba(12,18,40,0.88) !important;
  color: #94a3b8 !important;
  width: 38px !important;
  height: 38px !important;
  line-height: 38px !important;
  font-size: 18px !important;
  border: none !important;
  border-bottom: 1px solid rgba(255,255,255,0.06) !important;
  transition: background 0.15s, color 0.15s;
  backdrop-filter: blur(12px);
}

.leaflet-control-zoom a:hover {
  background: rgba(20,30,60,0.95) !important;
  color: #e2e8f0 !important;
}

.leaflet-control-zoom a:last-child {
  border-bottom: none !important;
}

/* Layer control */
.leaflet-control-layers {
  border: none !important;
  box-shadow: 0 2px 12px rgba(0,0,0,0.35) !important;
  border-radius: 10px !important;
  background: rgba(12,18,40,0.92) !important;
  backdrop-filter: blur(16px);
  font-family: 'Inter', system-ui, sans-serif;
  border: 1px solid rgba(255,255,255,0.06) !important;
}

.leaflet-control-layers-toggle {
  width: 38px !important;
  height: 38px !important;
  background-size: 20px 20px !important;
  border-radius: 10px !important;
  filter: invert(0.8);
}

.leaflet-control-layers-expanded {
  padding: 12px 16px !important;
  min-width: 145px;
}

.leaflet-control-layers label {
  font-size: 0.78rem !important;
  color: #cbd5e1 !important;
  margin-bottom: 3px;
  padding: 3px 0;
}

.leaflet-control-layers-separator {
  border-top-color: rgba(255,255,255,0.06) !important;
}

.leaflet-control-layers-selector {
  margin-right: 8px !important;
  accent-color: #06b6d4;
}

/* Scale control */
.leaflet-control-scale-line {
  border: none !important;
  border-bottom: 2px solid rgba(255,255,255,0.2) !important;
  background: rgba(12,18,40,0.65) !important;
  padding: 2px 8px;
  font-size: 0.62rem;
  color: #94a3b8;
  border-radius: 3px;
  line-height: 1.4;
  font-family: 'Inter', system-ui, sans-serif;
  backdrop-filter: blur(6px);
}

/* Attribution */
.leaflet-control-attribution {
  background: rgba(12,18,40,0.55) !important;
  font-size: 0.55rem !important;
  color: #64748b !important;
  padding: 2px 8px !important;
  border-radius: 4px 0 0 0;
}

.leaflet-control-attribution a {
  color: #22d3ee !important;
}


/* ══════════════════════════════════════════════
   GPS Locate Button
   ══════════════════════════════════════════════ */

.ps-locate-btn {
  border: none !important;
  box-shadow: 0 2px 10px rgba(0,0,0,0.35) !important;
  border-radius: 10px !important;
  overflow: hidden;
}

.ps-locate-btn a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: rgba(12,18,40,0.88);
  color: #94a3b8;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  backdrop-filter: blur(12px);
}

.ps-locate-btn a:hover {
  background: rgba(20,30,60,0.95);
  color: #60a5fa;
}

.ps-locate-btn svg {
  stroke: currentColor;
}


/* ══════════════════════════════════════════════
   Mini Overview Map
   ══════════════════════════════════════════════ */

.ps-minimap-container {
  width: 150px;
  height: 100px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
  border: 2px solid rgba(255,255,255,0.08);
  margin-bottom: 6px;
  cursor: default;
}

.ps-minimap-container .leaflet-container {
  background: #0a1128;
}


/* ══════════════════════════════════════════════
   Coordinate Display
   ══════════════════════════════════════════════ */

.ps-coord-display {
  background: rgba(12,18,40,0.8);
  backdrop-filter: blur(10px);
  padding: 4px 12px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', 'Inter', monospace, system-ui;
  font-size: 0.62rem;
  color: #64748b;
  box-shadow: 0 1px 6px rgba(0,0,0,0.2);
  letter-spacing: 0.02em;
  user-select: text;
  border: 1px solid rgba(255,255,255,0.04);
}


/* ══════════════════════════════════════════════
   Source & Destination Markers (Pulsing)
   ══════════════════════════════════════════════ */

.ps-marker-source,
.ps-marker-dest {
  background: none !important;
  border: none !important;
}

.ps-marker-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: ps-pulse 2s ease-out infinite;
}

.ps-pulse-green {
  background: rgba(16, 185, 129, 0.25);
}

.ps-pulse-cyan {
  background: rgba(6, 182, 212, 0.25);
}

@keyframes ps-pulse {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(2.2); opacity: 0; }
}

.ps-marker-pin {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border: 3px solid rgba(255,255,255,0.9);
  transition: transform 0.2s;
}

.ps-marker-pin:hover {
  transform: translate(-50%, -50%) scale(1.12);
}

.ps-pin-green {
  background: #10b981;
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.5), 0 2px 8px rgba(0,0,0,0.3);
}

.ps-pin-cyan {
  background: #06b6d4;
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.5), 0 2px 8px rgba(0,0,0,0.3);
}


/* ══════════════════════════════════════════════
   Tooltips — Dark Default
   ══════════════════════════════════════════════ */

.ps-tooltip {
  background: rgba(12,18,40,0.95) !important;
  border: 1px solid rgba(255,255,255,0.08) !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35) !important;
  border-radius: 8px !important;
  padding: 6px 12px !important;
  font-family: 'Inter', system-ui, sans-serif !important;
  font-size: 0.75rem !important;
  font-weight: 600 !important;
  color: #e2e8f0 !important;
}

.ps-tooltip::before {
  border-top-color: rgba(12,18,40,0.95) !important;
}

.ps-tooltip-green {
  border-left: 3px solid #10b981 !important;
}

.ps-tooltip-cyan {
  border-left: 3px solid #06b6d4 !important;
}


/* ══════════════════════════════════════════════
   Route Line Animations
   ══════════════════════════════════════════════ */

@keyframes route-flow {
  to { stroke-dashoffset: -20; }
}


/* ══════════════════════════════════════════════
   Direction Arrows
   ══════════════════════════════════════════════ */

.ps-direction-arrow {
  background: none !important;
  border: none !important;
}

.ps-direction-arrow div {
  font-size: 10px;
  font-weight: 900;
  text-shadow: 0 0 6px rgba(0,0,0,0.6), 0 0 2px rgba(255,255,255,0.3);
  opacity: 0.9;
  line-height: 1;
}


/* ══════════════════════════════════════════════
   TEI Score Badges
   ══════════════════════════════════════════════ */

.ps-tei-label {
  background: none !important;
  border: none !important;
}

.ps-tei-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  color: #fff;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  border: 2px solid rgba(255,255,255,0.85);
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}


/* ══════════════════════════════════════════════
   Report Markers
   ══════════════════════════════════════════════ */

.ps-report-marker {
  background: none !important;
  border: none !important;
}

.ps-report-pin {
  width: 28px;
  height: 28px;
  border-radius: 50% 50% 50% 4px;
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255,255,255,0.7);
  transition: transform 0.2s;
}

.ps-report-pin span {
  transform: rotate(45deg);
  font-size: 0.72rem;
  line-height: 1;
}

.ps-report-pin:hover {
  transform: rotate(-45deg) scale(1.15);
}

.ps-report-stem {
  width: 2px;
  height: 10px;
  margin: 0 auto;
  opacity: 0.35;
  border-radius: 0 0 2px 2px;
}


/* ══════════════════════════════════════════════
   Segment Popup — Dark Card
   ══════════════════════════════════════════════ */

.ps-segment-popup .leaflet-popup-content-wrapper {
  border-radius: 14px !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4) !important;
  border: 1px solid rgba(255,255,255,0.06);
  padding: 0 !important;
  overflow: hidden;
  background: rgba(12,18,40,0.96) !important;
}

.ps-segment-popup .leaflet-popup-content {
  margin: 0 !important;
  font-family: 'Inter', system-ui, sans-serif;
  color: #e2e8f0;
}

.ps-segment-popup .leaflet-popup-tip {
  background: rgba(12,18,40,0.96) !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
}

.ps-segment-popup .leaflet-popup-close-button {
  color: #64748b !important;
  font-size: 20px !important;
  width: 28px !important;
  height: 28px !important;
  padding: 0 !important;
  top: 6px !important;
  right: 6px !important;
}

.ps-segment-popup .leaflet-popup-close-button:hover {
  color: #cbd5e1 !important;
}

/* Override popup inner text colors for dark */
.ps-segment-popup .leaflet-popup-content div[style*="color:#1f2937"] {
  color: #e2e8f0 !important;
}

.ps-segment-popup .leaflet-popup-content div[style*="color:#555"] {
  color: #94a3b8 !important;
}

.ps-segment-popup .leaflet-popup-content div[style*="color:#6b7280"] {
  color: #94a3b8 !important;
}

/* Standard Leaflet popups dark */
.leaflet-popup-content-wrapper {
  background: rgba(12,18,40,0.95) !important;
  border-radius: 10px !important;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4) !important;
  border: 1px solid rgba(255,255,255,0.06) !important;
  color: #e2e8f0 !important;
}

.leaflet-popup-tip {
  background: rgba(12,18,40,0.95) !important;
}

.leaflet-popup-content {
  color: #e2e8f0 !important;
}

.leaflet-popup-content strong {
  color: #f1f5f9 !important;
}

.leaflet-popup-content span[style*="color:#666"] {
  color: #94a3b8 !important;
}


/* ══════════════════════════════════════════════
   Map Legend — Dark Default
   ══════════════════════════════════════════════ */

.map-legend {
  position: fixed;
  bottom: 70px;
  left: 420px;
  z-index: 900;
  background: rgba(12,18,40,0.88);
  backdrop-filter: blur(16px);
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.06);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}

.map-legend.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.map-legend-title {
  font-size: 0.68rem;
  font-weight: 700;
  color: #e2e8f0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.map-legend-items {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.map-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.68rem;
  color: #94a3b8;
}

.map-legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}


/* ══════════════════════════════════════════════
   Light Mode Overrides (when Streets/Light/OSM/Topo tile)
   ══════════════════════════════════════════════ */

body:not(.map-dark-mode) .leaflet-control-zoom a {
  background: #fff !important;
  color: #555 !important;
  border-bottom-color: #e5e7eb !important;
}

body:not(.map-dark-mode) .leaflet-control-zoom a:hover {
  background: #f3f4f6 !important;
  color: #111 !important;
}

body:not(.map-dark-mode) .leaflet-control-layers {
  background: rgba(255,255,255,0.97) !important;
  border-color: rgba(0,0,0,0.06) !important;
  box-shadow: 0 1px 6px rgba(0,0,0,0.12) !important;
}

body:not(.map-dark-mode) .leaflet-control-layers-toggle {
  filter: none;
}

body:not(.map-dark-mode) .leaflet-control-layers label {
  color: #374151 !important;
}

body:not(.map-dark-mode) .ps-locate-btn a {
  background: #fff;
  color: #555;
}

body:not(.map-dark-mode) .ps-locate-btn a:hover {
  background: #f3f4f6;
  color: #4285f4;
}

body:not(.map-dark-mode) .ps-minimap-container {
  border-color: #fff;
}

body:not(.map-dark-mode) .ps-coord-display {
  background: rgba(255,255,255,0.85);
  color: #6b7280;
  border-color: transparent;
}

body:not(.map-dark-mode) .ps-tooltip {
  background: #fff !important;
  border-color: transparent !important;
  color: #1f2937 !important;
}

body:not(.map-dark-mode) .ps-tooltip::before {
  border-top-color: #fff !important;
}

body:not(.map-dark-mode) .leaflet-control-scale-line {
  background: rgba(255,255,255,0.75) !important;
  color: #555 !important;
  border-bottom-color: rgba(0,0,0,0.25) !important;
}

body:not(.map-dark-mode) .leaflet-control-attribution {
  background: rgba(255,255,255,0.7) !important;
  color: #999 !important;
}

body:not(.map-dark-mode) .leaflet-popup-content-wrapper {
  background: #fff !important;
  color: #1f2937 !important;
  border-color: transparent !important;
}

body:not(.map-dark-mode) .leaflet-popup-tip {
  background: #fff !important;
}

body:not(.map-dark-mode) .leaflet-popup-content {
  color: #1f2937 !important;
}

body:not(.map-dark-mode) .map-legend {
  background: rgba(255,255,255,0.95);
  border-color: rgba(0,0,0,0.04);
}

body:not(.map-dark-mode) .map-legend-title {
  color: #374151;
}

body:not(.map-dark-mode) .map-legend-item {
  color: #6b7280;
}


/* ══════════════════════════════════════════════
   Responsive
   ══════════════════════════════════════════════ */

@media (max-width: 768px) {
  .ps-minimap-container {
    width: 100px;
    height: 65px;
  }

  .ps-coord-display {
    display: none;
  }

  .map-legend {
    left: 12px;
    bottom: 55px;
  }
}
