:root {
  --brand: #006298;
  --brand-600: #00507c;
  --brand-50: #e8f3f9;
  --accent: #f59e0b;
  --ok: #10b981;
  --ok-50: #e7f8f1;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --line: #e2e8f0;
  --bg: #f5f7fb;
  --card: #ffffff;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); }
button { font: inherit; cursor: pointer; }
img { max-width: 100%; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  border: 0; border-radius: 12px; padding: .75rem 1.15rem;
  font-weight: 700; font-size: .95rem; text-decoration: none;
  transition: transform .15s, background .15s, box-shadow .15s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(0, 98, 152, .25); }
.btn-primary:hover { background: var(--brand-600); }
.btn-ghost { background: var(--brand-50); color: var(--brand); }
.btn-ghost:hover { background: #d6eaf5; }
.btn-ok { background: var(--ok); color: #fff; }
.btn[disabled] { opacity: .6; cursor: default; }

/* ---------- Login ---------- */
.login {
  min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr;
}
.login-hero {
  background: radial-gradient(circle at 20% 20%, #0a85c7 0, var(--brand) 45%, #003a5c 100%);
  color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.login-hero::after {
  content: ""; position: absolute; width: 520px; height: 520px; border-radius: 50%;
  border: 70px solid rgba(255, 255, 255, .06); right: -180px; bottom: -200px;
}
.login-hero h1 { font-size: clamp(2rem, 4vw, 3.2rem); line-height: 1.05; margin: 0 0 1rem; letter-spacing: -.02em; }
.login-hero p { font-size: 1.1rem; opacity: .85; max-width: 30rem; line-height: 1.6; }
.login-hero .tag { font-weight: 700; letter-spacing: .12em; text-transform: uppercase; font-size: .8rem; opacity: .8; }
.login-form-wrap { display: grid; place-items: center; padding: 2rem 1rem; }
.login-form { width: 100%; max-width: 380px; }
.login-form img.logo { height: 56px; margin-bottom: 1.5rem; }
.login-form h2 { margin: 0 0 .35rem; font-size: 1.6rem; }
.login-form .sub { color: var(--ink-2); margin: 0 0 1.75rem; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .4rem; }
.field input {
  width: 100%; padding: .85rem 1rem; border-radius: 12px; border: 1.5px solid var(--line);
  font: inherit; background: #fff; transition: border-color .15s, box-shadow .15s;
}
.field input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-50); }
.login-form .btn { width: 100%; justify-content: center; margin-top: .5rem; padding: .9rem; }
.error { background: #fef2f2; color: #b91c1c; padding: .75rem 1rem; border-radius: 10px; font-size: .9rem; margin-bottom: 1rem; }

/* ---------- Layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10; background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.topbar-in { max-width: 1200px; margin: 0 auto; padding: .75rem 1rem; display: flex; align-items: center; gap: 1rem; }
.topbar img.logo { height: 38px; }
.topbar nav { display: flex; gap: .25rem; margin-left: 1rem; }
.topbar nav a { text-decoration: none; color: var(--ink-2); font-weight: 600; padding: .5rem .85rem; border-radius: 10px; font-size: .92rem; }
.topbar nav a.on, .topbar nav a:hover { background: var(--brand-50); color: var(--brand); }
.topbar .spacer { flex: 1; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: .85rem;
}
.user-menu { display: flex; align-items: center; gap: .6rem; }
.user-menu .name { font-weight: 600; font-size: .9rem; }
.user-menu button { background: none; border: 0; color: var(--ink-3); font-size: .85rem; }
.user-menu button:hover { color: #b91c1c; }
main { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }

/* ---------- Dashboard ---------- */
.welcome {
  background: linear-gradient(120deg, var(--brand) 0%, #0a85c7 100%); color: #fff;
  border-radius: 22px; padding: 2rem; display: flex; gap: 2rem; align-items: center; justify-content: space-between;
  flex-wrap: wrap; position: relative; overflow: hidden;
}
.welcome::after {
  content: ""; position: absolute; width: 300px; height: 300px; border-radius: 50%;
  border: 50px solid rgba(255, 255, 255, .08); right: -80px; top: -120px;
}
.welcome h1 { margin: 0 0 .35rem; font-size: 1.75rem; letter-spacing: -.01em; }
.welcome p { margin: 0; opacity: .85; }
.stats { display: flex; gap: .75rem; flex-wrap: wrap; position: relative; z-index: 1; }
.stat { background: rgba(255, 255, 255, .14); border-radius: 14px; padding: .85rem 1.1rem; min-width: 120px; }
.stat b { display: block; font-size: 1.6rem; line-height: 1.1; }
.stat span { font-size: .8rem; opacity: .85; }

.continue {
  margin-top: 1.25rem; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.continue .ico { width: 48px; height: 48px; border-radius: 12px; background: #fff7e6; display: grid; place-items: center; font-size: 1.4rem; }
.continue .txt { flex: 1; min-width: 200px; }
.continue small { color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; font-size: .72rem; }
.continue div.t { font-weight: 700; margin-top: .15rem; }

.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 2rem 0 1rem; }
.section-title h2 { margin: 0; font-size: 1.3rem; }
.filters { display: flex; gap: .4rem; }
.chip { border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: .4rem .9rem; font-weight: 600; font-size: .85rem; color: var(--ink-2); }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.25rem; }
.course-card {
  background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  text-decoration: none; color: inherit; display: flex; flex-direction: column; transition: transform .2s, box-shadow .2s;
}
.course-card:hover { transform: translateY(-4px); box-shadow: 0 16px 40px rgba(15, 23, 42, .12); }
.course-card .img { aspect-ratio: 16 / 9; background: var(--brand-50) center / cover no-repeat; position: relative; }
.course-card .badge {
  position: absolute; top: .75rem; left: .75rem; background: #fff; color: var(--ink); font-size: .72rem;
  font-weight: 700; padding: .3rem .6rem; border-radius: 999px;
}
.course-card .badge.done { background: var(--ok); color: #fff; }
.course-card .body { padding: 1rem 1.1rem 1.2rem; display: flex; flex-direction: column; gap: .75rem; flex: 1; }
.course-card h3 { margin: 0; font-size: 1.02rem; line-height: 1.35; }
.course-card .meta { color: var(--ink-3); font-size: .82rem; margin-top: auto; }

.progress { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--brand), #0a9be0); transition: width .6s; }
.progress.done > i { background: var(--ok); }
.progress-row { display: flex; align-items: center; gap: .6rem; font-size: .82rem; font-weight: 700; color: var(--ink-2); }
.progress-row .progress { flex: 1; }

/* ---------- Curso ---------- */
.course-layout { display: grid; grid-template-columns: 320px 1fr; gap: 1.5rem; align-items: start; }
.sidebar { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); position: sticky; top: 80px; max-height: calc(100vh - 100px); overflow: auto; }
.sidebar-head { padding: 1.1rem 1.1rem .9rem; border-bottom: 1px solid var(--line); }
.sidebar-head a.back { font-size: .82rem; font-weight: 600; text-decoration: none; color: var(--ink-3); }
.sidebar-head h2 { font-size: 1.02rem; margin: .5rem 0 .75rem; line-height: 1.35; }
.sec { border-bottom: 1px solid var(--line); }
.sec > button {
  width: 100%; background: none; border: 0; text-align: left; padding: .85rem 1.1rem;
  display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: .9rem; color: var(--ink);
}
.sec > button .count { margin-left: auto; color: var(--ink-3); font-size: .75rem; font-weight: 600; }
.sec > button .chev { transition: transform .2s; color: var(--ink-3); }
.sec.open > button .chev { transform: rotate(90deg); }
.sec ul { list-style: none; margin: 0; padding: 0 .5rem .6rem; display: none; }
.sec.open ul { display: block; }
.sec li a {
  display: flex; align-items: center; gap: .6rem; padding: .55rem .6rem; border-radius: 10px;
  text-decoration: none; color: var(--ink-2); font-size: .87rem; line-height: 1.3;
}
.sec li a:hover { background: var(--bg); }
.sec li a.on { background: var(--brand-50); color: var(--brand); font-weight: 600; }
.check {
  flex: none; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line);
  display: grid; place-items: center; font-size: .65rem; color: #fff;
}
.check.done { background: var(--ok); border-color: var(--ok); }
.check.none { border-style: dashed; }

.content { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2rem; min-height: 60vh; }
.content .kicker { color: var(--brand); font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
.content h1 { margin: .35rem 0 1.25rem; font-size: 1.7rem; line-height: 1.2; letter-spacing: -.01em; }
.prose { line-height: 1.75; color: #1e293b; font-size: 1.02rem; overflow-wrap: anywhere; }
.prose img, .prose video, .prose iframe { max-width: 100%; height: auto; border-radius: 12px; }
.prose iframe { aspect-ratio: 16 / 9; width: 100%; border: 0; }
.prose table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; }
.prose td, .prose th { border: 1px solid var(--line); padding: .5rem; }
.prose pre { background: #0f172a; color: #e2e8f0; padding: 1rem; border-radius: 12px; overflow-x: auto; }
.content-foot {
  margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line);
  display: flex; gap: .75rem; justify-content: space-between; align-items: center; flex-wrap: wrap;
}
.done-pill { display: inline-flex; align-items: center; gap: .4rem; background: var(--ok-50); color: #047857; font-weight: 700; padding: .6rem 1rem; border-radius: 12px; font-size: .9rem; }
.file-box { display: flex; align-items: center; gap: 1rem; background: var(--bg); border-radius: 14px; padding: 1rem 1.2rem; margin: 1rem 0; }
.file-box .ico { font-size: 1.8rem; }
.file-box .grow { flex: 1; }
.file-box small { color: var(--ink-3); }
.pdf { width: 100%; height: 75vh; border: 0; border-radius: 12px; margin-top: 1rem; }
.note { background: #fff7e6; border-radius: 12px; padding: .85rem 1rem; color: #92400e; font-size: .9rem; }

.overview-sec { margin-bottom: 1.5rem; }
.overview-sec h3 { margin: 0 0 .6rem; font-size: 1.05rem; }
.overview-list { display: grid; gap: .5rem; }
.overview-list a {
  display: flex; align-items: center; gap: .75rem; padding: .8rem 1rem; border: 1.5px solid var(--line);
  border-radius: 12px; text-decoration: none; color: var(--ink); font-weight: 500; transition: border-color .15s;
}
.overview-list a:hover { border-color: var(--brand); }
.overview-list .type { margin-left: auto; color: var(--ink-3); font-size: .78rem; }

/* ---------- Progreso ---------- */
.table-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row { display: grid; grid-template-columns: 1.6fr 1fr 110px; gap: 1rem; padding: 1rem 1.25rem; align-items: center; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row.head { background: var(--bg); font-size: .78rem; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.row .grade { font-weight: 800; font-size: 1.05rem; text-align: right; }

/* ---------- Estados ---------- */
.loading { display: grid; place-items: center; min-height: 50vh; color: var(--ink-3); gap: 1rem; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 4px solid var(--brand-50); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, #eef2f7 25%, #f8fafc 50%, #eef2f7 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--radius); }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; }
  .login-hero { padding: 2rem 1.25rem; min-height: 240px; }
  .course-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; }
  .content { padding: 1.25rem; }
  .topbar nav { margin-left: 0; }
  .user-menu .name { display: none; }
  .row { grid-template-columns: 1fr 80px; }
  .row .hide-sm { display: none; }
}
@media (max-width: 520px) {
  .topbar img.logo { height: 30px; }
  .topbar nav a { padding: .45rem .55rem; font-size: .85rem; }
  .welcome { padding: 1.4rem; }
}

/* Ajustes móviles */
.topbar nav a { white-space: nowrap; }
.section-title { flex-wrap: wrap; gap: .75rem; }
.section-title h2 { white-space: nowrap; }
@media (max-width: 520px) {
  .topbar-in { gap: .5rem; }
  .stat { min-width: 0; flex: 1 1 40%; }
  .continue .btn { width: 100%; justify-content: center; }
}

/* Celular y tablet: primero el contenido (la lección o la portada del curso) y después el índice del curso */
@media (max-width: 900px) {
  .course-layout > .content { order: -1; }
}

/* ======================================================================
 * Página del curso (catálogo)
 * ====================================================================== */
.course-card .card-title { color: inherit; text-decoration: none; }
.course-card .card-title:hover { color: var(--brand); }
.course-card a.img { display: block; }
.card-action { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ci-more {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem; width: 100%;
  padding: .5rem .85rem; border: 1.5px solid var(--brand); border-radius: 10px;
  font-size: .85rem; font-weight: 700; text-decoration: none; color: var(--brand); background: transparent;
  transition: background .15s;
}
.ci-more:hover { background: var(--brand-50); }
.ci-more:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.ci-hero { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 28px; align-items: center; margin: 12px 0 24px;
  background: var(--card); border-radius: 22px; padding: 28px; box-shadow: var(--shadow); }
.ci-hero h1 { font-size: clamp(1.6rem, 3vw, 2.3rem); line-height: 1.15; margin: 6px 0 10px; letter-spacing: -.02em; }
.ci-summary { color: var(--ink-2); }
.ci-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 18px; }
.ci-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--brand-50); color: var(--brand); font-weight: 700; font-size: .85rem; }
.ci-chip .lp-ico { width: 16px; height: 16px; }
.ci-cta .btn { min-height: 48px; padding: 0 22px; }
.ci-media { position: relative; }
.ci-video, .ci-cover { position: relative; aspect-ratio: 16 / 9; border-radius: 16px; overflow: hidden; background: #0b1a2c center / cover no-repeat; }
.ci-cover { background-color: var(--brand-50); }
.ci-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.ci-tag { position: absolute; left: 12px; top: 12px; padding: 4px 10px; border-radius: 999px; background: rgba(4, 31, 51, .78); color: #fff; font-size: .75rem; font-weight: 700; pointer-events: none; }
.ci-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.ci-col { display: grid; gap: 20px; }
.ci-card { padding: 22px 24px; }
.ci-card h2 { font-size: 1.15rem; margin: 0 0 14px; }
.ci-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ci-head small { color: var(--ink-3); }
.ci-learn { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; }
.ci-learn li { display: flex; gap: 10px; align-items: flex-start; line-height: 1.4; }
.ci-learn .lp-ico { width: 20px; height: 20px; color: var(--ok, #16a34a); flex: none; margin-top: 1px; }
.ci-sec { border: 1px solid var(--line); border-radius: 14px; margin-top: 10px; overflow: hidden; }
.ci-sec summary { display: flex; justify-content: space-between; gap: 10px; padding: 12px 16px; cursor: pointer; font-weight: 700; background: var(--bg); list-style: none; }
.ci-sec summary::-webkit-details-marker { display: none; }
.ci-sec summary::before { content: '▸'; margin-right: 8px; transition: transform .2s; display: inline-block; }
.ci-sec[open] summary::before { transform: rotate(90deg); }
.ci-sec summary span { flex: 1; }
.ci-sec summary small { color: var(--ink-3); font-weight: 600; white-space: nowrap; }
.ci-sec ul { list-style: none; margin: 0; padding: 6px 16px 10px; }
.ci-sec li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .93rem; }
.ci-sec li:last-child { border-bottom: 0; }
.ci-sec li span:nth-child(2) { flex: 1; }
.ci-sec li small { color: var(--ink-3); white-space: nowrap; }
.ci-list { margin: 0; padding-left: 20px; display: grid; gap: 8px; line-height: 1.45; }
.ci-teacher { display: flex; align-items: center; gap: 12px; padding: 6px 0; }
.ci-teacher b, .ci-teacher small { display: block; }
.ci-teacher small { color: var(--ink-3); }
.ci-av { width: 42px; height: 42px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--brand); color: #fff; font-weight: 800; flex: none; }
.ci-inc { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ci-inc li { display: flex; gap: 10px; align-items: center; }
.ci-inc .lp-ico { width: 20px; height: 20px; color: var(--brand); flex: none; }
@media (max-width: 900px) {
  .ci-hero, .ci-grid { grid-template-columns: minmax(0, 1fr); }
  .ci-hero { padding: 20px; }
  .ci-media { order: -1; }
}
@media (max-width: 520px) {
  .ci-learn { grid-template-columns: minmax(0, 1fr); }
  .ci-cta .btn { width: 100%; justify-content: center; }
}
.ci-cover-empty { display: grid; place-content: center; justify-items: center; gap: 12px; padding: 20px; text-align: center; color: #fff;
  background: radial-gradient(500px 260px at 85% 10%, rgba(56, 189, 248, .35), transparent 70%), linear-gradient(135deg, #0a4f7c, #041f33); }
.ci-cover-empty span { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; background: rgba(255, 255, 255, .14); }
.ci-cover-empty .lp-ico { width: 34px; height: 34px; }
.ci-cover-empty b { font-size: 1.25rem; max-width: 22ch; line-height: 1.25; }

/* Botón «Agregar a LinkedIn» (azul de LinkedIn) */
.btn.btn-linkedin { background: #0a66c2; color: #fff; gap: 8px; }
.btn.btn-linkedin:hover { background: #004182; color: #fff; }
.btn.btn-linkedin .li-logo { width: 18px; height: 18px; flex: none; }
@media (max-width: 900px) {
  .ci-cover { max-height: 300px; }
  .ci-cover-empty { aspect-ratio: auto; min-height: 150px; }
  .ci-video { max-width: 640px; }
}

/* Iconos de tipo de actividad (Lectura, Tarea, Foro…): finos, en gris y del tamaño del texto */
.lp-ico.mod-ico { width: 1.05em; height: 1.05em; stroke-width: 1.5; color: var(--ink-3); vertical-align: -.17em; margin-right: .4em; }
.content .kicker .lp-ico.mod-ico { width: 1.15em; height: 1.15em; margin-right: .3em; }
.ci-ico { display: inline-flex; align-items: center; }
.ci-ico .lp-ico.mod-ico { margin-right: 0; }
