/**
 * Simulador de Película Analógica - Hoja de Estilos Canónica
 * Paleta Midnight Slate, laboratorio fotográfico ámbar y cian, visor split antes/después
 * 
 * Desarrollado para Fijate Tools (fijate.com)
 */

:root {
  --bg-main: #0b0f17;
  --bg-surface: #121927;
  --bg-surface-elevated: #1a2336;
  --bg-card: #151e30;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-hover: rgba(255, 255, 255, 0.18);
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --accent-amber: #f59e0b;
  --accent-amber-glow: rgba(245, 158, 11, 0.25);
  --accent-cyan: #06b6d4;
  --accent-red: #ef4444;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 10px 35px rgba(0, 0, 0, 0.6);
}

[data-theme="light"] {
  --bg-main: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  --border-color-hover: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --accent-amber: #d97706;
  --accent-amber-glow: rgba(217, 119, 6, 0.2);
  --accent-cyan: #0891b2;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* Reset y Contención Base */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', sans-serif;
  margin: 0;
  font-weight: 700;
  line-height: 1.25;
}

.font-mono {
  font-family: 'JetBrains Mono', monospace;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Layout Canónico */
.tool-layout {
  max-width: 1320px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  flex: 1 0 auto;
}

.tool-with-sidebar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2rem;
  width: 100%;
}

@media (min-width: 1536px) {
  .tool-with-sidebar {
    grid-template-columns: minmax(0, 1fr) 320px;
  }
}

.tool-main-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: 100%;
  min-width: 0;
}

/* Tarjetas Principales */
.card-main {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

/* Barra de Acción Rápida y Muestras */
.lab-action-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--bg-surface);
}

.action-bar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.action-bar-hint {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.action-bar-samples {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-sample-photo {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 38px;
  transition: all 0.2s ease;
}

.btn-sample-photo:hover {
  border-color: var(--accent-amber);
  transform: translateY(-1px);
}

.btn-sample-photo.active {
  background: rgba(245, 158, 11, 0.12);
  border-color: var(--accent-amber);
  color: var(--accent-amber);
  font-weight: 600;
}

.sample-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

/* Área de Trabajo Dividida (Visor vs Controles) */
.film-lab-workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  width: 100%;
}

@media (min-width: 1024px) {
  .film-lab-workspace {
    grid-template-columns: minmax(0, 1.45fr) minmax(360px, 1fr);
  }
}

/* Columna Izquierda: Visor Fotográfico */
.workspace-viewport-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem;
}

.viewport-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

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

.btn-tab-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-height: 34px;
  transition: all 0.2s ease;
}

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

.btn-tab-pill.active {
  background: var(--bg-card);
  color: var(--accent-amber);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.btn-tool-action {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  min-height: 38px;
  user-select: none;
  transition: all 0.15s ease;
}

.btn-tool-action:active {
  background: rgba(245, 158, 11, 0.2);
  border-color: var(--accent-amber);
  transform: scale(0.98);
}

/* Lienzo y Slider Antes / Después */
.viewport-canvas-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
  background: #06090e;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05), var(--shadow-md);
  cursor: crosshair;
  touch-action: pan-y;
  user-select: none;
}

.viewport-canvas-wrapper.drag-over {
  border: 2px dashed var(--accent-amber);
  box-shadow: 0 0 25px var(--accent-amber-glow);
}

.canvas-layer-box {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.film-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.processed-canvas {
  transition: opacity 0.1s ease;
}

/* Badges sobre la foto */
.viewport-badge {
  position: absolute;
  top: 14px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  pointer-events: none;
  z-index: 5;
  backdrop-filter: blur(6px);
}

.badge-left {
  left: 14px;
  background: rgba(0, 0, 0, 0.65);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.badge-right {
  right: 14px;
  background: rgba(245, 158, 11, 0.85);
  color: #0f172a;
}

/* Barra Divisoria Split Slider */
.split-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: #ffffff;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.8), 0 0 4px var(--accent-amber);
  z-index: 10;
  pointer-events: none;
  transform: translateX(-50%);
}

.split-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 2px solid #ffffff;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6), 0 0 10px var(--accent-amber-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-amber);
  cursor: ew-resize;
  pointer-events: auto;
  z-index: 12;
  transition: transform 0.15s ease, background-color 0.2s ease;
}

.split-handle:hover {
  transform: translate(-50%, -50%) scale(1.1);
  background: var(--bg-surface-elevated);
}

/* Overlay de Carga */
.canvas-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(11, 15, 23, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  z-index: 20;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: all 0.2s ease;
}

.canvas-loading-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.loading-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(245, 158, 11, 0.2);
  border-top-color: var(--accent-amber);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Pie del Visor con Histograma */
.viewport-footer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.film-quick-spec {
  flex: 1 1 240px;
}

.film-active-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}

.film-active-badge strong {
  font-size: 1.05rem;
  font-family: 'Outfit', sans-serif;
  color: var(--text-main);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.badge-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-amber);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

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

.film-active-desc {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.histogram-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
}

.histogram-label {
  font-size: 0.68rem;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  color: var(--text-muted);
}

.histogram-canvas {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  display: block;
}

/* Columna Derecha: Panel de Control de Carretes y Sliders */
.workspace-controls-card {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.25rem;
}

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

.controls-section-title {
  font-size: 1.15rem;
}

.btn-icon-text {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-md);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon-text:hover {
  color: var(--accent-amber);
  border-color: var(--accent-amber);
}

/* Pestañas de categorías */
.film-category-tabs {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 4px;
}

.film-tab-btn {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  min-height: 34px;
  transition: all 0.2s ease;
}

.film-tab-btn:hover {
  color: var(--text-main);
  border-color: var(--border-color-hover);
}

.film-tab-btn.active {
  background: var(--accent-amber);
  color: #0f172a;
  border-color: var(--accent-amber);
  font-weight: 600;
}

/* Grid de Carretes de Película */
.emulsion-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.65rem;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 4px;
}

/* Scrollbar estilizado */
.emulsion-grid::-webkit-scrollbar {
  width: 5px;
}
.emulsion-grid::-webkit-scrollbar-track {
  background: var(--bg-surface-elevated);
  border-radius: 4px;
}
.emulsion-grid::-webkit-scrollbar-thumb {
  background: var(--border-color-hover);
  border-radius: 4px;
}

.film-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.65rem;
  cursor: pointer;
  min-height: 44px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.film-card.hidden {
  display: none !important;
}

.film-card:hover {
  border-color: var(--accent-amber);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.film-card.active {
  border-color: var(--accent-amber);
  background: rgba(245, 158, 11, 0.08);
  box-shadow: 0 0 0 1px var(--accent-amber);
}

.film-canister-thumb {
  width: 100%;
  height: 38px;
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
}

.canister-body {
  flex: 1;
  height: 100%;
  border-radius: 4px;
  background: #232733;
  border: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 6px;
}

/* Decoraciones temáticas por emulsión */
.film-color .canister-body {
  border-left: 5px solid #f59e0b;
}
.film-cine .canister-body {
  border-left: 5px solid #ef4444;
}
.film-bw .canister-body {
  border-left: 5px solid #e2e8f0;
}
.film-retro .canister-body {
  border-left: 5px solid #06b6d4;
}

.canister-iso {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--accent-amber);
}

.canister-brand {
  font-size: 0.68rem;
  font-weight: 600;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.film-card-info {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.film-card-title {
  font-size: 0.78rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.film-card-meta {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* Ajustes de Sliders */
.controls-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.controls-group-title {
  font-size: 0.95rem;
  color: var(--text-main);
}

.btn-text-action {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.76rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease;
}

.btn-text-action:hover {
  color: var(--accent-amber);
}

.control-sliders-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
}

@media (min-width: 640px) and (max-width: 1023px) {
  .control-sliders-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

.slider-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
}

.slider-header label {
  color: var(--text-main);
  font-weight: 500;
}

.slider-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--accent-amber);
  font-weight: 600;
}

/* Estilo unificado de Sliders */
.input-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--bg-surface-elevated);
  border-radius: 4px;
  outline: none;
  cursor: pointer;
  border: 1px solid var(--border-color);
}

.input-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--accent-amber);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.input-slider::-webkit-slider-thumb:hover {
  transform: scale(1.18);
}

.input-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--accent-amber);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

/* Sliders con gradiente especial */
.slider-temp {
  background: linear-gradient(to right, #38bdf8, #94a3b8, #f59e0b);
}

.slider-tint {
  background: linear-gradient(to right, #22c55e, #94a3b8, #ec4899);
}

/* Sección de Efectos Especiales */
.special-effects-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
}

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

.effect-row-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.effect-label {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-main);
}

.effect-body.hidden {
  display: none !important;
}

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

/* Switch iOS / Toggle */
.switch-container {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  user-select: none;
}

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

.switch-slider {
  position: relative;
  width: 38px;
  height: 22px;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.switch-slider::before {
  content: "";
  position: absolute;
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: #ffffff;
  border-radius: 50%;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

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

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

.switch-text {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-main);
}

/* Form Controls Estrictos */
.form-select-custom {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  background-color: var(--bg-surface-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.5rem 2.5rem 0.5rem 0.85rem;
  font-size: 0.84rem;
  min-height: 40px;
  cursor: pointer;
  appearance: none;
  background-image: 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='%23f59e0b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
}

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

.input-text {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.45rem 0.75rem;
  font-size: 0.84rem;
  min-height: 40px;
  outline: none;
  transition: border-color 0.15s ease;
}

.input-text:focus {
  border-color: var(--accent-amber);
}

.date-stamp-row,
.param-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Botonera de Exportación */
.export-actions-box {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: 'Outfit', sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: none;
  min-height: 42px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
}

.btn-block {
  width: 100%;
}

.btn-lg {
  min-height: 48px;
  font-size: 1rem;
}

.btn-primary {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #0f172a;
  box-shadow: 0 4px 15px var(--accent-amber-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  border-color: var(--accent-amber);
  color: var(--accent-amber);
}

.export-secondary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

/* Sección Didáctica Guía de Película */
.film-guide-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: var(--bg-surface);
}

.guide-title {
  font-size: 1.35rem;
}

.guide-intro {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.film-guide-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 0.5rem;
}

@media (min-width: 768px) {
  .film-guide-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.guide-item {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.15rem;
}

.guide-item-title {
  font-size: 1rem;
  color: var(--accent-amber);
  margin-bottom: 0.4rem;
}

.guide-item p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Modales Canónicos */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: all 0.25s ease;
  padding: 1rem;
}

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

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: modalScale 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-card-sm {
  max-width: 420px;
}

@keyframes modalScale {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

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

.modal-title {
  font-size: 1.15rem;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease;
}

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

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

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background: var(--bg-surface-elevated);
  border-top: 1px solid var(--border-color);
}

/* Ficha Técnica de Emulsión */
.emulsion-spec-box {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.spec-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
}

.spec-label {
  color: var(--text-muted);
}

.spec-value {
  color: var(--text-main);
  font-weight: 600;
}

.emulsion-history-desc {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.emulsion-tips {
  background: rgba(245, 158, 11, 0.08);
  border-left: 3px solid var(--accent-amber);
  padding: 0.75rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.82rem;
  color: var(--text-main);
}

.emulsion-tips strong {
  display: block;
  color: var(--accent-amber);
  margin-bottom: 0.25rem;
}

/* Adaptación Móvil Extrema */
@media (max-width: 639px) {
  .card-main {
    padding: 1rem;
  }

  .lab-action-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .action-bar-left {
    flex-direction: column;
    align-items: stretch;
  }

  .action-bar-left .btn {
    width: 100%;
  }

  .action-bar-samples {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    width: 100%;
  }

  .btn-sample-photo {
    justify-content: center;
  }

  .export-secondary-grid {
    grid-template-columns: 1fr;
  }

  .viewport-footer-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .histogram-box {
    align-items: stretch;
    width: 100%;
  }

  .histogram-canvas {
    width: 100%;
    height: 48px;
  }
}
