/* Reset & Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-color: #0d1117;
  --surface-color: rgba(22, 27, 34, 0.8);
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;

  /* Neon Palette */
  --neon-green: #00FFA3;
  --neon-blue: #00B8FF;
  --neon-red: #FF0055;
  --neon-yellow: #FFD600;

  --font-heading: 'Rajdhani', sans-serif;
  --font-body: 'Inter', sans-serif;
}

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: var(--font-body);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--surface-color);
  border-bottom: 1px solid rgba(0, 184, 255, 0.2);
  backdrop-filter: blur(10px);
  z-index: 10;
}

h1 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--neon-blue);
  text-shadow: 0 0 10px rgba(0, 184, 255, 0.5);
  letter-spacing: 2px;
}

#connection-status {
  font-size: 0.875rem;
  color: var(--neon-green);
  text-shadow: 0 0 8px rgba(0, 255, 163, 0.5);
  font-family: var(--font-heading);
  font-weight: 600;
  text-transform: uppercase;
}

/* Main Layout */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  gap: 1rem;
  overflow-y: auto;
}

/* Map Container */
#map-container {
  flex: 1;
  min-height: 500px;
  background: radial-gradient(circle at center, #161b22 0%, #0d1117 100%);
  border: 1px solid rgba(0, 255, 163, 0.2);
  border-radius: 12px;
  position: relative;
  overflow: hidden;
}

.mock-map {
  width: 100%;
  height: 100%;
  position: relative;
}

/* Environmental BG */
.environment-bg {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(circle at center, rgba(13, 27, 42, 0) 40%, rgba(5, 10, 15, 0.8) 100%), #16222b;
  background-image: radial-gradient(#111 1px, transparent 1px);
  background-size: 20px 20px;
  opacity: 0.8;
  z-index: 0;
}

/* Realistic Stadium Structure */
.stadium-structure {
  position: absolute;
  top: 18%; bottom: 18%; left: 8%; right: 8%;
  display: flex; justify-content: center; align-items: center;
  z-index: 2;
  pointer-events: none;
}

.stadium-seating {
  position: absolute;
  width: 100%; height: 100%;
  background: linear-gradient(135deg, #0d1b2a, #1b263b);
  border-radius: 60px;
  box-shadow: 
    0 0 30px rgba(0, 184, 255, 0.4), 
    inset 0 0 50px rgba(0, 0, 0, 0.9),
    inset 0 0 15px rgba(0, 184, 255, 0.5);
  border: 4px solid rgba(0, 184, 255, 0.8);
  background-image: repeating-radial-gradient(
    circle at center, transparent, transparent 10px, rgba(0, 184, 255, 0.05) 10px, rgba(0, 184, 255, 0.05) 20px
  );
}

.stadium-pitch {
  position: absolute;
  width: 55%; height: 45%;
  background: #1b4332;
  border: 2px solid rgba(255, 255, 255, 0.4);
  background-image: repeating-linear-gradient(
    to right, transparent, transparent 10%, rgba(255, 255, 255, 0.05) 10%, rgba(255, 255, 255, 0.05) 20%
  );
  display: flex; align-items: center; justify-content: space-between;
}

.pitch-center-line {
  position: absolute; left: 50%; top: 0; bottom: 0; width: 2px;
  background: rgba(255, 255, 255, 0.4); transform: translateX(-50%);
}

.pitch-center-circle {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 25%; aspect-ratio: 1; border: 2px solid rgba(255, 255, 255, 0.4); border-radius: 50%;
}

.pitch-penalty-left, .pitch-penalty-right {
  width: 15%; height: 50%; border: 2px solid rgba(255, 255, 255, 0.4);
}
.pitch-penalty-left { border-left: none; }
.pitch-penalty-right { border-right: none; }

/* Roads */
.road {
  position: absolute;
  background: #1a1e24;
  z-index: 1;
  border: 1px solid #111;
  box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

.road::after {
  content: ''; position: absolute;
  background: repeating-linear-gradient(to bottom, transparent, transparent 10px, #ffcc00 10px, #ffcc00 20px);
}

.road.vertical {
  width: 40px; margin-left: -20px; left: 50%;
}
.road.vertical::after {
  width: 2px; left: 50%; top: 0; bottom: 0; transform: translateX(-50%);
}

.road.horizontal {
  height: 40px; margin-top: -20px; top: 50%;
}
.road.horizontal::after {
  background: repeating-linear-gradient(to right, transparent, transparent 10px, #ffcc00 10px, #ffcc00 20px);
  height: 2px; top: 50%; left: 0; right: 0; transform: translateY(-50%);
}

/* Specific road positions */
.top-road { top: 0; bottom: 82%; }
.bottom-road { top: 82%; bottom: 0; }
.left-road { left: 0; right: 92%; }
.right-road { left: 92%; right: 0; }

.road.diagonal {
  width: 40px; height: 35%; left: 50%; top: 50%; transform-origin: top center;
}
.road.diagonal::after {
  width: 2px; left: 50%; top: 0; bottom: 0; transform: translateX(-50%);
}
.road-tl { transform: translate(-50%, -50%) rotate(45deg) translate(0, -100%); }
.road-tr { transform: translate(-50%, -50%) rotate(-45deg) translate(0, -100%); }
.road-bl { transform: translate(-50%, -50%) rotate(135deg) translate(0, -100%); }
.road-br { transform: translate(-50%, -50%) rotate(-135deg) translate(0, -100%); }

.map-node {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translate(-50%, -50%);
  transition: all 0.3s ease;
  z-index: 10;
}

.map-node:focus {
  outline: 2px solid var(--neon-blue);
  outline-offset: 4px;
}

.map-node .icon {
  font-size: 1.5rem;
  background: rgba(0, 0, 0, 0.5);
  padding: 0.5rem;
  border-radius: 50%;
  border: 2px solid var(--neon-green);
  box-shadow: 0 0 15px rgba(0, 255, 163, 0.3);
}

.node-info {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.node-name {
  background: rgba(0, 0, 0, 0.85);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--neon-green);
  font-size: 0.75rem;
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--neon-green);
  white-space: nowrap;
}

.node-density-container {
  background: rgba(0, 0, 0, 0.9);
  border: 1px solid var(--neon-yellow);
  padding: 4px 10px;
  border-radius: 6px;
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--neon-yellow);
  font-size: 0.85rem;
}

/* Dynamic Status Colors */
.status-congested .icon, .status-congested .node-name, .status-congested .node-density-container {
  border-color: var(--neon-red);
  color: var(--neon-red);
}
.status-congested .icon {
  box-shadow: 0 0 15px rgba(255, 0, 85, 0.5);
}

.status-warning .icon, .status-warning .node-name, .status-warning .node-density-container {
  border-color: var(--neon-yellow);
  color: var(--neon-yellow);
}
.status-warning .icon {
  box-shadow: 0 0 15px rgba(255, 214, 0, 0.5);
}

/* Panels */
.panel {
  background: var(--surface-color);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 1.25rem;
  backdrop-filter: blur(10px);
}

.panel h2 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  color: var(--text-primary);
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Input Group */
.input-group {
  display: flex;
  gap: 0.5rem;
}

input {
  flex: 1;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(0, 184, 255, 0.3);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.875rem;
  transition: border-color 0.3s;
}

input:focus {
  outline: none;
  border-color: var(--neon-blue);
  box-shadow: 0 0 8px rgba(0, 184, 255, 0.3);
}

button {
  background: rgba(0, 184, 255, 0.1);
  border: 1px solid var(--neon-blue);
  color: var(--neon-blue);
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
}

button:hover,
button:focus {
  background: var(--neon-blue);
  color: #000;
  box-shadow: 0 0 15px rgba(0, 184, 255, 0.4);
  outline: none;
}

#ai-response {
  margin-top: 1rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--neon-green);
}

/* Incidents List */
#incidents-list {
  list-style: none;
}

#incidents-list li {
  padding: 0.75rem;
  background: rgba(255, 0, 85, 0.1);
  border-left: 3px solid var(--neon-red);
  margin-bottom: 0.5rem;
  border-radius: 0 4px 4px 0;
  font-size: 0.875rem;
  color: #fff;
}

#incidents-list li:last-child {
  margin-bottom: 0;
}

/* Desktop override */
@media (min-width: 768px) {
  main {
    flex-direction: row;
  }

  #map-container {
    flex: 2;
  }

  .side-panels {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }
}