/**
 * Estilos canónicos del Simulador IS-LM-BP
 * Fijate Tools • Macro Studio
 */

:root {
  --bg-body: #0a0e17;
  --bg-card: #121826;
  --bg-card-subtle: #182234;
  --bg-card-hover: #1f2c42;
  --border-color: #26334d;
  --border-focus: #3b82f6;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #ff8507;
  --accent-glow: rgba(255, 133, 7, 0.18);
  --is-color: #38bdf8;
  --lm-color: #10b981;
  --bp-color: #fb923c;
  --eq-color: #f43f5e;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --font-mono: 'JetBrains Mono', monospace;
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

[data-theme="light"] {
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-card-hover: #e2e8f0;
  --border-color: #cbd5e1;
  --border-focus: #2563eb;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --accent: #ea580c;
  --accent-glow: rgba(234, 88, 12, 0.12);
  --is-color: #0284c7;
  --lm-color: #059669;
  --bp-color: #d97706;
  --eq-color: #e11d48;
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-wrapper.tool-layout {
  max-width: 1360px;
  margin: 1rem auto 3rem;
  padding: 0 1rem;
  width: 100%;
  flex: 1;
}

.tool-with-sidebar {
  display: flex;
  gap: 1.75rem;
  align-items: flex-start;
}

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  width: 100%;
}

/* --- Presets Bar --- */
.card-presets {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.presets-header {
  margin-bottom: 0.65rem;
}

.presets-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.presets-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn-preset {
  background: var(--bg-card-subtle);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
}

.btn-preset:hover {
  border-color: var(--accent);
  background: var(--bg-card-hover);
  transform: translateY(-1px);
}

.btn-preset.active {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* --- Grid Principal --- */
.sim-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .sim-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Tarjeta de Controles Izquierda --- */
.card-controls {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.card-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.btn-reset {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0.2rem 0.4rem;
}

.btn-reset:hover {
  color: var(--accent);
}

.control-group {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.group-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.group-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}

.is-badge {
  background: rgba(56, 189, 248, 0.15);
  color: var(--is-color);
  border: 1px solid var(--is-color);
}

.lm-badge {
  background: rgba(16, 185, 129, 0.15);
  color: var(--lm-color);
  border: 1px solid var(--lm-color);
}

.bp-badge {
  background: rgba(251, 146, 60, 0.15);
  color: var(--bp-color);
  border: 1px solid var(--bp-color);
}

.group-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
}

.slider-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.slider-val {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-main);
}

input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border-color);
  outline: none;
  cursor: pointer;
  accent-color: var(--accent);
}

.field-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.input-label {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.form-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  min-height: 40px;
  cursor: pointer;
}

.form-select:focus {
  border-color: var(--border-focus);
  outline: none;
}

/* --- Escenario Gráfico Derecho --- */
.card-stage {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.stage-header {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.75rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.legend-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.legend-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 20px;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
}

.legend-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.is-pill { color: var(--is-color); }
.is-pill .dot { background: var(--is-color); }

.lm-pill { color: var(--lm-color); }
.lm-pill .dot { background: var(--lm-color); }

.bp-pill { color: var(--bp-color); }
.bp-pill .dot { background: var(--bp-color); }

.eq-pill { color: var(--eq-color); }
.eq-pill .dot { background: var(--eq-color); }

.stage-toggle-prev {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider.round {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--border-color);
  transition: 0.3s;
  border-radius: 20px;
}

.slider.round:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

input:checked + .slider.round {
  background-color: var(--accent);
}

input:checked + .slider.round:before {
  transform: translateX(16px);
}

.toggle-text {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* --- Gráfico SVG --- */
.graph-canvas-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}

#macro-svg {
  width: 100%;
  height: auto;
  min-height: 380px;
  display: block;
}

/* Elementos SVG */
.grid-line {
  stroke: var(--border-color);
  stroke-dasharray: 4, 4;
  stroke-width: 0.75;
}

.axis-line {
  stroke: var(--text-muted);
  stroke-width: 1.5;
}

.axis-text {
  fill: var(--text-muted);
  font-family: var(--font-body);
  font-size: 11px;
}

.curve-is {
  stroke: var(--is-color);
  stroke-width: 3;
  fill: none;
  transition: all 0.3s ease;
}

.curve-lm {
  stroke: var(--lm-color);
  stroke-width: 3;
  fill: none;
  transition: all 0.3s ease;
}

.curve-bp {
  stroke: var(--bp-color);
  stroke-width: 2.5;
  stroke-dasharray: 6, 3;
  fill: none;
  transition: all 0.3s ease;
}

.curve-prev {
  stroke-dasharray: 4, 4;
  stroke-width: 1.5;
  opacity: 0.45;
  fill: none;
}

.eq-halo {
  fill: var(--eq-color);
  opacity: 0.25;
  animation: pulse-halo 2s infinite ease-in-out;
}

.eq-point {
  fill: var(--eq-color);
  stroke: #ffffff;
  stroke-width: 2;
  cursor: pointer;
}

.guide-line {
  stroke: var(--eq-color);
  stroke-dasharray: 3, 3;
  stroke-width: 1;
  opacity: 0.7;
}

@keyframes pulse-halo {
  0% { r: 8px; opacity: 0.4; }
  50% { r: 16px; opacity: 0.1; }
  100% { r: 8px; opacity: 0.4; }
}

/* --- Tarjetas de Equilibrio --- */
.equilibrium-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

@media (max-width: 768px) {
  .equilibrium-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

.eq-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.eq-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.eq-val {
  font-family: var(--font-mono);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-main);
}

.eq-sub {
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 500;
}

/* --- Caja de Transmisión --- */
.transmission-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.transmission-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}

.transmission-chain {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-card-subtle);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border-color);
}

.chain-step {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.chain-arrow {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.9rem;
}

.transmission-detail {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.transmission-detail strong {
  color: var(--text-main);
}

/* --- Fórmulas Card --- */
.formulas-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.formulas-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.formulas-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

@media (max-width: 640px) {
  .formulas-grid {
    grid-template-columns: 1fr;
  }
}

.formula-item {
  background: var(--bg-card-subtle);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.formula-name {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.formula-expr {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

/* --- Modales Canónicos --- */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
}

.modal-dialog-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-body {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.25rem;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  min-height: 40px;
}

.btn-primary:hover {
  opacity: 0.9;
}
