/* ==========================================================================
   SGEA-CFU (sistema visual compartido con el CRM de Rematrícula) — Componentes compartidos por todas las pantallas
   Se carga DESPUÉS de dashboard.css (usa sus variables).
   ========================================================================== */

/* ---------- Utilidades ---------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.muted { color: var(--text-muted); font-size: 12px; }

/* ---------- Encabezado de página ---------- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.breadcrumb a:hover { color: var(--purple-600); }

.page-head__subtitle { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
}
.btn .icon { width: 18px; height: 18px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn--primary { color: #fff; background: var(--purple-600); box-shadow: 0 6px 16px rgba(124, 58, 237, .28); }
.btn--primary:hover:not(:disabled) { background: var(--purple-700); }

.btn--ghost { color: var(--gray-700); background: #fff; border-color: var(--border); }
.btn--ghost:hover:not(:disabled) { background: var(--gray-50); border-color: var(--gray-300); }
.btn--ghost[aria-expanded="true"] { color: var(--purple-700); background: var(--purple-50); border-color: var(--purple-200); }

.btn--text { height: 36px; padding: 0 10px; color: var(--gray-600); background: transparent; }
.btn--text:hover:not(:disabled) { color: var(--purple-700); background: var(--purple-50); }

.btn--danger { background: var(--rose-600); box-shadow: 0 6px 16px rgba(225, 29, 72, .25); }
.btn--danger:hover:not(:disabled) { background: #be123c; }

.btn--sm { height: 32px; padding: 0 12px; font-size: 12px; border-radius: 8px; }

.btn__count {
  display: grid; place-items: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; font-size: 11px; color: #fff; background: var(--purple-600);
}

/* Botón de ícono pequeño (acciones de fila) */
.mini-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--gray-600);
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.mini-btn .icon { width: 16px; height: 16px; }
.mini-btn:hover { color: var(--purple-700); background: var(--purple-50); border-color: var(--purple-200); }
.mini-btn[aria-expanded="true"] { color: var(--purple-700); background: var(--purple-50); border-color: var(--purple-200); }
.mini-btn[aria-expanded="true"] .icon { transform: rotate(180deg); }

/* ---------- Campos de formulario ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.field__label { font-size: 12px; font-weight: 600; color: var(--gray-600); padding: 0; }
.field__input,
.field select {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  font-size: 13px;
  color: var(--gray-900);
}
.field__textarea { height: auto; padding: 8px 10px; resize: vertical; }
.field__input:focus,
.field select:focus {
  outline: none;
  border-color: var(--purple-400);
  box-shadow: 0 0 0 3px var(--purple-100);
}
.field select:disabled { background: var(--gray-50); color: var(--gray-400); }
.field__help { font-size: 12px; color: var(--text-muted); }
.field__error { font-size: 12px; color: var(--rose-600); }
.field.has-error .field__input,
.field.has-error select { border-color: var(--rose-500); }

.form-error {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--rose-600);
  background: var(--rose-50);
}

.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--gray-700); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--purple-600); flex-shrink: 0; }

.select-field {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--gray-500);
}
.select-field .icon { width: 16px; height: 16px; }
.select-field select {
  max-width: 240px;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  cursor: pointer;
}
.select-field select:focus { outline: none; }
.select-field:focus-within { border-color: var(--purple-400); box-shadow: 0 0 0 4px var(--purple-100); }
.select-field--compact { height: 34px; }

/* Opciones tipo píldora (radio) */
.segmented-options { display: flex; flex-wrap: wrap; gap: 8px; }
.option-pill { position: relative; }
.option-pill input { position: absolute; opacity: 0; pointer-events: none; }
.option-pill span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  cursor: pointer;
  transition: all var(--transition);
}
.option-pill .icon { width: 16px; height: 16px; }
.option-pill input:focus-visible + span { outline: 2px solid var(--purple-500); outline-offset: 2px; }
.option-pill input:checked + span { color: var(--purple-700); background: var(--purple-50); border-color: var(--purple-400); }
.option-pill--ok input:checked + span { color: var(--green-600); background: var(--green-50); border-color: var(--green-600); }
.option-pill--fail input:checked + span { color: var(--rose-600); background: var(--rose-50); border-color: var(--rose-500); }

.contact-hint {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  color: var(--gray-700);
  background: var(--gray-50);
}
.contact-hint:empty { display: none; }
.contact-hint > .icon { width: 18px; height: 18px; color: var(--purple-600); margin-top: 1px; }
.contact-hint > div { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }

/* ---------- Etiquetas ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 6px 0 10px;
  border: 1px solid var(--purple-200);
  border-radius: 999px;
  background: #fff;
  font-size: 12px;
  color: var(--gray-700);
}
.chip strong { color: var(--purple-700); font-weight: 600; }
.chip button {
  display: grid; place-items: center;
  width: 18px; height: 18px;
  border: 0; border-radius: 50%;
  background: var(--purple-100); color: var(--purple-700);
}
.chip button .icon { width: 12px; height: 12px; stroke-width: 2.4; }
.chip button:hover { background: var(--purple-200); }

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-600);
  background: var(--gray-100);
  white-space: nowrap;
}

/* Promesa de pago */
.promise {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--gray-600);
  background: var(--gray-100);
}
.promise .icon { width: 12px; height: 12px; }
.promise--proxima { color: var(--amber-600); background: var(--amber-50); }
.promise--vencida { color: var(--rose-600); background: var(--rose-50); }

/* Prioridad */
.priority { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.priority::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: currentColor; }
.priority--ALTA { color: var(--rose-600); }
.priority--MEDIA { color: var(--amber-600); }
.priority--BAJA { color: var(--gray-500); }

/* ---------- Estado vacío ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 48px 22px;
  text-align: center;
}
.empty-state__icon {
  display: grid; place-items: center;
  width: 52px; height: 52px; margin-bottom: 6px;
  border-radius: 14px; color: var(--purple-600); background: var(--purple-50);
}
.empty-state__title { font-weight: 650; font-size: 15px; }
.empty-state__text { color: var(--text-muted); margin-bottom: 10px; max-width: 420px; }

/* ---------- Ventanas (modal) ---------- */
.modal {
  width: min(440px, calc(100% - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  color: var(--text);
}
.modal--wide { width: min(560px, calc(100% - 32px)); }
.modal::backdrop { background: rgba(21, 24, 33, .45); }
.modal__body { display: flex; flex-direction: column; gap: 14px; padding: 24px; }
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: -6px -6px 0 0; }
.modal__title { font-size: 18px; font-weight: 700; }
.modal__text { color: var(--text-muted); font-size: 13px; }
.modal__text strong { color: var(--gray-900); }
.modal__text ul { margin: 8px 0 0; padding-left: 18px; }
.modal__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; flex-wrap: wrap; }

/* ---------- Aviso breve ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  max-width: min(520px, calc(100% - 32px));
  padding: 12px 18px;
  border-radius: 10px;
  background: var(--gray-900);
  color: #fff;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  transform: translateX(-50%);
}
.toast[data-type="success"] { background: #065f46; }
.toast[data-type="warn"] { background: #92400e; }

/* ---------- Menú de perfil: rol de demostración ---------- */
.profile__section {
  padding: 6px 10px 2px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--gray-400);
}
.profile__role-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  color: var(--gray-700);
}
.profile__role-opt:hover { background: var(--gray-50); }
.profile__role-opt .icon { width: 16px; height: 16px; color: var(--purple-600); visibility: hidden; }
.profile__role-opt[aria-checked="true"] { font-weight: 600; color: var(--purple-700); }
.profile__role-opt[aria-checked="true"] .icon { visibility: visible; }

/* ---------- Pestañas ---------- */
.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border: 0;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-500);
  white-space: nowrap;
}
.tab:hover { color: var(--gray-900); }
.tab::after {
  content: "";
  position: absolute; left: 10px; right: 10px; bottom: -1px; height: 3px;
  border-radius: 3px 3px 0 0; background: transparent;
}
.tab[aria-selected="true"] { color: var(--purple-700); }
.tab[aria-selected="true"]::after { background: var(--purple-600); }
.tab__count {
  min-width: 22px; padding: 1px 7px; border-radius: 999px;
  font-size: 11px; text-align: center; color: var(--gray-600); background: var(--gray-100);
}
.tab[aria-selected="true"] .tab__count { color: var(--purple-700); background: var(--purple-100); }

/* ---------- Lista de datos (etiqueta: valor) ---------- */
.data-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px 24px;
  margin: 0;
}
.data-list div { min-width: 0; }
.data-list dt { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.data-list dd { margin: 4px 0 0; font-size: 14px; color: var(--gray-900); overflow-wrap: anywhere; }

/* ---------- Línea de tiempo ---------- */
.timeline { margin: 0; padding: 0; list-style: none; }
.timeline__item {
  position: relative;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 12px;
  padding-bottom: 18px;
}
.timeline__item:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 17px;
  top: 38px;
  bottom: 2px;
  width: 2px;
  background: var(--gray-100);
}
.timeline__icon {
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 10px;
  color: var(--purple-600); background: var(--purple-50);
}
.timeline__icon .icon { width: 18px; height: 18px; }
.timeline__icon--ok { color: var(--green-600); background: var(--green-50); }
.timeline__icon--fail { color: var(--rose-600); background: var(--rose-50); }
.timeline__icon--warn { color: var(--amber-600); background: var(--amber-50); }
.timeline__icon--muted { color: var(--gray-600); background: var(--gray-100); }
.timeline__title { font-weight: 600; font-size: 13px; }
.timeline__text { margin-top: 2px; font-size: 13px; color: var(--gray-600); }
.timeline__meta { margin-top: 4px; font-size: 11px; color: var(--gray-400); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Aviso dentro de la página ---------- */
.notice {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--purple-100);
  border-radius: var(--radius);
  background: var(--purple-50);
  font-size: 13px;
  color: var(--gray-700);
}
.notice > .icon { width: 18px; height: 18px; color: var(--purple-600); margin-top: 1px; }
.notice--warn { border-color: #fde68a; background: var(--amber-50); }
.notice--warn > .icon { color: var(--amber-600); }
.notice--danger { border-color: #fecdd3; background: var(--rose-50); }
.notice--danger > .icon { color: var(--rose-600); }

/* ---------- Plantillas dentro de "Registrar interacción" ---------- */
.template-box { display: flex; flex-direction: column; gap: 10px; }
.template-preview {
  padding: 12px 14px;
  border: 1px dashed var(--purple-300);
  border-radius: 10px;
  background: #fff;
  font-size: 13px;
  color: var(--gray-700);
}
.template-preview__subject { margin-bottom: 6px; }
.template-preview__body { white-space: pre-wrap; }
.template-preview__actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 10px; }

/* ---------- Tareas ---------- */
.task-state {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap;
}
.task-state--PENDIENTE { color: var(--purple-700); background: var(--purple-100); }
.task-state--VENCIDA { color: var(--rose-600); background: var(--rose-50); }
.task-state--COMPLETADA { color: var(--green-600); background: var(--green-50); }
.task-state--CANCELADA { color: var(--gray-500); background: var(--gray-100); }
.task-origin { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--amber-600); font-weight: 600; }
.task-origin .icon { width: 12px; height: 12px; }
.task-summary { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: 10px; background: var(--gray-50); font-size: 13px; }
.task-summary__title { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.task-summary__title .icon { width: 16px; height: 16px; color: var(--purple-600); }

/* ---------- Responsive ---------- */
@media (max-width: 767px) {
  .page-head { align-items: stretch; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .modal__body { padding: 20px; }
  .data-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
}
@media (max-width: 420px) {
  .data-list { grid-template-columns: minmax(0, 1fr); }
}
