/**
 * Estilos canónicos de la herramienta de banco óptico y trazado de rayos láser
 */

:root {
  --bg-bench: #060b13;
  --panel-bg: #0f172a;
  --panel-border: #1e293b;
  --accent-cyan: #38bdf8;
  --accent-green: #22c55e;
  --accent-red: #ef4444;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --font-mono: 'JetBrains Mono', monospace;
  --font-heading: 'Outfit', sans-serif;
  --radius-md: 10px;
  --radius-lg: 14px;
}

[data-theme="light"] {
  --panel-bg: #ffffff;
  --panel-border: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --bg-bench: #060b13; /* La mesa de simulación láser permanece oscura como laboratorio óptico */
}

[data-theme="light"] .optical-card {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .control-card,
[data-theme="light"] .optical-hud {
  background: #f8fafc;
  border-color: #e2e8f0;
}

[data-theme="light"] .toolbar-select {
  background: #ffffff;
  color: #0f172a;
  border-color: #cbd5e1;
}

[data-theme="light"] .btn-secondary {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #cbd5e1;
}

[data-theme="light"] .btn-secondary:hover {
  background: #e2e8f0;
}

[data-theme="light"] .modal-content {
  background: #ffffff;
  border-color: #e2e8f0;
}

[data-theme="light"] .modal-title {
  color: #0f172a;
}

[data-theme="light"] .modal-body {
  color: #334155;
}

/* Reglas canónicas tipográficas y de contención */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text-main);
  background-color: var(--bg-bench);
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6, .brand-title, .theory-title, .control-card-title, .modal-title, .preset-info-badge {
  font-family: 'Outfit', sans-serif;
}

button, input, select, textarea {
  font-family: inherit;
}

code, pre, .hud-metric-value, .control-row-val {
  font-family: 'JetBrains Mono', monospace;
}

/* Contenedor general */
.optical-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Tarjeta principal */
.optical-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
}

/* Tira de guía interactiva rápida */
.interactive-guide-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.15rem;
  padding: 0.75rem 1rem;
  background: rgba(30, 41, 59, 0.45);
  border: 1px solid rgba(51, 65, 85, 0.6);
  border-radius: var(--radius-md);
}

[data-theme="light"] .interactive-guide-strip {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.guide-step {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.825rem;
  color: #cbd5e1;
  line-height: 1.35;
}

[data-theme="light"] .guide-step {
  color: #334155;
}

.guide-step strong {
  color: var(--text-main);
  font-weight: 600;
}

.guide-icon {
  font-size: 1.15rem;
  flex-shrink: 0;
}

@media (max-width: 680px) {
  .interactive-guide-strip {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
}

/* Tarjeta explicativa del experimento activo */
.preset-info-card {
  margin-bottom: 1.15rem;
  padding: 0.9rem 1.1rem;
  background: linear-gradient(135deg, rgba(14, 116, 144, 0.12) 0%, rgba(15, 23, 42, 0.6) 100%);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-left: 4px solid var(--accent-cyan);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

[data-theme="light"] .preset-info-card {
  background: #f0fdf4;
  border-color: #86efac;
  border-left-color: #16a34a;
}

.preset-info-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

[data-theme="light"] .preset-info-badge {
  color: #15803d;
}

.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan);
}

[data-theme="light"] .badge-dot {
  background: #16a34a;
  box-shadow: 0 0 6px #16a34a;
}

.preset-info-desc {
  font-size: 0.85rem;
  color: #e2e8f0;
  margin: 0;
  line-height: 1.45;
}

[data-theme="light"] .preset-info-desc {
  color: #1e293b;
}

.preset-info-tip {
  font-size: 0.8rem;
  color: #94a3b8;
  margin-top: 0.15rem;
  line-height: 1.4;
}

[data-theme="light"] .preset-info-tip {
  color: #475569;
}

.preset-info-tip strong {
  color: #38bdf8;
}

[data-theme="light"] .preset-info-tip strong {
  color: #15803d;
}

/* Cabecera del banco y selector de presets */
.optical-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1 1 280px;
}

.toolbar-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.toolbar-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 40px;
  padding: 0 0.85rem;
  background: #1e293b;
  color: var(--text-main);
  border: 1px solid #334155;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.toolbar-select:focus {
  border-color: var(--accent-cyan);
}

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

.btn-action {
  height: 40px;
  padding: 0 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
  text-decoration: none;
}

.btn-primary {
  background: #0284c7;
  color: #ffffff;
}

.btn-primary:hover {
  background: #0369a1;
}

.btn-secondary {
  background: #1e293b;
  color: var(--text-main);
  border-color: #334155;
}

.btn-secondary:hover {
  background: #334155;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.25);
  border-color: #ef4444;
}

.btn-danger:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Área del canvas */
.canvas-wrapper {
  position: relative;
  width: 100%;
  background: var(--bg-bench);
  border: 1px solid #1e293b;
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.8);
}

#optical-canvas {
  display: block;
  touch-action: none;
  cursor: default;
}

.canvas-overlay-hint {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 0.75rem;
  color: rgba(148, 163, 184, 0.85);
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  border: 1px solid rgba(51, 65, 85, 0.5);
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  user-select: none;
}

[data-theme="light"] .canvas-overlay-hint {
  background: rgba(255, 255, 255, 0.85);
  color: #334155;
  border-color: #cbd5e1;
}

/* Barra de HUD de telemetría */
.optical-hud {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
  padding: 0.85rem;
  background: #090e17;
  border: 1px solid #1e293b;
  border-radius: var(--radius-md);
}

.hud-metric {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.hud-metric-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: none;
}

.hud-metric-value {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

/* Panel de controles y propiedades */
.controls-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

@media (max-width: 768px) {
  .controls-layout {
    grid-template-columns: 1fr;
  }
}

.control-card {
  background: #090e17;
  border: 1px solid #1e293b;
  border-radius: var(--radius-md);
  padding: 1rem;
}

.control-card-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.control-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}

.control-row:last-child {
  margin-bottom: 0;
}

.control-row-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.825rem;
  color: var(--text-muted);
}

.control-row-val {
  font-family: var(--font-mono);
  color: var(--accent-cyan);
  font-weight: 600;
}

.control-slider {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #1e293b;
  outline: none;
  accent-color: var(--accent-cyan);
  cursor: pointer;
}

.add-grid {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

.add-grid select {
  flex: 1 1 0%;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.add-grid .btn-action {
  flex: 0 0 auto;
  min-width: 84px;
}

@media (max-width: 768px) {
  .toolbar-group {
    flex: 1 1 100%;
    width: 100%;
  }

  .toolbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .toolbar-actions .btn-action {
    width: 100%;
  }

  .optical-hud {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  .optical-card {
    padding: 0.85rem;
  }

  .optical-hud {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    padding: 0.65rem;
  }

  .canvas-wrapper {
    border-radius: 8px;
  }
}

/* Artículos y explicaciones físicas inferiores */
.optical-theory {
  margin-top: 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.theory-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.theory-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.6rem;
}

.theory-text {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Clases de utilidad */
.hidden {
  display: none !important;
}

/* Modal canónico */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 9999;
}

.modal-content {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: var(--radius-lg);
  max-width: 540px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

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

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

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
}

.modal-body {
  font-size: 0.9rem;
  color: #cbd5e1;
  line-height: 1.6;
}

.modal-body ul {
  padding-left: 1.25rem;
  margin: 0.5rem 0 1rem;
}

.modal-body li {
  margin-bottom: 0.35rem;
}

.modal-footer {
  margin-top: 1.25rem;
  display: flex;
  justify-content: flex-end;
}
