/* ══════════════════════════════════════════
   VARIABLES & RESET
══════════════════════════════════════════ */
:root {
  --primary:       #7C3AED;
  --primary-dk:    #5B21B6;
  --primary-lt:    #EDE9FE;
  --success:       #059669;
  --success-lt:    #D1FAE5;
  --error:         #DC2626;
  --error-lt:      #FEE2E2;
  --gold:          #C9A84C;
  --gold-lt:       #FEF3C7;
  --neutral-900:   #1E293B;
  --neutral-700:   #334155;
  --neutral-500:   #64748B;
  --neutral-300:   #CBD5E1;
  --neutral-100:   #F1F5F9;
  --white:         #FFFFFF;

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --serif: Georgia, 'Times New Roman', serif;

  --sh-sm:  0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --sh-md:  0 4px 6px -1px rgba(0,0,0,.10), 0 2px 4px -1px rgba(0,0,0,.06);
  --sh-lg:  0 10px 15px -3px rgba(0,0,0,.10), 0 4px 6px -2px rgba(0,0,0,.05);
  --sh-xl:  0 20px 25px -5px rgba(0,0,0,.10), 0 10px 10px -5px rgba(0,0,0,.04);

  --r:    0.625rem;
  --r-lg: 1rem;
  --r-xl: 1.25rem;
  --t:    0.18s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--neutral-100);
  color: var(--neutral-900);
  line-height: 1.6;
  min-height: 100vh;
}

/* ══════════════════════════════════════════
   SCREENS
══════════════════════════════════════════ */
.screen { display: none; min-height: 100vh; animation: fadeIn .25s ease; }
.screen.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ══════════════════════════════════════════
   COMMON: PROGRESS BAR
══════════════════════════════════════════ */
.prog-track {
  height: 6px;
  background: var(--neutral-300);
  border-radius: 999px;
  overflow: hidden;
}
.prog-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #A855F7);
  border-radius: 999px;
  transition: width .4s ease;
  width: 0%;
}

/* ══════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════ */
button { font-family: var(--font); cursor: pointer; transition: all var(--t); }

.btn-primary {
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: var(--r);
  padding: .6rem 1.25rem;
  font-size: .95rem;
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dk); transform: translateY(-1px); box-shadow: var(--sh-md); }
.btn-primary:disabled { background: var(--neutral-300); cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary.btn-large { width: 100%; padding: .85rem 1.5rem; font-size: 1.05rem; }

.btn-secondary {
  background: var(--white);
  color: var(--neutral-700);
  border: 2px solid var(--neutral-300);
  border-radius: var(--r);
  padding: .6rem 1.25rem;
  font-size: .95rem;
  font-weight: 600;
}
.btn-secondary:hover:not(:disabled) { border-color: var(--neutral-500); background: var(--neutral-100); }
.btn-secondary:disabled { color: var(--neutral-300); cursor: not-allowed; }

.btn-success {
  background: var(--success);
  color: var(--white);
  border: none;
  border-radius: var(--r);
  padding: .6rem 1.5rem;
  font-size: .95rem;
  font-weight: 600;
}
.btn-success:hover { background: #047857; transform: translateY(-1px); }

.btn-mark {
  background: var(--primary-lt);
  color: var(--primary);
  border: 2px solid transparent;
  border-radius: var(--r);
  padding: .6rem 1.25rem;
  font-size: .95rem;
  font-weight: 600;
}
.btn-mark:hover { background: var(--primary); color: var(--white); }
.btn-mark.marked { background: var(--success); color: var(--white); cursor: default; }

.btn-danger {
  background: var(--error);
  color: var(--white);
  border: none;
  border-radius: var(--r);
  padding: .6rem 1.25rem;
  font-size: .95rem;
  font-weight: 600;
}
.btn-danger:hover { background: #b91c1c; }

.btn-link {
  background: none;
  border: none;
  color: var(--neutral-500);
  font-size: .85rem;
  padding: .25rem .5rem;
}
.btn-link:hover { color: var(--neutral-700); }

/* ══════════════════════════════════════════
   WELCOME SCREEN
══════════════════════════════════════════ */
.welcome-wrap {
  max-width: 540px;
  margin: 0 auto;
  padding: 3rem 1rem 5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.75rem;
}

.inst-badge {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: var(--white);
  border: 1px solid var(--neutral-300);
  border-radius: 999px;
  padding: .4rem 1rem;
  font-size: .85rem;
  color: var(--neutral-500);
  box-shadow: var(--sh-sm);
}

.hero { text-align: center; }
.hero-icon { font-size: 4.5rem; line-height: 1; margin-bottom: .75rem; }
.hero h1 {
  font-size: clamp(2.2rem, 7vw, 3.2rem);
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary) 0%, #A855F7 60%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: .5rem;
}
.hero-sub {
  color: var(--neutral-500);
  font-size: 1rem;
  max-width: 380px;
  margin: 0 auto 1.5rem;
}
.hero-stats {
  display: flex;
  justify-content: center;
  gap: 1rem;
}
.stat {
  background: var(--white);
  border: 1px solid var(--neutral-300);
  border-radius: var(--r);
  padding: .75rem 1.25rem;
  text-align: center;
  box-shadow: var(--sh-sm);
  min-width: 90px;
}
.stat strong { display: block; font-size: 1.4rem; color: var(--primary); }
.stat span { font-size: .8rem; color: var(--neutral-500); }

.welcome-card {
  width: 100%;
  background: var(--white);
  border-radius: var(--r-xl);
  padding: 1.75rem;
  box-shadow: var(--sh-lg);
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.welcome-card label { font-weight: 600; font-size: .95rem; }
.welcome-card input {
  width: 100%;
  padding: .75rem 1rem;
  border: 2px solid var(--neutral-300);
  border-radius: var(--r);
  font-size: 1rem;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--t);
}
.welcome-card input:focus { border-color: var(--primary); }
.welcome-card input.error { border-color: var(--error); }

/* ══════════════════════════════════════════
   TOP BAR (COURSE)
══════════════════════════════════════════ */
.top-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .75rem 1.5rem;
  background: var(--white);
  border-bottom: 1px solid var(--neutral-300);
  box-shadow: var(--sh-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}
.top-bar-brand { font-weight: 700; color: var(--primary); white-space: nowrap; }
.top-bar-progress {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .2rem;
}
.top-bar-progress .prog-track { width: min(240px, 100%); }
.prog-label { font-size: .72rem; color: var(--neutral-500); }
.top-bar-user { font-size: .85rem; color: var(--neutral-500); white-space: nowrap; }

/* ══════════════════════════════════════════
   COURSE LAYOUT
══════════════════════════════════════════ */
.course-body {
  display: flex;
  min-height: calc(100vh - 56px);
}

/* Sidebar */
.sidebar {
  width: 270px;
  flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--neutral-300);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.sidebar-title {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--neutral-500);
  margin-bottom: .75rem;
}
.lesson-nav {
  list-style: none;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.lesson-nav-item {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .6rem .75rem;
  border-radius: var(--r);
  cursor: pointer;
  font-size: .875rem;
  transition: background var(--t);
  line-height: 1.3;
}
.lesson-nav-item:hover { background: var(--neutral-100); }
.lesson-nav-item.active { background: var(--primary-lt); color: var(--primary); font-weight: 600; }
.lesson-nav-item.locked { color: var(--neutral-300); cursor: not-allowed; }
.lesson-nav-item.locked:hover { background: transparent; }

.lesson-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--neutral-300);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .72rem;
  font-weight: 700;
  flex-shrink: 0;
  color: var(--neutral-700);
}
.lesson-nav-item.completed .lesson-num { background: var(--success); color: var(--white); }
.lesson-nav-item.active .lesson-num { background: var(--primary); color: var(--white); }
.lesson-nav-item.locked .lesson-num { background: var(--neutral-100); color: var(--neutral-300); }
.sidebar-footer { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--neutral-300); }

/* Main content */
.lesson-main {
  flex: 1;
  padding: 1.5rem;
  max-width: 900px;
  min-width: 0;
}

/* Video */
.video-box { margin-bottom: 1.5rem; }
.player-wrapper {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  background: #111;
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--sh-xl);
}
.player-wrapper iframe,
.player-wrapper > div:first-child {
  position: absolute !important;
  top: 0; left: 0;
  width: 100% !important;
  height: 100% !important;
  border: none;
}
.locked-overlay, .placeholder-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  text-align: center;
  z-index: 5;
}
.locked-overlay { background: rgba(10,10,20,.85); }
.placeholder-overlay { background: rgba(30,30,50,.9); }
.lock-msg span, .placeholder-msg span { font-size: 2.5rem; display: block; margin-bottom: .6rem; }
.lock-msg p, .placeholder-msg p { font-size: .95rem; line-height: 1.5; }
.placeholder-msg code { background: rgba(255,255,255,.15); padding: .1rem .4rem; border-radius: .25rem; font-size: .9rem; }

/* Lesson info */
.lesson-info-block { margin-bottom: 1.25rem; }
.lesson-meta-row { display: flex; align-items: center; gap: .75rem; margin-bottom: .4rem; }
.lesson-counter { font-size: .78rem; font-weight: 700; color: var(--neutral-500); text-transform: uppercase; letter-spacing: .05em; }
.done-badge { background: var(--success-lt); color: #065F46; font-size: .78rem; font-weight: 700; padding: .2rem .65rem; border-radius: 999px; }
#lesson-title { font-size: 1.4rem; font-weight: 700; margin-bottom: .35rem; }
#lesson-desc { color: var(--neutral-500); font-size: .95rem; }

/* Controls */
.lesson-controls { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }

/* Quiz banner */
.quiz-banner {
  margin-top: 1.5rem;
  background: linear-gradient(135deg, #F0FDF4, #DCFCE7);
  border: 1px solid #86EFAC;
  border-radius: var(--r-lg);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  font-weight: 500;
  color: #15803D;
  flex-wrap: wrap;
}

/* ══════════════════════════════════════════
   QUIZ SCREEN
══════════════════════════════════════════ */
.quiz-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 2.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}
.quiz-header { text-align: center; }
.quiz-header h1 { font-size: 2rem; margin-bottom: .4rem; }
.quiz-header p { color: var(--neutral-500); }
.quiz-progress-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  margin-top: 1rem;
}
#q-counter { font-size: .82rem; font-weight: 700; color: var(--neutral-500); }
.quiz-prog-track { width: 280px; height: 8px; }

.q-card {
  background: var(--white);
  border-radius: var(--r-xl);
  padding: 2rem;
  box-shadow: var(--sh-lg);
  animation: fadeIn .2s ease;
}
.question-text {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  line-height: 1.55;
}
.options-list { list-style: none; display: flex; flex-direction: column; gap: .55rem; }
.option-item {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .85rem 1rem;
  border: 2px solid var(--neutral-300);
  border-radius: var(--r);
  cursor: pointer;
  transition: all var(--t);
  user-select: none;
}
.option-item:hover:not(.submitted) { border-color: var(--primary); background: var(--primary-lt); }
.option-item.selected { border-color: var(--primary); background: var(--primary-lt); }
.option-item.opt-correct { border-color: var(--success); background: var(--success-lt); color: #065F46; cursor: default; }
.option-item.opt-wrong   { border-color: var(--error);   background: var(--error-lt);   color: #991B1B; cursor: default; }
.option-item.submitted   { cursor: default; }

.opt-radio {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid var(--neutral-300);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all var(--t);
}
.option-item.selected .opt-radio { border-color: var(--primary); background: var(--primary); }
.option-item.selected .opt-radio::after {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--white);
}
.option-item.opt-correct .opt-radio { border-color: var(--success); background: var(--success); }
.option-item.opt-correct .opt-radio::after { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--white); }
.option-item.opt-wrong   .opt-radio { border-color: var(--error);   background: var(--error); }
.option-item.opt-wrong   .opt-radio::after { content: '✕'; font-size: 10px; color: var(--white); }

.opt-text { font-size: .95rem; line-height: 1.4; }

.quiz-nav {
  display: flex;
  gap: .75rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ══════════════════════════════════════════
   RESULTS SCREEN
══════════════════════════════════════════ */
.results-wrap {
  max-width: 580px;
  margin: 0 auto;
  padding: 4rem 1rem;
  text-align: center;
}
.results-icon { font-size: 5rem; margin-bottom: 1.25rem; }
.score-ring {
  width: 160px; height: 160px;
  border-radius: 50%;
  border: 10px solid;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  margin: 0 auto 1.75rem;
}
.score-ring.pass { border-color: var(--success); }
.score-ring.fail { border-color: var(--error); }
.score-pct { font-size: 2.8rem; font-weight: 800; line-height: 1; }
.score-ring.pass .score-pct { color: var(--success); }
.score-ring.fail .score-pct { color: var(--error); }
.score-tag { font-size: .8rem; font-weight: 700; letter-spacing: .05em; color: var(--neutral-500); }
.results-title { font-size: 1.9rem; font-weight: 700; margin-bottom: .4rem; }
.results-sub { color: var(--neutral-500); margin-bottom: .75rem; }
.results-detail { color: var(--neutral-500); font-size: .9rem; margin-bottom: 2rem; }
.results-actions { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }

/* ══════════════════════════════════════════
   CERTIFICATE SCREEN
══════════════════════════════════════════ */
.cert-screen-wrap {
  padding: 2rem 1rem 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}
.cert-screen-title { font-size: 1.75rem; text-align: center; }
.cert-scroll-area { max-width: 100%; overflow-x: auto; }

/* ─── Certificado (tamaño fijo para html2canvas) ─── */
.cert-paper {
  width: 880px;
  height: 620px;
  background: #FFFDF5;
  font-family: var(--serif);
  position: relative;
  flex-shrink: 0;
}
.cert-outer {
  position: absolute;
  inset: 14px;
  border: 3px solid var(--gold);
}
.cert-inner {
  position: absolute;
  inset: 10px;
  border: 1px solid var(--gold);
  display: flex;
  flex-direction: column;
  padding: 2rem 3.5rem;
  gap: 0;
}

.cert-top { text-align: center; margin-bottom: 1rem; }
.cert-inst {
  font-family: var(--font);
  font-size: .9rem;
  font-weight: 700;
  letter-spacing: .08em;
  color: #5B3A00;
  margin-bottom: .6rem;
}
.cert-line-gold {
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.cert-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: .3rem;
}
.cert-certifica {
  font-family: var(--font);
  font-size: .78rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
}
.cert-name {
  font-size: 2.6rem;
  font-weight: 700;
  color: #1A1A2E;
  line-height: 1.15;
  margin: .2rem 0;
}
.cert-text-body { font-size: .95rem; color: #5B3A00; font-style: italic; }
.cert-course {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
  margin: .15rem 0;
}
.cert-subtitle-course {
  font-family: var(--font);
  font-size: .78rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--gold);
}

.cert-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-top: 1.5rem;
}
.cert-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .3rem;
  min-width: 180px;
}
.cert-field-label {
  font-family: var(--font);
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gold);
}
.cert-field-value {
  font-size: .92rem;
  font-weight: 600;
  color: #1A1A2E;
}
.cert-field-line {
  display: block;
  width: 100%;
  height: 1px;
  background: var(--gold);
}
.cert-seal {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: .25rem;
}
.cert-seal-ring {
  width: 78px; height: 78px;
  border-radius: 50%;
  border: 3px solid var(--gold);
  background: radial-gradient(circle at 40% 35%, #FFFDF5, #F0E6B2);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem;
  box-shadow: 0 2px 10px rgba(201,168,76,.3);
}

.cert-actions {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* ══════════════════════════════════════════
   MODAL
══════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
}
.modal-box {
  background: var(--white);
  border-radius: var(--r-xl);
  padding: 2rem;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--sh-xl);
}
.modal-box h3 { margin-bottom: .65rem; font-size: 1.2rem; }
.modal-box p  { color: var(--neutral-500); margin-bottom: 1.5rem; font-size: .95rem; }
.modal-actions { display: flex; gap: .75rem; justify-content: flex-end; }

/* ══════════════════════════════════════════
   UTILITIES
══════════════════════════════════════════ */
.hidden { display: none !important; }

/* ══════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Top bar */
  .top-bar { flex-wrap: wrap; padding: .6rem 1rem; gap: .4rem; }
  .top-bar-progress { order: 3; flex: 1 1 100%; }
  .top-bar-progress .prog-track { width: 100%; }
  .top-bar-user { display: none; }

  /* Course layout: stacked */
  .course-body { flex-direction: column; }
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--neutral-300);
    max-height: 180px;
    padding: .75rem;
  }
  .lesson-nav { flex-direction: row; flex-wrap: wrap; }
  .lesson-nav-item { flex: 1 1 auto; min-width: 100px; font-size: .8rem; }
  .sidebar-footer { display: none; }

  .lesson-main { padding: 1rem; }
  .lesson-controls { justify-content: center; }
  #lesson-title { font-size: 1.2rem; }

  /* Quiz */
  .quiz-wrap { padding: 1.5rem 1rem; }
  .q-card { padding: 1.25rem; }

  /* Certificate — allow horizontal scroll */
  .cert-screen-wrap { padding: 1.5rem .75rem 2.5rem; }
  .cert-scroll-area { width: 100%; }
  .cert-paper { transform-origin: top left; }

  /* Results */
  .results-wrap { padding: 2.5rem 1rem; }
}
