/**
 * Simulador de lentes progresivas — css/style.css
 * Fijate Tools — Estilos visuales premium, modo oscuro/claro y layout responsive
 */

:root {
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-heading: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Paleta corporativa óptica Midnight Slate */
  --bg-primary: #0b0f17;
  --bg-card: #111827;
  --bg-card-hover: #1e293b;
  --bg-card-subtle: rgba(17, 24, 39, 0.7);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #38bdf8;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-heading: #ffffff;

  --accent-cyan: #38bdf8;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-indigo: #6366f1;

  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 25px -5px rgba(56, 189, 248, 0.25);
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-card-subtle: rgba(248, 250, 252, 0.85);
  --border-color: rgba(0, 0, 0, 0.08);
  --border-focus: #0284c7;

  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-heading: #0f172a;

  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.06), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 0 20px -3px rgba(2, 132, 199, 0.15);
}

/* Base obligatoria de contención */
body {
  margin: 0;
  padding: 0;
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-main);
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* Layout de la herramienta */
.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  box-sizing: border-box;
  flex: 1 0 auto;
}

.tool-with-sidebar {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  width: 100%;
}

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

/* Encabezado Hero de la herramienta */
.tool-hero-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.tool-hero-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #38bdf8, #818cf8, #34d399);
}

.tool-hero-title {
  font-family: var(--font-heading);
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--text-heading);
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}

.tool-hero-desc {
  margin: 0;
  font-size: 0.96rem;
  line-height: 1.6;
  color: var(--text-muted);
}

/* Barra de presets rápidos */
.presets-strip {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  padding: 0.85rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.presets-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.preset-btn {
  background: var(--bg-card-hover);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.45rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 36px;
}

.preset-btn:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  transform: translateY(-1px);
}

/* =========================================================================
   CONTENEDOR PRINCIPAL DEL SIMULADOR Y CANVAS
   ========================================================================= */
.sim-stage-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

/* Barra superior del simulador */
.sim-toolbar-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: var(--bg-card-subtle);
  border-bottom: 1px solid var(--border-color);
  gap: 1rem;
  flex-wrap: wrap;
}

.scene-chips-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.scene-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.95rem;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 40px;
}

.scene-chip:hover {
  border-color: var(--accent-cyan);
  color: var(--text-heading);
}

.scene-chip.active {
  background: rgba(56, 189, 248, 0.12);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  font-weight: 600;
}

.tool-actions-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.btn-action-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 40px;
}

.btn-action-pill:hover {
  background: var(--bg-card-hover);
  color: var(--text-heading);
}

.btn-action-pill.active {
  background: rgba(52, 211, 153, 0.15);
  border-color: var(--accent-emerald);
  color: var(--accent-emerald);
  font-weight: 600;
}

.btn-center-nose {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #ffffff;
  border: none;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-center-nose:hover {
  background: linear-gradient(135deg, #0369a1, #1d4ed8);
  transform: translateY(-1px);
}

.btn-pulse {
  animation: pulseHighlight 0.4s ease-out;
}

@keyframes pulseHighlight {
  0% { transform: scale(1); }
  50% { transform: scale(1.06); filter: brightness(1.2); }
  100% { transform: scale(1); }
}

/* Viewport interactivo del Canvas */
.canvas-viewport-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 600px;
  background: #000000;
  overflow: hidden;
  cursor: crosshair;
}

#progressive-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Badges flotantes sobre el visor */
.canvas-hud-overlay {
  position: absolute;
  top: 1rem;
  left: 1rem;
  right: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  gap: 0.75rem;
}

.hud-glass-badge {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: #f8fafc;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.status-badge {
  padding: 0.3rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.status-sharp {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.status-warning {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.status-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.canvas-hint-bottom {
  position: absolute;
  bottom: 0.85rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(6px);
  padding: 0.4rem 0.9rem;
  border-radius: 9999px;
  font-size: 0.78rem;
  color: #cbd5e1;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  white-space: nowrap;
}

/* =========================================================================
   PANEL DE TELEMETRÍA ÓPTICA EN VIVO
   ========================================================================= */
.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  padding: 1.25rem;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
}

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

.telemetry-label {
  font-size: 0.76rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.telemetry-value {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-heading);
}

/* =========================================================================
   SELECTOR DE GAMAS Y PROPIEDADES DE LENTE
   ========================================================================= */
.section-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-heading);
  margin: 1.75rem 0 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.profile-selector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.profile-card:hover {
  border-color: var(--accent-cyan);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.profile-card.active {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.08);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.profile-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.badge-std { background: rgba(148, 163, 184, 0.2); color: #94a3b8; }
.badge-adv { background: rgba(56, 189, 248, 0.2); color: #38bdf8; }
.badge-prem { background: rgba(129, 140, 248, 0.25); color: #818cf8; }
.badge-occ { background: rgba(52, 211, 153, 0.2); color: #34d399; }

.profile-card-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-heading);
  margin: 0 0 0.35rem;
}

.profile-card-desc {
  font-size: 0.83rem;
  line-height: 1.5;
  color: var(--text-muted);
  margin: 0 0 0.85rem;
}

/* =========================================================================
   CONTROLES ÓPTICOS (ADICIÓN, PASILLO, MONTURA)
   ========================================================================= */
.controls-config-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-card);
}

.controls-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.control-item {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.control-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.control-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-heading);
}

.control-val-display {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

.range-slider {
  width: 100%;
  accent-color: var(--accent-cyan);
  cursor: pointer;
  height: 6px;
}

.chips-selector {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.chip-option {
  flex: 1;
  padding: 0.5rem 0.75rem;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
  min-height: 40px;
}

.chip-option:hover {
  border-color: var(--accent-cyan);
  color: var(--text-heading);
}

.chip-option.active {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  font-weight: 600;
}

/* =========================================================================
   GUÍA DIDÁCTICA Y BLOQUES PEDAGÓGICOS
   ========================================================================= */
.didactic-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.didactic-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.35rem;
  box-shadow: var(--shadow-card);
}

.didactic-card-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.didactic-card-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
}

.didactic-card-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-heading);
  margin: 0;
}

.didactic-card-p {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-muted);
  margin: 0 0 0.85rem;
}

.btn-inline-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent-cyan);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: underline;
}

.btn-inline-link:hover {
  color: #7dd3fc;
}

/* =========================================================================
   MODALES ACCESIBLES (SIN ALERTS)
   ========================================================================= */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 560px;
  width: 100%;
  padding: 1.75rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  transform: translateY(12px);
  transition: transform 0.25s ease;
}

.modal-overlay.visible .modal-card {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

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

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.modal-close-btn:hover {
  color: var(--text-heading);
}

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

.modal-highlight-box {
  background: rgba(56, 189, 248, 0.08);
  border-left: 3px solid var(--accent-cyan);
  padding: 0.75rem 1rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 0.85rem 0;
  font-size: 0.9rem;
}

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

.btn-modal-primary {
  background: var(--accent-cyan);
  color: #0b0f17;
  border: none;
  padding: 0.6rem 1.4rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
  transition: filter 0.2s ease;
  min-height: 40px;
}

.btn-modal-primary:hover {
  filter: brightness(1.1);
}

/* =========================================================================
   ADAPTACIÓN RESPONSIVA (MÓVIL Y TABLET)
   ========================================================================= */
@media (max-width: 991px) {
  .tool-with-sidebar {
    display: block;
  }

  .canvas-viewport-container {
    aspect-ratio: 4 / 3;
  }
}

@media (max-width: 640px) {
  .tool-layout {
    padding: 0 0.75rem;
    margin: 1rem auto 2rem;
  }

  .tool-hero-box {
    padding: 1.25rem 1rem;
  }

  .tool-hero-title {
    font-size: 1.35rem;
  }

  .sim-toolbar-top {
    flex-direction: column;
    align-items: stretch;
    padding: 0.85rem;
  }

  .scene-chips-group, .tool-actions-group {
    width: 100%;
    justify-content: space-between;
  }

  .scene-chip, .btn-action-pill {
    flex: 1;
    justify-content: center;
  }

  .telemetry-grid {
    grid-template-columns: 1fr 1fr;
    padding: 0.85rem;
  }

  .canvas-viewport-container {
    aspect-ratio: 1 / 1;
  }
}
