/* ==========================================================================
   Teoría Electromagnética - Plataforma Web Interactiva
   Estilo: Clean White / Minimalista / Telecomunicaciones (Actualizado)
   ========================================================================== */

:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-card: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  
  --brand-blue: #0284c7;
  --brand-blue-hover: #0369a1;
  --brand-blue-light: #e0f2fe;
  --brand-dark: #0f172a;
  
  --positive-red: #ef4444;
  --negative-blue: #2563eb;
  --accent-green: #10b981;
  --accent-amber: #d97706;
  
  --border-light: #e2e8f0;
  --border-focus: #0284c7;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.03);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   HEADER / BARRA SUPERIOR
   ========================================================================== */
.top-header {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-light);
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  z-index: 50;
  flex-shrink: 0;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-badge {
  background: var(--brand-dark);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.course-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.course-subtitle {
  color: var(--text-muted);
  font-size: 0.825rem;
  font-weight: 400;
  display: inline-block;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.unit-selector {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  font-size: 0.825rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}

.unit-selector:focus {
  border-color: var(--brand-blue);
}

.slide-counter {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  border: 1px solid var(--border-light);
  min-width: 60px;
  text-align: center;
}

.header-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  padding: 0.4rem 0.65rem;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.header-btn:hover {
  background: var(--bg-primary);
  color: var(--brand-blue);
  border-color: var(--brand-blue);
}

/* ==========================================================================
   PROGRESS BAR
   ========================================================================== */
.progress-bar-container {
  height: 3px;
  background: var(--border-light);
  width: 100%;
  position: relative;
  flex-shrink: 0;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-blue), #38bdf8);
  width: 8%;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   MAIN SLIDE VIEWER
   ========================================================================== */
.presentation-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg-secondary);
}

.slides-wrapper {
  height: 100%;
  width: 100%;
  position: relative;
}

.slide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 1.5rem 2rem 5rem 2rem;
  display: none;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.slide.active {
  display: flex;
  flex-direction: column;
  opacity: 1;
  transform: translateX(0);
}

/* ==========================================================================
   SLIDE LAYOUTS (GRID & SPLITS)
   ========================================================================== */
.slide-grid-2col {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 1.5rem;
  flex: 1;
  align-items: stretch;
  min-height: 0;
}

.slide-grid-cover {
  display: grid;
  grid-template-columns: 0.95fr 1.3fr;
  gap: 2.5rem;
  flex: 1;
  align-items: center;
  min-height: 0;
  height: 100%;
}

.cover-content-left {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  max-width: 540px;
}

.cover-image-slot {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  max-height: 520px;
  min-height: 380px;
}

.cover-image-slot img {
  width: 100%;
  height: 100%;
  max-height: 480px;
  object-fit: contain;
  display: block;
}

.slide-grid-equal {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  flex: 1;
  min-height: 0;
}

.slide-content-left {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.slide-content-right {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  min-height: 380px;
}

/* ==========================================================================
   TYPOGRAPHY & TAGS
   ========================================================================== */
.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.725rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  background: var(--brand-blue-light);
  color: var(--brand-blue);
  width: fit-content;
}

.tag-telecom {
  background: #fef3c7;
  color: #b45309;
}

.slide-title {
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.25;
}

.slide-lead {
  font-size: 0.975rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ==========================================================================
   IMAGE SLOT COMPONENT (CON PLACEHOLDER LIMPIO)
   ========================================================================== */
.image-slot {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  width: 100%;
}

.image-slot img {
  width: 100%;
  height: auto;
  max-height: 280px;
  object-fit: cover;
  display: block;
}

.image-slot-caption {
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: #fbfcfd;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.image-slot-caption code {
  font-family: var(--font-mono);
  background: var(--bg-secondary);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  color: var(--brand-blue);
}

/* ==========================================================================
   WHITE CLEAN CARDS & CALLOUTS
   ========================================================================== */
.clean-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 1.15rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.clean-card:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-md);
}

.telecom-callout {
  background: #ffffff;
  border-left: 4px solid var(--brand-blue);
  border-radius: 0 12px 12px 0;
  padding: 0.9rem 1.15rem;
  border-top: 1px solid var(--border-light);
  border-right: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
}

.telecom-callout-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  color: var(--brand-blue);
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
}

/* ==========================================================================
   FORMULA BOXES
   ========================================================================== */
.formula-box {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  text-align: center;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.formula-label {
  position: absolute;
  top: -10px;
  left: 16px;
  background: var(--bg-card);
  padding: 0 8px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--brand-blue);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid var(--border-light);
  border-radius: 4px;
}

.formula-math {
  font-size: 1.35rem;
  margin: 0.35rem 0;
  color: var(--text-primary);
}

.formula-anatomy {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.5rem;
  margin-top: 0.75rem;
  text-align: left;
}

.anatomy-item {
  font-size: 0.75rem;
  background: var(--bg-secondary);
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  border-left: 2px solid var(--brand-blue);
  color: var(--text-secondary);
}

.anatomy-symbol {
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

/* ==========================================================================
   3D SIMULATION CONTAINER
   ========================================================================== */
.sim-container {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
  min-height: 380px;
  position: relative;
}

.sim-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border-light);
  background: #fbfcfd;
}

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

.sim-badge-live {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.65rem;
  font-weight: 700;
  background: #dcfce7;
  color: #15803d;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  text-transform: uppercase;
}

.sim-badge-live::before {
  content: '';
  width: 6px;
  height: 6px;
  background: #16a34a;
  border-radius: 50%;
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.sim-canvas-wrapper {
  flex: 1;
  position: relative;
  width: 100%;
  min-height: 270px;
  background: #ffffff;
}

.sim-canvas-wrapper canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  outline: none;
}

.sim-controls-bar {
  padding: 0.65rem 1rem;
  background: #fbfcfd;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.sim-btn {
  background: #ffffff;
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-size: 0.775rem;
  font-weight: 600;
  padding: 0.4rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s ease;
  text-align: left;
}

.sim-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-color: #cbd5e1;
}

.sim-btn.active {
  background: var(--brand-blue-light);
  color: var(--brand-blue);
  border-color: var(--brand-blue);
}

.sim-slider-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: #ffffff;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border-light);
}

.sim-slider-group input[type="range"] {
  accent-color: var(--brand-blue);
  cursor: pointer;
}

.sim-tip-overlay {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(4px);
  border: 1px solid var(--border-light);
  font-size: 0.7rem;
  color: var(--text-secondary);
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  pointer-events: none;
  z-index: 10;
}

/* ==========================================================================
   TEACHER CONTROL PANEL & PROBLEM SOLVER
   ========================================================================== */
.teacher-control-panel {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

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

.teacher-title {
  font-size: 0.825rem;
  font-weight: 700;
  color: var(--brand-blue);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.step-buttons-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.4rem;
}

.step-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-size: 0.725rem;
  font-weight: 600;
  padding: 0.45rem 0.35rem;
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.step-btn:hover {
  border-color: var(--brand-blue);
  color: var(--brand-blue);
}

.step-btn.unlocked {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}

.step-btn.current {
  background: var(--brand-blue);
  border-color: var(--brand-blue);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(2, 132, 199, 0.25);
}

.problem-solution-card {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  margin-top: 0.5rem;
  display: none;
  animation: fadeIn 0.3s ease;
}

.problem-solution-card.visible {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.solution-step-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.solution-math-content {
  font-size: 0.9rem;
  color: var(--text-secondary);
  padding: 0.35rem 0;
}

/* ==========================================================================
   2D PROBLEM CANVAS CONTAINER
   ========================================================================== */
.problem-canvas-box {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  position: relative;
  flex: 1;
  min-height: 380px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

#problem2dCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ==========================================================================
   HOME EXPERIMENT CARD STYLING
   ========================================================================== */
.experiment-step {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.experiment-step-num {
  width: 28px;
  height: 28px;
  background: var(--brand-blue-light);
  color: var(--brand-blue);
  font-weight: 700;
  font-size: 0.85rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.experiment-materials {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.material-tag {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* ==========================================================================
   NAVIGATION BAR INFERIOR
   ========================================================================== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 56px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 50;
}

.nav-hint {
  font-size: 0.775rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.nav-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
}

.nav-btn:hover:not(:disabled) {
  background: var(--bg-secondary);
  border-color: #cbd5e1;
}

.nav-btn.primary {
  background: var(--brand-blue);
  color: #ffffff;
  border-color: var(--brand-blue);
}

.nav-btn.primary:hover:not(:disabled) {
  background: var(--brand-blue-hover);
}

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

/* ==========================================================================
   DRAWER / ÍNDICE DE SEMANAS
   ========================================================================== */
.menu-drawer {
  position: fixed;
  top: 0;
  left: -320px;
  width: 320px;
  height: 100%;
  background: #ffffff;
  border-right: 1px solid var(--border-light);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.menu-drawer.open {
  left: 0;
}

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

.drawer-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.drawer-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-muted);
  cursor: pointer;
}

.drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.drawer-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0.75rem 0 0.5rem 0.5rem;
}

.drawer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  margin-bottom: 0.25rem;
}

.drawer-item:hover {
  background: var(--bg-secondary);
  color: var(--brand-blue);
}

.drawer-item.active {
  background: var(--brand-blue-light);
  color: var(--brand-blue);
  font-weight: 600;
}

.drawer-item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.drawer-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.3);
  backdrop-filter: blur(2px);
  z-index: 90;
  display: none;
}

.drawer-backdrop.open {
  display: block;
}

/* ==========================================================================
   RESPONSIVIDAD (MÓVIL & TABLET)
   ========================================================================== */
@media (max-width: 900px) {
  .slide {
    padding: 1rem 1rem 4.5rem 1rem;
  }

  .slide-grid-2col,
  .slide-grid-equal,
  .slide-grid-cover {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .cover-image-slot {
    min-height: 260px;
    max-height: 320px;
    padding: 1rem;
  }

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

  .slide-lead {
    font-size: 0.925rem;
  }

  .sim-container {
    min-height: 340px;
    height: 360px;
  }

  .problem-canvas-box {
    min-height: 320px;
  }

  .course-subtitle {
    display: none;
  }

  .nav-hint {
    display: none;
  }

  .step-buttons-row {
    grid-template-columns: repeat(5, 1fr);
  }
}

@media (max-width: 480px) {
  .top-header {
    padding: 0 0.75rem;
  }

  .slide-title {
    font-size: 1.2rem;
  }

  .sim-container {
    height: 310px;
    min-height: 290px;
  }

  .step-buttons-row {
    grid-template-columns: repeat(3, 1fr);
  }
}
