/* ============================================================
   GSIC-EMIC – Bootstrap 5.3 overrides & custom components
   ============================================================ */

/* ---- Brand colours (override Bootstrap primary) ----------- */
:root {
  --bs-primary:              #2563eb;
  --bs-primary-rgb:          37, 99, 235;
  --bs-link-color-rgb:       37, 99, 235;
  --bs-link-hover-color-rgb: 29, 78, 216;
}

.btn-primary {
  --bs-btn-bg:               #2563eb;
  --bs-btn-border-color:     #2563eb;
  --bs-btn-hover-bg:         #1d4ed8;
  --bs-btn-hover-border-color: #1d4ed8;
  --bs-btn-active-bg:        #1e40af;
  --bs-btn-disabled-bg:      #2563eb;
  --bs-btn-disabled-border-color: #2563eb;
}

.btn-outline-primary {
  --bs-btn-color:            #2563eb;
  --bs-btn-border-color:     #2563eb;
  --bs-btn-hover-bg:         #2563eb;
  --bs-btn-hover-border-color: #2563eb;
  --bs-btn-active-bg:        #1d4ed8;
}

/* ---- Legacy variable aliases (used in inline styles) ------- */
:root, [data-bs-theme="light"] {
  --color-primary:        #2563eb;
  --color-primary-dark:   #1d4ed8;
  --color-text-secondary: #475569;
  --color-text-muted:     #94a3b8;
  --color-border:         #e2e8f0;
  --color-bg:             #ffffff;
  --color-bg-secondary:   #f8fafc;
  --color-bg-card:        #ffffff;
  --color-success:        #16a34a;
  --color-success-bg:     #f0fdf4;
  --color-error:          #dc2626;
  --color-error-bg:       #fef2f2;
  --color-warning:        #d97706;
  --color-warning-bg:     #fffbeb;
  --color-info:           #0284c7;
  --color-info-bg:        #f0f9ff;
  --navbar-bg:            #ffffff;
  --footer-bg:            #1e293b;
  --footer-text:          #cbd5e1;
  --shadow-sm:   0 1px 2px 0 rgba(0,0,0,.05);
  --shadow-md:   0 4px 6px -1px rgba(0,0,0,.1);
  --shadow-lg:   0 10px 15px -3px rgba(0,0,0,.1);
}

[data-bs-theme="dark"] {
  --color-primary:        #3b82f6;
  --color-primary-dark:   #2563eb;
  --color-text-secondary: #94a3b8;
  --color-text-muted:     #64748b;
  --color-border:         #334155;
  --color-bg:             #0f172a;
  --color-bg-secondary:   #1e293b;
  --color-bg-card:        #1e293b;
  --color-success:        #22c55e;
  --color-error:          #f87171;
  --color-warning:        #f59e0b;
  --navbar-bg:            #1e293b;
  --footer-bg:            #0f172a;
  --footer-text:          #94a3b8;
  --shadow-sm:   0 1px 2px 0 rgba(0,0,0,.3);
  --shadow-md:   0 4px 6px -1px rgba(0,0,0,.4);
}

/* ---- Loading ------------------------------------------------ */
.loading-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}

/* ---- Navbar ------------------------------------------------- */
.gsic-navbar {
  border-bottom: 1px solid var(--bs-border-color);
  box-shadow: var(--shadow-sm);
}

.navbar-logo {
  height: 38px;
  width: auto;
  flex-shrink: 0;
}

.brand-name { font-weight: 700; font-size: 1rem; line-height: 1.2; }
.brand-sub  { font-size: 0.7rem; opacity: .6; }

.lang-flag-switch {
  background: none;
  border: none;
  padding: 2px 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 1.2rem;
  line-height: 1;
  border-radius: 6px;
}
.lang-flag-switch:hover { background: var(--bs-secondary-bg); }

/* Las etiquetas de la barra nunca se parten en dos líneas («TFG y / TFM») */
.gsic-navbar .nav-link, .gsic-navbar .btn { white-space: nowrap; }
/* Barra completa en 1200–1399 px: enlaces algo más juntos para que quepa
   también con sesión iniciada (sección «Administración» de más) */
@media (min-width: 1200px) and (max-width: 1399.98px) {
  .gsic-navbar .navbar-nav { --bs-navbar-nav-link-padding-x: .4rem; }
}

/* Botón de tema claro/oscuro (navbar.js), junto a las banderas */
.theme-switch {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; flex-shrink: 0;
  padding: 0; border: none; border-radius: 6px;
  background: none; color: var(--bs-body-color);
}
.theme-switch:hover { background: var(--bs-secondary-bg); }
.theme-switch:focus-visible { outline: 2px solid var(--bs-primary); outline-offset: 2px; }
.lang-flag-switch .flag-active   { opacity: 1; }
.lang-flag-switch .flag-inactive { opacity: 0.35; filter: grayscale(40%); }
.lang-flag-switch:hover .flag-inactive { opacity: 0.65; }

/* Logotipo completo con variante para tema oscuro (components/groupLogo.js) */
.group-logo { display: block; }
.group-logo img { max-width: 100%; }
.group-logo-dark { display: none; }
[data-bs-theme="dark"] .group-logo-light { display: none; }
[data-bs-theme="dark"] .group-logo-dark { display: inline; }

/* ---- Hero --------------------------------------------------- */
.gsic-hero {
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
  color: #fff;
  padding: 4rem 0;
}

[data-bs-theme="dark"] .gsic-hero {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
}

.gsic-hero h1 {
  font-size: clamp(1.75rem, 4vw, 3rem);
  font-weight: 800;
}

.hero-badge {
  display: inline-block;
  padding: .3rem .8rem;
  background: rgba(255,255,255,.2);
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 999px;
  font-size: .8rem;
  color: #fff;
  backdrop-filter: blur(4px);
}

/* ---- Stat cards (hero) ------------------------------------- */
.stat-card {
  background: rgba(255,255,255,.15);
  border-radius: 12px;
  padding: 1.25rem;
  text-align: center;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,.2);
}

.stat-card .number { font-size: 2rem; font-weight: 800; color: #fff; line-height: 1; }
.stat-card .label  { font-size: .78rem; color: rgba(255,255,255,.8); margin-top: .25rem; }

/* ---- Page header ------------------------------------------- */
.page-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--bs-border-color);
}

.page-header h1 {
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  font-weight: 800;
  margin-bottom: .375rem;
}

.page-header p { color: var(--bs-secondary-color); margin: 0; }

/* ---- Section title ----------------------------------------- */
.section-title {
  font-size: 1.2rem;
  font-weight: 700;
  padding-bottom: .625rem;
  border-bottom: 2px solid var(--bs-primary);
  margin-bottom: 1.5rem;
}

/* ---- Person cards ------------------------------------------ */
.person-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1.25rem 1rem;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  transition: transform .15s, box-shadow .15s;
  height: 100%;
}

.person-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  color: inherit;
  text-decoration: none;
  border-color: var(--bs-primary);
}

.person-avatar {
  width: 80px; height: 80px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: .75rem;
  border: 2px solid var(--bs-primary);
}

.person-avatar-placeholder {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--bs-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: .75rem;
  flex-shrink: 0;
}

.person-card h3 { font-size: .95rem; font-weight: 600; margin-bottom: .2rem; }
.person-card p  { font-size: .8rem; color: var(--bs-secondary-color); margin: 0; }

/* ---- Person profile (detail) ------------------------------- */
.person-photo-large {
  width: 180px; height: 180px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--bs-primary);
}

.person-photo-placeholder {
  width: 180px; height: 180px;
  border-radius: 50%;
  background: var(--bs-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  font-weight: 700;
}

.person-social-links { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }

.social-link {
  padding: .2rem .7rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 999px;
  font-size: .78rem;
  text-decoration: none;
  color: var(--bs-body-color);
  transition: background .15s, color .15s;
}

.social-link:hover {
  background: var(--bs-primary);
  color: #fff;
  border-color: var(--bs-primary);
}

/* ---- Publications ------------------------------------------ */
.pub-group-title {
  padding-bottom: .4rem;
  margin-bottom: .75rem;
  border-bottom: 2px solid var(--bs-primary);
}
.pub-list { list-style: none; padding: 0; margin: 0; }

.pub-item {
  padding: 1rem 0;
  border-bottom: 1px solid var(--bs-border-color);
}

.pub-item:last-child { border-bottom: none; }
/* Los DOI/URL largos no tienen puntos de corte: permitir partirlos para no
   desbordar en pantallas estrechas */
.pub-ref { overflow-wrap: anywhere; }
.pub-title   { font-weight: 600; line-height: 1.4; margin-bottom: .25rem; }
.pub-authors { font-size: .875rem; color: var(--bs-secondary-color); margin-bottom: .2rem; }
.pub-authors a { color: var(--bs-primary); text-decoration: none; }
.pub-authors a:hover { text-decoration: underline; }
.pub-venue   { font-size: .85rem; color: var(--bs-secondary-color); }
.pub-year    { display: inline-block; font-size: .78rem; color: var(--bs-tertiary-color); margin-left: .4rem; }
.pub-links   { margin-top: .375rem; display: flex; gap: .4rem; flex-wrap: wrap; }

.pub-link {
  font-size: .75rem;
  padding: .15rem .55rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 6px;
  text-decoration: none;
  color: var(--bs-secondary-color);
  transition: background .15s, color .15s;
}

.pub-link:hover {
  background: var(--bs-primary-bg-subtle);
  border-color: var(--bs-primary);
  color: var(--bs-primary);
}

.pub-link-pdf { border-color: #dc2626; color: #dc2626; }
.pub-link-pdf:hover { background: #fee2e2; color: #dc2626; border-color: #dc2626; }

/* ---- Status badges (projects) ------------------------------ */
.status-active {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .72rem;
  font-weight: 600;
  color: #16a34a;
  background: #f0fdf4;
  padding: .2rem .625rem;
  border-radius: 999px;
  margin-bottom: .5rem;
}

[data-bs-theme="dark"] .status-active { color: #4ade80; background: #052e16; }

.status-finished {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .72rem;
  font-weight: 600;
  color: var(--bs-secondary-color);
  background: var(--bs-secondary-bg);
  padding: .2rem .625rem;
  border-radius: 999px;
  margin-bottom: .5rem;
}

.dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.dot-pulse { animation: dotPulse 1.5s infinite; }

@keyframes dotPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .3; }
}

/* ---- Tags / chips ------------------------------------------ */
.tag {
  display: inline-block;
  padding: .18rem .55rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 6px;
  font-size: .75rem;
  color: var(--bs-secondary-color);
}

.tag-primary {
  border-color: var(--bs-primary);
  color: var(--bs-primary);
  background: var(--bs-primary-bg-subtle, #eff6ff);
}

.chip {
  display: inline-block;
  padding: .25rem .75rem;
  background: var(--bs-primary-bg-subtle, #eff6ff);
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 500;
  color: var(--bs-primary);
}

/* ---- Team member chips (project detail) -------------------- */
.team-list { display: flex; flex-wrap: wrap; gap: .5rem; }

/* Equipo de un proyecto: rejilla alineada (más fácil de recorrer por apellidos) */
.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: .25rem .75rem;
}
/* En la rejilla, filas sencillas en vez de píldoras: los nombres largos
   ocupan dos líneas sin deformar la forma */
.team-grid .team-member-chip {
  width: 100%;
  align-items: center;
  background: transparent;
  border-color: transparent;
  border-radius: var(--bs-border-radius);
  padding: .3rem .5rem;
  line-height: 1.3;
}
.team-grid .team-member-chip:hover { background: var(--bs-primary-bg-subtle); border-color: transparent; }
.team-grid .team-avatar-sm, .team-grid .team-avatar-sm-placeholder { width: 32px; height: 32px; flex-shrink: 0; }
.team-grid .team-avatar-sm { border: 2px solid var(--bs-primary); }

/* Investigadores/as principales: una tarjeta por línea */
.pi-list { display: flex; flex-direction: column; gap: .75rem; }
.pi-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .75rem 1rem;
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius-lg);
}
/* Mismo aro azul que las fotos de personas del resto del sitio */
.pi-avatar { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; flex-shrink: 0; border: 2px solid var(--bs-primary); }
.pi-avatar-placeholder {
  display: flex; align-items: center; justify-content: center;
  background: var(--bs-primary); color: #fff; font-weight: 700; font-size: 1.25rem;
}
.pi-name { display: block; font-weight: 600; color: var(--bs-body-color); text-decoration: none; line-height: 1.3; }
.pi-card:hover .pi-name { color: var(--bs-primary); }
.min-w-0 { min-width: 0; }

.team-member-chip {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .3rem .75rem;
  background: var(--bs-secondary-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 999px;
  text-decoration: none;
  color: var(--bs-body-color);
  font-size: .875rem;
  transition: background .15s, color .15s;
}

.team-member-chip:hover {
  background: var(--bs-primary-bg-subtle);
  color: var(--bs-primary);
  border-color: var(--bs-primary);
}

.team-avatar-sm {
  width: 26px; height: 26px;
  border-radius: 50%;
  object-fit: cover;
}

.team-avatar-sm-placeholder {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--bs-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .65rem;
  font-weight: 700;
}

/* ---- Project logo -------------------------------------------- */
.project-logo-large {
  width: 220px;
  height: 220px;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid var(--bs-border-color);
  flex-shrink: 0;
}
@media (max-width: 575.98px) {
  .project-logo-large { width: 140px; height: 140px; }
}

/* Cabecera del proyecto: logo y datos en la misma fila desde tableta; en
   móvil, el logo encima. El bloque de texto ocupa el resto (min-width: 0
   para que un título largo se parta en líneas en vez de bajar de fila) */
.project-header { display: flex; flex-direction: column; align-items: flex-start; gap: 1.5rem; }
.project-header-info { flex: 1; min-width: 0; }
@media (min-width: 768px) {
  .project-header { flex-direction: row; align-items: center; }
  .project-header .project-logo-large { width: 160px; height: 160px; }
}

/* ---- Funders ----------------------------------------------- */
.funders-list { display: flex; flex-wrap: wrap; gap: .5rem; }

.funder-item {
  padding: .35rem .75rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 8px;
  font-size: .875rem;
  text-decoration: none;
  color: var(--bs-body-color);
}

a.funder-item:hover { border-color: var(--bs-primary); color: var(--bs-primary); }

/* ---- News card --------------------------------------------- */
.news-card {
  display: block;
  padding: 1rem 1.25rem;
  border-left: 3px solid var(--bs-primary);
  background: var(--bs-secondary-bg);
  border-radius: 0 8px 8px 0;
  margin-bottom: 1rem;
}
.news-card { position: relative; }   /* contiene el enlace extendido del título */
.news-card:hover { background: var(--bs-tertiary-bg); }
.news-card .stretched-link:focus-visible { outline: none; }
.news-card:has(.stretched-link:focus-visible) { outline: 2px solid var(--bs-primary); outline-offset: 2px; }

.news-date { font-size: .78rem; color: var(--bs-secondary-color); margin-bottom: .2rem; }

.news-img-thumb-main img { outline: 2px solid var(--bs-primary); outline-offset: 2px; }

/* ---- Empty state ------------------------------------------- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--bs-secondary-color);
}

.empty-icon { font-size: 3rem; display: block; margin-bottom: 1rem; }

/* ---- Back link --------------------------------------------- */
.back-link {
  display: inline-block;
  margin-bottom: 1.5rem;
  color: var(--bs-secondary-color);
  text-decoration: none;
  font-size: .875rem;
}

.back-link:hover { color: var(--bs-primary); }

/* ---- Divider ----------------------------------------------- */
.divider {
  border: none;
  border-top: 1px solid var(--bs-border-color);
  margin: 1.5rem 0;
}

/* ---- Footer ------------------------------------------------- */
footer#footer {
  background: var(--footer-bg, #1e293b);
  color: var(--footer-text, #cbd5e1);
  margin-top: auto;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 1.5rem 1.5rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

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

.footer-brand h3  { color: #fff; margin-bottom: .5rem; }
.footer-brand p   { font-size: .875rem; opacity: .8; }
.footer-links h4  { color: #fff; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; margin-bottom: .75rem; }
.footer-links ul  { list-style: none; padding: 0; margin: 0; }
.footer-links li  { margin-bottom: .35rem; }
.footer-links a   { color: var(--footer-text, #cbd5e1); font-size: .875rem; text-decoration: none; opacity: .8; }
.footer-links a:hover { opacity: 1; color: #fff; }
/* Encabezado de columna que además es enlace (Universidad de Valladolid) */
.footer-links h4 a { font-size: inherit; color: inherit; opacity: 1; }
.footer-links h4 a:hover { text-decoration: underline; }

.footer-bottom {
  border-top: 1px solid rgba(255,255,255,.1);
  padding-top: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .78rem;
  opacity: .7;
  flex-wrap: wrap;
  gap: .5rem;
}

/* ---- Admin layout ------------------------------------------ */
.admin-sidebar {
  background: var(--bs-body-bg);
  border-right: 1px solid var(--bs-border-color);
  min-height: calc(100vh - 60px);
}

@media (max-width: 992px) {
  .admin-sidebar {
    min-height: auto;
    border-right: none;
    border-bottom: 1px solid var(--bs-border-color);
  }
}

.admin-menu { padding: .5rem 0; }

.admin-menu a {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem 1.25rem;
  color: var(--bs-body-color);
  text-decoration: none;
  font-size: .875rem;
  transition: background .15s;
  white-space: nowrap;
}

.admin-menu a:hover { background: var(--bs-secondary-bg); color: var(--bs-primary); }

.admin-menu a.active {
  background: var(--bs-primary-bg-subtle, #eff6ff);
  color: var(--bs-primary);
  font-weight: 600;
  border-left: 3px solid var(--bs-primary);
  padding-left: calc(1.25rem - 3px);
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: .75rem;
}

.admin-header h2 { margin: 0; font-size: 1.375rem; }

/* ---- Toasts ------------------------------------------------- */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-width: 340px;
  width: calc(100% - 3rem);
}

.toast-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .875rem 1rem;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  animation: toastIn .25s ease;
  color: var(--bs-body-color);
}

.toast-item.success { border-left: 4px solid #16a34a; }
.toast-item.error   { border-left: 4px solid #dc2626; }
.toast-item.info    { border-left: 4px solid #0284c7; }
.toast-item.warning { border-left: 4px solid #d97706; }
.toast-icon { font-size: 1rem; flex-shrink: 0; }
.toast-item.success .toast-icon { color: #16a34a; }
.toast-item.error   .toast-icon { color: #dc2626; }
.toast-item.info    .toast-icon { color: #0284c7; }
.toast-item.warning .toast-icon { color: #d97706; }
.toast-msg { font-size: .875rem; }

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

/* ---- Contact grid ------------------------------------------ */
.contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; margin-top: 2rem; }
@media (max-width: 768px) { .contact-grid { grid-template-columns: 1fr; } }

/* ---- Person dropdown (ORCID author mapping) ---------------- */
.person-combobox .dropdown-menu { min-width: 260px; }
.person-combobox .person-list   { max-height: 200px; overflow-y: auto; }
.person-combobox .dropdown-item[data-value=""] { color: #6c757d; font-style: italic; }
.person-combobox .no-results { padding: .25rem .75rem; font-size: .875rem; color: #6c757d; font-style: italic; }

/* ---- Rich text editor --------------------------------------- */
.rich-editor-wrapper { margin-bottom: 1rem; }
.rich-editor-toolbar {
  display: flex;
  gap: .25rem;
  padding: .3rem .4rem;
  background: var(--bs-secondary-bg);
  border: 1px solid var(--bs-border-color);
  border-bottom: none;
  border-radius: .375rem .375rem 0 0;
}
.rich-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: .25rem;
  padding: .15rem .5rem;
  cursor: pointer;
  font-size: .9rem;
  color: var(--bs-body-color);
  transition: background .15s, border-color .15s;
}
.rich-btn:hover  { background: var(--bs-tertiary-bg); border-color: var(--bs-border-color); }
.rich-btn:active { background: var(--bs-secondary-bg); }
.rich-editor-content {
  border-top-left-radius: 0 !important;
  border-top-right-radius: 0 !important;
}
.rich-editor-content:focus { outline: none; }
.rich-sep { width: 1px; margin: .2rem .25rem; background: var(--bs-border-color); }
.rich-btn[aria-pressed="true"] { background: var(--bs-primary-bg-subtle); border-color: var(--bs-primary); color: var(--bs-primary); }
.rich-btn:focus-visible { outline: 2px solid var(--bs-primary); outline-offset: 1px; }
.rich-link-bar {
  display: flex; flex-wrap: wrap; gap: .4rem; align-items: center;
  padding: .4rem; background: var(--bs-secondary-bg);
  border: 1px solid var(--bs-border-color); border-bottom: none;
}
.rich-link-bar[hidden] { display: none; }
.rich-link-input { flex: 1 1 14rem; }
.rich-content a { color: var(--bs-primary); text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
/* En oscuro el azul principal no llega al contraste mínimo sobre el fondo (≈2,7:1) */
[data-bs-theme="dark"] .rich-content a { color: #60a5fa; }

/* Contenido enriquecido (editor y vista pública: noticias, proyectos, software).
   Las secciones (h2) son más pequeñas que el título de la página (h1) */
.rich-content { line-height: 1.8; }
.rich-content h2 { font-size: 1.2rem; font-weight: 600; line-height: 1.35; margin: 1.5rem 0 .5rem; }
.rich-content h2:first-child { margin-top: 0; }
.rich-content p { margin-bottom: 1rem; }
.rich-content ul { padding-left: 1.4rem; margin-bottom: 1rem; }
.rich-content li { margin-bottom: .25rem; }
.rich-content li::marker { color: var(--bs-primary); }
.rich-editor-content.rich-content p:last-child, .rich-content > :last-child { margin-bottom: 0; }

/* ---- GitHub banner (Software) --------------------------------- */
.github-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--bs-border-color);
  border-radius: .625rem;
  background: var(--bs-tertiary-bg);
  color: var(--bs-body-color);
  text-decoration: none;
  transition: border-color .15s, box-shadow .15s;
}
.github-banner:hover {
  color: var(--bs-body-color);
  border-color: var(--color-primary);
  box-shadow: 0 2px 10px rgba(0,0,0,.06);
}
.github-banner-text { display: flex; flex-direction: column; line-height: 1.35; }
.github-banner-text span { font-size: .85rem; color: var(--bs-secondary-color); }
.github-banner-arrow { margin-left: auto; font-size: 1.25rem; color: var(--color-primary); }

/* ---- Journal quartile badges ---------------------------------- */
.quartile-badge {
  display: inline-block;
  font-size: .7rem;
  font-weight: 700;
  padding: .15rem .5rem;
  border-radius: .375rem;
  line-height: 1.2;
}
.quartile-q1 { background: #dcfce7; color: #15803d; }
.quartile-q2 { background: #dbeafe; color: #1d4ed8; }
.quartile-q3 { background: #fef9c3; color: #a16207; }
.quartile-q4 { background: #f3f4f6; color: #4b5563; }
[data-bs-theme="dark"] .quartile-q1 { background: #052e16; color: #4ade80; }
[data-bs-theme="dark"] .quartile-q2 { background: #172554; color: #93c5fd; }
[data-bs-theme="dark"] .quartile-q3 { background: #422006; color: #fde047; }
[data-bs-theme="dark"] .quartile-q4 { background: #1f2937; color: #9ca3af; }

/* ---- Thesis genealogy diagram --------------------------------- */
/* Eje temporal vertical: una fila por año; tarjetas con foto;
   líneas director → doctorando en una capa SVG posicionada debajo. */

/* Cada director de tesis tiene su propio tono (repartidos por ángulo áureo
   en genealogy.js, uno por persona sin límite de cuántas haya) para
   identificar linajes a simple vista sin depender del hover. --gen-hue lo
   fija cada tarjeta/arista inline; --gen-sat/--gen-light se definen aquí por
   tema para que el contraste se ajuste solo al cambiar de claro a oscuro. */
:root, [data-bs-theme="light"] {
  --gen-sat: 65%;
  --gen-light: 42%;
}
[data-bs-theme="dark"] {
  --gen-sat: 65%;
  --gen-light: 62%;
}
.gen-card.gen-colored .gen-photo { border-color: hsl(var(--gen-hue) var(--gen-sat) var(--gen-light)); }
.gen-edge.gen-colored { stroke: hsl(var(--gen-hue) var(--gen-sat) var(--gen-light)); }
.gen-scroll {
  overflow-x: auto;
  padding-bottom: .5rem;
}
.gen-canvas {
  position: relative;
  width: max-content;
  min-width: 100%;
}
.gen-edges {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.gen-edge {
  fill: none;
  stroke: var(--color-primary);
  stroke-width: 1.5;
  opacity: .45;
  transition: opacity .15s, stroke-width .15s;
}
.gen-row {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: 1.1rem 0;
  border-top: 1px dashed var(--bs-border-color);
}
.gen-row:first-of-type { border-top: none; }
.gen-yearlabel {
  flex: 0 0 3.2rem;
  position: sticky;
  left: 0;
  font-weight: 700;
  color: var(--bs-secondary-color);
  font-variant-numeric: tabular-nums;
  background: var(--bs-body-bg);
  z-index: 2;
}
.gen-cells {
  display: flex;
  flex: 1;
  justify-content: center;
  align-items: flex-start;
  gap: 1.75rem;
}
.gen-card {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 9.5rem;
  text-align: center;
  text-decoration: none;
  color: var(--bs-body-color);
  transition: opacity .15s;
}
.gen-card-nolink { cursor: default; }
.gen-photo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--color-primary);
  background: var(--bs-tertiary-bg);
  transition: box-shadow .15s, transform .15s;
}
.gen-photo-initials {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--color-primary);
}
.gen-card:hover .gen-photo {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-primary) 30%, transparent);
  transform: scale(1.05);
}
.gen-name {
  margin-top: .4rem;
  font-size: .82rem;
  font-weight: 600;
  line-height: 1.25;
}
a.gen-card:hover .gen-name { text-decoration: underline; }
.gen-thesis {
  margin-top: .15rem;
  font-size: .72rem;
  line-height: 1.3;
  color: var(--bs-secondary-color);
}
.gen-thesis-title { display: block; font-style: italic; }
.gen-thesis-date  { display: block; margin-top: .1rem; font-weight: 600; }
/* Hover: atenuar lo no relacionado y realzar las tesis de la persona */
.gen-focus .gen-card:not(.gen-on) { opacity: .22; }
.gen-focus .gen-edge:not(.gen-on) { opacity: .08; }
.gen-focus .gen-edge.gen-on { opacity: .95; stroke-width: 2.5; }
@media (max-width: 576px) {
  .gen-card { width: 7.5rem; }
  .gen-cells { gap: 1rem; }
  .gen-photo { width: 52px; height: 52px; }
}

/* Zoom semántico del árbol: cada nivel quita información para compactar.
   Nivel 3 (por defecto): foto + nombre + título y fecha de la tesis.
   Nivel 2: foto + nombre.  Nivel 1: solo fotos (nombre en tooltip). */
.gen-zoom-2 .gen-thesis { display: none; }
.gen-zoom-2 .gen-card  { width: 6.5rem; }
.gen-zoom-2 .gen-photo { width: 48px; height: 48px; }
.gen-zoom-2 .gen-name  { font-size: .76rem; }
.gen-zoom-2 .gen-cells { gap: 1rem; }
.gen-zoom-2 .gen-row   { padding: .8rem 0; }

.gen-zoom-1 .gen-thesis { display: none; }
.gen-zoom-1 .gen-name   { display: none; }
.gen-zoom-1 .gen-card   { width: 3rem; }
.gen-zoom-1 .gen-photo  { width: 38px; height: 38px; }
.gen-zoom-1 .gen-photo-initials { font-size: .7rem; }
.gen-zoom-1 .gen-cells  { gap: .6rem; }
.gen-zoom-1 .gen-row    { padding: .5rem 0; }
.gen-zoom-1 .gen-yearlabel { font-size: .85rem; flex-basis: 2.6rem; }

/* ---- Print -------------------------------------------------- */
@media print {
  header, footer, #toast-container, .modal,
  .btn, .admin-sidebar { display: none !important; }
  body { color: #000; background: #fff; }
  .pub-item { break-inside: avoid; }
}

/* ---- Analíticas (panel de administración) ---- */
.stats-viz {
  --viz-surface: #fcfcfb;
  --viz-ink:     #0b0b0b;
  --viz-ink-2:   #52514e;
  --viz-muted:   #898781;
  --viz-grid:    #e1e0d9;
  --viz-axis:    #c3c2b7;
  --viz-s1:      #2a78d6;   /* visitas */
  --viz-s2:      #008300;   /* visitantes únicos */
  /* Ficha de persona: publicaciones por año, 3 grupos en tonos de un azul
     (validados: monotonía, ΔL entre vecinos y contraste del tono claro).
     Más relevante = más contraste con el fondo. */
  --viz-pub-journals:    #1d4f91;
  --viz-pub-conferences: #2a78d6;
  --viz-pub-other:       #7aaee8;
}
[data-bs-theme="dark"] .stats-viz {
  --viz-surface: #1a1a19;
  --viz-ink:     #ffffff;
  --viz-ink-2:   #c3c2b7;
  --viz-grid:    #2c2c2a;
  --viz-axis:    #383835;
  --viz-s1:      #3987e5;
  /* En oscuro se invierte: el tono más luminoso es el que más destaca */
  --viz-pub-journals:    #a9cbf5;
  --viz-pub-conferences: #3987e5;
  --viz-pub-other:       #1f5aa8;
}
.stats-card {
  background: var(--viz-surface);
  border: 1px solid var(--viz-grid);
  border-radius: .5rem;
  padding: 1rem 1.25rem;
}
.stats-tile .stats-tile-label { color: var(--viz-ink-2); font-size: .85rem; }
.stats-tile .stats-tile-value { color: var(--viz-ink); font-size: 2rem; font-weight: 600; line-height: 1.2; }
.stats-legend { display: flex; gap: 1rem; font-size: .85rem; color: var(--viz-ink-2); flex-wrap: wrap; }
.stats-legend .key { display: inline-block; width: 18px; height: 0; border-top: 2px solid; border-radius: 2px; vertical-align: middle; margin-right: .35rem; }
.stats-chart-wrap { position: relative; }
.stats-chart-wrap svg { display: block; width: 100%; height: auto; }
.stats-chart-wrap:focus-visible { outline: 2px solid var(--viz-s1); outline-offset: 2px; border-radius: .25rem; }
.stats-tooltip {
  position: absolute; pointer-events: none; z-index: 10; display: none;
  background: var(--viz-surface); border: 1px solid var(--viz-grid); border-radius: .4rem;
  padding: .45rem .65rem; font-size: .8rem; color: var(--viz-ink-2);
  box-shadow: 0 2px 8px rgba(0,0,0,.12); min-width: 9rem;
}
.stats-tooltip .tip-date { color: var(--viz-muted); margin-bottom: .15rem; }
.stats-tooltip .tip-val { color: var(--viz-ink); font-weight: 600; }
.stats-bar-row { display: grid; grid-template-columns: minmax(8rem, 18rem) 1fr auto; gap: .75rem; align-items: center; padding: .3rem 0; }
.stats-bar-row .bar-label { font-size: .875rem; color: var(--viz-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats-bar-row .bar-label a { color: inherit; }
.stats-bar-track { display: block; min-width: 40px; }
.stats-bar-fill { display: block; height: 12px; background: var(--viz-s1); border-radius: 0 4px 4px 0; min-width: 2px; }
.stats-bar-row .bar-value { font-variant-numeric: tabular-nums; font-size: .875rem; color: var(--viz-ink-2); }
.stats-table td, .stats-table th { font-size: .875rem; }
.stats-table .num { font-variant-numeric: tabular-nums; text-align: right; }

/* ---- Selector múltiple con buscador (components/multiPicker.js) ---- */
.multi-picker .mp-list { background: var(--bs-body-bg); }
.multi-picker .mp-item { display: flex; gap: .5rem; align-items: flex-start; cursor: pointer; border-bottom: 1px solid var(--color-border); margin: 0; }
.multi-picker .mp-item[hidden] { display: none; }
.multi-picker .mp-item:last-of-type { border-bottom: none; }
.multi-picker .mp-item:hover { background: var(--color-bg-secondary); }
.multi-picker .mp-detail { font-size: .75rem; }
/* Selección ordenada (ordered: true), p. ej. IP1, IP2 */
.multi-picker .mp-order { border: 1px solid var(--bs-border-color); border-radius: var(--bs-border-radius); background: var(--bs-tertiary-bg); }
.multi-picker .mp-order[hidden] { display: none; }
.multi-picker .mp-order-item { display: flex; align-items: center; gap: .5rem; padding: .25rem .5rem; border-bottom: 1px solid var(--bs-border-color); }
.multi-picker .mp-order-item:last-child { border-bottom: none; }
.multi-picker .mp-order-n {
  flex-shrink: 0; width: 1.4rem; height: 1.4rem; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bs-primary); color: #fff; font-size: .75rem; font-weight: 600;
}
.multi-picker .mp-order-item .btn:disabled { visibility: hidden; }

/* ---- Desglose del ranking (citations.js#rankingDetail) ----- */
.pub-ranking { margin-top: .25rem; line-height: 1.7; }
.pub-ranking .quartile-badge { font-size: .65rem; }

/* ---- Mapa estático con varios marcadores (components/staticMap.js) ---- */
.static-map {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  background: var(--color-bg-secondary);
}
.static-map-layer { position: absolute; left: 50%; top: 50%; width: 0; height: 0; }
.static-map-layer img {
  position: absolute; width: 256px; height: 256px; max-width: none;
  user-select: none; pointer-events: none;
}
/* Mismo tono que el resto de la web en modo oscuro, sin perder legibilidad */
[data-bs-theme="dark"] .static-map-layer img { filter: brightness(.8) contrast(1.1); }
.static-map-pin {
  position: absolute;
  transform: translate(-50%, -100%);
  display: block; width: 28px; height: 40px;
  text-decoration: none;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.35));
}
.static-map-pin svg { display: block; }
.static-map-pin path { fill: var(--pin-color); stroke: #fff; stroke-width: 1.5; }
.static-map-pin span {
  position: absolute; top: 5px; left: 0; width: 100%;
  text-align: center; font-size: .75rem; font-weight: 700; color: #fff;
}
.static-map-pin:hover, .static-map-pin:focus-visible { z-index: 2; filter: drop-shadow(0 3px 4px rgba(0,0,0,.5)); }
.static-map-pin:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; border-radius: 4px; }
.static-map-attrib {
  position: absolute; right: 0; bottom: 0;
  padding: 0 .4rem; font-size: .7rem;
  background: rgba(255,255,255,.85); color: #333;
  border-top-left-radius: 6px;
}
/* Siempre sobre fondo claro (las teselas), también en modo oscuro */
.static-map-attrib a { color: #0b57d0; }

/* ---- Ficha de persona: cabecera compacta y resumen de actividad ---- */
.person-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1.25rem;
  align-items: center;
}
.person-header .person-social-links { margin-top: 0; }
.person-photo-header {
  width: 112px; height: 112px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--bs-primary);
}
.person-photo-header-initials {
  display: flex; align-items: center; justify-content: center;
  background: var(--bs-primary); color: #fff;
  font-size: 2.25rem; font-weight: 700;
}
.person-contact li { margin-bottom: .25rem; color: var(--bs-secondary-color); overflow-wrap: anywhere; }
@media (max-width: 768px) {
  .person-header { grid-template-columns: auto 1fr; gap: 1rem; }
  .person-contact { grid-column: 1 / -1; }
  .person-photo-header { width: 80px; height: 80px; }
  .person-photo-header-initials { font-size: 1.6rem; }
}

.person-summary-card {
  border: 1px solid var(--bs-border-color);
  border-radius: .75rem;
  padding: 1rem 1.25rem;
  background: var(--bs-body-bg);
}
.person-stats { font-size: .95rem; }
.person-stats strong { font-size: 1.15rem; }

/* Publicaciones por año (personSummary.js): tokens --viz-* de .stats-viz */
.pyc-wrap { position: relative; }
.pyc-bars {
  display: flex; align-items: stretch; gap: 2px;
  height: 120px;
  border-bottom: 1px solid var(--viz-axis);
}
.pyc-col {
  flex: 1 1 0;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  outline: none;
}
.pyc-bar {
  /* Pila continua de tramos (revistas abajo), sin separación: los tres tonos
     ya se distinguen por luminosidad. Solo la parte superior va redondeada */
  display: flex; flex-direction: column;
  width: 100%; min-height: 3px;
  border-radius: 4px 4px 0 0; overflow: hidden;
  transition: filter .15s;
}
.pyc-seg { display: block; flex-basis: 0; min-height: 2px; }
.pyc-journals    { background: var(--viz-pub-journals); }
.pyc-conferences { background: var(--viz-pub-conferences); }
.pyc-other       { background: var(--viz-pub-other); }
.pyc-legend { display: flex; flex-wrap: wrap; gap: .25rem 1rem; margin: 0 0 .5rem; font-size: .8rem; color: var(--viz-ink-2); }
.pyc-legend li { display: inline-flex; align-items: center; gap: .35rem; }
.pyc-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.pyc-col.active .pyc-bar { filter: brightness(1.2); }
.pyc-col:focus-visible .pyc-bar { outline: 2px solid var(--viz-ink); outline-offset: 1px; }
.pyc-peak { font-size: .75rem; line-height: 1rem; color: var(--viz-ink-2); font-variant-numeric: tabular-nums; }
.pyc-years { display: flex; justify-content: space-between; font-size: .75rem; color: var(--viz-muted); margin-top: .2rem; }
.pyc-tooltip {
  position: absolute; transform: translateX(-50%);
  display: none; pointer-events: none; white-space: nowrap; z-index: 5;
  background: var(--viz-surface); border: 1px solid var(--viz-grid); border-radius: .4rem;
  padding: .3rem .55rem; font-size: .8rem; color: var(--viz-ink);
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}

/* Coautores del grupo */
.person-coauthors li { display: flex; align-items: center; gap: .5rem; padding: .2rem 0; }
.person-coauthors a { display: flex; align-items: center; gap: .5rem; min-width: 0; flex: 1; text-decoration: none; color: var(--bs-body-color); }
.person-coauthors a:hover .coauthor-name { text-decoration: underline; }
.coauthor-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.coauthor-initials {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bs-secondary-bg); color: var(--bs-secondary-color);
  font-size: .7rem; font-weight: 700;
}
.coauthor-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.coauthor-count { font-variant-numeric: tabular-nums; color: var(--bs-secondary-color); font-size: .85rem; }

/* Cifras del resumen como enlaces a su sección (personSummary.js) */
.person-stat-link {
  background: none; border: 0; padding: 0; font: inherit; color: inherit;
  text-decoration: underline dotted; text-underline-offset: 3px; cursor: pointer;
}
.person-stat-link:hover, .person-stat-link:focus-visible { color: var(--bs-primary); text-decoration-style: solid; }
#person-tabs, .pub-type-section { scroll-margin-top: 90px; }
.pub-type-section h2:focus { outline: none; }
.pub-type-section h2:focus-visible { outline: 2px solid var(--bs-primary); outline-offset: 4px; }

/* ---- Tarjetas pulsables enteras (patrón "stretched link") ----
   Un único enlace real (el título, con .stretched-link) cuyo ::after cubre
   toda la tarjeta: el lector de pantalla solo anuncia el título y el
   teclado tiene una sola parada por tarjeta. */
.card-clickable { transition: transform .15s, box-shadow .15s, border-color .15s; }
.card-clickable:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--bs-primary);
}
/* El foco del título se muestra como anillo de toda la tarjeta */
.card-clickable .stretched-link:focus-visible { outline: none; }
.card-clickable:has(.stretched-link:focus-visible) {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
}
/* Enlaces internos (web, repositorio…) por encima del enlace extendido */
.card-clickable .card-inner-links { position: relative; z-index: 2; }

/* ---- Galería de noticias y visor en modal (components/lightbox.js) ---- */
.news-gallery-main {
  display: block; width: 100%; padding: 0; border: 0; background: none;
  border-radius: var(--bs-border-radius-lg, .5rem); overflow: hidden; cursor: zoom-in;
}
.news-gallery-main img { display: block; width: 100%; max-height: 400px; object-fit: cover; transition: transform .3s; }
.news-gallery-main:hover img { transform: scale(1.015); }
.news-gallery-thumbs { display: flex; gap: .5rem; flex-wrap: wrap; }
.news-gallery-thumb {
  padding: 0; border: 0; background: none; border-radius: .4rem; overflow: hidden; cursor: zoom-in;
  width: 72px; height: 72px; flex-shrink: 0;
}
.news-gallery-thumb img { width: 100%; height: 100%; object-fit: cover; transition: opacity .15s; }
.news-gallery-thumb:hover img { opacity: .8; }
.news-gallery-main:focus-visible, .news-gallery-thumb:focus-visible { outline: 3px solid var(--bs-primary); outline-offset: 2px; }

html.lightbox-open { overflow: hidden; }
.lightbox {
  width: 100vw; height: 100vh; max-width: 100vw; max-height: 100vh;
  margin: 0; padding: 0; border: 0; background: transparent;
}
.lightbox::backdrop { background: rgba(0, 0, 0, .9); }
.lightbox-inner {
  position: relative; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center; gap: .5rem; padding: 3rem 1rem;
}
.lightbox-figure { margin: 0; display: flex; flex-direction: column; align-items: center; max-width: 100%; max-height: 100%; }
.lightbox-img {
  max-width: min(100%, 1400px); max-height: calc(100vh - 7rem);
  object-fit: contain; border-radius: .4rem; user-select: none; touch-action: pan-y;
}
.lightbox-counter { color: #e5e7eb; font-size: .9rem; margin-top: .6rem; font-variant-numeric: tabular-nums; }
.lightbox-btn {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: rgba(255, 255, 255, .15); color: #fff; font-size: 1.6rem; line-height: 1;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.lightbox-btn:hover { background: rgba(255, 255, 255, .3); }
.lightbox-btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.lightbox-close { position: absolute; top: .75rem; right: .75rem; font-size: 1.1rem; }
@media (max-width: 576px) {
  /* En móvil las flechas van encima de la foto para no restarle ancho */
  .lightbox-prev, .lightbox-next { position: absolute; bottom: 1rem; }
  .lightbox-prev { left: 1rem; }
  .lightbox-next { right: 1rem; }
  .lightbox-inner { padding: 3rem .5rem 4.5rem; }
}
