/* ==========================================================================
   MEMORIA EXTRAORDINARIA — ESTILOS DE PLATAFORMA (INSPIRADO EN HOTMART CLUB)
   ========================================================================== */

:root,
[data-theme="dark"] {
  --bg-app: #0b0e14;
  --bg-surface: #121722;
  --bg-card: #171d2b;
  --bg-card-hover: #1e2638;
  --bg-elevated: #212a3d;
  --bg-input: #0e131d;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);

  --text-primary: #f3f6fc;
  --text-secondary: #9ba6bc;
  --text-muted: #69758c;

  --accent-primary: #ff6224;
  --accent-primary-hover: #ff7742;
  --accent-secondary: #6366f1;
  --accent-gradient: linear-gradient(135deg, #ff6224 0%, #ff8c42 100%);
  --accent-soft: rgba(255, 98, 36, 0.14);

  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.15);
  --info: #3b82f6;
  --info-soft: rgba(59, 130, 246, 0.15);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.15);
  --purple: #a855f7;
  --purple-soft: rgba(168, 85, 247, 0.15);

  --topbar-height: 64px;
  --sidebar-width: 390px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.45);
}

[data-theme="light"] {
  --bg-app: #f4f6fa;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafd;
  --bg-elevated: #eef2f8;
  --bg-input: #f1f5f9;
  --border-color: rgba(15, 23, 42, 0.09);
  --border-strong: rgba(15, 23, 42, 0.18);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --accent-primary: #ea580c;
  --accent-primary-hover: #d9460f;
  --accent-soft: rgba(234, 88, 12, 0.1);
  --shadow-card: 0 8px 24px -8px rgba(15, 23, 42, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

.hidden {
  display: none !important;
}

/* Scrollbar personalizado */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(155, 166, 188, 0.22);
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(155, 166, 188, 0.4);
}

/* ==========================================================================
   BARRA SUPERIOR (TOPBAR)
   ========================================================================== */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  z-index: 100;
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-gradient);
  color: #fff;
  font-family: "Plus Jakarta Sans", sans-serif;
  font-weight: 800;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(255, 98, 36, 0.35);
}

.brand-text {
  min-width: 0;
}

.brand-title {
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.brand-subtitle {
  display: block;
  font-size: 11.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-center {
  flex: 1;
  max-width: 340px;
  display: flex;
  justify-content: center;
}

.global-progress-card {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 7px 13px;
  border-radius: 10px;
}

.global-progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  margin-bottom: 5px;
}

.progress-label {
  color: var(--text-secondary);
  font-weight: 500;
}

.progress-stats {
  color: var(--text-primary);
  font-weight: 700;
}

.progress-bar-track {
  width: 100%;
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success) 0%, #34d399 100%);
  border-radius: 99px;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.18s ease;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.topbar-action-btn {
  height: 38px;
  padding: 0 13px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  transition: all 0.18s ease;
  white-space: nowrap;
}

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

/* ==========================================================================
   LAYOUT PRINCIPAL (MAIN STAGE + SIDEBAR)
   ========================================================================== */
.app-layout {
  display: flex;
  padding-top: var(--topbar-height);
  min-height: 100vh;
}

.main-stage {
  flex: 1;
  min-width: 0;
  padding: 24px 28px 60px;
  overflow-y: auto;
  transition: all 0.25s ease;
}

.stage-container {
  max-width: 1060px;
  margin: 0 auto;
}

.app-layout.theater-mode .course-sidebar {
  display: none;
}

.app-layout.theater-mode .stage-container {
  max-width: 1280px;
}

/* Encabezado sobre el reproductor */
.lesson-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
  flex-wrap: wrap;
}

.lesson-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.module-pill {
  background: var(--accent-soft);
  color: var(--accent-primary);
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 12px;
  letter-spacing: 0.02em;
}

.breadcrumb-sep {
  color: var(--text-muted);
}

.lesson-counter {
  color: var(--text-secondary);
  font-weight: 500;
}

.lesson-nav-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-step-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  transition: all 0.15s ease;
}

.nav-step-btn:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
}

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

/* ==========================================================================
   REPRODUCTOR DE VIDEO (ESTILO HOTMART)
   ========================================================================== */
.video-player-card {
  background: #05070a;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  margin-bottom: 18px;
}

.video-aspect-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}

.html5-video,
.embed-video-frame {
  width: 100%;
  height: 100%;
  display: block;
  border: none;
  background: #000;
}

.video-error-overlay {
  position: absolute;
  inset: 0;
  background: rgba(11, 14, 20, 0.92);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}

.video-error-box {
  max-width: 460px;
}

.error-icon {
  font-size: 42px;
  margin-bottom: 10px;
}

.video-error-box h3 {
  font-size: 18px;
  margin-bottom: 8px;
  color: #fff;
}

.video-error-box p {
  font-size: 13.5px;
  color: #9ba6bc;
  margin-bottom: 18px;
}

.video-error-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Barra inferior de herramientas del video */
.player-toolbar {
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.player-toolbar-left,
.player-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-chip {
  padding: 5px 10px;
  border-radius: 7px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.toolbar-chip:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
  text-decoration: none;
}

.speed-selector {
  display: inline-flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 7px;
  padding: 2px 4px;
  gap: 2px;
}

.toolbar-label {
  font-size: 11.5px;
  color: var(--text-muted);
  padding: 0 6px;
}

.speed-btn {
  padding: 3px 7px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

.speed-btn:hover {
  color: var(--text-primary);
}

.speed-btn.active {
  background: var(--accent-primary);
  color: #fff;
}

.autoplay-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  padding: 4px 8px;
}

.autoplay-toggle input {
  accent-color: var(--accent-primary);
}

/* ==========================================================================
   TÍTULO DE LA CLASE Y BOTÓN "MARCAR COMO VISTA"
   ========================================================================== */
.lesson-title-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.lesson-main-title {
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 21px;
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 4px;
}

.lesson-module-subtitle {
  font-size: 13.5px;
  color: var(--text-secondary);
}

.btn-complete {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1.5px solid var(--border-strong);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.btn-complete:hover {
  border-color: var(--success);
  background: var(--success-soft);
}

.btn-complete .check-circle {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: transparent;
  transition: all 0.2s ease;
}

.btn-complete.is-completed {
  background: var(--success-soft);
  border-color: var(--success);
  color: var(--success);
}

.btn-complete.is-completed .check-circle {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

/* ==========================================================================
   PESTAÑAS DE ESTUDIO (MATERIAL COMPLEMENTARIO / LECTOR PDF / APUNTES)
   ========================================================================== */
.study-tabs-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.study-tabs-header {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card);
  overflow-x: auto;
}

.study-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2.5px solid transparent;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.study-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.02);
}

.study-tab.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
  background: var(--bg-surface);
}

.tab-badge {
  padding: 2px 7px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.study-tab.active .tab-badge {
  background: var(--accent-soft);
  color: var(--accent-primary);
}

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

.study-tab-panel {
  display: none;
  padding: 22px;
}

.study-tab-panel.active {
  display: block;
}

/* ==========================================================================
   TARJETAS DE MATERIAL COMPLEMENTARIO (PDFs, LINKS .TXT, EXCELS)
   ========================================================================== */
.resource-group-title {
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin: 18px 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.resource-group-title:first-child {
  margin-top: 0;
}

.resources-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.resource-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 15px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: all 0.18s ease;
  flex-wrap: wrap;
}

.resource-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-card-hover);
}

.resource-card-left {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-width: 0;
  flex: 1;
}

.resource-icon-box {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
}

.resource-icon-box.pdf-apuntes {
  background: var(--accent-soft);
  color: var(--accent-primary);
}

.resource-icon-box.pdf-lectura {
  background: var(--purple-soft);
  color: var(--purple);
}

.resource-icon-box.link-ext {
  background: var(--info-soft);
  color: var(--info);
}

.resource-icon-box.excel-sheet {
  background: var(--success-soft);
  color: var(--success);
}

.resource-meta {
  min-width: 0;
  flex: 1;
}

.resource-badges-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.res-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
}

.res-badge.apuntes {
  background: var(--accent-soft);
  color: var(--accent-primary);
}

.res-badge.lectura {
  background: var(--purple-soft);
  color: var(--purple);
}

.res-badge.link {
  background: var(--info-soft);
  color: var(--info);
}

.res-badge.excel {
  background: var(--success-soft);
  color: var(--success);
}

.res-size {
  font-size: 11.5px;
  color: var(--text-muted);
}

.resource-title {
  font-weight: 700;
  font-size: 14.5px;
  color: var(--text-primary);
  word-break: break-word;
}

.resource-link-url {
  display: inline-block;
  margin-top: 3px;
  font-size: 13px;
  color: var(--info);
  word-break: break-all;
  font-weight: 500;
}

.resource-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Reproductor embebido opcional para links de YouTube del txt */
.yt-inline-embed {
  margin-top: 12px;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.yt-inline-embed iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* ==========================================================================
   VISOR DE PDF INTEGRADO
   ========================================================================== */
.pdf-reader-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  background: var(--bg-card);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.pdf-selector-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 220px;
}

.pdf-selector-wrap label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.pdf-select {
  flex: 1;
  max-width: 460px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 7px 11px;
  font-size: 13.5px;
  font-family: inherit;
}

.pdf-reader-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pdf-viewer-wrapper {
  width: 100%;
  height: 680px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}

.inline-pdf-frame {
  width: 100%;
  height: 100%;
  border: none;
}

/* ==========================================================================
   MIS APUNTES DE LA CLASE
   ========================================================================== */
.notes-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.notes-header-info h4 {
  font-size: 15px;
  margin-bottom: 2px;
}

.notes-header-info p {
  font-size: 12.5px;
  color: var(--text-secondary);
}

.notes-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.notes-textarea {
  width: 100%;
  min-height: 220px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
}

.notes-textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.timestamps-bar {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ts-chip {
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent-primary);
  font-size: 12px;
  font-weight: 700;
  transition: all 0.15s ease;
}

.ts-chip:hover {
  background: var(--accent-primary);
  color: #fff;
}

/* ==========================================================================
   SIDEBAR LATERAL (TEMARIO ESTILO HOTMART CLUB)
   ========================================================================== */
.course-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-color);
  height: calc(100vh - var(--topbar-height));
  position: sticky;
  top: var(--topbar-height);
  display: flex;
  flex-direction: column;
  z-index: 90;
}

.sidebar-top {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface);
}

.sidebar-search-box {
  position: relative;
  margin-bottom: 10px;
}

.sidebar-search-box .search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.sidebar-search-box input {
  width: 100%;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 12px 8px 34px;
  font-size: 13px;
  font-family: inherit;
}

.sidebar-search-box input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.sidebar-filters {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.filter-chip {
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  white-space: nowrap;
  transition: all 0.15s ease;
}

.filter-chip:hover {
  color: var(--text-primary);
}

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

/* Lista Acordeón de Módulos */
.modules-accordion-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px 28px;
}

.module-block {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  overflow: hidden;
  transition: border-color 0.18s ease;
}

.module-block.active-module {
  border-color: rgba(255, 98, 36, 0.45);
}

.module-header-btn {
  width: 100%;
  padding: 13px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  background: var(--bg-card);
  transition: background 0.15s ease;
}

.module-header-btn:hover {
  background: var(--bg-card-hover);
}

.module-header-info {
  min-width: 0;
  flex: 1;
}

.module-num-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-primary);
  display: block;
  margin-bottom: 2px;
}

.module-name-title {
  font-size: 13.8px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.module-submeta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-top: 5px;
}

.module-chevron {
  color: var(--text-muted);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.module-block.is-open .module-chevron {
  transform: rotate(180deg);
}

.module-mini-bar {
  height: 3px;
  background: var(--bg-elevated);
  width: 100%;
}

.module-mini-bar-fill {
  height: 100%;
  background: var(--success);
  transition: width 0.25s ease;
}

.module-lessons-list {
  display: none;
  border-top: 1px solid var(--border-color);
  background: var(--bg-surface);
}

.module-block.is-open .module-lessons-list {
  display: block;
}

.lesson-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background 0.15s ease;
}

.lesson-item:last-child {
  border-bottom: none;
}

.lesson-item:hover {
  background: var(--bg-card-hover);
}

.lesson-item.active {
  background: var(--accent-soft);
  border-left: 3.5px solid var(--accent-primary);
  padding-left: 10.5px;
}

.lesson-check-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  font-size: 11px;
  color: transparent;
  transition: all 0.15s ease;
}

.lesson-check-btn:hover {
  border-color: var(--success);
}

.lesson-item.completed .lesson-check-btn {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.lesson-item-body {
  flex: 1;
  min-width: 0;
}

.lesson-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  margin-bottom: 4px;
}

.lesson-item.completed .lesson-item-title {
  color: var(--text-secondary);
}

.lesson-item.active .lesson-item-title {
  color: var(--accent-primary);
  font-weight: 700;
}

.lesson-item-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--text-muted);
}

.mini-tag {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ==========================================================================
   BOTONES Y COMPONENTES GENERALES
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  transition: all 0.16s ease;
  white-space: nowrap;
  cursor: pointer;
}

.btn:hover {
  text-decoration: none;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12.5px;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 4px 12px rgba(255, 98, 36, 0.25);
}

.btn-primary:hover {
  filter: brightness(1.08);
  color: #fff;
}

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

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
}

.empty-state {
  text-align: center;
  padding: 36px 20px;
  color: var(--text-secondary);
}

.empty-icon {
  font-size: 36px;
  margin-bottom: 10px;
}

/* ==========================================================================
   MODALES (BIBLIOTECA, PDF PANTALLA COMPLETA, CONFIGURACIÓN NUBE)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 11, 0.78);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 200;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.65);
  overflow: hidden;
}

.modal-lg {
  max-width: 880px;
}

.modal-fullscreen {
  max-width: 96vw;
  height: 92vh;
}

.modal-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-card);
}

.modal-header h3 {
  font-size: 17px;
  font-weight: 700;
}

.modal-subtitle {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-body-pdf {
  flex: 1;
  background: #000;
}

.fullscreen-pdf-frame {
  width: 100%;
  height: 100%;
  border: none;
}

.modal-body-scroll {
  padding: 22px;
  overflow-y: auto;
  flex: 1;
}

/* Biblioteca General */
.library-controls {
  padding: 14px 22px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface);
}

.library-search {
  width: 100%;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 13.5px;
  margin-bottom: 10px;
}

.library-filter-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.lib-filter-btn {
  padding: 5px 12px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.lib-filter-btn.active {
  background: var(--accent-soft);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.library-list-container {
  padding: 18px 22px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Secciones del Modal Nube / Drive */
.settings-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 16px;
}

.settings-section h4 {
  font-size: 15px;
  margin-bottom: 6px;
}

.settings-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.radio-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.radio-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: pointer;
}

.radio-card input {
  margin-top: 3px;
  accent-color: var(--accent-primary);
}

.radio-card-body strong {
  display: block;
  font-size: 13px;
  margin-bottom: 3px;
}

.radio-card-body span {
  display: block;
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.form-input,
.form-textarea {
  width: 100%;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
}

.input-with-btn {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.current-lesson-drive-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 13px;
}

.apps-script-details {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

.apps-script-details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: var(--accent-primary);
}

.apps-script-content {
  margin-top: 12px;
  font-size: 12.8px;
}

.steps-list {
  padding-left: 18px;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.code-snippet {
  background: #080b10;
  color: #a5b4fc;
  padding: 10px 12px;
  border-radius: 7px;
  font-size: 12px;
  overflow-x: auto;
  border: 1px solid var(--border-color);
  margin: 8px 0;
}

.two-col-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.sub-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 13px;
}

.sub-card h5 {
  font-size: 13.5px;
  margin-bottom: 4px;
}

.small-note {
  font-size: 12px;
  color: var(--text-secondary);
}

.mt-8 {
  margin-top: 8px;
}

.mt-12 {
  margin-top: 12px;
}

.flex-row-gap {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.status-msg {
  font-size: 12.5px;
  margin-top: 6px;
  color: var(--success);
  font-weight: 600;
}

.file-label-btn {
  cursor: pointer;
}

/* Pantalla de Bloqueo Privado */
.lock-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-app);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lock-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-card);
}

.lock-logo {
  font-size: 44px;
  margin-bottom: 10px;
}

.lock-card h2 {
  font-size: 20px;
  margin-bottom: 4px;
}

.lock-card p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 18px;
}

.lock-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lock-form input {
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  text-align: center;
}

.lock-error {
  color: #ef4444 !important;
  margin-top: 10px;
  margin-bottom: 0 !important;
}

/* ==========================================================================
   RESPONSIVE (MÓVIL Y TABLET — OPTIMIZADO PARA XIAOMI REDMI NOTE 14 PRO)
   ========================================================================== */
.show-mobile-only {
  display: none;
}

.mobile-pdf-canvas-container {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: auto;
  background: #141821;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

.mobile-pdf-canvas-container canvas {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  background: #fff;
}

@media (max-width: 1024px) {
  .show-mobile-only {
    display: inline-flex;
  }

  .course-sidebar {
    position: fixed;
    top: var(--topbar-height);
    right: 0;
    bottom: 0;
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
    width: min(390px, 92vw);
    height: calc(100dvh - var(--topbar-height));
  }

  .course-sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: var(--topbar-height) 0 0 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(2px);
    z-index: 85;
  }

  .hide-mobile {
    display: none !important;
  }

  .main-stage {
    padding: 14px 12px 64px;
  }

  .lesson-complete-actions {
    display: flex;
    width: 100%;
    gap: 8px;
    flex-wrap: wrap;
  }

  .btn-curriculum-mobile {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 14px;
    border-radius: 10px;
    background: var(--bg-elevated);
    border: 1.5px solid var(--border-strong);
    font-size: 13.5px;
    font-weight: 700;
    color: var(--text-primary);
  }

  .btn-complete {
    flex: 1;
    justify-content: center;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 0 10px;
    gap: 8px;
  }

  .brand-title {
    font-size: 14.5px;
  }

  .brand-subtitle {
    display: none;
  }

  .topbar-center {
    max-width: 135px;
  }

  .global-progress-card {
    padding: 5px 8px;
  }

  .progress-label {
    display: none;
  }

  .global-progress-info {
    justify-content: center;
    font-size: 11px;
  }

  .topbar-action-btn {
    padding: 0 10px;
  }

  .topbar-action-btn .btn-label {
    display: none;
  }

  .player-toolbar {
    padding: 10px 12px;
    gap: 8px;
  }

  .player-toolbar-left,
  .player-toolbar-right {
    width: 100%;
    justify-content: space-between;
  }

  .speed-selector {
    flex: 1;
    justify-content: space-between;
    overflow-x: auto;
  }

  .toolbar-label {
    display: none;
  }

  .lesson-title-card {
    padding: 14px;
  }

  .lesson-main-title {
    font-size: 17px;
  }

  .study-tab {
    padding: 12px 13px;
    font-size: 12.5px;
  }

  .study-tab-panel {
    padding: 14px 12px;
  }

  .resource-card {
    padding: 13px;
    flex-direction: column;
    align-items: stretch;
  }

  .resource-card-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
  }

  .pdf-viewer-wrapper {
    height: 72dvh;
    min-height: 460px;
  }
}
