/* ==========================================================================
   CRM Rematrícula — Gestión de estudiantes (listado)
   Se carga después de dashboard.css y componentes.css.
   ========================================================================== */

.students-card { padding: 0; overflow: hidden; }

/* ---------- Pestañas por etapa de gestión (filtro por estado) ---------- */
.stage-tabs {
  display: flex;
  gap: 6px;
  padding: 14px 22px 0;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
}
.stage-tabs::-webkit-scrollbar { display: none; }
.stage-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 12px;
  border: 0;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-500);
  white-space: nowrap;
  transition: color var(--transition);
}
.stage-tab:hover { color: var(--gray-900); }
.stage-tab::after {
  content: "";
  position: absolute; left: 8px; right: 8px; bottom: -1px; height: 3px;
  border-radius: 3px 3px 0 0; background: transparent;
  transition: background var(--transition);
}
.stage-tab[aria-selected="true"] { color: var(--purple-700); }
.stage-tab[aria-selected="true"]::after { background: var(--purple-600); }
.stage-tab .icon { width: 14px; height: 14px; stroke-width: 2.4; color: var(--green-600); }
.stage-tab__dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.stage-tab__count {
  min-width: 24px; padding: 1px 7px; border-radius: 999px;
  font-size: 11px; text-align: center; color: var(--gray-600); background: var(--gray-100);
}
.stage-tab[aria-selected="true"] .stage-tab__count { color: var(--purple-700); background: var(--purple-100); }
.stage-tab--pendiente .stage-tab__dot { color: var(--gray-400); }
.stage-tab--validada  .stage-tab__dot { color: var(--purple-500); }
.stage-tab--observada .stage-tab__dot { color: var(--amber-600); }
.stage-tab--cambio    .stage-tab__dot { color: var(--blue-600); }
.stage-tab--confirma  .stage-tab__dot { color: var(--green-600); }
.stage-tab--conf-edit .stage-tab__dot { color: #0d9488; }
.stage-tab--no-remat  .stage-tab__dot { color: var(--rose-600); }
.stage-tab--egresado  .stage-tab__dot { color: var(--gray-500); }
.stage-tab__sep { width: 1px; margin: 10px 4px 12px; background: var(--border); flex-shrink: 0; }

/* ---------- Barra de herramientas ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 22px;
}
.search--inline { max-width: 420px; }
.toolbar__right { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-wrap: wrap; }

/* Filtro de categoría de observación (solo con la pestaña PROY. OBSERVADA) */
.obs-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 22px 16px;
  padding: 10px 14px;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  background: var(--amber-50);
  font-size: 13px;
  color: var(--gray-700);
}
.obs-filter .icon { width: 18px; height: 18px; color: var(--amber-600); }
.obs-filter select {
  flex: 1;
  min-width: 220px;
  max-width: 420px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  background: #fff;
  font: inherit;
  font-size: 13px;
}

/* ---------- Filtros avanzados ---------- */
.filters {
  margin: 0 22px 16px;
  padding: 16px;
  border: 1px solid var(--purple-100);
  border-radius: var(--radius);
  background: var(--purple-50);
}
.filters__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.filters__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

.active-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 0 22px 14px; }

.results-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 22px 12px; }
.results-bar__text { font-size: 13px; color: var(--text-muted); }
.results-bar__text strong { color: var(--gray-900); }

/* ---------- Barra de asignación en bloque ---------- */
.bulk-bar {
  position: sticky;
  top: var(--topbar-h);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px 14px;
  flex-wrap: wrap;
  padding: 12px 22px;
  background: var(--purple-600);
  color: #fff;
}
.bulk-bar__count { font-weight: 700; font-size: 13px; }
.bulk-bar__all {
  padding: 0;
  border: 0;
  background: none;
  color: #fff;
  font-size: 12px;
  text-decoration: underline;
  opacity: .9;
}
.bulk-bar__controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.bulk-bar select,
.bulk-bar input {
  height: 34px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: #fff;
  font: inherit;
  font-size: 13px;
  color: var(--gray-900);
}
.bulk-bar input { width: 120px; }
.bulk-bar .btn--primary { background: #fff; color: var(--purple-700); box-shadow: none; }
.bulk-bar .btn--primary:hover:not(:disabled) { background: var(--purple-50); }
.bulk-bar .btn--text { color: #fff; }
.bulk-bar .btn--text:hover { background: rgba(255, 255, 255, .15); color: #fff; }

/* ---------- Tabla ---------- */
.students-card .table-wrap { margin: 0; }
.table--students th { padding: 10px 14px; }
.table--students td { padding: 12px 14px; vertical-align: middle; white-space: normal; }
.table--students th:first-child,
.table--students td:first-child { padding-left: 22px; }
.table--students th:last-child,
.table--students td:last-child { padding-right: 22px; }
.table--students td.num,
.table--students td.cell-stage,
.table--students .student__name,
.table--students .status-pill { white-space: nowrap; }
.table--students tbody tr.row-main { cursor: pointer; }
.table--students tbody tr.is-selected { background: var(--purple-50); }
.table--students .cell-check { width: 44px; padding-right: 0; }
.table--students input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--purple-600); cursor: pointer; }

.th-sort {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 0; border: 0; background: transparent; font: inherit; color: inherit;
}
.th-sort .icon { width: 14px; height: 14px; opacity: .35; }
.th-sort:hover { color: var(--gray-900); }
th[aria-sort="ascending"] .th-sort,
th[aria-sort="descending"] .th-sort { color: var(--purple-700); }
th[aria-sort="ascending"] .th-sort .icon,
th[aria-sort="descending"] .th-sort .icon { opacity: 1; }

.num { text-align: right; font-variant-numeric: tabular-nums; }
th.num .th-sort { flex-direction: row-reverse; }
.debt { font-weight: 600; color: var(--gray-900); font-variant-numeric: tabular-nums; }
.debt--zero { font-weight: 500; color: var(--gray-400); }

.cell-sub { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 4px; }
.obs-cat { font-size: 11px; color: var(--amber-600); max-width: 220px; white-space: normal; line-height: 1.3; }
.obs-cat--revisada { color: var(--purple-600); font-weight: 600; }   /* "OBSERVACIÓN REVISADA" (2026-10-08) */

/* Acciones rápidas de la fila */
.row-actions { display: inline-flex; gap: 4px; }
.row-actions .mini-btn { width: 30px; height: 30px; }
.table--students td.cell-actions { white-space: nowrap; }

/* Cursos proyectados desplegables */
.row-detail > td { padding: 0 22px 16px 22px !important; background: var(--gray-25); border-bottom: 1px solid var(--gray-100); }
.row-detail:hover { background: transparent !important; }
.courses {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}
.courses__title { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 12px; font-weight: 700; color: var(--gray-600); }
.courses__title .icon { width: 16px; height: 16px; color: var(--purple-600); }
.courses table { width: 100%; border-collapse: collapse; font-size: 13px; }
.courses th { padding: 6px 8px; text-align: left; font-size: 11px; font-weight: 600; color: var(--gray-500); border-bottom: 1px solid var(--border); }
.courses td { padding: 7px 8px; border-bottom: 1px solid var(--gray-100); color: var(--gray-700); }
.courses tr:last-child td { border-bottom: 0; }
.courses code { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--gray-900); }

/* ---------- Paginación ---------- */
.pagination {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px 22px; border-top: 1px solid var(--border);
}
.pagination__size { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.pagination__size select {
  height: 32px; padding: 0 6px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; font: inherit; color: var(--gray-900);
}
.pagination__pages { display: flex; align-items: center; gap: 4px; }
.page-btn {
  display: grid; place-items: center; min-width: 34px; height: 34px; padding: 0 8px;
  border: 1px solid transparent; border-radius: 8px; background: transparent;
  font-size: 13px; font-weight: 600; color: var(--gray-600);
}
.page-btn:hover:not(:disabled) { background: var(--gray-100); }
.page-btn[aria-current="page"] { color: #fff; background: var(--purple-600); }
.page-btn:disabled { opacity: .35; cursor: not-allowed; }
.page-btn .icon { width: 16px; height: 16px; }
.page-gap { padding: 0 4px; color: var(--gray-400); }

/* ---------- Responsive ---------- */

/* Menos de 1600 px: se oculta "Estado actual" (sigue visible en la Vista 360°) */
@media (max-width: 1599px) {
  .col-md-hide { display: none; }
}

/* Menos de 1280 px: cada fila se convierte en una tarjeta */
@media (max-width: 1279px) {
  .table--students thead { display: none; }
  .table--students,
  .table--students tbody { display: block; }
  .table--students tr.row-main {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px 12px;
    padding: 14px 16px;
    border-top: 1px solid var(--gray-100);
  }
  .table--students td,
  .table--students td:first-child,
  .table--students td:last-child { padding: 0; border: 0; white-space: normal; }
  .table--students td.col-card-hide { display: none; }
  .table--students td[data-label]::before { content: attr(data-label) ": "; font-size: 12px; color: var(--text-muted); }
  /* Orden de la tarjeta: casilla + estudiante · etapa · deuda · contactabilidad · acciones */
  .table--students td.cell-check { grid-column: 1; grid-row: 1; width: auto; padding-top: 8px; }
  .table--students td.cell-student { grid-column: 2 / -1; grid-row: 1; }
  .table--students td.cell-stage { grid-column: 2 / -1; order: 1; white-space: normal; }
  .table--students td.num { order: 2; text-align: left; }
  .table--students td.cell-wide:not(.num):not(.cell-actions) { order: 3; }
  .table--students td.cell-actions { order: 4; }
  .table--students td.cell-wide { grid-column: 2 / -1; }
  .table--students .student__name { white-space: normal; }

  /* Sin columna de selección (rol Asesor) */
  .table--students.no-select tr.row-main { grid-template-columns: minmax(0, 1fr); }
  .table--students.no-select td.cell-student,
  .table--students.no-select td.cell-stage,
  .table--students.no-select td.cell-wide { grid-column: 1 / -1; }

  .table--students tr.row-detail { display: block; }
  .table--students tr.row-detail[hidden] { display: none; }
  .table--students .row-detail > td { display: block; padding: 0 16px 14px !important; }
}

@media (max-width: 767px) {
  .page-actions .btn span { overflow: hidden; text-overflow: ellipsis; }
  .stage-tabs { padding: 10px 12px 0; }
  .toolbar { padding: 14px 16px; }
  .search--inline { max-width: none; flex-basis: 100%; }
  .toolbar__right { width: 100%; margin-left: 0; }
  .toolbar__right > * { flex: 1; }
  .select-field select { max-width: none; width: 100%; }
  .filters, .obs-filter { margin: 0 16px 14px; }
  .filters__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters__actions .btn { flex: 1; }
  .active-filters, .results-bar { padding-inline: 16px; }
  .bulk-bar { padding: 12px 16px; top: var(--topbar-h); }
  .bulk-bar__controls { margin-left: 0; width: 100%; }
  .bulk-bar__controls > * { flex: 1 1 140px; }
  .pagination { justify-content: center; padding: 14px 16px; }
  .pagination__size { display: none; }
  .courses { overflow-x: auto; }
}

@media (max-width: 420px) {
  .filters__grid { grid-template-columns: minmax(0, 1fr); }
  .page-actions .btn--ghost span { display: none; }
  .page-actions .btn--ghost { flex: 0 0 auto; }
}
