/* ==========================================================================
   Simulador de distancia focal, sensor y profundidad de campo de cámara
   Hoja de estilos canónica - fijate.com
   ========================================================================== */

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

  /* Paleta Tema Oscuro (por defecto) */
  --bg-primary: #0b0f19;
  --bg-surface: #111827;
  --bg-surface-elevated: #1e293b;
  --bg-surface-alt: #162033;
  --border-color: #334155;
  --border-color-subtle: #1e293b;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent-primary: #38bdf8;
  --accent-primary-hover: #0ea5e9;
  --accent-primary-alpha: rgba(56, 189, 248, 0.15);

  --accent-success: #22c55e;
  --accent-success-alpha: rgba(34, 197, 94, 0.15);

  --accent-warning: #fbbf24;
  --accent-warning-alpha: rgba(251, 191, 36, 0.15);

  --accent-purple: #c084fc;
  --accent-purple-alpha: rgba(192, 132, 252, 0.15);

  --accent-rose: #f43f5e;
  --accent-rose-alpha: rgba(244, 63, 94, 0.15);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.4);

  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --bg-surface-alt: #e2e8f0;
  --border-color: #cbd5e1;
  --border-color-subtle: #e2e8f0;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;

  --accent-primary: #0284c7;
  --accent-primary-hover: #0369a1;
  --accent-primary-alpha: rgba(2, 132, 199, 0.12);

  --accent-success: #16a34a;
  --accent-success-alpha: rgba(22, 163, 74, 0.12);

  --accent-warning: #d97706;
  --accent-warning-alpha: rgba(217, 119, 6, 0.12);

  --accent-purple: #9333ea;
  --accent-purple-alpha: rgba(147, 51, 234, 0.12);

  --accent-rose: #e11d48;
  --accent-rose-alpha: rgba(225, 29, 72, 0.12);

  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.06);

  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

/* Reset y estructura general */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  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;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-main);
}

.mono {
  font-family: var(--font-mono);
}

/* Layout Canónico de fijate.com */
.tool-layout {
  max-width: 1200px;
  margin: 1.25rem auto 3rem;
  padding: 0 1rem;
  width: 100%;
  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%;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Tarjeta Principal */
.card-main {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

@media (max-width: 640px) {
  .card-main {
    padding: 1rem;
  }
}

/* Barra de Presets Fotográficos de 1 Clic */
.presets-bar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

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

.presets-scroll-wrap {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.35rem;
  scrollbar-width: thin;
}

.preset-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background-color: var(--bg-surface-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 0.45rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.preset-chip:hover, .preset-chip:focus-visible {
  border-color: var(--accent-primary);
  background-color: var(--accent-primary-alpha);
  color: var(--accent-primary);
  outline: none;
}

.preset-chip.active {
  background-color: var(--accent-primary);
  color: #0b0f19;
  border-color: var(--accent-primary);
}

/* Visor y Barra de Herramientas de Visualización */
.viewer-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.viewer-header-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.25rem 0;
}

.mode-toggle-group {
  display: inline-flex;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}

.mode-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
}

.mode-btn:hover {
  color: var(--text-main);
}

.mode-btn.active {
  background-color: var(--accent-primary);
  color: #0b0f19;
}

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

.viewer-subselect {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 500;
  height: 38px;
  padding: 0 34px 0 0.75rem;
  appearance: none;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  cursor: pointer;
  outline: none;
}

.btn-toggle-tool {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: var(--radius-md);
  height: 38px;
  padding: 0 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-toggle-tool:hover {
  border-color: var(--text-muted);
  color: var(--text-main);
}

.btn-toggle-tool.active {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background-color: var(--accent-primary-alpha);
}

/* Contenedor del Canvas */
.canvas-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 280px;
  max-height: 520px;
  background-color: #050811;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.6);
}

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

/* Cuadrícula de Parámetros y Controles Ópticos */
.controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

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

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

.control-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.control-value-badge {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-primary);
  background-color: var(--accent-primary-alpha);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
}

/* Desplegables blindados canónicos */
.form-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 42px;
  background-color: var(--bg-surface-alt);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0 40px 0 0.85rem;
  font-size: 0.9rem;
  font-family: var(--font-sans);
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  appearance: none;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s ease;
}

.form-select option, .form-select optgroup {
  background-color: var(--bg-surface);
  color: var(--text-main);
  padding: 8px 12px;
}

.form-select:focus {
  border-color: var(--accent-primary);
}

/* Sliders con pistas modernas */
.range-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.range-input {
  width: 100%;
  height: 7px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-surface-alt);
  border-radius: 4px;
  outline: none;
  cursor: pointer;
}

.range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 2px solid var(--bg-surface);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  cursor: grab;
  transition: transform 0.1s;
}

.range-input::-webkit-slider-thumb:active {
  transform: scale(1.15);
  cursor: grabbing;
}

.range-input::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 2px solid var(--bg-surface);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  cursor: grab;
}

.range-scale-markers {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

/* Botones de pasos estándar (pills de focal y diafragma) */
.quick-steps-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.step-chip {
  background-color: var(--bg-surface-alt);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.step-chip:hover {
  border-color: var(--accent-primary);
  color: var(--text-main);
}

.step-chip.active {
  background-color: var(--accent-primary-alpha);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* Panel de Telemetría Óptica (KPIs) */
.telemetry-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
}

.kpi-card {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background-color: var(--border-color);
}

.kpi-card.kpi-dof::before { background-color: var(--accent-success); }
.kpi-card.kpi-hyper::before { background-color: var(--accent-purple); }
.kpi-card.kpi-fov::before { background-color: var(--accent-primary); }
.kpi-card.kpi-eq::before { background-color: var(--accent-warning); }

.kpi-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.15;
}

.kpi-subtitle {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* Barra de Distribución de Nitidez */
.dof-distribution-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.1rem;
}

.distribution-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.distribution-track {
  height: 10px;
  border-radius: 5px;
  background-color: var(--bg-surface-alt);
  display: flex;
  overflow: hidden;
}

.distribution-front {
  background-color: var(--accent-primary);
  height: 100%;
  transition: width 0.2s ease;
}

.distribution-behind {
  background-color: var(--accent-success);
  height: 100%;
  transition: width 0.2s ease;
}

.distribution-legend {
  display: flex;
  gap: 1.5rem;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.distribution-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-dot-front {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-primary);
}

.legend-dot-behind {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-success);
}

/* Acciones y Exportación */
.actions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: flex-end;
}

.btn-action {
  height: 42px;
  padding: 0 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.btn-action-primary {
  background-color: var(--accent-primary);
  color: #0b0f19;
}

.btn-action-primary:hover {
  background-color: var(--accent-primary-hover);
}

.btn-action-outline {
  background-color: transparent;
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-action-outline:hover {
  border-color: var(--text-muted);
  background-color: var(--bg-surface-elevated);
}

/* Guía Educativa y Didáctica */
.guide-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 1rem;
}

.guide-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.guide-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

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

.concept-box {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.concept-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-primary);
}

.concept-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.math-formula {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent-purple);
  margin-top: 0.25rem;
  overflow-x: auto;
}

/* Tabla comparativa de sensores */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.sensors-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  text-align: left;
}

.sensors-table th {
  background-color: var(--bg-surface-elevated);
  color: var(--text-main);
  font-weight: 700;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.sensors-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color-subtle);
  color: var(--text-muted);
}

.sensors-table tr:last-child td {
  border-bottom: none;
}

.sensors-table tr:hover td {
  background-color: var(--accent-primary-alpha);
  color: var(--text-main);
}

/* FAQ Acordeón */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.faq-item {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.faq-question {
  width: 100%;
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: color 0.2s;
}

.faq-question:hover {
  color: var(--accent-primary);
}

.faq-icon {
  transition: transform 0.3s ease;
}

.faq-item.open .faq-icon {
  transform: rotate(180deg);
}

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
  padding: 0 1.25rem;
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.faq-item.open .faq-answer {
  max-height: 400px;
  padding: 0 1.25rem 1.25rem 1.25rem;
}

/* Modales Nativos Canónicos */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.modal-dialog {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 580px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

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

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

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
}

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

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.6;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Toast flotante de retroalimentación */
.toast-notice {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--accent-primary);
  color: var(--text-main);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  z-index: 10000;
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}

.toast-notice.show {
  opacity: 1;
  transform: translateY(0);
}

/* Adaptabilidad móvil */
@media (max-width: 768px) {
  .controls-grid {
    grid-template-columns: 1fr;
  }
  
  .telemetry-panel {
    grid-template-columns: repeat(2, 1fr);
  }

  .canvas-container {
    aspect-ratio: 4 / 3;
    min-height: 250px;
  }

  .actions-bar {
    justify-content: stretch;
  }

  .actions-bar .btn-action {
    width: 100%;
    justify-content: center;
  }
}
