/* =====================================================================
   Simulador de aerogenerador — hoja de estilos
   Tema oscuro tipo laboratorio, acentos verde/cian.
   ===================================================================== */

:root {
  --fondo: #050d13;
  --panel: rgba(12, 29, 38, 0.82);
  --panel-solido: #0b1a23;
  --borde: rgba(130, 200, 230, 0.13);
  --borde-fuerte: rgba(130, 200, 230, 0.24);
  --texto: #dceaf3;
  --suave: #8ba3b2;
  --tenue: #5d7482;
  --verde: #38e1a4;
  --verde-oscuro: #0f4a3a;
  --cian: #4cc9f0;
  --ambar: #ffd166;
  --rojo: #ff6b6b;
  --violeta: #b58cff;
  --radio: 18px;
  --mono: "SFMono-Regular", "Cascadia Mono", "Roboto Mono", Consolas, monospace;
  --sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--fondo);
  color: var(--texto);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.fondo {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1200px 700px at 75% -10%, rgba(23, 92, 96, 0.35), transparent 60%),
    radial-gradient(900px 600px at 5% 100%, rgba(18, 60, 82, 0.5), transparent 65%),
    linear-gradient(180deg, #061019 0%, #040b11 100%);
}

.orbita {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.35;
  pointer-events: none;
}
.orbita-a {
  width: 420px; height: 420px;
  top: -140px; right: 8%;
  background: #1d7d78;
}
.orbita-b {
  width: 360px; height: 360px;
  bottom: -160px; left: -80px;
  background: #144a63;
}

.app {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(1720px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 22px 20px;
}

/* ------------------------------ Cabecera ------------------------------ */
.cabecera {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.marca { display: flex; align-items: center; gap: 13px; }

.marca-icono {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  color: #071b16;
  background: linear-gradient(145deg, var(--verde), #2bb9cf);
  box-shadow: 0 8px 24px rgba(56, 225, 164, 0.28);
}
.marca-icono svg { width: 26px; height: 26px; }

.marca-texto h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.marca-texto p {
  margin: 2px 0 0;
  color: var(--suave);
  font-size: 12px;
}
.marca-texto span { color: var(--verde); margin: 0 2px; }

.estado {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 8px 14px;
  border: 1px solid var(--borde);
  border-radius: 999px;
  background: rgba(12, 29, 38, 0.7);
  color: var(--suave);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.estado-punto {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--tenue);
  box-shadow: 0 0 0 4px rgba(93, 116, 130, 0.12);
  transition: background 0.25s, box-shadow 0.25s;
}
.estado.ok { color: #bff5df; border-color: rgba(56, 225, 164, 0.35); }
.estado.ok .estado-punto { background: var(--verde); box-shadow: 0 0 0 4px rgba(56, 225, 164, 0.16), 0 0 14px rgba(56, 225, 164, 0.8); }
.estado.warn { color: #ffe8ae; border-color: rgba(255, 209, 102, 0.3); }
.estado.warn .estado-punto { background: var(--ambar); box-shadow: 0 0 0 4px rgba(255, 209, 102, 0.14), 0 0 12px rgba(255, 209, 102, 0.7); }
.estado.peligro { color: #ffc2c2; border-color: rgba(255, 107, 107, 0.38); }
.estado.peligro .estado-punto { background: var(--rojo); box-shadow: 0 0 0 4px rgba(255, 107, 107, 0.16), 0 0 12px rgba(255, 107, 107, 0.8); }

/* ------------------------------ Paneles ------------------------------ */
.panel {
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  background: linear-gradient(160deg, rgba(15, 34, 44, 0.9), rgba(7, 19, 26, 0.92));
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.035);
  padding: 16px 16px 14px;
  min-width: 0;
}

.panel-titulo {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.panel-titulo h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #cfe2ee;
}
.panel-nota {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tenue);
  white-space: nowrap;
}

/* ------------------------------ Reproductor ------------------------------ */
.principal {
  flex: 1;
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr) 300px;
  grid-template-areas: "controles escenario instrumentos";
  gap: 14px;
  min-height: 470px;
}

.controles { grid-area: controles; display: flex; flex-direction: column; }
.escenario { grid-area: escenario; }
.instrumentos { grid-area: instrumentos; display: flex; flex-direction: column; overflow: auto; }

/* ------------------------------ Controles ------------------------------ */
.control { margin-bottom: 17px; }

.control-fila {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.control-fila label {
  font-size: 12px;
  font-weight: 600;
  color: #b9cedb;
}
.control-fila output {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--verde);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 999px;
  background: rgba(150, 200, 225, 0.16);
  border: 1px solid rgba(150, 200, 225, 0.08);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 17px;
  height: 17px;
  margin-top: -7px;
  border-radius: 50%;
  background: linear-gradient(160deg, #8ff8d1, var(--verde));
  border: 2px solid #04231c;
  box-shadow: 0 0 0 3px rgba(56, 225, 164, 0.18), 0 2px 8px rgba(0, 0, 0, 0.5);
  transition: box-shadow 0.2s;
}
input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 6px rgba(56, 225, 164, 0.28);
}
input[type="range"]::-moz-range-track {
  height: 5px;
  border-radius: 999px;
  background: rgba(150, 200, 225, 0.16);
}
input[type="range"]::-moz-range-thumb {
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--verde);
  border: 2px solid #04231c;
  box-shadow: 0 0 0 3px rgba(56, 225, 164, 0.18);
}

.escala {
  display: flex;
  justify-content: space-between;
  margin-top: 1px;
  font-size: 9px;
  color: var(--tenue);
  letter-spacing: 0.04em;
}

.presets { margin-top: 2px; }
.presets-titulo {
  display: block;
  margin-bottom: 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tenue);
}
.presets-fila { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.presets button {
  padding: 8px 6px;
  border-radius: 10px;
  border: 1px solid var(--borde);
  background: rgba(255, 255, 255, 0.035);
  color: #b9cedb;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, color 0.18s, transform 0.12s;
}
.presets button:hover { border-color: var(--borde-fuerte); background: rgba(255, 255, 255, 0.07); }
.presets button:active { transform: translateY(1px); }
.presets button.activo {
  color: #04231c;
  background: linear-gradient(160deg, #8ff8d1, var(--verde));
  border-color: transparent;
  box-shadow: 0 6px 18px rgba(56, 225, 164, 0.22);
}

.nota {
  margin: auto 0 0;
  padding-top: 14px;
  border-top: 1px dashed rgba(130, 200, 230, 0.14);
  color: var(--tenue);
  font-size: 10.5px;
  line-height: 1.55;
}
.nota strong { color: #b9cedb; }
.nota-corta {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed rgba(130, 200, 230, 0.12);
}

/* ------------------------------ Escenario 3D ------------------------------ */
.escenario {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  background:
    radial-gradient(120% 90% at 50% 0%, #12303a 0%, #071620 55%, #050e14 100%);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  min-height: 470px;
}

.escenario canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.escenario-hud {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  gap: 8px;
  pointer-events: none;
}

.hud-chip {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 92px;
  padding: 9px 13px;
  border: 1px solid rgba(160, 215, 240, 0.16);
  border-radius: 13px;
  background: rgba(5, 16, 22, 0.62);
  backdrop-filter: blur(8px);
}
.hud-etiqueta {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #7fa0b1;
}
.hud-valor {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.hud-valor b { font-size: 21px; font-weight: 700; color: #f2fbff; letter-spacing: -0.02em; }
.hud-chip-verde .hud-valor b { color: var(--verde); }
.hud-valor i { font-style: normal; font-size: 10px; color: var(--suave); }

.escenario-pie {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 12px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
  flex-wrap: wrap;
}
.vista-chip {
  padding: 6px 11px;
  border: 1px solid rgba(160, 215, 240, 0.12);
  border-radius: 999px;
  background: rgba(5, 16, 22, 0.55);
  color: #8fb0c1;
  font-size: 10px;
  backdrop-filter: blur(6px);
}
.vista-chip b { color: var(--verde); font-weight: 600; }

.aviso-webgl {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 30px;
  text-align: center;
  background: rgba(4, 12, 17, 0.9);
}
.aviso-webgl[hidden] { display: none; }
.aviso-webgl strong { font-size: 15px; }
.aviso-webgl p { margin: 0; color: var(--suave); font-size: 12px; max-width: 340px; }

/* ------------------------------ Instrumentos ------------------------------ */
.datos {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.dato {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 7px 9px;
  border: 1px solid rgba(130, 200, 230, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.028);
  min-width: 0;
}
.dato span {
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tenue);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dato b {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  color: #e8f6fc;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  white-space: nowrap;
}
.dato i {
  font-style: normal;
  font-size: 9px;
  color: var(--tenue);
  line-height: 1;
}

.led {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--borde);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
  transition: border-color 0.3s, background 0.3s;
}
.led.encendido { border-color: rgba(255, 140, 90, 0.35); background: rgba(255, 90, 50, 0.06); }

.led-foco {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #6f2a22, #2a0d0b 70%);
  border: 1px solid rgba(255, 150, 120, 0.28);
  transition: background 0.25s, box-shadow 0.25s;
}
.led.encendido .led-foco {
  background: radial-gradient(circle at 35% 30%, #fff1d6, #ff5b33 55%, #c11d0d);
  border-color: #ffb199;
}

.led-texto { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.led-texto strong { font-size: 11.5px; font-weight: 700; }
.led-texto span { font-size: 9.5px; color: var(--tenue); }

.brillo-pista {
  height: 5px;
  margin-top: 10px;
  border-radius: 999px;
  background: rgba(150, 200, 225, 0.12);
  overflow: hidden;
}
.brillo-relleno {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2a7f65, var(--verde) 60%, #d6ffe9);
  box-shadow: 0 0 12px rgba(56, 225, 164, 0.5);
  transition: width 0.12s linear;
}
.brillo-escala {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 8.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tenue);
}

/* ------------------------------ Inferior ------------------------------ */
.inferior {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 14px;
}

.grafica {
  position: relative;
  width: 100%;
  height: 196px;
}
.grafica canvas { display: block; width: 100%; height: 100%; }

.leyenda {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 7px;
  font-size: 10px;
  color: var(--suave);
}
.leyenda span { display: inline-flex; align-items: center; gap: 6px; }
.leyenda i {
  width: 8px; height: 8px;
  border-radius: 2px;
  display: inline-block;
}

/* ------------------------------ Balance ------------------------------ */
.balance-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
  font-size: 11px;
  color: var(--suave);
}
.balance-total b {
  font-family: var(--mono);
  font-size: 15px;
  color: #e8f6fc;
  font-variant-numeric: tabular-nums;
}
.balance-fuente {
  margin: -2px 0 8px;
  font-size: 9.5px;
  letter-spacing: 0.04em;
  color: var(--tenue);
}

.barra-energia {
  display: flex;
  height: 13px;
  border-radius: 7px;
  overflow: hidden;
  background: rgba(150, 200, 225, 0.08);
  border: 1px solid rgba(150, 200, 225, 0.08);
}
.seg {
  display: block;
  height: 100%;
  width: 0%;
  transition: width 0.16s linear;
}
.seg.no-capturada, .muestra.no-capturada { background: #2f4657; }
.seg.almacenada, .muestra.almacenada { background: #4cc9f0; }
.seg.friccion, .muestra.friccion { background: #ff9f5a; }
.seg.generador, .muestra.generador { background: var(--violeta); }
.seg.resistencia, .muestra.resistencia { background: var(--rojo); }
.seg.led, .muestra.led { background: var(--verde); }

.leyenda-energia {
  list-style: none;
  margin: 11px 0 0;
  padding: 0;
  display: grid;
  gap: 5px;
}
.leyenda-energia li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10.5px;
  color: var(--suave);
}
.leyenda-energia b {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  color: #cfe2ee;
  font-variant-numeric: tabular-nums;
}
.muestra {
  flex: 0 0 auto;
  width: 8px; height: 8px;
  border-radius: 2px;
}

/* ------------------------------ Ecuaciones ------------------------------ */
.panel-ecuaciones { grid-column: 1 / -1; }

.ecuaciones {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px 22px;
}

.ecuacion {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 7px 11px;
  border: 1px solid rgba(130, 200, 230, 0.07);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.022);
  min-width: 0;
}
.ecuacion code {
  font-family: var(--mono);
  font-size: 11px;
  color: #9fd9f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ecuacion sub { font-size: 8px; }
.ecuacion span {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--verde);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ------------------------------ Pie ------------------------------ */
.pie {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 2px 4px 0;
  color: var(--tenue);
  font-size: 10px;
}

/* ------------------------------ Responsive ------------------------------ */
@media (max-width: 1360px) {
  .principal { grid-template-columns: 270px minmax(0, 1fr) 280px; }
  .inferior { grid-template-columns: 1.15fr 1fr; }
  .inferior .panel:nth-child(3) { grid-column: 1 / -1; }
  .panel-ecuaciones { grid-column: 1 / -1; }
}

@media (max-width: 1120px) {
  .principal {
    grid-template-columns: 260px minmax(0, 1fr);
    grid-template-areas:
      "controles escenario"
      "instrumentos instrumentos";
  }
  .instrumentos { overflow: visible; }
  .datos { grid-template-columns: repeat(5, 1fr); }
  .escenario { min-height: 430px; }
}

@media (max-width: 820px) {
  .app { padding: 14px 14px 18px; gap: 12px; }
  .cabecera { align-items: flex-start; }
  .principal {
    grid-template-columns: 1fr;
    grid-template-areas:
      "escenario"
      "controles"
      "instrumentos";
    min-height: 0;
  }
  .escenario { min-height: 380px; }
  .inferior { grid-template-columns: 1fr; }
  .inferior .panel:nth-child(3) { grid-column: auto; }
  .panel-ecuaciones { grid-column: auto; }
  .ecuaciones { grid-template-columns: 1fr; }
  .datos { grid-template-columns: repeat(2, 1fr); }
  .pie { flex-direction: column; gap: 4px; }
  .escenario-pie { display: none; }
  .grafica { height: 210px; }
}

@media (max-width: 480px) {
  .marca-texto h1 { font-size: 15px; }
  .marca-texto p { font-size: 10.5px; }
  .estado { padding: 6px 10px; font-size: 10.5px; }
  .hud-chip { min-width: 76px; padding: 7px 10px; }
  .hud-valor b { font-size: 17px; }
  .escenario { min-height: 330px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
