/* ============================================================
   TEMA — capa sobria del rediseño D-1
   ============================================================

   Se carga DESPUÉS de base, layout, components y animations, y por eso gana
   a igual especificidad. Hace tres cosas:

     1. Declara las fuentes, servidas desde assets/fonts/ (nada depende de
        Google Fonts: la aplicación pinta igual sin red).
     2. Aplana las piezas compartidas —botones, tarjetas, campos, insignias—
        para que toda pantalla herede el mismo tono sin tocar su maquetación.
     3. Viste el armazón: menú lateral, cabecera y tutor flotante.

   Los colores salen de tokens.css. Aquí no debería aparecer ningún valor
   hexadecimal salvo el blanco sobre fondos de marca.
   ============================================================ */

/* ---- FUENTES (subconjunto latino, SIL Open Font License) ---- */
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../../assets/fonts/ibm-plex-sans-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../../assets/fonts/ibm-plex-sans-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../../assets/fonts/ibm-plex-sans-latin-600-normal.woff2') format('woff2');
}
/* Poppins, la letra de la marca: solo títulos y cifras grandes. */
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../../assets/fonts/poppins-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../../assets/fonts/poppins-latin-700-normal.woff2') format('woff2');
}

/* ============================================================
   BASE
   ============================================================ */
h1, h2 {
  font-family: var(--font-titulo);
  font-weight: 600;
  color: var(--titulo);
  letter-spacing: -0.01em;
}
h1 { font-weight: 700; }

/* Logo: dos imágenes, una por fondo; los tokens deciden cuál se pinta. */
.logo-marca { display: inline-flex; align-items: center; line-height: 0; text-decoration: none; border-radius: var(--radius-sm); }
.logo-marca img { height: auto; max-width: 100%; }
.logo-marca .logo-sobre-claro { display: var(--logo-claro); }
.logo-marca .logo-sobre-oscuro { display: var(--logo-oscuro); }
h3, h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: 600;
}

::selection {
  background: var(--acento-suave);
  color: var(--text-primary);
}

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Enlace de texto: azul de marca, subrayado al pasar. Los enlaces con forma de
   botón o de fila de menú no lo usan. */
.enlace {
  color: var(--enlace);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  background: none;
  border: 0;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
}
.enlace:hover { color: var(--enlace-hover); text-decoration-color: currentColor; }

.cifra {
  font-family: var(--font-titulo);
  font-weight: 600;
  color: var(--titulo);
  font-variant-numeric: lining-nums;
}

/* ============================================================
   BOTONES
   ============================================================ */
.btn {
  border-radius: var(--radius-md);
  line-height: 1.25;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}
.btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--boton-fondo);
  color: var(--boton-texto);
  border: 1px solid var(--boton-fondo);
  box-shadow: none;
}
.btn-primary:hover {
  background: var(--boton-fondo-hover);
  border-color: var(--boton-fondo-hover);
  color: var(--boton-texto);
  transform: none;
  box-shadow: none;
}

/* Llamada destacada: relleno dorado con texto azul marino (nunca al revés). */
.btn-dorado {
  background: var(--marca-dorado);
  color: var(--marca-navy);
  border: 1px solid var(--marca-dorado);
  font-weight: 600;
}
.btn-dorado:hover {
  background: var(--marca-dorado-hover);
  border-color: var(--marca-dorado-hover);
  color: var(--marca-navy);
}

.btn-secondary,
.btn-outline {
  background: var(--bg-surface);
  color: var(--titulo);
  border: 1px solid var(--titulo);
}
.btn-secondary:hover,
.btn-outline:hover {
  background: var(--acento-suave);
  border-color: var(--titulo);
  color: var(--titulo);
}

.btn-ghost:hover { background: var(--bg-surface-2); }

.btn-success { background: var(--marca-verde); color: #FFFFFF; }
.btn-success:hover { background: var(--marca-verde-hover); transform: none; }
.btn-warning { background: #B45309; color: #FFFFFF; }
.btn-danger  { background: #B42318; color: #FFFFFF; }

.btn-lg {
  padding: 14px 26px;
  font-size: 1.0625rem;
  border-radius: var(--radius-md);
}

.btn-icon { border-color: var(--border-subtle); }

/* Nada se levanta ni proyecta sombra al pasar el cursor: el cambio de borde
   basta para decir «esto se puede pulsar». */
.hover-lift:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--border-strong) !important;
}

/* ============================================================
   TARJETAS, INSIGNIAS, BARRAS
   ============================================================ */
.card { border-radius: var(--radius-lg); }
.card:hover { box-shadow: none; }
.card-interactive:hover,
.role-card:hover,
.competence-card:hover {
  transform: none;
  box-shadow: none;
}
.card-glass {
  background: var(--bg-surface);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.progress-bar { background: var(--barra-fondo); }
.progress-fill { background: var(--barra); }
.progress-fill.rector  { background: var(--role-rector); }
.progress-fill.coord   { background: var(--role-coord); }
.progress-fill.orient  { background: var(--role-orient); }
.progress-fill.docente { background: var(--role-docente); }

.badge-nuevo { background: var(--acento-suave); color: var(--titulo); }
.badge-hecho { background: var(--verde-suave); color: var(--color-success); }

.skeleton {
  background: var(--bg-surface-2);
  animation: none;
}

.match-tile.selected { box-shadow: none; }

/* ============================================================
   CAMPOS
   ============================================================ */
.input,
.form-control,
.search-input {
  background: var(--bg-surface);
  border: 1px solid var(--borde-campo);
  border-radius: var(--radius-md);
  color: var(--text-primary);
}
.input:focus,
.form-control:focus,
.search-input:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
  border-color: var(--color-accent);
  box-shadow: none;
}
.input::placeholder,
.form-control::placeholder { color: var(--text-tertiary); opacity: 0.8; }

/* ============================================================
   VELOS Y MODALES — opacos, sin desenfoque
   ============================================================ */
.overlay,
.modal-backdrop,
.modal-overlay {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.study-route-modal-box { box-shadow: var(--shadow-xl); }

/* ============================================================
   ARMAZÓN — menú lateral
   ============================================================ */
.sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
}

.sidebar-header {
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
  padding: var(--space-6) 28px var(--space-4);
  border-bottom: 0;
}

.sidebar-marca { margin: 0 0 var(--space-2) -6px; }

.sidebar-usuario {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--text-tertiary);
}
.sidebar-usuario-nombre {
  color: var(--text-secondary);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-nav { padding: var(--space-2) var(--space-4) var(--space-4); }

.nav-bloque + .nav-bloque { margin-top: var(--space-3); }

.sidebar-nav .nav-bloque-titulo {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  padding: var(--space-2) var(--space-3) var(--space-1);
}

.nav-lista { gap: 2px; }
.nav-lista[hidden] { display: none; }

/* Bloques plegables (M-1). El encabezado es un botón a todo el ancho; el
   título conserva su tipografía y solo se añade el chevrón. */
.sidebar-nav .nav-bloque-titulo:has(.nav-bloque-boton) { padding: 0; }
.nav-bloque-boton {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 36px;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}
.nav-bloque-boton:hover { background: var(--bg-surface-2); color: var(--text-primary); }
.nav-bloque-boton:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}
.nav-bloque-nombre { flex: 1; min-width: 0; }
.nav-bloque-chevron { display: inline-flex; transition: transform var(--transition-fast); }
.nav-bloque-chevron svg { width: 16px; height: 16px; }
.nav-bloque.cerrado .nav-bloque-chevron { transform: rotate(-90deg); }
/* El total solo acompaña al bloque cerrado: abierto, ya se ve en su destino. */
.nav-bloque:not(.cerrado) .nav-bloque-total { display: none; }
.nav-bloque + .nav-bloque.cerrado,
.nav-bloque.cerrado + .nav-bloque { margin-top: var(--space-1); }
@media (pointer: coarse), (max-width: 768px) {
  .nav-bloque-boton { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .nav-bloque-chevron { transition: none; }
}

.nav-item {
  min-height: 44px;
  padding: 0 var(--space-3);
  margin: 0;
  gap: var(--space-3);
  border: 0;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.9375rem;
  font-weight: 400;
  line-height: 1.3;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.nav-item:hover {
  background: var(--bg-surface-2);
  color: var(--text-primary);
  transform: none;
}

.nav-item.active,
.sidebar-nav .nav-item.activo {
  background: var(--acento-suave);
  color: var(--titulo);
  font-weight: 600;
  /* Marca dorada a la izquierda: el único acento del menú. */
  box-shadow: inset 3px 0 0 var(--marca-dorado);
}
.nav-item.active::before { content: none; }

.nav-inicio { font-weight: 400; }

.nav-item-icon {
  width: 20px;
  height: 20px;
  font-size: inherit;
  color: inherit;
}

.sidebar-nav .nav-item:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

.nav-item-badge,
.nav-conteo {
  background: var(--bg-surface-3);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0;
  box-shadow: none;
}

.sidebar-footer {
  background: transparent;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.sidebar-salir {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 44px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.9375rem;
  text-align: left;
}
.sidebar-salir:hover { background: var(--bg-surface-2); color: var(--text-primary); }
.sidebar-version {
  padding: 0 var(--space-3);
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

/* ============================================================
   ARMAZÓN — cabecera
   ============================================================ */
.app-header {
  background: var(--bg-surface);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  gap: var(--space-3);
}

.header-izquierda { display: flex; align-items: center; gap: var(--space-2); flex: none; }
.header-historial { display: flex; align-items: center; gap: var(--space-1); }

.header-title {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
}
.header-title #header-seccion { font-weight: 600; color: var(--titulo); }
.header-title #header-sep { color: var(--text-tertiary); }
.header-title #header-pagina {
  color: var(--text-secondary);
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-toggle,
.btn-historial {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  align-items: center;
  justify-content: center;
  font-size: inherit;
}
.btn-historial { display: inline-flex; }
.sidebar-toggle:hover,
.btn-historial:hover { border-color: var(--border-strong); color: var(--text-primary); }

.estado-chip {
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border-color: var(--border-subtle);
  font-size: 0.8125rem;
  font-weight: 500;
}
.estado-accion:hover { border-color: var(--border-strong); }
.estado-accion:focus-visible { outline: 2px solid var(--color-accent); }

/* La racha y la experiencia informan; no son un aviso, así que no llevan
   ámbar. El cargo identifica, sin color propio por cargo. */
#header-racha { color: var(--text-secondary); border-color: var(--border-subtle); }
.estado-cargo,
.estado-admin {
  color: var(--titulo);
  border-color: var(--border-subtle);
  background: var(--acento-suave);
  font-weight: 600;
}

.admin-logo {
  background: var(--marca-navy);
  color: #FFFFFF;
  box-shadow: none;
}

.main-content { background: var(--bg-base); }

@media (max-width: 1100px) {
  /* Antes de que la cabecera se quede sin sitio se retira lo que solo
     informa y ya está en otro lugar: el cargo (panel y menú) y la
     experiencia (panel de progreso). */
  .app-header .estado-cargo,
  .app-header .estado-xp { display: none; }
}

@media (max-width: 768px) {
  .sidebar { box-shadow: var(--shadow-xl); width: min(var(--sidebar-width), 86vw); }
  .sidebar-toggle { display: inline-flex; width: 44px; height: 44px; }
  .app-header { padding: 0 var(--space-3); gap: var(--space-2); }
  .header-historial,
  .app-header #header-racha { display: none; }
  .header-actions { gap: var(--space-1); }
  .estado-accion { height: 44px; min-width: 44px; justify-content: center; padding: 0 10px; }
  .header-title #header-seccion,
  .header-title #header-sep { display: none; }
}

/* ============================================================
   TUTOR FLOTANTE — plano
   ============================================================ */
.tutor-avatar-wrapper {
  width: 52px;
  height: 52px;
  background: var(--marca-navy);
  color: #FFFFFF;
  border: 1px solid var(--marca-navy);
  box-shadow: var(--shadow-lg);
  transition: none;
}
.tutor-avatar-wrapper:hover { transform: none; }
.tutor-avatar-circle {
  width: 100%;
  height: 100%;
  background: transparent;
  border: 0 !important;
  font-size: inherit;
}
.tutor-avatar-pulse { display: none; }
.tutor-mini-badge {
  background: var(--marca-dorado) !important;
  color: var(--marca-navy) !important;
  border-color: var(--bg-surface);
}
.tutor-bubble {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  animation: none;
}
.tutor-badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--acento-suave) !important;
  color: var(--titulo) !important;
  border: 0 !important;
}
.tutor-ctrl-btn { display: inline-flex; align-items: center; justify-content: center; }
.tutor-tip-icon { display: inline-flex; color: var(--ambar-fuerte); }

/* ============================================================
   PIEZAS COMPARTIDAS POR PORTADA, ENTRADA Y PANEL
   ============================================================ */

/* Barras de resultado por área. El relleno es azul marino; .es-debil lo
   pasa a ámbar, que en esta aplicación significa una sola cosa: por debajo
   del mínimo. El número va siempre al lado: el color no es el único canal. */
.barras { display: flex; flex-direction: column; gap: 16px; }
.barra-fila {
  display: grid;
  grid-template-columns: minmax(0, 220px) minmax(0, 1fr) 40px;
  gap: 8px 16px;
  align-items: center;
  font-size: 0.9375rem;
  color: var(--text-primary);
}
.barra-nombre { min-width: 0; overflow-wrap: anywhere; }
.barra-pista {
  display: block;
  height: 10px;
  background: var(--barra-fondo);
  border-radius: 5px;
  overflow: hidden;
}
.barra-relleno {
  display: block;
  height: 10px;
  background: var(--barra);
  border-radius: 5px;
}
.barra-fila.es-debil .barra-relleno { background: var(--ambar); }
.barra-valor { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* Campo de formulario: etiqueta real encima del control, 48 px de alto. */
.campo { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.campo > label,
.campo-etiqueta {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.campo .form-control {
  min-height: 48px;
  padding: 0 14px;
  font-size: 1rem;
}
.campo select.form-control { padding-right: 8px; }

@media (max-width: 768px) {
  .hide-mobile { display: none; }
}

/* Concurso elegido (debajo del cargo) y enlace para cambiarlo. */
.sidebar-concurso { font-size: 0.75rem; color: var(--text-tertiary); }
.sidebar-plan { font-size: 0.75rem; margin-top: 2px; }
.sidebar-plan a { color: var(--text-secondary); text-decoration: underline; }
.sidebar-plan a.sidebar-plan-pro { color: var(--color-primary); font-weight: 600; text-decoration: none; }
.sidebar-cambiar-concurso { text-decoration: none; }

/* Tarjeta del plan Pro y prueba gratis de 7 días en el drawer (menú lateral). */
.sidebar-plan-card {
  margin: var(--space-3) var(--space-2) var(--space-1);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-surface-2);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sidebar-plan-card-gratis,
.sidebar-plan-card-prueba {
  border-color: var(--color-primary);
}
.sidebar-plan-card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 0.8125rem;
  line-height: 1.3;
}
.sidebar-plan-card-icon {
  display: inline-flex;
  align-items: center;
  color: var(--color-primary);
  flex-shrink: 0;
}
.sidebar-plan-card-icon svg {
  width: 16px;
  height: 16px;
}
.sidebar-plan-card-desc {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--text-secondary);
}
.sidebar-plan-card-btn,
.sidebar-plan-card-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--boton-fondo);
  color: var(--boton-texto);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.sidebar-plan-card-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}
.sidebar-plan-card-link {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-decoration: underline;
}
.sidebar-plan-card-msg {
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--color-error);
}
