/* =====================================================
   SIRA-UNASAM: Hoja de Estilos Principal
   Universidad Nacional Santiago Antúnez de Mayolo
   VRI - Vicerrectorado de Investigación v1.0
   ===================================================== */

/* --- Variables UNASAM Brand Colors --- */
:root {
  --unasam-azul:        #1B3A6B;   /* Azul institucional UNASAM */
  --unasam-azul-oscuro: #0f2444;
  --unasam-azul-medio:  #2563EB;
  --unasam-azul-claro:  #DBEAFE;
  --unasam-verde:       #166534;   /* Verde institucional */
  --unasam-verde-claro: #DCFCE7;
  --unasam-oro:         #D4AF37;   /* Dorado/Oro */
  --unasam-oro-claro:   #FEF3C7;
  --unasam-rojo:        #DC2626;
  --unasam-gris:        #6B7280;
  --unasam-gris-claro:  #F9FAFB;
  --sidebar-width:      260px;
  --header-height:      64px;
  --border-radius:      8px;
  --shadow-sm:          0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --shadow-md:          0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:          0 10px 15px rgba(0,0,0,.10), 0 4px 6px rgba(0,0,0,.05);
  --transition:         all 0.25s ease;

  /* Sidebar theme variables (defaults = Investigador / sin rol) */
  --sidebar-bg-from:    #1B3A6B;
  --sidebar-bg-to:      #1a4a80;
  --sidebar-accent:     #D4AF37;
  --sidebar-avatar-bg:  #D4AF37;
  --sidebar-avatar-fg:  #1a1a1a;
  --sidebar-rol-label:  rgba(255,255,255,0.55);
}

/* =====================================================
   PALETAS DE COLOR POR ROL — UNASAM
   Administrador  (rol 1): Azul marino profundo + oro
   VRI            (rol 2): Azul UNASAM + verde institucional
   Coordinador    (rol 3): Verde institucional + oro
   Evaluador      (rol 4): Ámbar/naranja + azul oscuro
   Investigador   (rol 5): Azul medio + verde
   ===================================================== */

/* ROL 1 — ADMINISTRADOR: Azul marino oscuro + oro */
body.rol-admin {
  --sidebar-bg-from:    #0a1628;
  --sidebar-bg-to:      #0f2444;
  --sidebar-accent:     #D4AF37;
  --sidebar-avatar-bg:  #D4AF37;
  --sidebar-avatar-fg:  #0a1628;
  --sidebar-rol-label:  #D4AF37;
}

/* ROL 2 — VRI: Azul UNASAM + verde institucional */
body.rol-vri {
  --sidebar-bg-from:    #0f2444;
  --sidebar-bg-to:      #1B3A6B;
  --sidebar-accent:     #22c55e;
  --sidebar-avatar-bg:  #22c55e;
  --sidebar-avatar-fg:  #0f2444;
  --sidebar-rol-label:  #86efac;
}

/* ROL 3 — COORDINADOR: Verde institucional + oro */
body.rol-coordinador {
  --sidebar-bg-from:    #0d3320;
  --sidebar-bg-to:      #166534;
  --sidebar-accent:     #D4AF37;
  --sidebar-avatar-bg:  #D4AF37;
  --sidebar-avatar-fg:  #0d3320;
  --sidebar-rol-label:  #D4AF37;
}

/* ROL 4 — EVALUADOR: Ámbar/naranja oscuro + azul */
body.rol-evaluador {
  --sidebar-bg-from:    #431407;
  --sidebar-bg-to:      #7c2d12;
  --sidebar-accent:     #fbbf24;
  --sidebar-avatar-bg:  #fbbf24;
  --sidebar-avatar-fg:  #431407;
  --sidebar-rol-label:  #fde68a;
}

/* ROL 5 — INVESTIGADOR: Azul medio + azul UNASAM */
body.rol-investigador {
  --sidebar-bg-from:    #1e3a5f;
  --sidebar-bg-to:      #2563EB;
  --sidebar-accent:     #D4AF37;
  --sidebar-avatar-bg:  #D4AF37;
  --sidebar-avatar-fg:  #1e3a5f;
  --sidebar-rol-label:  rgba(255,255,255,0.6);
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; }
body {
  font-family: 'Source Sans 3', 'Segoe UI', Arial, sans-serif;
  font-size: 14px;
  color: #1e293b;
  background: #eef2f7;
  margin: 0;
  padding: 0;
  line-height: 1.6;
}

a { color: var(--unasam-azul); text-decoration: none; }
a:hover { color: var(--unasam-azul-medio); }

/* ============================
   LOGIN PAGE
   ============================ */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--unasam-azul-oscuro) 0%, var(--unasam-azul) 50%, #1a5276 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: rgba(255,255,255,0.04);
  pointer-events: none;
}

.login-page::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -15%;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: rgba(212,175,55,0.08);
  pointer-events: none;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.4);
  overflow: hidden;
  position: relative;
  z-index: 1;
  animation: slideUp 0.5s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-header {
  background: linear-gradient(135deg, var(--unasam-azul) 0%, var(--unasam-azul-oscuro) 100%);
  padding: 36px 32px 28px;
  text-align: center;
  position: relative;
}

.login-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 30px solid transparent;
  border-right: 30px solid transparent;
  border-top: 15px solid var(--unasam-azul-oscuro);
}

.login-logo {
  width: 80px;
  height: 80px;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  font-size: 36px;
  color: var(--unasam-azul);
  font-weight: 900;
}

.login-header h1 {
  color: white;
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: 1px;
}

.login-header p {
  color: rgba(255,255,255,0.7);
  font-size: 12px;
  margin: 0;
}

.login-header .sistema-badge {
  display: inline-block;
  margin-top: 10px;
  background: var(--unasam-oro);
  color: #1a1a1a;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 20px;
  letter-spacing: 1.5px;
}

.login-body { padding: 36px 32px 28px; }
.login-body .form-label {
  font-weight: 600;
  color: var(--unasam-azul);
  font-size: 13px;
  margin-bottom: 6px;
}

.login-body .form-control {
  border: 2px solid #e2e8f0;
  border-radius: var(--border-radius);
  padding: 10px 14px 10px 40px;
  font-size: 14px;
  transition: var(--transition);
}

.login-body .form-control:focus {
  border-color: var(--unasam-azul);
  box-shadow: 0 0 0 3px rgba(27,58,107,0.15);
}

.input-group-icon {
  position: relative;
}

.input-group-icon .form-control { padding-left: 40px; }
.input-group-icon .icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--unasam-gris);
  z-index: 10;
  font-size: 16px;
}

.btn-login {
  width: 100%;
  background: linear-gradient(135deg, var(--unasam-azul), var(--unasam-azul-oscuro));
  border: none;
  color: white;
  padding: 12px;
  border-radius: var(--border-radius);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-login:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(27,58,107,0.4);
}

.login-footer {
  background: var(--unasam-gris-claro);
  padding: 16px 32px;
  text-align: center;
  font-size: 12px;
  color: var(--unasam-gris);
  border-top: 1px solid #e2e8f0;
}

/* ============================
   LAYOUT PRINCIPAL
   ============================ */

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: linear-gradient(180deg, var(--sidebar-bg-from) 0%, var(--sidebar-bg-to) 100%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.3s ease;
  box-shadow: 4px 0 15px rgba(0,0,0,0.2);
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.sidebar-brand-icon {
  width: 44px;
  height: 44px;
  background: white;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 900;
  color: var(--unasam-azul);
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.sidebar-brand-text h2 {
  font-size: 15px;
  font-weight: 800;
  color: white;
  margin: 0;
  letter-spacing: 1px;
}

.sidebar-brand-text p {
  font-size: 10px;
  color: rgba(255,255,255,0.6);
  margin: 0;
  letter-spacing: 0.5px;
}

/* Sidebar User */
.sidebar-user {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--sidebar-avatar-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--sidebar-avatar-fg);
  font-size: 14px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-info .name {
  font-size: 13px;
  font-weight: 600;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-info .role {
  font-size: 11px;
  color: var(--sidebar-rol-label);
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* Sidebar Nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 4px; }

.sidebar-section {
  padding: 8px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.4);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: var(--transition);
  position: relative;
  border-radius: 0;
  margin: 1px 8px;
  border-radius: 8px;
}

.sidebar-item:hover {
  color: white;
  background: rgba(255,255,255,0.12);
}

.sidebar-item.active {
  color: white;
  background: rgba(255,255,255,0.18);
  font-weight: 600;
}

.sidebar-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 60%;
  background: var(--sidebar-accent);
  border-radius: 0 4px 4px 0;
  margin-left: -8px;
}

.sidebar-item i {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-badge {
  margin-left: auto;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--sidebar-accent);
  color: var(--sidebar-avatar-fg);
  font-weight: 700;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  text-align: center;
}

/* Main Content */
.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin 0.3s ease;
}

/* Top Header */
.topbar {
  height: var(--header-height);
  background: white;
  border-bottom: 2px solid var(--unasam-azul-claro);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 900;
  box-shadow: var(--shadow-sm);
}

.topbar-toggle {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--unasam-azul);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  display: none;
}

.topbar-breadcrumb {
  flex: 1;
}

.topbar-breadcrumb .breadcrumb {
  margin: 0;
  background: none;
  padding: 0;
  font-size: 13px;
}

.topbar-breadcrumb .breadcrumb-item.active { color: var(--unasam-azul); font-weight: 600; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-btn {
  width: 38px;
  height: 38px;
  border: none;
  background: var(--unasam-gris-claro);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--unasam-azul);
  cursor: pointer;
  font-size: 17px;
  transition: var(--transition);
  position: relative;
  text-decoration: none;
}

.topbar-btn:hover { background: var(--unasam-azul-claro); color: var(--unasam-azul); }

.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--unasam-rojo);
  color: white;
  font-size: 10px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  border: 2px solid white;
}

/* Page Content */
.page-content {
  flex: 1;
  padding: 28px 28px 40px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.page-title h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--unasam-azul);
  margin: 0 0 4px;
  line-height: 1.2;
}

.page-title p {
  color: var(--unasam-gris);
  font-size: 13px;
  margin: 0;
}

/* ============================
   CARDS Y CONTENEDORES
   ============================ */

.card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: var(--transition);
}

.card:hover { box-shadow: var(--shadow-md); }

.card-header {
  padding: 16px 20px;
  background: white;
  border-bottom: 2px solid var(--unasam-azul-claro);
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-header h5, .card-header h6 {
  margin: 0;
  color: var(--unasam-azul);
  font-weight: 700;
  font-size: 14px;
}

.card-header .card-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--unasam-azul-claro);
  color: var(--unasam-azul);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.card-body { padding: 20px; }

/* Stat Cards (Dashboard) */
.stat-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid #e2e8f0;
  transition: var(--transition);
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  opacity: 0.08;
  transform: translate(20px, -20px);
}

.stat-card.azul::before  { background: var(--unasam-azul); }
.stat-card.verde::before { background: var(--unasam-verde); }
.stat-card.oro::before   { background: var(--unasam-oro); }
.stat-card.rojo::before  { background: var(--unasam-rojo); }

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.stat-icon.azul  { background: var(--unasam-azul-claro); color: var(--unasam-azul); }
.stat-icon.verde { background: var(--unasam-verde-claro); color: var(--unasam-verde); }
.stat-icon.oro   { background: var(--unasam-oro-claro);   color: #92400e; }
.stat-icon.rojo  { background: #FEE2E2; color: var(--unasam-rojo); }

.stat-info { flex: 1; min-width: 0; }
.stat-info .value {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
  color: var(--unasam-azul);
}

.stat-info .label {
  font-size: 12.5px;
  color: var(--unasam-gris);
  font-weight: 500;
}

.stat-info .change {
  font-size: 11px;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 3px;
}

.stat-info .change.up   { color: #16a34a; }
.stat-info .change.down { color: var(--unasam-rojo); }

/* ============================
   TABLAS
   ============================ */

.table-container {
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  border: 1px solid #e2e8f0;
  overflow: hidden;
}

.table-toolbar {
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.table-toolbar .title {
  font-size: 14px;
  font-weight: 700;
  color: var(--unasam-azul);
  flex: 1;
}

.table-search {
  position: relative;
}

.table-search input {
  padding: 8px 12px 8px 34px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  min-width: 220px;
  outline: none;
  transition: var(--transition);
}

.table-search input:focus {
  border-color: var(--unasam-azul);
  box-shadow: 0 0 0 2px rgba(27,58,107,0.1);
}

.table-search i {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--unasam-gris);
  font-size: 14px;
}

.table { margin: 0; }
.table thead th {
  background: var(--unasam-azul);
  color: white;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  border: none;
  white-space: nowrap;
}

.table tbody td {
  padding: 12px 16px;
  vertical-align: middle;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13.5px;
}

.table tbody tr:hover { background: #f8faff; }
.table tbody tr:last-child td { border-bottom: none; }

/* Acciones de tabla */
.table-actions {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.btn-action {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: var(--transition);
  text-decoration: none;
}

.btn-action.view   { background: var(--unasam-azul-claro); color: var(--unasam-azul); }
.btn-action.edit   { background: #FEF9C3; color: #713f12; }
.btn-action.delete { background: #FEE2E2; color: var(--unasam-rojo); }
.btn-action.eval   { background: var(--unasam-verde-claro); color: var(--unasam-verde); }
.btn-action:hover  { transform: scale(1.15); opacity: 0.85; }

/* ============================
   FORMULARIOS
   ============================ */

.form-section {
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  border: 1px solid #e2e8f0;
  overflow: hidden;
  margin-bottom: 24px;
}

.form-section-header {
  background: linear-gradient(90deg, var(--unasam-azul) 0%, #2a5298 100%);
  padding: 14px 20px;
  color: white;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
}

.form-section-body { padding: 24px; }

.form-label {
  font-weight: 600;
  font-size: 13px;
  color: #374151;
  margin-bottom: 6px;
}

.form-label .required {
  color: var(--unasam-rojo);
  margin-left: 3px;
}

.form-control, .form-select {
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  padding: 9px 13px;
  font-size: 13.5px;
  transition: var(--transition);
  color: #1e293b;
}

.form-control:focus, .form-select:focus {
  border-color: var(--unasam-azul);
  box-shadow: 0 0 0 3px rgba(27,58,107,0.12);
  outline: none;
}

.form-text { font-size: 11.5px; color: var(--unasam-gris); }

textarea.form-control { min-height: 100px; resize: vertical; }

/* ============================
   BOTONES
   ============================ */

.btn {
  font-size: 13.5px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 8px;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  cursor: pointer;
}

.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn-primary {
  background: var(--unasam-azul);
  color: white;
}
.btn-primary:hover { background: var(--unasam-azul-oscuro); color: white; }

.btn-success {
  background: var(--unasam-verde);
  color: white;
}
.btn-success:hover { background: #14532d; color: white; }

.btn-warning {
  background: var(--unasam-oro);
  color: #1a1a1a;
}
.btn-warning:hover { background: #b8960f; color: #1a1a1a; }

.btn-danger {
  background: var(--unasam-rojo);
  color: white;
}
.btn-danger:hover { background: #b91c1c; color: white; }

.btn-outline-primary {
  background: transparent;
  color: var(--unasam-azul);
  border: 2px solid var(--unasam-azul);
}
.btn-outline-primary:hover {
  background: var(--unasam-azul);
  color: white;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12.5px;
}

.btn-lg {
  padding: 12px 28px;
  font-size: 15px;
}

/* ============================
   BADGES Y STATUS
   ============================ */

.badge {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge.bg-primary   { background: var(--unasam-azul) !important; }
.badge.bg-success   { background: var(--unasam-verde) !important; }
.badge.bg-warning   { background: var(--unasam-oro) !important; color: #1a1a1a !important; }
.badge.bg-danger    { background: var(--unasam-rojo) !important; }
.badge.bg-info      { background: #0891b2 !important; }
.badge.bg-secondary { background: #6b7280 !important; }
.badge.bg-dark      { background: #1e293b !important; }

/* Progress bar */
.progress { border-radius: 10px; background: #e2e8f0; }
.progress-bar { border-radius: 10px; transition: width 0.6s ease; }

/* ============================
   ALERTS
   ============================ */

.alert {
  border-radius: 10px;
  border-left: 4px solid transparent;
  padding: 14px 18px;
  font-size: 13.5px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-success { border-left-color: var(--unasam-verde); background: var(--unasam-verde-claro); color: #14532d; }
.alert-danger  { border-left-color: var(--unasam-rojo);  background: #FEE2E2; color: #991b1b; }
.alert-warning { border-left-color: #d97706; background: #FEF3C7; color: #92400e; }
.alert-info    { border-left-color: #0891b2; background: #E0F2FE; color: #0c4a6e; }

/* ============================
   TIMELINE (para historial)
   ============================ */

.timeline { position: relative; padding-left: 24px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #e2e8f0;
}

.timeline-item { position: relative; padding-bottom: 20px; }
.timeline-item::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--unasam-azul);
  border: 2px solid white;
  box-shadow: 0 0 0 2px var(--unasam-azul);
}

.timeline-item.success::before { background: var(--unasam-verde); box-shadow: 0 0 0 2px var(--unasam-verde); }
.timeline-item.warning::before { background: var(--unasam-oro); box-shadow: 0 0 0 2px var(--unasam-oro); }
.timeline-item.danger::before  { background: var(--unasam-rojo); box-shadow: 0 0 0 2px var(--unasam-rojo); }

.timeline-content {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
}

.timeline-time {
  font-size: 11px;
  color: var(--unasam-gris);
  margin-bottom: 4px;
}

/* ============================
   CHARTS (área de gráficos)
   ============================ */

.chart-container {
  position: relative;
  padding: 20px;
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  border: 1px solid #e2e8f0;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.chart-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--unasam-azul);
}

/* ============================
   EVALUACIÓN - Criterios
   ============================ */

.eval-criterio {
  background: var(--unasam-gris-claro);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
  border-left: 3px solid var(--unasam-azul);
}

.eval-criterio .criterio-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.eval-criterio .criterio-name {
  font-weight: 600;
  color: var(--unasam-azul);
  font-size: 13px;
}

.eval-criterio .criterio-max {
  font-size: 12px;
  color: var(--unasam-gris);
  background: white;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
}

/* ============================
   PERFIL INVESTIGADOR
   ============================ */

.investigador-card {
  text-align: center;
  padding: 28px 20px;
}

.investigador-avatar {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  margin: 0 auto 16px;
  border: 3px solid var(--unasam-azul);
  overflow: hidden;
  background: var(--unasam-azul-claro);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 700;
  color: var(--unasam-azul);
}

.investigador-metrics {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 12px 0;
}

.metric-item {
  text-align: center;
  padding: 8px 14px;
  background: var(--unasam-gris-claro);
  border-radius: 8px;
  flex: 1;
}

.metric-item .value {
  font-size: 20px;
  font-weight: 800;
  color: var(--unasam-azul);
}

.metric-item .label {
  font-size: 10px;
  color: var(--unasam-gris);
}

/* ============================
   TABS
   ============================ */

.nav-tabs {
  border-bottom: 2px solid var(--unasam-azul-claro);
}

.nav-tabs .nav-link {
  color: var(--unasam-gris);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 18px;
  border: none;
  border-radius: 0;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-tabs .nav-link:hover { color: var(--unasam-azul); }
.nav-tabs .nav-link.active {
  color: var(--unasam-azul);
  border-bottom: 2px solid var(--unasam-azul);
  background: none;
}

/* ============================
   RESPONSIVE
   ============================ */

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
  }

  .sidebar-overlay.show { display: block; }

  .main-wrapper { margin-left: 0; }
  .topbar-toggle { display: flex; }

  .page-content { padding: 16px; }
  .page-header { flex-direction: column; }

  .stat-card .stat-info .value { font-size: 22px; }
  .table-toolbar { flex-direction: column; align-items: stretch; }
  .table-search input { min-width: auto; width: 100%; }
}

/* ============================
   UTILITIES
   ============================ */

.text-unasam  { color: var(--unasam-azul) !important; }
.text-verde   { color: var(--unasam-verde) !important; }
.text-oro     { color: var(--unasam-oro) !important; }
.bg-unasam    { background: var(--unasam-azul) !important; color: white !important; }
.bg-unasam-light { background: var(--unasam-azul-claro) !important; }

.border-unasam { border-color: var(--unasam-azul) !important; }

.fw-700 { font-weight: 700 !important; }
.fw-800 { font-weight: 800 !important; }

.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

/* Loading spinner */
.spinner-unasam {
  width: 40px;
  height: 40px;
  border: 4px solid var(--unasam-azul-claro);
  border-top-color: var(--unasam-azul);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 20px auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Overlay para carga de página */
#page-loader {
  position: fixed;
  inset: 0;
  background: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.3s ease;
}

#page-loader.hidden { opacity: 0; pointer-events: none; }

/* Print styles */
@media print {
  .sidebar, .topbar, .btn, .table-toolbar { display: none !important; }
  .main-wrapper { margin-left: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

/* Animaciones */
.fade-in {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.slide-in {
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-15px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* =====================================================
   CORRECCIONES v1.1 — ESCALA, COMPACIDAD Y COLORES ROL
   ===================================================== */

/* --- Escala general: reducir padding excesivo --- */
.page-content {
  padding: 20px 24px 32px;
}

.page-header {
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.page-title h1 {
  font-size: 20px;
}

.page-title p {
  font-size: 12.5px;
}

/* Cards más compactas */
.card-body { padding: 16px; }
.card-header { padding: 12px 16px; }
.card-header h5, .card-header h6 { font-size: 13.5px; }

/* Stat cards compactas */
.stat-card {
  padding: 16px;
  gap: 12px;
}

.stat-icon {
  width: 46px;
  height: 46px;
  font-size: 21px;
  border-radius: 10px;
}

.stat-info .value {
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
}

.stat-info .label {
  font-size: 12px;
  color: var(--unasam-gris);
}

/* Tabla más compacta */
.table th {
  font-size: 11.5px;
  padding: 10px 12px;
}

.table td {
  font-size: 12.5px;
  padding: 9px 12px;
}

.table-toolbar {
  padding: 12px 16px;
}

/* --- Topbar con acento de rol --- */
.topbar {
  border-bottom: 2px solid transparent;
  border-image: linear-gradient(90deg, var(--sidebar-bg-from), var(--sidebar-accent), var(--sidebar-bg-to)) 1;
}

/* Badge de notificaciones con accent del rol */
.notif-badge {
  background: var(--sidebar-accent);
  color: var(--sidebar-avatar-fg, #1a1a1a);
  border: 2px solid white;
}

/* Botones primarios respetan color de rol */
body.rol-coordinador .btn-primary,
body.rol-coordinador .btn-primary:hover {
  background: var(--unasam-verde);
  border-color: var(--unasam-verde);
}

body.rol-evaluador .btn-primary,
body.rol-evaluador .btn-primary:hover {
  background: #92400e;
  border-color: #92400e;
}

body.rol-vri .btn-primary,
body.rol-vri .btn-primary:hover {
  background: var(--unasam-azul);
  border-color: var(--unasam-azul);
}

/* Indicador de rol en topbar — stripe superior de color */
.main-wrapper::before {
  content: '';
  display: block;
  height: 3px;
  width: 100%;
  background: linear-gradient(90deg, var(--sidebar-bg-from), var(--sidebar-accent) 50%, var(--sidebar-bg-to));
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  z-index: 901;
}

/* Sidebar active item: fondo con accent suave */
.sidebar-item.active {
  background: rgba(255,255,255,0.15);
  color: white;
}

.sidebar-item:hover {
  background: rgba(255,255,255,0.1);
  color: white;
}

/* Avatar topbar también respeta el rol */
.topbar-avatar-bg {
  background: var(--sidebar-bg-from);
}

/* Card header: borde superior con accent del rol */
.card { border-top: 3px solid transparent; }
body.rol-admin       .card { border-top-color: var(--unasam-azul-oscuro); }
body.rol-vri         .card { border-top-color: var(--unasam-azul); }
body.rol-coordinador .card { border-top-color: var(--unasam-verde); }
body.rol-evaluador   .card { border-top-color: #92400e; }
body.rol-investigador .card { border-top-color: #2563EB; }

/* --- Responsive: sidebar colapsable en pantallas <1200px --- */
@media (max-width: 1199px) {
  .main-wrapper::before { left: 0; }
}

/* Sidebar footer más compacto */
.sidebar-footer {
  padding: 12px 16px;
  font-size: 10px;
}

/* Form labels */
.form-label.fw-600 { font-size: 12.5px; }
.form-control, .form-select { font-size: 13px; padding: 7px 11px; }

/* =====================================================
   MODO OSCURO — SIRA-UNASAM v2
   Activado con body[data-theme="dark"]
   ===================================================== */

body[data-theme="dark"] {
  /* Fondos */
  --bg-main:       #111827;
  --bg-surface:    #1f2937;
  --bg-surface-2:  #283548;
  --bg-border:     #374151;

  /* Texto */
  --text-primary:   #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted:     #94a3b8;

  /* Sobreescribir variables de marca para modo oscuro */
  --unasam-azul:        #60a5fa;   /* azul claro visible */
  --unasam-azul-oscuro: #93c5fd;
  --unasam-azul-medio:  #3b82f6;
  --unasam-azul-claro:  rgba(59,130,246,0.18);
  --unasam-verde:       #4ade80;
  --unasam-verde-claro: rgba(74,222,128,0.15);
  --unasam-oro:         #fbbf24;
  --unasam-oro-claro:   rgba(251,191,36,0.15);
  --unasam-rojo:        #f87171;
  --unasam-gris:        #94a3b8;
  --unasam-gris-claro:  #1f2937;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.5);
  --shadow-md: 0 4px 8px rgba(0,0,0,.45);
  --shadow-lg: 0 10px 20px rgba(0,0,0,.5);

  background: var(--bg-main);
  color: var(--text-primary);
}

/* ── Estructura principal ── */
body[data-theme="dark"] .main-wrapper,
body[data-theme="dark"] .main-content,
body[data-theme="dark"] .content-area,
body[data-theme="dark"] .page-wrapper { background: var(--bg-main) !important; }

/* ── Topbar ── */
body[data-theme="dark"] .topbar,
body[data-theme="dark"] header.topbar {
  background: var(--bg-surface) !important;
  border-bottom: 1px solid var(--bg-border) !important;
  box-shadow: 0 1px 0 var(--bg-border) !important;
}
body[data-theme="dark"] .topbar-btn {
  color: var(--text-secondary) !important;
  background: transparent !important;
}
body[data-theme="dark"] .topbar-btn:hover {
  background: var(--bg-surface-2) !important;
  color: var(--text-primary) !important;
}
body[data-theme="dark"] .topbar-breadcrumb,
body[data-theme="dark"] .breadcrumb-item,
body[data-theme="dark"] .breadcrumb-item::before { color: var(--text-muted) !important; }
body[data-theme="dark"] .breadcrumb-item.active   { color: var(--text-secondary) !important; }
body[data-theme="dark"] .breadcrumb-item a        { color: var(--text-secondary) !important; }

/* ── Sidebar ── */
body[data-theme="dark"] .sidebar {
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%) !important;
  border-right: 1px solid #1e293b !important;
}
body[data-theme="dark"] .sidebar-brand         { border-bottom-color: rgba(255,255,255,.08) !important; }
body[data-theme="dark"] .sidebar-item          { color: #94a3b8 !important; }
body[data-theme="dark"] .sidebar-item:hover,
body[data-theme="dark"] .sidebar-item.active   { background: rgba(96,165,250,.12) !important; color: #93c5fd !important; }
body[data-theme="dark"] .sidebar-item.active   { border-left-color: #60a5fa !important; }
body[data-theme="dark"] .sidebar-section-title { color: #475569 !important; }
body[data-theme="dark"] .sidebar-footer        { border-top-color: rgba(255,255,255,.06) !important; color: #64748b !important; }

/* ── Cards ── */
body[data-theme="dark"] .card {
  background: var(--bg-surface) !important;
  border-color: var(--bg-border) !important;
  color: var(--text-primary) !important;
}
body[data-theme="dark"] .card-header {
  background: var(--bg-surface) !important;
  border-bottom: 1px solid var(--bg-border) !important;
}
body[data-theme="dark"] .card-header h5,
body[data-theme="dark"] .card-header h6  { color: var(--text-primary) !important; }
body[data-theme="dark"] .card-header .card-icon {
  background: rgba(96,165,250,.18) !important;
  color: #93c5fd !important;
}
body[data-theme="dark"] .card-body        { background: var(--bg-surface) !important; }

/* ── Stat cards ── */
body[data-theme="dark"] .stat-card {
  background: var(--bg-surface) !important;
  border-color: var(--bg-border) !important;
}
body[data-theme="dark"] .stat-card .value  { color: var(--text-primary) !important; }
body[data-theme="dark"] .stat-card .label  { color: var(--text-secondary) !important; }
body[data-theme="dark"] .stat-card .change { color: var(--text-muted) !important; }
body[data-theme="dark"] .stat-icon         { background: rgba(96,165,250,.18) !important; color: #93c5fd !important; }
body[data-theme="dark"] .stat-icon.azul    { background: rgba(59,130,246,.2) !important; color: #93c5fd !important; }
body[data-theme="dark"] .stat-icon.verde   { background: rgba(74,222,128,.15) !important; color: #4ade80 !important; }
body[data-theme="dark"] .stat-icon.oro     { background: rgba(251,191,36,.15) !important; color: #fbbf24 !important; }
body[data-theme="dark"] .stat-icon.rojo    { background: rgba(248,113,113,.15) !important; color: #f87171 !important; }

/* ── Tablas ── */
/* Forzar variable Bootstrap 5 + background en todos los niveles */
body[data-theme="dark"] .table-container         { background: var(--bg-surface) !important; border-color: var(--bg-border) !important; }
body[data-theme="dark"] .table                   { --bs-table-bg: transparent !important; --bs-table-striped-bg: transparent !important; --bs-table-hover-bg: rgba(255,255,255,.04) !important; color: var(--text-primary) !important; }
body[data-theme="dark"] .table > :not(caption) > * > *   { background-color: transparent !important; color: var(--text-primary) !important; border-bottom-color: var(--bg-border) !important; }
body[data-theme="dark"] table                    { color: var(--text-primary) !important; }
body[data-theme="dark"] thead th,
body[data-theme="dark"] thead td,
body[data-theme="dark"] .table thead th         { background: var(--bg-surface-2) !important; color: var(--text-secondary) !important; border-color: var(--bg-border) !important; }
/* Selector exacto Bootstrap 5 */
body[data-theme="dark"] .table > thead > tr > th,
body[data-theme="dark"] .table > thead > tr > td { background: var(--bg-surface-2) !important; color: var(--text-secondary) !important; }
body[data-theme="dark"] .table > tbody > tr > td,
body[data-theme="dark"] .table > tbody > tr > th { background: transparent !important; border-color: var(--bg-border) !important; color: var(--text-primary) !important; }
body[data-theme="dark"] tbody td,
body[data-theme="dark"] tbody th                { border-color: var(--bg-border) !important; color: var(--text-primary) !important; background: transparent !important; }
body[data-theme="dark"] tbody tr                { background: transparent !important; }
body[data-theme="dark"] tbody tr:hover,
body[data-theme="dark"] .table tbody tr:hover   { background: rgba(255,255,255,.04) !important; }
body[data-theme="dark"] tbody tr:hover td,
body[data-theme="dark"] tbody tr:hover th       { background: rgba(255,255,255,.04) !important; }
body[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * { background-color: rgba(255,255,255,.02) !important; }
body[data-theme="dark"] .table-toolbar         { background: var(--bg-surface) !important; border-bottom-color: var(--bg-border) !important; }
body[data-theme="dark"] .table-toolbar .title  { color: var(--text-primary) !important; }

/* ── Formularios ── */
body[data-theme="dark"] .form-control,
body[data-theme="dark"] .form-select,
body[data-theme="dark"] textarea.form-control {
  background: var(--bg-surface-2) !important;
  border-color: var(--bg-border) !important;
  color: var(--text-primary) !important;
}
body[data-theme="dark"] .form-control:focus,
body[data-theme="dark"] .form-select:focus {
  background: var(--bg-surface-2) !important;
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 3px rgba(59,130,246,.2) !important;
  color: var(--text-primary) !important;
}
body[data-theme="dark"] .form-control::placeholder  { color: var(--text-muted) !important; }
body[data-theme="dark"] .form-label                 { color: var(--text-secondary) !important; }
body[data-theme="dark"] .form-text                  { color: var(--text-muted) !important; }
body[data-theme="dark"] .form-check-label           { color: var(--text-secondary) !important; }
body[data-theme="dark"] .input-group-text {
  background: var(--bg-surface-2) !important;
  border-color: var(--bg-border) !important;
  color: var(--text-secondary) !important;
}
body[data-theme="dark"] .form-check-input {
  background-color: var(--bg-surface-2) !important;
  border-color: var(--bg-border) !important;
}
body[data-theme="dark"] .form-check-input:checked {
  background-color: #3b82f6 !important;
  border-color: #3b82f6 !important;
}

/* ── Dropdowns ── */
body[data-theme="dark"] .dropdown-menu {
  background: var(--bg-surface) !important;
  border: 1px solid var(--bg-border) !important;
  box-shadow: 0 8px 24px rgba(0,0,0,.5) !important;
}
body[data-theme="dark"] .dropdown-item          { color: var(--text-primary) !important; }
body[data-theme="dark"] .dropdown-item:hover,
body[data-theme="dark"] .dropdown-item:focus    { background: var(--bg-surface-2) !important; color: var(--text-primary) !important; }
body[data-theme="dark"] .dropdown-item.active   { background: rgba(59,130,246,.25) !important; color: #93c5fd !important; }
body[data-theme="dark"] .dropdown-divider        { border-color: var(--bg-border) !important; }
body[data-theme="dark"] .dropdown-header         { color: var(--text-muted) !important; font-size: 11px; }
body[data-theme="dark"] .dropdown-item-text      { color: var(--text-secondary) !important; }

/* ── Notificaciones ── */
body[data-theme="dark"] #notif-dropdown          { background: var(--bg-surface) !important; }
body[data-theme="dark"] #notif-dropdown .px-3    { border-bottom-color: var(--bg-border) !important; }
body[data-theme="dark"] #notif-dropdown strong   { color: #93c5fd !important; }
body[data-theme="dark"] #notif-dropdown .dropdown-item { border-bottom-color: var(--bg-border) !important; }
body[data-theme="dark"] #notif-dropdown .dropdown-item .fw-600 { color: var(--text-primary) !important; }
body[data-theme="dark"] #notif-dropdown .dropdown-item .text-muted { color: var(--text-muted) !important; }
body[data-theme="dark"] #notif-dropdown .bg-light { background: rgba(59,130,246,.12) !important; border-left: 2px solid #3b82f6 !important; }
body[data-theme="dark"] .notif-badge              { background: #ef4444 !important; }

/* ── Botones ── */
body[data-theme="dark"] .btn-primary             { background: #2563eb !important; border-color: #2563eb !important; color: #fff !important; }
body[data-theme="dark"] .btn-primary:hover       { background: #1d4ed8 !important; border-color: #1d4ed8 !important; }
body[data-theme="dark"] .btn-outline-primary     { color: #60a5fa !important; border-color: #60a5fa !important; background: transparent !important; }
body[data-theme="dark"] .btn-outline-primary:hover { background: rgba(96,165,250,.15) !important; color: #93c5fd !important; }
body[data-theme="dark"] .btn-outline-secondary   { color: var(--text-secondary) !important; border-color: var(--bg-border) !important; }
body[data-theme="dark"] .btn-outline-secondary:hover { background: var(--bg-surface-2) !important; }
body[data-theme="dark"] .btn-outline-danger      { color: #f87171 !important; border-color: #f87171 !important; }
body[data-theme="dark"] .btn-outline-success     { color: #4ade80 !important; border-color: #4ade80 !important; }
body[data-theme="dark"] .btn-action              { background: var(--bg-surface-2) !important; color: var(--text-secondary) !important; border-color: var(--bg-border) !important; }
body[data-theme="dark"] .btn-action:hover        { background: var(--bg-border) !important; color: var(--text-primary) !important; }

/* ── Badges ── */
body[data-theme="dark"] .badge.bg-primary        { background: #2563eb !important; color: #fff !important; }
body[data-theme="dark"] .badge.bg-success        { background: #16a34a !important; color: #fff !important; }
body[data-theme="dark"] .badge.bg-warning        { background: #d97706 !important; color: #fff !important; }
body[data-theme="dark"] .badge.bg-danger         { background: #dc2626 !important; color: #fff !important; }
body[data-theme="dark"] .badge.bg-secondary      { background: #475569 !important; color: #e2e8f0 !important; }
body[data-theme="dark"] .badge.bg-light          { background: var(--bg-surface-2) !important; color: var(--text-secondary) !important; }
body[data-theme="dark"] .badge.bg-dark           { background: #0f172a !important; color: #e2e8f0 !important; }
body[data-theme="dark"] [class*="badge"][style*="background:#DBEAFE"]  { background: rgba(59,130,246,.25) !important; color: #93c5fd !important; }
body[data-theme="dark"] [class*="badge"][style*="background:#DCFCE7"]  { background: rgba(74,222,128,.2) !important; color: #4ade80 !important; }
body[data-theme="dark"] [class*="badge"][style*="background:#FEF3C7"]  { background: rgba(251,191,36,.2) !important; color: #fbbf24 !important; }
body[data-theme="dark"] [class*="badge"][style*="background:#FEE2E2"]  { background: rgba(248,113,113,.2) !important; color: #f87171 !important; }
body[data-theme="dark"] [class*="badge"][style*="background:#F3E8FF"]  { background: rgba(167,139,250,.2) !important; color: #c4b5fd !important; }

/* ── Texto ── */
body[data-theme="dark"] h1,body[data-theme="dark"] h2,
body[data-theme="dark"] h3,body[data-theme="dark"] h4,
body[data-theme="dark"] h5,body[data-theme="dark"] h6 { color: var(--text-primary) !important; }
body[data-theme="dark"] p                { color: var(--text-secondary); }
body[data-theme="dark"] .text-muted      { color: var(--text-muted) !important; }
body[data-theme="dark"] .text-dark       { color: var(--text-primary) !important; }
body[data-theme="dark"] .text-secondary  { color: var(--text-secondary) !important; }
body[data-theme="dark"] .fw-600          { color: inherit; }
body[data-theme="dark"] small            { color: var(--text-muted) !important; }
/* Links dentro de contenido (no botones ni sidebar) */
body[data-theme="dark"] .card a:not(.btn):not(.dropdown-item):not(.sidebar-item) { color: #60a5fa; }
body[data-theme="dark"] .card a:not(.btn):not(.dropdown-item):not(.sidebar-item):hover { color: #93c5fd; }

/* ── Colores inline forzados ── */
body[data-theme="dark"] [style*="color:var(--unasam-azul)"]        { color: #93c5fd !important; }
body[data-theme="dark"] [style*="color:var(--unasam-verde)"]       { color: #4ade80 !important; }
body[data-theme="dark"] [style*="color:var(--unasam-oro)"]         { color: #fbbf24 !important; }
body[data-theme="dark"] [style*="color:var(--unasam-gris)"]        { color: #94a3b8 !important; }
body[data-theme="dark"] [style*="color:#1B3A6B"]                   { color: #93c5fd !important; }
body[data-theme="dark"] [style*="color:#1e40af"]                   { color: #93c5fd !important; }
body[data-theme="dark"] [style*="color:#14532D"],
body[data-theme="dark"] [style*="color:#166534"]                   { color: #4ade80 !important; }
body[data-theme="dark"] [style*="color:#713f12"],
body[data-theme="dark"] [style*="color:#92400e"]                   { color: #fbbf24 !important; }
body[data-theme="dark"] [style*="color:#374151"],
body[data-theme="dark"] [style*="color:#1f2937"],
body[data-theme="dark"] [style*="color:#111827"]                   { color: var(--text-primary) !important; }
body[data-theme="dark"] [style*="color:#6b7280"],
body[data-theme="dark"] [style*="color:#9ca3af"]                   { color: var(--text-muted) !important; }

/* Fondos inline claros → oscuro */
body[data-theme="dark"] [style*="background:white"],
body[data-theme="dark"] [style*="background: white"],
body[data-theme="dark"] [style*="background:#fff"],
body[data-theme="dark"] [style*="background: #fff"]                { background: var(--bg-surface) !important; }
body[data-theme="dark"] [style*="background:#f8fafc"],
body[data-theme="dark"] [style*="background:#F8FAFC"],
body[data-theme="dark"] [style*="background:#f1f5f9"],
body[data-theme="dark"] [style*="background:#F1F5F9"]              { background: var(--bg-surface-2) !important; }
body[data-theme="dark"] [style*="background:#DBEAFE"]              { background: rgba(59,130,246,.18) !important; }
body[data-theme="dark"] [style*="background:#DCFCE7"]              { background: rgba(74,222,128,.15) !important; }
body[data-theme="dark"] [style*="background:#FEF3C7"],
body[data-theme="dark"] [style*="background:#FEF9C3"]              { background: rgba(251,191,36,.15) !important; }
body[data-theme="dark"] [style*="background:#FEE2E2"]              { background: rgba(248,113,113,.15) !important; }
body[data-theme="dark"] [style*="background:#F3E8FF"]              { background: rgba(167,139,250,.15) !important; }
body[data-theme="dark"] [style*="background:var(--unasam-azul-claro)"] { background: rgba(59,130,246,.18) !important; }
body[data-theme="dark"] [style*="background:var(--unasam-gris-claro)"] { background: var(--bg-surface-2) !important; }

/* ── Page header ── */
body[data-theme="dark"] .page-header             { border-bottom-color: var(--bg-border) !important; background: transparent !important; }
body[data-theme="dark"] .page-header h1          { color: var(--text-primary) !important; }
body[data-theme="dark"] .page-header p           { color: var(--text-secondary) !important; }
body[data-theme="dark"] .page-title h1           { color: var(--text-primary) !important; }

/* ── Alertas ── */
body[data-theme="dark"] .alert                   { border-width: 1px; }
body[data-theme="dark"] .alert-info    { background: rgba(59,130,246,.12) !important; border-color: rgba(59,130,246,.3) !important; color: #93c5fd !important; }
body[data-theme="dark"] .alert-success { background: rgba(74,222,128,.1)  !important; border-color: rgba(74,222,128,.3)  !important; color: #4ade80 !important; }
body[data-theme="dark"] .alert-warning { background: rgba(251,191,36,.1)  !important; border-color: rgba(251,191,36,.3)  !important; color: #fbbf24 !important; }
body[data-theme="dark"] .alert-danger  { background: rgba(248,113,113,.1) !important; border-color: rgba(248,113,113,.3) !important; color: #f87171 !important; }
body[data-theme="dark"] .alert i       { opacity: .9; }

/* ── Filtros y barras de herramientas ── */
body[data-theme="dark"] .filter-bar             { background: var(--bg-surface) !important; border-color: var(--bg-border) !important; }
body[data-theme="dark"] .filter-bar label,
body[data-theme="dark"] .filter-bar span        { color: var(--text-secondary) !important; }

/* ── Modales ── */
body[data-theme="dark"] .modal-content          { background: var(--bg-surface) !important; border-color: var(--bg-border) !important; color: var(--text-primary) !important; }
body[data-theme="dark"] .modal-header           { border-bottom-color: var(--bg-border) !important; background: var(--bg-surface) !important; }
body[data-theme="dark"] .modal-body             { background: var(--bg-surface) !important; }
body[data-theme="dark"] .modal-footer           { border-top-color: var(--bg-border) !important; background: var(--bg-surface) !important; }
body[data-theme="dark"] .modal-title            { color: var(--text-primary) !important; }
body[data-theme="dark"] .btn-close              { filter: invert(1) grayscale(1) brightness(2); }

/* ── Progress bars ── */
body[data-theme="dark"] .progress               { background: var(--bg-surface-2) !important; }

/* ── Charts ── */
body[data-theme="dark"] .chart-header .chart-title  { color: var(--text-primary) !important; }
body[data-theme="dark"] canvas                       { filter: brightness(.95) contrast(1.05); }

/* ── Usuario topbar ── */
body[data-theme="dark"] [style*="background:var(--unasam-gris-claro)"][data-bs-toggle="dropdown"] {
  background: var(--bg-surface-2) !important;
}
body[data-theme="dark"] [style*="color:var(--unasam-azul)"][style*="font-weight:600"] { color: #93c5fd !important; }
body[data-theme="dark"] [style*="color:var(--unasam-gris)"] { color: var(--text-muted) !important; }

/* ── Scroll ── */
body[data-theme="dark"] ::-webkit-scrollbar        { width: 6px; height: 6px; }
body[data-theme="dark"] ::-webkit-scrollbar-track  { background: var(--bg-main); }
body[data-theme="dark"] ::-webkit-scrollbar-thumb  { background: #374151; border-radius: 3px; }
body[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #4b5563; }

/* ── Toggle icon ── */
#dark-mode-toggle  { transition: var(--transition); }
#dark-mode-icon    { transition: transform .35s ease, opacity .2s; }
body[data-theme="dark"] #dark-mode-icon { transform: rotate(20deg); }

/* =====================================================
   DARK MODE — FIXES ESPECÍFICOS v3
   Correcciones por módulo para inline styles problemáticos
   ===================================================== */

/* ── Lineas de Investigación ── */
/* Fila de línea (background:white + cursor:pointer) */
body[data-theme="dark"] [style*="background:white"][style*="cursor:pointer"],
body[data-theme="dark"] [style*="background: white"][style*="cursor:pointer"] {
  background: var(--bg-surface) !important;
}
body[data-theme="dark"] [style*="background:white"][style*="cursor:pointer"]:hover {
  background: var(--bg-surface-2) !important;
}
/* Contenido expandido sublineas (#fafafa) */
body[data-theme="dark"] [style*="background:#fafafa"],
body[data-theme="dark"] [style*="background: #fafafa"] {
  background: var(--bg-surface-2) !important;
}
/* Bordes internos de líneas */
body[data-theme="dark"] [style*="border-bottom:1px solid #f1f5f9"],
body[data-theme="dark"] [style*="border-top:1px solid #f1f5f9"] {
  border-color: var(--bg-border) !important;
}
/* Texto de sublineas y descripciones */
body[data-theme="dark"] [style*="color:#374151"]    { color: var(--text-secondary) !important; }
body[data-theme="dark"] [style*="color:#6b7280"]    { color: var(--text-muted) !important; }
body[data-theme="dark"] [style*="color:#9ca3af"]    { color: var(--text-muted) !important; }
body[data-theme="dark"] [style*="color:#111827"]    { color: var(--text-primary) !important; }
body[data-theme="dark"] [style*="color:#1f2937"]    { color: var(--text-primary) !important; }

/* ── Investigaciones — badges de tipo ── */
/* Los badges usan color hex + "18" como fondo: #1B3A6B18, #16653418, etc. */
/* En dark mode cambiar el texto a versión clara y el fondo a versión oscura semitransparente */
body[data-theme="dark"] [style*="color:#1B3A6B;background:#1B3A6B"] { color: #93c5fd !important; background: rgba(59,130,246,.2) !important; }
body[data-theme="dark"] [style*="color:#166534;background:#166534"] { color: #4ade80 !important; background: rgba(74,222,128,.15) !important; }
body[data-theme="dark"] [style*="color:#0891b2;background:#0891b2"] { color: #22d3ee !important; background: rgba(34,211,238,.15) !important; }
body[data-theme="dark"] [style*="color:#7C3AED;background:#7C3AED"] { color: #c4b5fd !important; background: rgba(196,181,253,.15) !important; }
body[data-theme="dark"] [style*="color:#92400e;background:#92400e"] { color: #fbbf24 !important; background: rgba(251,191,36,.15) !important; }
body[data-theme="dark"] [style*="color:#6b7280;background:#6b7280"] { color: #94a3b8 !important; background: rgba(148,163,184,.12) !important; }

/* Colores adicionales inline que faltan */
body[data-theme="dark"] [style*="color:#0891b2"] { color: #22d3ee !important; }
body[data-theme="dark"] [style*="color:#7C3AED"] { color: #c4b5fd !important; }
body[data-theme="dark"] [style*="color:#7c3aed"] { color: #c4b5fd !important; }
body[data-theme="dark"] [style*="color:#dc2626"] { color: #f87171 !important; }
body[data-theme="dark"] [style*="color:#d97706"] { color: #fbbf24 !important; }

/* ── Progress bar track ── */
body[data-theme="dark"] [style*="background:#e2e8f0"] { background: var(--bg-border) !important; }
body[data-theme="dark"] [style*="background: #e2e8f0"] { background: var(--bg-border) !important; }

/* ── Títulos con color fijo oscuro en tablas ── */
body[data-theme="dark"] td a[style*="color:#111827"],
body[data-theme="dark"] td [style*="color:#111827"] { color: var(--text-primary) !important; }
body[data-theme="dark"] td[style*="color:#374151"],
body[data-theme="dark"] td [style*="color:#374151"] { color: var(--text-secondary) !important; }

/* ── Fondos semi-transparentes inline claros ── */
body[data-theme="dark"] [style*="background:#f0f4ff"] { background: rgba(59,130,246,.15) !important; }
body[data-theme="dark"] [style*="background:#f0f9ff"] { background: rgba(34,211,238,.1) !important; }
body[data-theme="dark"] [style*="background:#fdf4ff"] { background: rgba(196,181,253,.1) !important; }
body[data-theme="dark"] [style*="background:#fff7ed"] { background: rgba(251,191,36,.1) !important; }
body[data-theme="dark"] [style*="background:#fef2f2"] { background: rgba(248,113,113,.1) !important; }

/* ── Stat card extra (lineas module) ── */
body[data-theme="dark"] [style*="border:1px solid #e2e8f0"] { border-color: var(--bg-border) !important; }
body[data-theme="dark"] [style*="border: 1px solid #e2e8f0"] { border-color: var(--bg-border) !important; }

/* ── Nota pie de página (lineas) ── */
body[data-theme="dark"] [style*="border-left:4px solid var(--unasam-azul)"] {
  background: rgba(59,130,246,.12) !important;
}
body[data-theme="dark"] [style*="border-left:4px solid var(--unasam-azul)"] [style*="color:#374151"] {
  color: var(--text-secondary) !important;
}

/* ── Chevron icon en collapse ── */
body[data-theme="dark"] [style*="color:#9ca3af"] { color: var(--text-muted) !important; }

/* ── Código de proyecto link ── */
body[data-theme="dark"] a[style*="color:var(--unasam-azul)"] { color: #60a5fa !important; }

/* ── Card header dinámico (lineas — usa $c['bg'] y $c['border']) ── */
/* Los colores de área son generados PHP, pero los card-headers heredan bien del selector general */
/* Forzar que el texto del código LL-01 sea legible */
body[data-theme="dark"] code[style*="background:"][style*="color:"] {
  opacity: .92;
  filter: brightness(1.3) saturate(.8);
}

/* ── Investigaciones: año y presupuesto ── */
body[data-theme="dark"] td[style*="font-weight:700;color:#374151"] { color: var(--text-secondary) !important; }
body[data-theme="dark"] td[style*="font-weight:600;font-size:12px"] { color: var(--text-secondary) !important; }

/* =====================================================
   DARK MODE FIXES v4 — Módulos específicos
   ===================================================== */

/* ── Fondos blancos en cards y containers ── */
body[data-theme="dark"] .card,
body[data-theme="dark"] .card-body,
body[data-theme="dark"] .card-header,
body[data-theme="dark"] .card-footer,
body[data-theme="dark"] [class*="chart-container"],
body[data-theme="dark"] .chart-wrapper { 
  background: var(--bg-surface) !important; 
  border-color: var(--bg-border) !important;
}

/* ── Tablas: filas blancas ── */
body[data-theme="dark"] tbody tr,
body[data-theme="dark"] tbody tr td,
body[data-theme="dark"] tbody tr th,
body[data-theme="dark"] .table tbody tr,
body[data-theme="dark"] .table tbody tr td { 
  background: var(--bg-surface) !important;
  background-color: var(--bg-surface) !important;
  --bs-table-bg: var(--bg-surface) !important;
  --bs-table-accent-bg: var(--bg-surface) !important;
  color: var(--text-primary) !important;
  border-color: var(--bg-border) !important;
}
body[data-theme="dark"] tbody tr:hover td,
body[data-theme="dark"] tbody tr:hover th {
  background: var(--bg-surface-2) !important;
  background-color: var(--bg-surface-2) !important;
}
body[data-theme="dark"] thead tr,
body[data-theme="dark"] thead tr th,
body[data-theme="dark"] thead tr td {
  background: #0f172a !important;
  background-color: #0f172a !important;
  color: #94a3b8 !important;
  border-color: var(--bg-border) !important;
}

/* ── Reportes: KPI cards con fondo blanco ── */
body[data-theme="dark"] [style*="background:white"],
body[data-theme="dark"] [style*="background: white"],
body[data-theme="dark"] [style*="background:#fff"],
body[data-theme="dark"] [style*="background: #fff"],
body[data-theme="dark"] [style*="background:#ffffff"],
body[data-theme="dark"] [style*="background: #ffffff"] { 
  background: var(--bg-surface) !important; 
}

/* ── Inputs y selects ── */
body[data-theme="dark"] input[type="text"],
body[data-theme="dark"] input[type="search"],
body[data-theme="dark"] input[type="email"],
body[data-theme="dark"] input[type="number"],
body[data-theme="dark"] select,
body[data-theme="dark"] textarea,
body[data-theme="dark"] .form-control,
body[data-theme="dark"] .form-select {
  background: #1e293b !important;
  background-color: #1e293b !important;
  border-color: #334155 !important;
  color: #e2e8f0 !important;
}
body[data-theme="dark"] input::placeholder { color: #64748b !important; }

/* ── Reportes: gauge/donut central y KPI cards ── */
body[data-theme="dark"] [style*="background:#f8fafc"],
body[data-theme="dark"] [style*="background: #f8fafc"],
body[data-theme="dark"] [style*="background:#F8FAFC"],
body[data-theme="dark"] [style*="background:#f1f5f9"],
body[data-theme="dark"] [style*="background: #f1f5f9"],
body[data-theme="dark"] [style*="background:#F1F5F9"] { 
  background: var(--bg-surface-2) !important; 
}

/* ── Líneas separadoras entre filas ── */
body[data-theme="dark"] tr { border-color: var(--bg-border) !important; }
body[data-theme="dark"] .border-bottom,
body[data-theme="dark"] [style*="border-bottom:1px solid #f1f5f9"],
body[data-theme="dark"] [style*="border-bottom: 1px solid #f1f5f9"],
body[data-theme="dark"] [style*="border-bottom:1px solid #e2e8f0"],
body[data-theme="dark"] [style*="border-bottom: 1px solid #e2e8f0"] { 
  border-color: var(--bg-border) !important; 
}

/* ── Bootstrap table override total ── */
body[data-theme="dark"] .table {
  --bs-table-bg: var(--bg-surface);
  --bs-table-striped-bg: var(--bg-surface-2);
  --bs-table-hover-bg: var(--bg-surface-2);
  --bs-table-border-color: var(--bg-border);
  --bs-table-color: var(--text-primary);
  color: var(--text-primary) !important;
}
body[data-theme="dark"] .table > * > tr > * {
  background-color: var(--bg-surface) !important;
  color: var(--text-primary) !important;
  border-bottom-color: var(--bg-border) !important;
}
body[data-theme="dark"] .table-hover > tbody > tr:hover > * {
  background-color: var(--bg-surface-2) !important;
}

/* ── Reportes: progress bars track ── */
body[data-theme="dark"] .progress { background: #1e293b !important; }
body[data-theme="dark"] [style*="background:#e2e8f0"],
body[data-theme="dark"] [style*="background: #e2e8f0"],
body[data-theme="dark"] [style*="background:#E2E8F0"] { 
  background: #334155 !important; 
}

/* ── Grupos: cards sin nombre (blancas) ── */
body[data-theme="dark"] .group-card,
body[data-theme="dark"] [class*="grupo"] .card { 
  background: var(--bg-surface) !important; 
}

/* ── Textos hardcoded oscuros ── */
body[data-theme="dark"] [style*="color:#1f2937"],
body[data-theme="dark"] [style*="color: #1f2937"],
body[data-theme="dark"] [style*="color:#111827"],
body[data-theme="dark"] [style*="color: #111827"],
body[data-theme="dark"] [style*="color:#0f172a"],
body[data-theme="dark"] [style*="color:#374151"],
body[data-theme="dark"] [style*="color: #374151"] { 
  color: var(--text-primary) !important; 
}
body[data-theme="dark"] [style*="color:#6b7280"],
body[data-theme="dark"] [style*="color:#64748b"],
body[data-theme="dark"] [style*="color:#9ca3af"],
body[data-theme="dark"] [style*="color:#94a3b8"] { 
  color: var(--text-muted) !important; 
}

/* ── Reportes: KPI card colors ── */
body[data-theme="dark"] small { color: #94a3b8 !important; }

/* ── Charts: fondo del canvas ── */
body[data-theme="dark"] canvas { background: transparent !important; }

/* ── Select2 ── */
body[data-theme="dark"] .select2-container--bootstrap-5 .select2-selection {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #e2e8f0 !important;
}
body[data-theme="dark"] .select2-dropdown {
  background: var(--bg-surface) !important;
  border-color: var(--bg-border) !important;
}
body[data-theme="dark"] .select2-results__option { color: var(--text-primary) !important; }
body[data-theme="dark"] .select2-results__option--highlighted { background: var(--bg-surface-2) !important; }

/* ── Pagination ── */
body[data-theme="dark"] .page-link {
  background: var(--bg-surface) !important;
  border-color: var(--bg-border) !important;
  color: var(--text-secondary) !important;
}
body[data-theme="dark"] .page-item.active .page-link { 
  background: #2563eb !important; 
  border-color: #2563eb !important; 
  color: white !important;
}

/* ── bg-white override ── */
body[data-theme="dark"] .bg-white { background: var(--bg-surface) !important; }
body[data-theme="dark"] .bg-light  { background: var(--bg-surface-2) !important; }

/* ── Usuarios: search box ── */
body[data-theme="dark"] [type="search"] {
  background: #1e293b !important;
  color: #e2e8f0 !important;
  border-color: #334155 !important;
}
