@import url('https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@500;700&family=JetBrains+Mono:wght@400;700&family=Rajdhani:wght@600;700&family=Saira+Stencil+One&display=swap');

:root {
  --bg: #0D0D0F;
  --bg-panel: #14140F;
  --bg-panel-alt: #1a1914;
  --panel-line: #5A2E0A;
  --orange: #FF6B1A;
  --orange-glow: rgba(255, 107, 26, 0.4);
  --amber: #FFA51F;
  --burnt: #C24405;
  --red: #E5342B;
  --red-dim: #5c1f1a;
  --green: #33C75A;
  --green-dim: #163d22;
  --orange-dim: #4a2e0c;
  --ink: #F5F1E6;
  --muted: #9a8f7d;
  
  --font-display: 'Chakra Petch', 'Saira Stencil One', sans-serif;
  --font-hud: 'Rajdhani', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font-hud);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 50% 0%, rgba(255, 107, 26, 0.08) 0%, transparent 60%),
    linear-gradient(rgba(255, 107, 26, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 107, 26, 0.03) 1px, transparent 1px);
  background-size: 100% 100%, 30px 30px, 30px 30px;
}

/* Scanlines overlay */
body::before {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%);
  background-size: 100% 4px;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.4;
}

/* Typography Helpers */
h1, h2, h3, h4, .hud-title {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ink);
}

.mono {
  font-family: var(--font-mono);
}

.text-orange { color: var(--orange); }
.text-amber { color: var(--amber); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-muted { color: var(--muted); }

/* Buttons & Inputs */
.hud-btn {
  background: linear-gradient(135deg, var(--orange) 0%, var(--burnt) 100%);
  color: #000;
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  border: 1px solid var(--amber);
  padding: 10px 24px;
  cursor: pointer;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-size: 0.95rem;
}

.hud-btn:hover {
  background: var(--amber);
  box-shadow: 0 0 15px var(--orange-glow);
  transform: translateY(-1px);
}

.hud-btn-secondary {
  background: transparent;
  color: var(--orange);
  border: 1px solid var(--orange);
}

.hud-btn-secondary:hover {
  background: rgba(255, 107, 26, 0.15);
  color: var(--amber);
}

.hud-btn-danger {
  background: linear-gradient(135deg, var(--red) 0%, var(--red-dim) 100%);
  border-color: #ff6b6b;
  color: #fff;
}

.hud-input {
  background: rgba(13, 13, 15, 0.9);
  border: 1px solid var(--panel-line);
  color: var(--ink);
  font-family: var(--font-mono);
  padding: 12px 16px;
  width: 100%;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.hud-input:focus {
  border-color: var(--orange);
  box-shadow: 0 0 8px var(--orange-glow);
}

/* HUD Panels */
.hud-panel {
  background-color: var(--bg-panel);
  border: 1px solid var(--panel-line);
  padding: 20px;
  position: relative;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  clip-path: polygon(
    0 12px, 
    12px 0, 
    calc(100% - 12px) 0, 
    100% 12px, 
    100% calc(100% - 12px), 
    calc(100% - 12px) 100%, 
    12px 100%, 
    0 calc(100% - 12px)
  );
}

.hud-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--panel-line);
  padding-bottom: 10px;
  margin-bottom: 16px;
}

.hud-panel-title {
  font-size: 1.1rem;
  color: var(--orange);
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-panel-title::before {
  content: "///";
  color: var(--amber);
  font-family: var(--font-mono);
}

/* Hazard Stripe Bar */
.hazard-stripe {
  height: 6px;
  background: repeating-linear-gradient(
    -45deg,
    var(--orange) 0,
    var(--orange) 16px,
    #0D0D0F 16px,
    #0D0D0F 32px
  );
  border-radius: 2px;
}

/* Navigation Header */
.app-header {
  background-color: var(--bg-panel);
  border-bottom: 2px solid var(--orange);
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  text-decoration: none;
}

.app-logo-badge {
  background: var(--orange);
  color: #000;
  font-family: var(--font-display);
  font-weight: 700;
  padding: 4px 20px 4px 12px;
  font-size: 1.1rem;
  letter-spacing: 1px;
  clip-path: polygon(0 0, 100% 0, 85% 100%, 0 100%);
}

.nav-links {
  display: flex;
  gap: 16px;
  align-items: center;
}

.nav-link {
  color: var(--muted);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  transition: color 0.2s;
}

.nav-link:hover, .nav-link.active {
  color: var(--orange);
}

/* Flash Messages */
.flash-container {
  max-width: 1200px;
  margin: 16px auto 0 auto;
  padding: 0 16px;
}

.flash-msg {
  padding: 12px 20px;
  margin-bottom: 12px;
  border-left: 4px solid var(--orange);
  background: var(--bg-panel);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.flash-success { border-color: var(--green); color: #8bffaa; background: rgba(51, 199, 90, 0.1); }
.flash-error { border-color: var(--red); color: #ff8b8b; background: rgba(229, 52, 43, 0.1); }
.flash-warning { border-color: var(--amber); color: #ffe38b; background: rgba(255, 165, 31, 0.1); }
.flash-info { border-color: var(--orange); color: var(--ink); }

/* Station Chips */
.station-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 32px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.85rem;
  border: 1px solid var(--panel-line);
  margin: 0 2px;
  position: relative;
}

.station-chip.resuelta {
  background: var(--green-dim);
  border-color: var(--green);
  color: var(--green);
  box-shadow: 0 0 6px rgba(51, 199, 90, 0.3);
}

.station-chip.en_curso {
  background: var(--orange-dim);
  border-color: var(--orange);
  color: var(--amber);
  box-shadow: 0 0 6px rgba(255, 107, 26, 0.3);
  animation: pulse-orange 2s infinite;
}

.station-chip.pendiente {
  background: rgba(255, 255, 255, 0.03);
  border-color: #3a2216;
  color: var(--muted);
}

.station-chip.bloqueada {
  background: #121214;
  border-color: #26262b;
  color: #444;
}

@keyframes pulse-orange {
  0% { border-color: var(--orange); }
  50% { border-color: var(--amber); box-shadow: 0 0 10px var(--orange-glow); }
  100% { border-color: var(--orange); }
}

/* Dashboard Spec Specific Layout */
.dashboard-page {
  max-width: 1920px;
  margin: 0 auto;
  padding: 16px 24px;
}

.dashboard-header-grid {
  display: grid;
  grid-template-columns: 280px 1fr 280px;
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
}

.pipeline-modules {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.pipeline-module {
  background: var(--bg-panel);
  border: 1px solid var(--orange);
  padding: 10px 16px;
  text-align: center;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
  min-width: 100px;
}

@keyframes laser-flow {
  0% { background-position: 0 0; }
  100% { background-position: 40px 0; }
}

.pipeline-connector {
  flex: 1;
  height: 4px;
  background: repeating-linear-gradient(90deg, var(--burnt) 0px, var(--orange) 10px, #ffdfa3 20px, var(--burnt) 30px);
  background-size: 40px 100%;
  box-shadow: 0 0 10px var(--orange);
  max-width: 40px;
  animation: laser-flow 1.2s linear infinite;
}

.live-pulse-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background-color: var(--green);
  border-radius: 50%;
  margin-right: 6px;
  position: relative;
  vertical-align: middle;
}

.live-pulse-dot::after {
  content: "";
  position: absolute;
  top: -4px; left: -4px; right: -4px; bottom: -4px;
  border-radius: 50%;
  border: 2px solid var(--green);
  animation: beacon-pulse 1.8s ease-out infinite;
}

@keyframes beacon-pulse {
  0% { transform: scale(0.6); opacity: 1; }
  100% { transform: scale(2.2); opacity: 0; }
}

.leaderboard-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 8px;
}

.leaderboard-table th {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--panel-line);
}

.leaderboard-table td {
  background: var(--bg-panel);
  padding: 14px 16px;
  border-top: 1px solid var(--panel-line);
  border-bottom: 1px solid var(--panel-line);
}

.leaderboard-table tr td:first-child {
  border-left: 1px solid var(--panel-line);
  clip-path: polygon(8px 0, 100% 0, 100% 100%, 0 100%, 0 8px);
}

.leaderboard-table tr td:last-child {
  border-right: 1px solid var(--panel-line);
}

.progress-bar-bg {
  height: 12px;
  background: #1f1d18;
  border: 1px solid var(--panel-line);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

@keyframes hazard-move {
  0% { background-position: 0 0; }
  100% { background-position: 34px 0; }
}

.hazard-stripe {
  height: 8px;
  background: repeating-linear-gradient(
    -45deg,
    var(--orange),
    var(--orange) 12px,
    #14140F 12px,
    #14140F 24px
  );
  background-size: 34px 34px;
  animation: hazard-move 2.5s linear infinite;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--burnt) 0%, var(--orange) 100%);
  box-shadow: 0 0 10px var(--orange);
  transition: width 0.5s ease;
  position: relative;
  overflow: hidden;
}

.progress-bar-fill::after {
  content: "";
  position: absolute;
  top: 0; left: -100%; width: 60%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { left: -100%; }
  100% { left: 200%; }
}

/* Footer Tagline */
.app-footer {
  text-align: center;
  padding: 20px;
  margin-top: 40px;
  border-top: 1px solid var(--panel-line);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--muted);
}

/* Victory Celebration Modal & Overlay */
.victory-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(8, 8, 10, 0.92);
  z-index: 10000;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
  backdrop-filter: blur(8px);
}

.victory-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

#fireworks-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 10001;
}

.victory-card {
  position: relative;
  z-index: 10002;
  background: radial-gradient(circle at 50% 30%, #1e1b10 0%, #100f0a 100%);
  border: 2px solid var(--amber);
  padding: 40px 60px;
  text-align: center;
  max-width: 900px;
  width: 90%;
  clip-path: polygon(
    0 24px, 
    24px 0, 
    calc(100% - 24px) 0, 
    100% 24px, 
    100% calc(100% - 24px), 
    calc(100% - 24px) 100%, 
    24px 100%, 
    0 calc(100% - 24px)
  );
  box-shadow: 0 0 50px rgba(255, 165, 31, 0.4), inset 0 0 30px rgba(255, 107, 26, 0.2);
  animation: victory-pop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.victory-team-name {
  font-family: var(--font-display);
  font-size: 3.8rem;
  font-weight: 700;
  color: #FFF;
  text-transform: uppercase;
  letter-spacing: 3px;
  text-shadow: 0 0 20px var(--amber), 0 0 40px var(--orange);
  margin: 16px 0;
  animation: victory-glow 2s infinite alternate;
}

@keyframes victory-glow {
  0% { text-shadow: 0 0 20px var(--amber), 0 0 40px var(--orange); transform: scale(1); }
  100% { text-shadow: 0 0 35px #FFDF00, 0 0 70px var(--orange); transform: scale(1.02); }
}

@keyframes victory-pop {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ==========================================================================
   MOBILE & RESPONSIVE DESIGN SYSTEM
   ========================================================================== */

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 12px;
  display: block;
}

.pipeline-modules {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  max-width: 100%;
  padding: 4px 0 8px 0;
}

@media (max-width: 992px) {
  .dashboard-header-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
  .dashboard-header-grid .hud-panel {
    text-align: center !important;
  }
}

@media (max-width: 768px) {
  /* Disable clip-path on mobile to prevent clipping table overflow and module truncation */
  .hud-panel {
    clip-path: none !important;
    padding: 12px 10px !important;
    border-radius: 4px;
  }

  main {
    padding: 8px 4px !important;
  }

  .dashboard-page {
    padding: 4px 2px !important;
  }

  .app-header {
    flex-direction: column;
    padding: 10px 10px;
    gap: 10px;
    text-align: center;
  }

  .app-brand {
    justify-content: center;
  }

  .nav-links {
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    width: 100%;
  }

  .nav-link {
    font-size: 0.8rem;
    padding: 4px 8px;
    background: rgba(20, 20, 15, 0.7);
    border: 1px solid var(--panel-line);
    border-radius: 3px;
    text-align: center;
  }

  .hud-panel-header {
    flex-direction: column;
    align-items: stretch !important;
    gap: 10px;
  }

  .hud-panel-header > div {
    width: 100%;
  }

  .hud-panel-title {
    font-size: 0.95rem;
    flex-wrap: wrap;
  }

  /* Pipeline Modules on Mobile: Compact Flex Grid without truncating names */
  .pipeline-modules {
    justify-content: center !important;
    gap: 6px !important;
  }

  .pipeline-module {
    padding: 4px 8px !important;
    min-width: 60px !important;
    font-size: 0.75rem !important;
    flex-shrink: 0;
    clip-path: none !important;
    border-radius: 3px;
  }

  .pipeline-connector {
    display: none !important; /* Hide connector bars on mobile to fit all 5 modules cleanly */
  }

  .leaderboard-table {
    min-width: 540px; /* Ensures all table columns fit cleanly with horizontal scroll */
  }

  .leaderboard-table th, 
  .leaderboard-table td, 
  .hud-table th, 
  .hud-table td {
    padding: 8px 6px;
    font-size: 0.8rem;
  }

  .station-chip {
    width: 22px !important;
    height: 22px !important;
    font-size: 0.65rem !important;
    margin: 0 1px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .stations-grid {
    grid-template-columns: 1fr !important;
  }

  .victory-card {
    padding: 20px 12px !important;
    max-width: 96% !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
    clip-path: none !important;
    border-radius: 8px;
  }

  .victory-team-name {
    font-size: 1.8rem !important;
    word-break: break-word;
  }

  .hud-btn {
    padding: 8px 12px;
    font-size: 0.8rem;
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  h1, .hud-title {
    font-size: 1.1rem;
  }

  .app-logo-badge {
    font-size: 0.85rem;
  }

  .victory-team-name {
    font-size: 1.5rem !important;
  }
}

