/* ============================================================
   OVO ACADEMY — app.css
   Shell + librería de componentes. Consume tokens.css.
   NUNCA valores sueltos: usar variables de tokens.css.
   ============================================================ */

/* ---------- Base ---------- */
a { color: inherit; text-decoration: none; }
a:hover { color: var(--ink-900); }
img { max-width: 100%; display: block; }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-sm); }

.icon { flex: none; width: 20px; height: 20px; stroke: currentColor; }
.icon-sm { width: 16px; height: 16px; }
.muted { color: var(--ink-500); }
.text-sm { font-size: var(--fs-sm); }
.nowrap { white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }

/* Utilidades de layout (evitan estilos inline) */
.stack { display: flex; flex-direction: column; gap: var(--s-3); }
.row { display: flex; align-items: center; gap: var(--s-3); }
.between { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; min-width: 0; }
.mb-0 { margin-bottom: 0; }

/* ============================================================
   SHELL
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.app-sidebar {
  position: sticky; top: 0; align-self: start;
  height: 100vh;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: var(--s-4) var(--s-3);
  overflow-y: auto;
}

.app-body { min-width: 0; display: flex; flex-direction: column; }

.app-topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--s-4);
  min-height: 60px; padding: 0 var(--s-8);
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.app-content {
  flex: 1;
  width: 100%; max-width: 1320px;
  margin: 0 auto;
  padding: var(--s-8) var(--s-8) var(--s-16);
}
.app-content--narrow { max-width: 720px; }
.app-content--wide { max-width: 1480px; }
.app-content--full { max-width: none; }   /* tablas operacionales: usar todo el ancho */

/* ============================================================
   SIDEBAR NAV
   ============================================================ */
.brand {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2) var(--s-3) var(--s-4);
  font-weight: var(--fw-semibold); letter-spacing: -.01em;
  color: var(--ink-900);
}
.brand img { width: 22px; height: 22px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-section {
  margin: var(--s-5) var(--s-3) var(--s-2);
  font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  text-transform: uppercase; letter-spacing: .06em; color: var(--ink-400);
}
.nav-item {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
  color: var(--ink-700); font-size: var(--fs-body); font-weight: var(--fw-medium);
  transition: background var(--transition), color var(--transition);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-item .icon { color: var(--ink-400); transition: color var(--transition); }
.nav-item:hover { background: var(--surface-2); color: var(--ink-900); }
.nav-item:hover .icon { color: var(--ink-700); }
.nav-item.is-active { background: var(--surface-3); color: var(--ink-900); font-weight: var(--fw-semibold); }
.nav-item.is-active .icon { color: var(--ink-900); }
.nav-item--sub { padding-left: var(--s-10); font-size: var(--fs-sm); font-weight: var(--fw-regular); color: var(--ink-500); }
.nav-item--sub.is-active { color: var(--ink-900); background: var(--surface-2); }

.nav-spacer { flex: 1; }

/* Usuario al pie del sidebar */
.nav-user { margin-top: var(--s-4); padding-top: var(--s-3); border-top: 1px solid var(--line); }

/* ============================================================
   MENU (dropdown CSS-only con <details>)
   ============================================================ */
.menu { position: relative; }
.menu > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-3); border-radius: var(--r-md);
  transition: background var(--transition);
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary:hover { background: var(--surface-2); }
.menu[open] > summary { background: var(--surface-2); }
.menu-panel {
  position: absolute; bottom: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: var(--shadow-lg);
  padding: var(--s-2); z-index: 40;
  display: flex; flex-direction: column; gap: 2px;
  animation: pop var(--transition);
}
.menu-panel--down { bottom: auto; top: calc(100% + 6px); }
.menu-item {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-3); border-radius: var(--r-sm);
  font-size: var(--fs-sm); color: var(--ink-700); cursor: pointer;
  background: none; border: 0; width: 100%; text-align: left;
}
.menu-item .icon { color: var(--ink-400); }
.menu-item:hover { background: var(--surface-2); color: var(--ink-900); }
.menu-item--danger:hover { color: var(--warning); }
.menu-divider { height: 1px; background: var(--line); margin: var(--s-1) 0; }

/* Paginación de listas del panel. */
.pagination { display: flex; align-items: center; justify-content: center; gap: var(--s-4); margin-top: var(--s-5); flex-wrap: wrap; }

/* Disparador de menú con forma de botón (ej. Exportar en Accesos). */
.menu > summary.btn { padding: 9px 16px; }
.menu-panel--actions {
  top: calc(100% + 6px); bottom: auto;
  left: 0; right: auto; min-width: 220px;
}

.avatar {
  flex: none; width: 30px; height: 30px; border-radius: var(--r-full);
  background: var(--ink-900); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-sm); font-weight: var(--fw-semibold);
}
.user-meta { min-width: 0; line-height: 1.25; }
.user-meta b { display: block; font-weight: var(--fw-medium); font-size: var(--fs-sm); color: var(--ink-900); overflow: hidden; text-overflow: ellipsis; }
.user-meta span { font-size: var(--fs-xs); color: var(--ink-400); }

@keyframes pop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ============================================================
   BREADCRUMB
   ============================================================ */
.breadcrumb { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); color: var(--ink-400); min-width: 0; }
.breadcrumb a { color: var(--ink-500); }
.breadcrumb a:hover { color: var(--ink-900); }
.breadcrumb .icon { width: 16px; height: 16px; color: var(--ink-300); }
.breadcrumb .current { color: var(--ink-900); font-weight: var(--fw-medium); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--s-3); }

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-head { margin-bottom: var(--s-8); }
.page-head .overline { font-size: var(--fs-xs); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-400); margin: 0 0 var(--s-2); }
.page-head h1 { font-size: var(--fs-h1); line-height: var(--lh-h1); font-weight: var(--fw-semibold); letter-spacing: -.02em; margin: 0; }
.page-head p { margin: var(--s-2) 0 0; color: var(--ink-500); max-width: 64ch; }
.page-head--row { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); }

/* Aviso de "estás mirando esto como equipo, no como alumno". Monocromático a
   propósito: informa, no alarma — no es un error ni un estado del curso. */
.banner-equipo { display: flex; align-items: flex-start; gap: var(--s-3); margin-bottom: var(--s-6); padding: var(--s-3) var(--s-4); background: var(--surface-3); border-left: 3px solid var(--ink-300); border-radius: var(--r-sm); color: var(--ink-500); font-size: var(--fs-sm); line-height: var(--lh-sm); }
.banner-equipo strong { color: var(--ink-900); font-weight: var(--fw-semibold); }
.banner-equipo .icon { flex: none; color: var(--ink-400); margin-top: 1px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  font-family: inherit; font-size: var(--fs-body); font-weight: var(--fw-medium);
  border-radius: var(--r-md); padding: 9px 16px; cursor: pointer;
  border: 1px solid transparent; transition: var(--transition);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  white-space: nowrap; line-height: 1;
}
.btn .icon { width: 18px; height: 18px; }
.btn-primary { background: var(--ink-900); color: #fff; }
.btn-primary:hover { background: #000; color: #fff; }
.btn-secondary { background: var(--surface); color: var(--ink-900); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--ink-700); }
.btn-ghost:hover { background: var(--surface-3); color: var(--ink-900); }
.btn-danger { background: var(--surface); color: var(--warning); border-color: var(--line-strong); }
.btn-danger:hover { background: var(--warning-soft); border-color: var(--warning); }
.btn-sm { padding: 6px 12px; font-size: var(--fs-sm); }
.btn-sm .icon { width: 16px; height: 16px; }
.btn-icon { padding: 7px; }
.btn-icon.btn-sm { padding: 5px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Estado ocupado: HTMX marca el elemento disparador con .htmx-request cuando
   lleva hx-disabled-elt="this"; los submits de página completa usan
   [aria-busy] vía setupSubmitOnce. Un solo estilo para ambos. */
.btn[aria-busy="true"], .btn.htmx-request {
  opacity: .7; cursor: progress; pointer-events: none;
}
.btn[aria-busy="true"]::after, .btn.htmx-request::after {
  content: ""; width: 1em; height: 1em; margin-left: var(--s-2);
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; display: inline-block; vertical-align: -2px;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   FORMS
   ============================================================ */
.form-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-8); }
.field { display: flex; flex-direction: column; gap: var(--s-2); margin-bottom: var(--s-5); }
.field:last-child { margin-bottom: 0; }
.label, label { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--ink-700); }
.input, .select, .textarea,
input[type=text], input[type=email], input[type=password], input[type=url],
input[type=number], input[type=date], input[type=datetime-local], input[type=search],
select, textarea {
  font-family: inherit; font-size: var(--fs-body); color: var(--ink-900);
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-md); padding: 9px 12px; width: 100%;
  transition: var(--transition);
}
input::placeholder, textarea::placeholder { color: var(--ink-400); }
input:focus, select:focus, textarea:focus,
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--ink-900);
  box-shadow: 0 0 0 3px rgba(10,132,255,.12);
}
textarea { min-height: 96px; resize: vertical; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238E8E93' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 34px; }
.help, .helptext { font-size: var(--fs-sm); color: var(--ink-500); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--ink-900); }
/* Rojo y no naranja desde E4 (D14): el error de un formulario es un error, no
   un aviso. Hasta que existieron los tokens `--danger` (E3) el repo usaba
   `--warning` para las dos cosas, así que un campo mal llenado y un «pendiente»
   se veían igual. Es un cambio global y a propósito: dejar naranja el error del
   formulario junto al rojo de «falta responder» sería peor que cualquiera de
   los dos colores solo. */
.errorlist { list-style: none; margin: 0; padding: 0; color: var(--danger); font-size: var(--fs-sm); }
.field-error input, .field-error select, .field-error textarea { border-color: var(--danger); }
.form-actions { display: flex; align-items: center; gap: var(--s-3); margin-top: var(--s-6); }
.form-actions--end { justify-content: flex-end; }

/* Django form.as_p compatibility (transición; preferir .field) */
.form-django p { display: flex; flex-direction: column; gap: var(--s-2); margin: 0 0 var(--s-5); }
.form-django label { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--ink-700); }
.form-django .helptext { display: block; }

/* ============================================================
   CARDS
   ============================================================ */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-6); }
.card-hover { transition: var(--transition); }
.card-hover:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card-pad-sm { padding: var(--s-5); }

.grid { display: grid; gap: var(--s-4); }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-metrics { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

/* Course card */
.course-card { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; transition: var(--transition); color: inherit; }
.course-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.course-card .thumb { aspect-ratio: 16 / 9; background: linear-gradient(135deg, #F4F4F2, #E6E6E2); display: flex; align-items: center; justify-content: center; color: var(--ink-300); }
.course-card .thumb .icon { width: 40px; height: 40px; }
.course-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.course-card .body { padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-2); }
.course-card .eyebrow { font-size: var(--fs-xs); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: .05em; color: var(--ink-400); }
.course-card h3 { font-size: var(--fs-h3); font-weight: var(--fw-semibold); letter-spacing: -.01em; margin: 0; }
.course-card .sub { font-size: var(--fs-sm); color: var(--ink-500); }
.course-card--locked { opacity: .72; }

/* Detail hero (cabecera de curso/cohorte) */
.detail-hero { display: flex; gap: var(--s-6); align-items: flex-start; }
.detail-hero .hero-thumb { width: 200px; aspect-ratio: 16 / 9; border-radius: var(--r-md); background: linear-gradient(135deg, #F4F4F2, #E6E6E2); display: flex; align-items: center; justify-content: center; color: var(--ink-300); flex: none; overflow: hidden; }
.detail-hero .hero-thumb img { width: 100%; height: 100%; object-fit: cover; }
.detail-hero .hero-thumb .icon { width: 44px; height: 44px; }
@media (max-width: 640px) { .detail-hero { flex-direction: column; } .detail-hero .hero-thumb { width: 100%; } }
.section-title { font-size: var(--fs-h2); line-height: var(--lh-h2); font-weight: var(--fw-semibold); letter-spacing: -.01em; margin: 0; }

/* ============================================================
   METRIC CARDS
   ============================================================ */
.metric { border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-5); background: var(--surface); }
.metric .metric-top { display: flex; align-items: center; justify-content: space-between; color: var(--ink-300); margin-bottom: var(--s-3); }
.metric .metric-n { font-size: var(--fs-display); line-height: 1; font-weight: var(--fw-semibold); letter-spacing: -.03em; color: var(--ink-900); }
.metric .metric-l { color: var(--ink-500); font-size: var(--fs-sm); margin-top: var(--s-2); }

/* Resalte verde cuando una métrica sube (panel en vivo). Reusa tokens --success. */
@keyframes metric-up {
  0%   { color: var(--success); transform: translateY(8px); background: var(--success-soft); }
  70%  { background: var(--success-soft); }
  100% { color: var(--ink-900); transform: translateY(0); background: transparent; }
}
.metric .metric-n.is-up { animation: metric-up 600ms ease-out; border-radius: var(--r-sm); }

/* Panel: métricas secundarias ocultas hasta pulsar "Mostrar todo" (js/dashboard.js). */
.metrics-min .metric-extra { display: none; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap { border: 1px solid var(--line); border-radius: var(--r-lg); overflow-x: auto; background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-body); }
.table th { text-align: left; font-size: var(--fs-xs); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: .05em; color: var(--ink-400); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.table td { padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); color: var(--ink-700); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--surface-2); }
.table .cell-strong { color: var(--ink-900); font-weight: var(--fw-medium); }
.table .cell-actions { text-align: right; white-space: nowrap; }
.table-actions { display: inline-flex; gap: var(--s-1); justify-content: flex-end; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table th.num { text-align: right; }

/* Densidad tipo planilla: filas bajas, fuente compacta */
.table--dense th { padding: var(--s-2) var(--s-3); }
.table--dense td { padding: 7px var(--s-3); font-size: var(--fs-sm); line-height: 1.35; }
.table--dense .cell-strong { font-size: var(--fs-sm); }
.table--dense .badge { padding: 2px 8px; }
.table--dense .btn-sm { padding: 3px 6px; }
.table--dense .avatar { width: 24px; height: 24px; font-size: var(--fs-xs); }

/* Columna de selección (checkbox) */
.table .col-check { width: 36px; text-align: center; padding-left: var(--s-3); padding-right: 0; }
.table .col-check input { cursor: pointer; }

/* Barra de acciones masivas (Excel-like) */
.bulk-bar {
  position: sticky; bottom: var(--s-4); z-index: 30;
  display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap;
  margin-top: var(--s-4);
  background: var(--ink-900); color: #fff;
  border-radius: var(--r-md); padding: var(--s-3) var(--s-4);
  box-shadow: var(--shadow-lg);
}
.bulk-bar.is-hidden { display: none; }

/* Selector de destinatarios con buscador (modal de correo a cohorte).
   El buscador UBICA: "Todos"/"Ninguno" operan sobre la cohorte entera aunque
   haya un filtro escrito, y por eso el contador informa el total real. */
.picker-toolbar { display: flex; gap: var(--s-2); align-items: center; margin-bottom: var(--s-2); }
.picker-toolbar .search-box { flex: 1; }
.picker-count { margin: 0 0 var(--s-2) 0; }
.picker-list {
  max-height: 220px; overflow: auto;
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: var(--s-3);
}
.picker-option { display: flex; gap: var(--s-2); align-items: center; padding: var(--s-1) 0; cursor: pointer; }
.picker-option.is-hidden, .picker-empty.is-hidden { display: none; }

.bulk-bar .bulk-count { font-weight: var(--fw-semibold); }
.bulk-bar .bulk-label { color: rgba(255,255,255,.7); font-size: var(--fs-sm); }
.bulk-bar select {
  width: auto; min-width: 200px;
  background-color: #2A2A2C; color: #fff; border-color: #3A3A3C;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23AEAEB2' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
.bulk-bar .btn-ghost { color: rgba(255,255,255,.85); }
.bulk-bar .btn-ghost:hover { background: rgba(255,255,255,.12); color: #fff; }
.bulk-bar .spacer { margin-left: auto; }

/* Filtros sobre tabla */
.toolbar { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; margin-bottom: var(--s-5); }
.toolbar form { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.toolbar .input, .toolbar select { width: auto; min-width: 180px; }
.date-filter { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--ink-500); white-space: nowrap; }
.date-filter input { width: auto; min-width: 0; }
.search-box { position: relative; }
.search-box .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-400); width: 18px; height: 18px; }
.search-box input { padding-left: 36px; }

/* ============================================================
   BADGES
   ============================================================ */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-xs); font-weight: var(--fw-medium); padding: 4px 10px; border-radius: var(--r-full); white-space: nowrap; }
.badge .icon { width: 13px; height: 13px; }
.badge-neutral { background: var(--surface-3); color: var(--ink-700); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
/* Rojo = error o prueba reprobada (D14). Amarillo sigue siendo «aviso». */
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: var(--r-full); background: currentColor; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty { text-align: center; padding: var(--s-16) var(--s-8); color: var(--ink-500); border: 1px dashed var(--line-strong); border-radius: var(--r-lg); background: var(--surface-2); }
.empty .icon { width: 40px; height: 40px; color: var(--ink-300); margin: 0 auto var(--s-4); }
.empty h3 { font-size: var(--fs-h3); font-weight: var(--fw-semibold); color: var(--ink-900); margin: 0 0 var(--s-2); }
.empty p { margin: 0 auto var(--s-5); max-width: 42ch; }

/* ============================================================
   TOASTS (mensajes Django)
   ============================================================ */
.toasts { position: fixed; top: var(--s-5); right: var(--s-5); z-index: 60; display: flex; flex-direction: column; gap: var(--s-2); max-width: 360px; }
.toast { display: flex; align-items: flex-start; gap: var(--s-3); background: var(--surface); border: 1px solid var(--line); border-left-width: 3px; border-radius: var(--r-md); box-shadow: var(--shadow-md); padding: var(--s-3) var(--s-4); font-size: var(--fs-sm); color: var(--ink-700); animation: pop var(--transition); }
.toast .icon { width: 18px; height: 18px; margin-top: 1px; }
.toast--success { border-left-color: var(--success); }
.toast--success .icon { color: var(--success); }
.toast--error { border-left-color: var(--warning); }
.toast--error .icon { color: var(--warning); }
.toast--info { border-left-color: var(--ink-400); }
.toast--info .icon { color: var(--ink-400); }

/* ============================================================
   MODAL / POPOVER
   ============================================================ */
.popover-form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-md); padding: var(--s-4); margin: var(--s-2) 0; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(17,17,17,.42);
  backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: var(--s-16) var(--s-4) var(--s-8);
  overflow-y: auto;
  animation: fade var(--transition);
}
.modal {
  width: 100%; max-width: 480px;
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  animation: pop var(--transition);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-5) var(--s-6); border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: var(--fs-h3); font-weight: var(--fw-semibold); }
.modal-body { padding: var(--s-6); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* Fila de cohorte del detalle del curso: con el botón «Ruta» (PR E2, 2026-09-04)
   las acciones ya no caben junto a los datos en un panel de ~960px, y el flex
   aplastaba la fecha hasta partirla en tres líneas. El umbral es de VENTANA
   (1440px), no del panel: con el sidebar de 260px y los márgenes, un notebook
   de 1440 deja ~1090px de contenido, que ya no alcanza para las dos zonas. */
@media (max-width: 1440px) {
  .cohorte-fila { flex-direction: column; align-items: stretch; }
  .cohorte-fila .table-actions { justify-content: flex-start; flex-wrap: wrap; }
}

/* Celda clickable (abre modal) sin estilo de botón */
.cell-btn { background: none; border: 0; padding: 0; margin: 0; font: inherit; color: inherit; cursor: pointer; }
.cell-btn:hover { filter: brightness(.96); }

/* ============================================================
   DRAWER TOGGLE (oculto en desktop)
   ============================================================ */
.drawer-toggle { display: none; }
.drawer-backdrop { display: none; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .app-content { padding: var(--s-8) var(--s-6) var(--s-12); }
  .app-topbar { padding: 0 var(--s-6); }
}

@media (max-width: 767px) {
  .app { grid-template-columns: 1fr; }
  .app-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 280px; z-index: 50;
    transform: translateX(-100%); transition: transform var(--transition);
    box-shadow: var(--shadow-lg);
  }
  .app-sidebar.is-open { transform: none; }
  .drawer-backdrop.is-open { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.28); z-index: 45; }
  .drawer-toggle { display: inline-flex; }
  .app-content { padding: var(--s-6) var(--s-4) var(--s-10); }
  .app-topbar { padding: 0 var(--s-4); }
  .page-head--row { flex-direction: column; align-items: stretch; }
  .toolbar .input, .toolbar select { width: 100%; min-width: 0; }
}

/* ============================================================
   MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .card-hover:hover, .course-card:hover { transform: none; }
}

/* ===== Checkout (/inscribir) — una columna estilo Hotmart ===== */
.checkout { min-height: 100dvh; background: var(--surface-2); padding-bottom: 96px; }
.checkout-topbar { display:flex; align-items:center; padding: var(--s-2) var(--s-4); background: var(--surface); border-bottom: 1px solid var(--line); }
.checkout-topbar .brand { display:flex; align-items:center; gap: var(--s-2); font-weight: var(--fw-semibold); font-size: var(--fs-body); color: var(--ink-700); }
.checkout-topbar .brand img { height: 20px; display:block; }
.checkout-main { max-width: 560px; margin: 0 auto; padding: var(--s-5); }
.co-course { display:flex; gap: var(--s-4); align-items:flex-start; padding-bottom: var(--s-5); border-bottom: 1px solid var(--line); }
.co-thumb { flex: 0 0 84px; width: 84px; height: 84px; border-radius: var(--r-md); background: var(--surface-3); display:flex; align-items:center; justify-content:center; overflow:hidden; }
.co-thumb img { width:100%; height:100%; object-fit: cover; }
.co-thumb svg { width: 28px; height: 28px; color: var(--ink-400); }
.co-course-info h1 { font-size: var(--fs-h2); line-height: var(--lh-h2); margin: 0; }
.co-cohorte { color: var(--ink-500); margin: 2px 0 var(--s-3); }
.co-price-amount { font-size: var(--fs-h1); line-height: var(--lh-h1); font-weight: var(--fw-semibold); }
.co-price-cuotas { color: var(--ink-500); font-size: var(--fs-sm); margin-top: 2px; }
.co-price-desc { color: var(--success); font-size: var(--fs-sm); margin-top: 2px; }
.checkout-form { margin-top: var(--s-5); }
.co-section { font-size: var(--fs-h3); margin: var(--s-5) 0 var(--s-3); }
.tel-row { display:flex; gap: var(--s-2); align-items:center; }
.tel-row .select-codigo { flex: 0 0 auto; width: auto; min-width: 130px; }
.tel-row input[name$="telefono_numero"] { flex: 1 1 auto; }
.field-check { margin: var(--s-3) 0; }
.co-cupon { display:flex; gap: var(--s-2); }
.co-secure { display:flex; align-items:center; gap: var(--s-2); color: var(--ink-500); font-size: var(--fs-sm); margin-top: var(--s-4); }
.co-secure svg { width:16px; height:16px; }
.co-secure a { color: var(--ink-700); text-decoration: underline; text-underline-offset: 2px; }
.co-secure a:hover { color: var(--ink-900); }
.co-terminos { color: var(--ink-500); font-size: var(--fs-sm); margin-top: var(--s-2); }
.co-terminos a { color: var(--ink-700); text-decoration: underline; text-underline-offset: 2px; }
.co-terminos a:hover { color: var(--ink-900); }
.co-doc-aviso { color: var(--ink-500); font-size: var(--fs-sm); margin: 4px 0 0; }
.checkout-bar { position: fixed; left:0; right:0; bottom:0; z-index: 40; padding: var(--s-3) var(--s-5); background: var(--surface); border-top: 1px solid var(--line-strong); box-shadow: 0 -4px 16px rgba(17,17,17,.06); }
.checkout-bar-inner { max-width: 560px; margin: 0 auto; display:flex; align-items:center; justify-content: space-between; gap: var(--s-4); }
.checkout-bar-total strong { font-size: var(--fs-h3); }
.btn-pay { background: var(--pay); color: #fff; border: none; font-weight: var(--fw-semibold); min-height: 48px; padding: 0 var(--s-6); }
.btn-pay:hover { background: var(--pay-hover); }
.btn-pay[aria-busy="true"] { opacity: .8; cursor: progress; }

@media (max-width: 640px) {
  .checkout-main { padding: var(--s-4) var(--s-3); max-width: none; }
  .co-thumb { flex-basis: 64px; width: 64px; height: 64px; }
  .checkout-bar { padding: var(--s-3); }
  .checkout-bar .btn-pay { flex: 1 1 auto; }
}

/* ===== Zona de acciones del modal de usuario ===== */
.modal-actions-zone { border-top: 1px solid var(--line); margin-top: var(--s-4); padding: var(--s-4); }
.modal-actions-zone h4 { margin: 0 0 var(--s-3); font-size: var(--fs-sm); color: var(--ink-500); text-transform: uppercase; letter-spacing: .04em; }
.modal-actions-zone .table-actions { flex-wrap: wrap; gap: var(--s-2); }

/* ===== QR de "Compartir inscripción" ===== */
.qr-box { display:flex; justify-content:center; padding: var(--s-4); background: var(--surface-2); border-radius: var(--r-md); margin-bottom: var(--s-4); }
.qr-box .qr-svg { width: 200px; height: 200px; }
/* Compartir inscripción: un canal (Chile) o dos lado a lado (Chile + LATAM). */
.modal-wide { max-width: 760px; }
.compartir-canales { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--s-6); }
.compartir-canal h4 { margin: 0 0 var(--s-1); font-size: var(--fs-h3); font-weight: var(--fw-semibold); }
.compartir-canal > .help { margin: 0 0 var(--s-3); }
.compartir-canal .form-actions { margin-top: var(--s-4); flex-wrap: wrap; }

/* ===== Botón con apariencia de link (acciones htmx dentro de un párrafo) =====
   Un <a href> real dejaría entrar el fragmento pelado por clic central/pestaña
   nueva: esto es una acción, no una navegación. */
.btn-link {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  text-decoration: underline;
  cursor: pointer;
}
.btn-link:hover { color: var(--ink-900); }

/* ===== Progreso de envío masivo (Task 6) ===== */
.envio-progreso-barra {
  display: block;
  width: 100%;
  height: 8px;
  margin: var(--s-3) 0 var(--s-2);
  border: none;
  border-radius: var(--r-full);
  accent-color: var(--accent);
}
.envio-progreso-barra::-webkit-progress-bar { background: var(--surface-3); border-radius: var(--r-full); }
.envio-progreso-barra::-webkit-progress-value { background: var(--accent); border-radius: var(--r-full); }
.envio-progreso-barra::-moz-progress-bar { background: var(--accent); border-radius: var(--r-full); }
.envio-progreso-resumen { color: var(--ink-500); font-size: var(--fs-sm); margin: 0 0 var(--s-3); }

/* ===== Horario de clases en vivo (detalle de cohorte) ===== */
.schedule-list { list-style: none; margin: var(--s-3) 0 var(--s-6); padding: 0; display: grid; gap: var(--s-2); }
.schedule-item { display: flex; justify-content: space-between; gap: var(--s-4); padding: var(--s-3) var(--s-4); border: 1px solid var(--line); border-radius: var(--r-md); }
.schedule-item--past { opacity: .55; }
.schedule-num { font-weight: var(--fw-semibold); }
.schedule-date { color: var(--ink-500); text-transform: capitalize; }

/* Horario en la zona del alumno: la referencia a Chile va discreta y sin capitalizar */
.schedule-chile { text-transform: none; color: var(--ink-500); font-size: var(--fs-sm); margin-left: var(--s-2); white-space: nowrap; }
.schedule-note { margin: calc(-1 * var(--s-4)) 0 var(--s-6); }

/* ===== Markdown de una cápsula: lector, código y callouts (PR E4) =====
   Vive en app.css y no en portal.css porque lo comparten DOS superficies: la
   cápsula que lee el alumno y la vista previa del editor del equipo. Cuando
   estaban duplicadas, el mismo `> [!TIP]` salía azul en el portal y verde en
   el editor, y quien escribía el material no veía lo que iba a publicar. */
.reader-md { max-width: 720px; font-size: 17px; line-height: 28px; color: var(--ink-700); }
.reader-md > :first-child { margin-top: 0; }
.reader-md h2 { font-size: var(--fs-h2); line-height: var(--lh-h2); font-weight: var(--fw-semibold); letter-spacing: -.01em; color: var(--ink-900); margin: var(--s-10) 0 var(--s-4); }
.reader-md h3 { font-size: var(--fs-h3); line-height: var(--lh-h3); font-weight: var(--fw-semibold); color: var(--ink-900); margin: var(--s-8) 0 var(--s-3); }
.reader-md h4 { font-size: var(--fs-body-l); line-height: var(--lh-body-l); font-weight: var(--fw-semibold); color: var(--ink-900); margin: var(--s-6) 0 var(--s-2); }
.reader-md p { margin: 0 0 var(--s-5); }
.reader-md ul, .reader-md ol { margin: 0 0 var(--s-5); padding-left: var(--s-6); }
.reader-md li { margin-bottom: var(--s-2); }
.reader-md a { color: var(--info); text-decoration: underline; text-underline-offset: 2px; }
.reader-md strong { color: var(--ink-900); font-weight: var(--fw-semibold); }
.reader-md img { display: block; max-width: 100%; height: auto; border-radius: var(--r-md); border: 1px solid var(--line); margin: var(--s-6) 0; }
.reader-md hr { border: 0; border-top: 1px solid var(--line); margin: var(--s-10) 0; }
.reader-md blockquote { margin: 0 0 var(--s-5); padding: var(--s-2) 0 var(--s-2) var(--s-5); border-left: 2px solid var(--line-strong); color: var(--ink-500); }
.reader-md blockquote p:last-child { margin-bottom: 0; }
.reader-md code { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; font-size: 14px; background: var(--surface-3); border-radius: var(--r-sm); padding: 2px 5px; }
/* El padding de arriba reserva el sitio del botón «Copiar»: si el botón se
   superpusiera al código, en un teléfono (donde está siempre visible) taparía
   justo el final de la línea que el alumno quiere copiar. */
.reader-md pre { position: relative; margin: 0 0 var(--s-6); padding: var(--s-10) var(--s-5) var(--s-5); background: var(--surface-3); border: 1px solid var(--line); border-radius: var(--r-md); overflow-x: auto; }
.reader-md pre code { display: block; background: none; padding: 0; font-size: 13.5px; line-height: 22px; color: var(--ink-900); white-space: pre; }
.reader-md table { width: 100%; border-collapse: collapse; margin: 0 0 var(--s-6); font-size: var(--fs-body); display: block; overflow-x: auto; }
.reader-md th, .reader-md td { border-bottom: 1px solid var(--line); padding: var(--s-2) var(--s-3); text-align: left; }
.reader-md th { color: var(--ink-900); font-weight: var(--fw-semibold); background: var(--surface-2); }

/* Botón «Copiar» de los bloques de código (lo inyecta static/js/ruta.js). */
.codigo-copiar { position: absolute; top: var(--s-2); right: var(--s-2); padding: 3px 10px; font-family: var(--font-sans); font-size: var(--fs-xs); font-weight: var(--fw-medium); color: var(--ink-500); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-sm); cursor: pointer; opacity: 0; transition: var(--transition); }
.reader-md pre:hover .codigo-copiar, .codigo-copiar:focus-visible { opacity: 1; }
.codigo-copiar:hover { color: var(--ink-900); }
.codigo-copiar.is-copiado { opacity: 1; color: var(--success); border-color: var(--success); }
.copiador-oculto { position: fixed; top: -1000px; opacity: 0; }

/* ---- Callouts del Markdown (D14: azul tip, amarillo aviso, gris nota) ---- */
.callout { display: flex; flex-direction: column; gap: var(--s-1); position: relative; margin: 0 0 var(--s-6); padding: var(--s-4) var(--s-5) var(--s-4) var(--s-10); border-radius: var(--r-md); border-left: 3px solid var(--ink-300); background: var(--surface-2); color: var(--ink-700); }
.callout p { margin: 0 0 var(--s-2); }
.callout > :last-child { margin-bottom: 0; }
.callout-titulo { font-weight: var(--fw-semibold); color: var(--ink-900); }
/* El icono va como máscara pintada con currentColor: hereda el color del
   callout sin duplicar un SVG por variante ni abrir img-src a nada nuevo. */
.callout::before { content: ""; position: absolute; left: var(--s-4); top: var(--s-4); width: 18px; height: 18px; background-color: currentColor; -webkit-mask: var(--callout-ico) center / contain no-repeat; mask: var(--callout-ico) center / contain no-repeat; }
.callout--tip { border-left-color: var(--info); background: var(--info-soft); color: var(--info); --callout-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.5' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 16v-5'/%3E%3Cpath d='M12 8h.01'/%3E%3C/svg%3E"); }
.callout--warning { border-left-color: var(--warning); background: var(--warning-soft); color: var(--warning); --callout-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.5' stroke-linecap='round'%3E%3Cpath d='M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z'/%3E%3Cpath d='M12 9v4'/%3E%3Cpath d='M12 17h.01'/%3E%3C/svg%3E"); }
.callout--note { border-left-color: var(--ink-300); background: var(--surface-2); color: var(--ink-500); --callout-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.5' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 16v-5'/%3E%3Cpath d='M12 8h.01'/%3E%3C/svg%3E"); }
.callout--tip .callout-titulo { color: var(--info); }
.callout--warning .callout-titulo { color: var(--warning); }
.callout--note .callout-titulo { color: var(--ink-700); }
.callout p:not(.callout-titulo), .callout li { color: var(--ink-700); }


@media (max-width: 640px) {
  .reader-md { font-size: 16px; line-height: 26px; }
  /* En un teléfono no hay hover: el botón «Copiar» se queda visible. */
  .codigo-copiar { opacity: 1; }
}
