/* ============================================================
   STA – Estilos personalizados
   ============================================================ */

:root {
  --sidebar-width: 260px;
  --sidebar-bg: #1a2035;
  --sidebar-text: #a0aec0;
  --sidebar-active: #ffffff;
  --sidebar-active-bg: rgba(255,255,255,.08);
  --sidebar-hover-bg: rgba(255,255,255,.05);
  --accent: #4f8ef7;
  --accent-dark: #3a7ae0;
  --danger-color: #e53e3e;
  --warning-color: #ed8936;
  --success-color: #38a169;
  --info-color: #3182ce;
}

/* ---- Layout ---- */
body { background: #f4f6fa; font-family: 'Segoe UI', system-ui, sans-serif; }

#app { display: flex; min-height: 100vh; }

/* ---- Sidebar ---- */
#sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s ease;
}
#sidebar .brand {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
#sidebar .brand h5 { color: #fff; font-weight: 700; margin: 0; font-size: .95rem; }
#sidebar .brand small { color: var(--sidebar-text); font-size: .75rem; }

#sidebar nav { flex: 1; overflow-y: auto; padding: .75rem 0; }
#sidebar nav a {
  display: flex; align-items: center; gap: .7rem;
  padding: .6rem 1.25rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .875rem;
  border-radius: 0;
  transition: background .15s, color .15s;
}
#sidebar nav a:hover { background: var(--sidebar-hover-bg); color: #fff; }
#sidebar nav a.active { background: var(--sidebar-active-bg); color: var(--sidebar-active); }
#sidebar nav a .bi { font-size: 1.05rem; }
#sidebar .nav-section {
  padding: .5rem 1.25rem .25rem;
  font-size: .65rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.3);
}
#sidebar .sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.08);
}
#sidebar .sidebar-footer .user-info { color: #fff; font-size: .8rem; }
#sidebar .sidebar-footer .user-info small { color: var(--sidebar-text); }

/* ---- Main content ---- */
#main {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
#topbar {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  position: sticky;
  top: 0;
  z-index: 99;
}
#topbar h4 { margin: 0; font-size: 1.05rem; font-weight: 600; flex: 1; }
#page-content { padding: 1.5rem; flex: 1; }

/* ---- Login ---- */
#view-login {
  min-height: 100vh;
  background: linear-gradient(135deg, #1a2035 0%, #2d3a5e 100%);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 12px;
  padding: 2.5rem;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-card .logo-icon {
  width: 56px; height: 56px;
  background: var(--accent);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.5rem;
}

/* ---- Stat cards ---- */
.stat-card {
  background: #fff;
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  display: flex; align-items: center; gap: 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  border-left: 4px solid transparent;
}
.stat-card.blue   { border-left-color: var(--info-color); }
.stat-card.green  { border-left-color: var(--success-color); }
.stat-card.yellow { border-left-color: var(--warning-color); }
.stat-card.red    { border-left-color: var(--danger-color); }
.stat-card .icon {
  width: 48px; height: 48px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0;
}
.stat-card.blue   .icon { background: #ebf4ff; color: var(--info-color); }
.stat-card.green  .icon { background: #f0fff4; color: var(--success-color); }
.stat-card.yellow .icon { background: #fffaf0; color: var(--warning-color); }
.stat-card.red    .icon { background: #fff5f5; color: var(--danger-color); }
.stat-card .value { font-size: 1.8rem; font-weight: 700; line-height: 1; color: #1a202c; }
.stat-card .label { font-size: .78rem; color: #718096; margin-top: .2rem; }

/* ---- Badges de riesgo ---- */
.badge-critico  { background:#c53030; color:#fff; }
.badge-alto     { background:#e53e3e; color:#fff; }
.badge-medio    { background:#ed8936; color:#fff; }
.badge-bajo     { background:#38a169; color:#fff; }
.badge-urgente  { background:#c53030; color:#fff; }
.badge-alta     { background:#e53e3e; color:#fff; }
.badge-media    { background:#ed8936; color:#fff; }
.badge-baja     { background:#718096; color:#fff; }

/* ---- Flags de estudiante ---- */
.flag-badge {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .7rem; padding: .2rem .5rem; border-radius: 4px;
  font-weight: 600;
}
.flag-judicial   { background:#fed7d7; color:#c53030; }
.flag-salud      { background:#bee3f8; color:#2b6cb0; }
.flag-conducta   { background:#feebc8; color:#c05621; }
.flag-ausentismo { background:#e9d8fd; color:#6b46c1; }
.flag-repitencia { background:#fefcbf; color:#744210; }
.flag-familia    { background:#c6f6d5; color:#276749; }
.flag-nee        { background:#e2e8f0; color:#4a5568; }
.flag-vulnerable { background:#fed7d7; color:#9b2c2c; }

/* ---- Tabla estudiantes ---- */
.table-students { table-layout: fixed; width: 100%; }
.table-students th {
  font-size: .78rem; text-transform: uppercase;
  letter-spacing: .05em; color: #718096;
  overflow: hidden; white-space: nowrap;
}
.table-students td { vertical-align: middle; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-students td:nth-child(5) { white-space: normal; }   /* Flags: allow wrap */
.nombre-link { font-weight: 600; color: #2d3748; cursor: pointer; }
.nombre-link:hover { color: var(--accent); }

/* ---- Curso browser dentro de Estudiantes ---- */
#est-panel-cursos .nivel-header {
  border-bottom: 2px solid rgba(0,0,0,.08);
  padding-bottom: .5rem;
  margin-bottom: 1rem;
}
.curso-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,.12) !important; }
.curso-card { transition: transform .15s, box-shadow .15s; }

/* ---- Perfil estudiante ---- */
.profile-header {
  background: linear-gradient(135deg, #1a2035, #2d3a5e);
  color: #fff; border-radius: 10px; padding: 1.5rem;
}
.profile-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: rgba(255,255,255,.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.obs-item {
  border-left: 4px solid #e2e8f0;
  padding: .75rem 1rem;
  background: #fff;
  border-radius: 0 6px 6px 0;
  margin-bottom: .6rem;
}
.obs-item.critico { border-left-color: #c53030; }
.obs-item.alto    { border-left-color: #e53e3e; }
.obs-item.medio   { border-left-color: #ed8936; }
.obs-item.bajo    { border-left-color: #38a169; }

/* ---- Alertas ---- */
.alerta-item {
  background: #fff; border-radius: 8px; padding: 1rem;
  border-left: 4px solid #e2e8f0; box-shadow: 0 1px 3px rgba(0,0,0,.05);
  margin-bottom: .5rem;
}
.alerta-item.urgente { border-left-color: #c53030; }
.alerta-item.alta    { border-left-color: #e53e3e; }
.alerta-item.media   { border-left-color: #ed8936; }
.alerta-item.baja    { border-left-color: #718096; }

/* ---- Drag & Drop CSV ---- */
.dropzone {
  border: 2px dashed #cbd5e0;
  border-radius: 10px;
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: #fff;
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--accent);
  background: #ebf4ff;
}
.dropzone .bi { font-size: 2.5rem; color: #a0aec0; }

/* ---- Charts ---- */
.chart-card {
  background: #fff; border-radius: 10px; padding: 1.25rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

/* ---- Loaders ---- */
.spinner-overlay {
  position: fixed; inset: 0;
  background: rgba(255,255,255,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}

/* ---- Toast ---- */
#toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 10000; }
.toast-msg {
  min-width: 280px; max-width: 380px;
  padding: .85rem 1.2rem;
  border-radius: 8px; color: #fff;
  font-size: .875rem;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  margin-top: .5rem;
  animation: slideIn .25s ease;
}
.toast-msg.success { background: var(--success-color); }
.toast-msg.error   { background: var(--danger-color);  }
.toast-msg.info    { background: var(--info-color);    }
.toast-msg.warning { background: var(--warning-color); }

@keyframes slideIn { from { transform: translateX(100%); opacity:0; } to { transform: translateX(0); opacity:1; } }

/* ---- Backdrop móvil ---- */
#sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 999;
  touch-action: manipulation;
  cursor: pointer;
}
#sidebar-backdrop.show { display: block; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
    z-index: 1000;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
  }
  #sidebar.open { transform: translateX(0); }
  #main { margin-left: 0; }
}

/* ---- Casos críticos: grid de tarjetas ---- */
.critico-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .6rem;
  padding: .25rem 0;
}

.critico-card {
  background: #fff;
  border: 1px solid #e8ecf0;
  border-radius: 8px;
  padding: .65rem .75rem;
  cursor: pointer;
  transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease;
}

.critico-card:hover {
  box-shadow: 0 4px 14px rgba(0,0,0,.1);
  transform: translateY(-1px);
  border-color: #c8d0db;
}

.critico-card__header {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin-bottom: .45rem;
}

.critico-avatar {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .8rem;
  letter-spacing: .02em;
}

.critico-card__info {
  flex: 1 1 0;
  min-width: 0;
}

.critico-card__nombre {
  font-size: .8rem;
  font-weight: 600;
  color: #1a202c;
  line-height: 1.25;
  word-break: break-word;
}

.critico-card__curso {
  font-size: .68rem;
  color: #718096;
  margin-top: .1rem;
}

.critico-score {
  flex-shrink: 0;
  min-width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .72rem;
  font-weight: 800;
  line-height: 1;
}

.critico-score--critical {
  background: #9b1c1c;
  color: #fff;
  box-shadow: 0 0 0 2px #fca5a5;
}

.critico-score--high {
  background: #c53030;
  color: #fff;
  box-shadow: 0 0 0 2px #fca5a5;
}

.critico-score--medium {
  background: #ed8936;
  color: #fff;
  box-shadow: 0 0 0 2px #fbd38d;
}

.critico-flags {
  display: flex;
  flex-wrap: wrap;
  gap: .2rem;
}

.critico-flags .flag-badge {
  font-size: .6rem;
  padding: .12rem .35rem;
}

@media (max-width: 500px) {
  .critico-grid {
    grid-template-columns: 1fr;
  }
}

/* ---- Alertas recientes: lista mejorada ---- */
.alerta-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem .85rem;
  border-left: 4px solid #e2e8f0;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: background .15s;
  text-decoration: none;
}
.alerta-row:hover {
  background: #f8fafc;
}
.alerta-row:last-of-type {
  border-bottom: none;
}
.alerta-avatar {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .75rem;
}
.alerta-body {
  flex: 1 1 0;
  min-width: 0;
}
.alerta-nombre {
  font-weight: 600;
  font-size: .82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.alerta-tipo {
  font-size: .76rem;
  color: #64748b;
  margin-top: .1rem;
  display: flex;
  align-items: center;
  gap: .3rem;
}
.alerta-meta {
  flex-shrink: 0;
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .2rem;
}
.alerta-tiempo {
  font-size: .7rem;
  color: #94a3b8;
}
.alerta-ver-todas {
  text-align: center;
  padding: .55rem 0 .25rem;
  border-top: 1px solid #f1f5f9;
}
.alerta-ver-todas a {
  font-size: .78rem;
  color: #4f8ef7;
  text-decoration: none;
}
.alerta-ver-todas a:hover {
  text-decoration: underline;
}

/* ============================================================
   USUARIOS
   ============================================================ */
.usr-avatar {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .8rem;
  letter-spacing: .02em;
}

/* ─── Restricciones por rol ─────────────────────────────────────────────────
   Solo admin y directivo pueden ver/marcar "Observación privada".
   Esta regla con !important garantiza que docentes y asistentes nunca
   lo vean, incluso si JavaScript falla o si LiteSpeed sirve un app.js viejo.
*/
body:not(.rol-admin):not(.rol-directivo) #obs-privada-wrapper {
  display: none !important;
}

/* Observación / alerta marcada como privada — solo la ven admin/directivo
   (el backend ya las filtra para otros roles) */
.obs-item.obs-privada,
.alerta-item.alerta-privada {
  border-left-style: dashed;
  background: linear-gradient(90deg, rgba(33,37,41,0.04), transparent 60%);
}
