/* ═══════════════════════════════════════════════════════════════════════════
   RunwAI - Live Airport Simulation
   Clean, minimal UI
   ═══════════════════════════════════════════════════════════════════════════ */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  background: #0a0d12;
  color: #e8ecf2;
  overflow: hidden;
  height: 100vh;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ─── HEADER ─────────────────────────────────────────────────────────────── */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: rgba(15, 20, 30, 0.95);
  border-bottom: 1px solid rgba(100, 140, 200, 0.15);
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.45rem;
  font-weight: 700;
}

.logo-icon {
  font-size: 1.5rem;
}

.logo-text {
  background: linear-gradient(135deg, #3dd5ff, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-stats {
  display: flex;
  gap: 24px;
}

.stat {
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 1.65rem;
  font-weight: 700;
  color: #3dd5ff;
}

.stat-label {
  font-size: 0.8rem;
  color: #6b7a8f;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat.alert .stat-value {
  color: #f87171;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(74, 222, 128, 0.15);
  border: 1px solid rgba(74, 222, 128, 0.3);
  border-radius: 20px;
}

.status-indicator {
  width: 10px;
  height: 10px;
  background: #4ade80;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

.status-text {
  font-size: 0.88rem;
  font-weight: 700;
  color: #4ade80;
  letter-spacing: 0.1em;
}

.header-status.alert {
  background: rgba(248, 113, 113, 0.15);
  border-color: rgba(248, 113, 113, 0.3);
}

.header-status.alert .status-indicator {
  background: #f87171;
  animation: pulse 0.5s infinite;
}

.header-status.alert .status-text {
  color: #f87171;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.9); }
}

/* ─── MAIN ───────────────────────────────────────────────────────────────── */

.main {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

/* ─── MAP ────────────────────────────────────────────────────────────────── */

.map-wrapper {
  flex: 1;
  position: relative;
  background: #0d1117;
  overflow: hidden;
  min-height: 0;
}

.map-container {
  width: 100%;
  height: 100%;
  overflow: hidden;
  cursor: grab;
}

.map-container:active {
  cursor: grabbing;
}

#airportCanvas {
  transform-origin: 0 0;
  image-rendering: crisp-edges;
}

/* Zoom Controls */
.zoom-controls {
  position: absolute;
  bottom: 20px;
  left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(15, 20, 30, 0.9);
  border: 1px solid rgba(100, 140, 200, 0.2);
  border-radius: 10px;
  padding: 8px;
}

.zoom-btn {
  width: 36px;
  height: 36px;
  background: rgba(40, 50, 70, 0.8);
  border: 1px solid rgba(100, 140, 200, 0.2);
  border-radius: 6px;
  color: #b8c8e0;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.15s;
}

.zoom-btn:hover {
  background: rgba(61, 213, 255, 0.2);
  border-color: #3dd5ff;
  color: #3dd5ff;
}

.zoom-btn.reset {
  font-size: 1rem;
}

.zoom-level {
  text-align: center;
  font-size: 0.88rem;
  color: #6b7a8f;
  padding: 4px 0;
}

/* Mini Legend */
.mini-legend {
  position: absolute;
  bottom: 20px;
  right: 20px;
  background: rgba(15, 20, 30, 0.9);
  border: 1px solid rgba(100, 140, 200, 0.2);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.95rem;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  color: #8a9db8;
}

.legend-row:last-child {
  margin-bottom: 0;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot.green { background: #4ade80; }
.dot.yellow { background: #fbbf24; }
.dot.red { background: #f87171; }

/* Storm Banner */
.storm-banner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(90deg, rgba(139, 92, 246, 0.9), rgba(248, 113, 113, 0.9));
  color: white;
  text-align: center;
  padding: 14px 16px;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.06em;
  transform: translateY(-100%);
  transition: transform 0.3s;
}

.storm-banner.visible {
  transform: translateY(0);
}

/* ─── SIDE PANEL ─────────────────────────────────────────────────────────── */

.side-panel {
  width: 320px;
  background: rgba(12, 16, 24, 0.98);
  border-left: 1px solid rgba(100, 140, 200, 0.15);
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
}

.scenario-box {
  display: flex;
  gap: 8px;
  padding: 12px;
  background: rgba(20, 28, 40, 0.8);
}

.scenario-box select {
  flex: 1;
  background: rgba(30, 40, 55, 0.9);
  border: 1px solid rgba(100, 140, 200, 0.2);
  border-radius: 6px;
  color: #e8ecf2;
  padding: 8px 10px;
  font-size: 0.92rem;
  cursor: pointer;
}

.scenario-box select option {
  background: #1a2030;
}

.run-btn {
  background: linear-gradient(135deg, #3dd5ff, #1ebbe2);
  border: none;
  border-radius: 6px;
  color: #062530;
  padding: 8px 14px;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.run-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(61, 213, 255, 0.4);
}

/* Panels */
.panel {
  background: rgba(18, 24, 35, 0.9);
  padding: 12px;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #8a9db8;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.panel-icon {
  font-size: 1rem;
}

/* Alerts Panel */
.alerts-panel {
  border-left: 3px solid transparent;
  transition: border-color 0.3s;
}

.alerts-panel.has-alerts {
  border-left-color: #f87171;
  background: rgba(248, 113, 113, 0.05);
}

.alerts-dock {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-top: 1px solid rgba(100, 140, 200, 0.2);
  padding: 0;
  overflow: visible;
}

.alerts-dock-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 2px;
  font-size: 0.68rem;
  font-weight: 700;
  color: #8a9db8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.alerts-dock-title {
  color: #c5d3e8;
}

.alerts-list {
  display: block;
  overflow-x: auto;
  overflow-y: visible;
  padding: 4px 8px 6px;
}

.alerts-policy-bar {
  font-size: 0.62rem;
  line-height: 1.25;
  color: #c8d4e8;
  padding: 4px 8px 5px;
  margin-bottom: 4px;
  background: rgba(61, 213, 255, 0.06);
  border: 1px solid rgba(61, 213, 255, 0.18);
  border-radius: 5px;
}

.alerts-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 6px;
  align-items: flex-start;
}

.no-alerts {
  text-align: center;
  color: #4ade80;
  font-size: 0.72rem;
  padding: 8px;
}

.alert-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  padding: 4px 7px 5px;
  background: rgba(30, 35, 45, 0.85);
  border-radius: 5px;
  border-left: 2px solid #fbbf24;
  flex: 1 1 200px;
  max-width: min(380px, 100%);
  min-width: min(180px, 100%);
}

.alert-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.alert-item.red {
  border-left-color: #f87171;
  background: rgba(248, 113, 113, 0.1);
}

.alert-item-ml {
  border-left-color: #60cfff;
  background: rgba(61, 213, 255, 0.07);
}

.alert-item-ml .alert-rule {
  background: rgba(61, 213, 255, 0.2);
  color: #7fe8ff;
}

.alert-rule {
  background: rgba(248, 113, 113, 0.2);
  color: #f87171;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.58rem;
  font-weight: 700;
}

.alert-item.yellow .alert-rule {
  background: rgba(251, 191, 36, 0.2);
  color: #fbbf24;
}

.alert-flights {
  flex: 1;
  font-size: 0.68rem;
  font-weight: 600;
  font-family: monospace;
}

.alert-dist {
  font-size: 0.62rem;
  color: #9eb0cc;
  font-family: monospace;
}

.alert-explain {
  font-size: 0.58rem;
  line-height: 1.2;
  color: #a8b6ca;
}

.alert-advice {
  font-size: 0.58rem;
  line-height: 1.2;
  color: #d8dee8;
  padding-top: 2px;
  margin-top: 1px;
  border-top: 1px solid rgba(100, 140, 200, 0.1);
}

.alert-advice-label {
  font-weight: 700;
  color: #5ec8f0;
  margin-right: 3px;
}

/* AI Panel */
.ai-panel {
  background: rgba(61, 213, 255, 0.03);
  border-left: 3px solid #3dd5ff;
}

.ai-idle {
  text-align: center;
  color: #6b7a8f;
  font-size: 1rem;
  padding: 15px;
}

.ai-action {
  background: rgba(61, 213, 255, 0.1);
  border: 1px solid rgba(61, 213, 255, 0.2);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}

.ai-target {
  font-size: 1.22rem;
  font-weight: 700;
  color: #3dd5ff;
  font-family: monospace;
  margin-bottom: 6px;
}

.ai-command {
  font-size: 1.22rem;
  font-weight: 700;
  color: #f87171;
  margin-bottom: 6px;
}

.ai-explain {
  font-size: 0.98rem;
  line-height: 1.45;
  color: #b8c8dc;
  text-align: left;
  margin-bottom: 8px;
}

.ai-advice {
  font-size: 1rem;
  line-height: 1.45;
  color: #e8ecf2;
  text-align: left;
}

.ai-advice-label {
  font-weight: 700;
  color: #3dd5ff;
}

.ai-action--crash {
  border-color: rgba(248, 113, 113, 0.45);
  background: rgba(248, 113, 113, 0.12);
}

/* Flights Panel */
.flights-panel {
  flex: 1;
  overflow-y: auto;
}

.flights-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.flight-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(30, 38, 50, 0.6);
  border-radius: 6px;
  border-left: 3px solid transparent;
}

.flight-row.conflict {
  border-left-color: #f87171;
  background: rgba(248, 113, 113, 0.1);
}

.flight-id {
  font-weight: 700;
  font-family: monospace;
  font-size: 1.08rem;
  color: #e8ecf2;
}

.flight-type {
  font-size: 0.85rem;
  color: #6b7a8f;
}

.flight-phase {
  margin-left: auto;
  font-size: 0.85rem;
  color: #3dd5ff;
  text-transform: uppercase;
}

.no-flights {
  text-align: center;
  color: #6b7a8f;
  font-size: 0.8rem;
  padding: 20px;
}

/* ─── SCROLLBAR ──────────────────────────────────────────────────────────── */

::-webkit-scrollbar {
  width: 5px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}

::-webkit-scrollbar-thumb {
  background: rgba(100, 140, 200, 0.3);
  border-radius: 3px;
}

/* ─── RESPONSIVE ─────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .side-panel {
    width: 240px;
  }
  
  .header-stats {
    gap: 16px;
  }
  
  .stat-value {
    font-size: 1.1rem;
  }
}

@media (max-width: 600px) {
  .header {
    flex-wrap: wrap;
    gap: 10px;
  }
  
  .side-panel {
    position: fixed;
    right: 0;
    top: 60px;
    bottom: 0;
    width: 260px;
    transform: translateX(100%);
    transition: transform 0.3s;
    z-index: 200;
  }
  
  .side-panel.open {
    transform: translateX(0);
  }
}
