/* Premium Map Layout */
.map-layout {
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  margin: 0;
  padding: 0;
  display: flex;
}

#map {
  flex-grow: 1;
  height: 100vh;
  z-index: 1;
}

/* Sidebar / Bottom Sheet Control Panel */
.sidebar {
  width: 380px;
  height: 100vh;
  background: var(--bg-primary);
  border-right: 1px solid var(--border-light);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  box-shadow: 5px 0 25px rgba(0,0,0,0.1);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
  padding: 25px 25px 15px 25px;
  border-bottom: 1px solid var(--border-light);
}

.logo-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.logo-wrap img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.logo-wrap span {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--text-primary);
}

.sidebar-content {
  padding: 25px;
  flex-grow: 1;
  overflow-y: auto;
}

.control-group {
  margin-bottom: 30px;
}

.control-group h3 {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 15px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 700;
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.icon-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 10px;
}

.icon-dot.safe { background: #34a853; box-shadow: 0 0 10px rgba(52, 168, 83, 0.4); } /* Google Green */
.icon-dot.danger { background: #ea4335; box-shadow: 0 0 10px rgba(234, 67, 53, 0.4); } /* Google Red */
.icon-dot.congestion { background: #f29900; box-shadow: 0 0 10px rgba(242, 153, 0, 0.4); } /* Google Yellow */

/* Toggle Switch CSS */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--border-light);
  transition: .4s;
  border: 1px solid var(--border-light);
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

input:checked + .slider {
  background-color: var(--accent-blue);
  border-color: var(--accent-blue);
}

input:checked + .slider:before {
  transform: translateX(22px);
}

.slider.round { border-radius: 26px; }
.slider.round:before { border-radius: 50%; }

/* Forms & Buttons */
.form-select {
  width: 100%;
  padding: 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  outline: none;
  transition: border-color 0.3s;
}

.form-select:focus {
  border-color: var(--accent-blue);
}

.form-select option {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.btn-primary {
  width: 100%;
  padding: 16px;
  font-size: 16px;
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--accent-blue);
  color: white;
  border-radius: var(--radius-lg);
  border: none;
  box-shadow: 0 4px 10px rgba(26, 115, 232, 0.3);
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

/* Leaflet Overrides */
.leaflet-container { background: var(--bg-secondary); }
.leaflet-popup-content-wrapper {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-glow);
  border-radius: var(--radius-md);
}
.leaflet-popup-tip { background: var(--bg-primary); }
.fan-popup h4 { margin-bottom: 5px; color: var(--accent-blue); font-family: var(--font-heading); }
.fan-popup p { font-size: 13px; color: var(--text-muted); margin: 2px 0; }

/* Custom Map Marker Glow Animation */
.custom-fan-icon > div {
  animation: markerFloat 3s ease-in-out infinite;
}

@keyframes markerFloat {
  0% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
  100% { transform: translateY(0); }
}

/* Onboarding Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.4); /* Lighter backdrop for light mode */
  backdrop-filter: blur(5px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
  text-align: center;
}

.modal-content h2 {
  color: var(--text-primary);
  margin-bottom: 10px;
}

.modal-content p {
  color: var(--text-muted);
  margin-bottom: 30px;
}

.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 15px;
}

.team-btn {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 15px 10px;
  cursor: pointer;
  color: var(--text-primary);
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.team-btn:hover {
  background: var(--bg-secondary);
  transform: translateY(-2px);
  border-color: var(--accent-blue);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.team-btn span.flag {
  font-size: 28px;
}

.team-btn span.name {
  font-size: 13px;
  font-weight: 600;
}

/* Mobile Responsive - Bottom Sheet */
@media (max-width: 768px) {
  .map-layout {
    flex-direction: column;
  }
  
  #map {
    height: 60vh; /* Map takes top portion */
  }

  .sidebar {
    width: 100%;
    height: 40vh; /* Bottom sheet takes remaining */
    border-right: none;
    border-top: 1px solid var(--border-light);
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.1);
    z-index: 1000;
    position: relative;
    margin-top: -20px; /* Overlap map slightly */
  }

  .sidebar::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: var(--border-light);
    border-radius: 2px;
  }

  .team-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }
}

/* Intel Panel */
.intel-panel {
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 15px;
  margin-bottom: 25px;
  border: 1px solid var(--border-light);
}
.intel-panel h3 {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 14px;
  color: var(--accent-blue);
}
.intel-panel p {
  margin: 5px 0;
  font-size: 12px;
  color: var(--text-muted);
}
.intel-panel p strong {
  color: var(--text-primary);
}

/* Pulsing Danger Zone Animation */
.pulsing-danger-zone {
  animation: pulseHazard 2s infinite alternate ease-in-out;
}

@keyframes pulseHazard {
  0% {
    fill-opacity: 0.15;
    filter: drop-shadow(0 0 5px rgba(234, 67, 53, 0.4));
  }
  100% {
    fill-opacity: 0.35;
    filter: drop-shadow(0 0 15px rgba(234, 67, 53, 0.9));
  }
}
