/* ==========================================================================
   FIERRERO - MOTORSPORT CAREER MANAGER
   Design System & Dashboard Stylesheet (v2.1 Layout Refinement)
   ========================================================================== */

:root {
  --bg-color: #0b0f19;
  --panel-bg: rgba(18, 26, 43, 0.88);
  --panel-border: rgba(255, 255, 255, 0.1);
  --card-bg: rgba(25, 36, 59, 0.65);
  --card-hover: rgba(35, 50, 80, 0.85);
  
  --primary-red: #e63946;
  --accent-cyan: #00f0ff;
  --accent-gold: #ffb703;
  --accent-green: #2ec4b6;
  --accent-purple: #9d4edd;
  
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;

  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

body {
  background-color: var(--bg-color);
  background-image: 
    radial-gradient(circle at 15% 20%, rgba(230, 57, 70, 0.08) 0%, transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(0, 240, 255, 0.06) 0%, transparent 45%);
  color: var(--text-main);
  font-family: var(--font-family);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 16px;
}

/* Header Dashboard Bar */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 14px 20px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon { font-size: 26px; }

.brand-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #ffffff 0%, var(--accent-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-transform: uppercase;
}

.brand-subtitle {
  font-size: 10px;
  color: var(--accent-gold);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.top-stats-container {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.top-stat-card {
  background: var(--card-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  min-width: 90px;
  text-align: center;
}

.top-stat-label {
  font-size: 9px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1px;
  margin-bottom: 2px;
}

.top-stat-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.top-stat-value.highlight-cyan { color: var(--accent-cyan); }
.top-stat-value.highlight-gold { color: var(--accent-gold); }
.top-stat-value.highlight-green { color: var(--accent-green); }
.top-stat-value.highlight-red { color: var(--primary-red); }

/* SUB-HEADER: VITRINA DE TROFEOS SIEMPRE VISIBLE */
.sub-header-trophies {
  background: rgba(18, 26, 43, 0.7);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 8px 18px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 12px;
}

.trophy-stat-badge {
  display: flex;
  align-items: center;
  gap: 6px;
}

.trophy-badge-label {
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 10px;
}

.trophy-badge-val {
  font-weight: 800;
  color: var(--accent-gold);
  font-size: 13px;
}

.trophies-recent-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.trophy-chip {
  background: rgba(255, 183, 3, 0.15);
  border: 1px solid var(--accent-gold);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--accent-gold);
  white-space: nowrap;
}

/* Layout Grid */
.main-dashboard {
  display: grid;
  grid-template-columns: 350px 1fr 360px;
  gap: 16px;
  flex: 1;
}

@media (max-width: 1250px) {
  .main-dashboard {
    grid-template-columns: 320px 1fr;
  }
  .right-sidebar {
    grid-column: span 2;
  }
}

@media (max-width: 880px) {
  .main-dashboard {
    grid-template-columns: 1fr;
  }
  .right-sidebar {
    grid-column: span 1;
  }
}

/* Panel Containers */
.dashboard-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.panel-header {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 8px;
}

/* Pilot Profile Card */
.pilot-profile-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card-bg);
  padding: 10px;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}

.pilot-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-red), var(--accent-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.pilot-info h3 { font-size: 14px; color: var(--text-main); }
.pilot-info p { font-size: 11px; color: var(--text-muted); }

/* Stats & Upgrades Grids */
.stats-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.stat-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
}

.stat-name { color: var(--text-muted); }
.stat-val { font-weight: 700; color: var(--accent-cyan); }

.progress-bar-bg {
  height: 5px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-green));
  border-radius: 3px;
  transition: width 0.4s ease;
}

.btn-secondary {
  background: var(--card-bg);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: var(--radius-md);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.btn-secondary:hover {
  background: var(--card-hover);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.btn-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: transparent;
}

/* CAR UPGRADES SECTION DESPLEGADA EN EL PANEL IZQUIERDO */
.upgrades-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.upgrade-card-inline {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.upgrade-title { font-size: 11px; font-weight: 700; color: var(--text-main); }
.upgrade-desc { font-size: 10px; color: var(--text-muted); }

/* Console & Narrative Feed */
.console-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.narrative-log {
  flex: 1;
  background: rgba(10, 14, 23, 0.9);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 14px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 280px;
  max-height: 540px;
}

.log-entry {
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
  border-left: 3px solid var(--accent-cyan);
  animation: fadeIn 0.3s ease-in-out;
  line-height: 1.5;
}

.log-entry.event {
  border-left-color: var(--accent-gold);
  background: rgba(255, 183, 3, 0.05);
}

.log-entry.race {
  border-left-color: var(--primary-red);
  background: rgba(230, 57, 70, 0.05);
}

.log-entry.season {
  border-left-color: var(--accent-green);
  background: rgba(46, 196, 182, 0.08);
}

.log-timestamp {
  font-size: 9px;
  color: var(--text-dim);
  margin-bottom: 3px;
  text-transform: uppercase;
}

/* Bottom Action Area */
.action-deck {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-buttons-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 8px;
}

.btn-primary-advance {
  width: 100%;
  background: linear-gradient(135deg, var(--primary-red) 0%, #b81424 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(230, 57, 70, 0.4);
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary-advance:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(230, 57, 70, 0.6);
  background: linear-gradient(135deg, #ff4d5e 0%, var(--primary-red) 100%);
}

.btn-advance-month {
  background: linear-gradient(135deg, var(--accent-purple) 0%, #6b21a8 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(157, 78, 221, 0.3);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-advance-month:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(157, 78, 221, 0.5);
}

/* Event Options Container */
.event-options-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.event-prompt-box {
  background: rgba(255, 183, 3, 0.1);
  border: 1px solid var(--accent-gold);
  border-radius: var(--radius-md);
  padding: 12px;
  color: var(--text-main);
  font-size: 12px;
}

.event-prompt-title {
  color: var(--accent-gold);
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
}

.btn-option {
  background: var(--card-bg);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-main);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.btn-option:hover {
  background: var(--card-hover);
  border-color: var(--accent-cyan);
}

.btn-option-title { font-weight: 700; font-size: 13px; color: var(--accent-cyan); }
.btn-option-desc { font-size: 11px; color: var(--text-muted); }
.btn-option-prob { font-size: 10px; color: var(--accent-gold); font-weight: 600; }

/* Leaderboards & Standings Tables */
.standings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.standings-table th {
  text-align: left;
  padding: 6px 4px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--panel-border);
  text-transform: uppercase;
  font-size: 9px;
}

.standings-table td {
  padding: 6px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.standings-table tr.highlight-player {
  background: rgba(0, 240, 255, 0.12);
  font-weight: 700;
}

.standings-table tr.highlight-player td {
  color: var(--accent-cyan);
}

/* Modales */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(5, 8, 15, 0.88);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
  z-index: 9999;
}

.modal-content {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 520px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.modal-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--accent-cyan);
  text-transform: uppercase;
}

.roulette-box {
  border: 4px solid var(--accent-gold);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  background: rgba(0,0,0,0.6);
  transition: border-color 0.1s ease;
}

.roulette-box.spinning {
  animation: pulseBorder 0.15s infinite alternate;
}

.roulette-box.success {
  border-color: var(--accent-green) !important;
  box-shadow: 0 0 40px rgba(46, 196, 182, 0.5);
}

.roulette-box.failure {
  border-color: var(--primary-red) !important;
  box-shadow: 0 0 40px rgba(230, 57, 70, 0.5);
}

.roulette-status {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 1px;
}

.apex-track-bg {
  width: 100%;
  height: 36px;
  background: #111;
  border: 2px solid var(--panel-border);
  border-radius: 18px;
  position: relative;
  overflow: hidden;
  margin: 16px 0;
}

.apex-target-zone {
  position: absolute;
  top: 0;
  height: 100%;
  width: 20%;
  left: 40%;
  background: linear-gradient(90deg, rgba(46, 196, 182, 0.3), var(--accent-green), rgba(46, 196, 182, 0.3));
  border-left: 2px solid var(--accent-green);
  border-right: 2px solid var(--accent-green);
}

.apex-indicator {
  position: absolute;
  top: 0;
  width: 6px;
  height: 100%;
  background: #ffffff;
  box-shadow: 0 0 10px #ffffff;
  left: 0%;
}

.lights-grid {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  background: #05080f;
  padding: 16px 24px;
  border-radius: var(--radius-md);
  border: 2px solid rgba(255, 255, 255, 0.15);
  margin: 16px 0;
}

.light-bulb {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  border-radius: 50%;
  background: #1a2332;
  border: 2px solid #000;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.9);
  transition: background 0.1s ease, box-shadow 0.1s ease;
}

.light-bulb.red {
  background: #ff0033 !important;
  box-shadow: 0 0 24px #ff0033, inset 0 0 6px #ffffff !important;
}

.light-bulb.green {
  background: #00ff66 !important;
  box-shadow: 0 0 28px #00ff66, inset 0 0 6px #ffffff !important;
}

.btn-pitstop-trigger {
  width: 100%;
  padding: 18px;
  font-size: 16px;
  font-weight: 800;
  text-transform: uppercase;
  color: #fff;
  background: var(--primary-red);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(230, 57, 70, 0.4);
  transition: transform 0.1s ease;
}

.btn-pitstop-trigger:active {
  transform: scale(0.97);
}

.wheels-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
}

.wheel-nut-btn {
  background: var(--card-bg);
  border: 2px solid var(--accent-cyan);
  border-radius: var(--radius-md);
  padding: 20px;
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
  transition: all 0.15s ease;
}

.wheel-nut-btn.done {
  background: rgba(46, 196, 182, 0.2);
  border-color: var(--accent-green);
  color: var(--accent-green);
}


/* Estilos para Minijuego de Matriz de Reacción en Grilla */
.grid-reaction-matrix {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 16px 0;
}

.grid-tile-btn {
  height: 75px;
  border-radius: var(--radius-md);
  border: 2px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.05);
  font-size: 20px;
  cursor: pointer;
  transition: all 0.1s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.grid-tile-btn:active {
  transform: scale(0.94);
}

.grid-tile-btn.tile-red {
  background: rgba(230, 57, 70, 0.85);
  border-color: #ff4d6d;
  box-shadow: 0 0 16px rgba(230, 57, 70, 0.6);
}

.grid-tile-btn.tile-green {
  background: rgba(46, 196, 182, 0.85);
  border-color: #00ffaa;
  box-shadow: 0 0 16px rgba(46, 196, 182, 0.6);
}

.grid-tile-btn.tile-blue {
  background: rgba(0, 240, 255, 0.85);
  border-color: #00f0ff;
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.6);
}

.grid-tile-btn.tile-off {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: none;
  opacity: 0.4;
}

.toast-msg {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--panel-bg);
  border-left: 4px solid var(--accent-cyan);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  font-size: 13px;
  z-index: 999;
  animation: slideIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulseBorder {
  from { border-color: var(--accent-cyan); }
  to { border-color: var(--primary-red); }
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
