/* ==========================================================================
   SISTEMA DE DISEÑO INSTITUCIONAL — BIBLIOTECA DIGITAL & REPOSITORIO INSUCE
   Inspirado en Biblioteca Digital UAM (BiDi UAM) y Repositorio DSpace UAM-X
   - Paleta institucional sobria: Deep Navy, Gold Aniversario, Slate y White
   - Algoritmo de rejilla adaptable: Móvil, iPad/Tablet, Laptop y Desktop
   - Facetas bibliográficas con contadores y navegación académica
   ========================================================================== */

:root {
  --navy-dark: #072146;
  --navy-primary: #0A3663;
  --navy-light: #134E8A;
  --navy-surface: #0E2A47;

  --gold-primary: #C69214;
  --gold-light: #E0B034;
  --gold-soft: #FEF9E7;
  --gold-dark: #9A7008;

  --brand: #0A3663;
  --brand-soft: #EDF4FA;
  --brand-gradient: linear-gradient(135deg, #072146 0%, #0A3663 60%, #134E8A 100%);
  --background: #F1F5F9;
  --surface: #FFFFFF;
  --surface-alt: #F8FAFC;

  --border: #CBD5E1;
  --border-subtle: #E2E8F0;
  --text: #1E293B;
  --text-muted: #64748B;
  --link: #0A4C96;

  --success: #15803D;
  --success-bg: #DCFCE7;
  --warning: #B45309;
  --warning-bg: #FEF3C7;
  --danger: #B91C1C;
  --danger-bg: #FEE2E2;

  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 8px;
  --font: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  background-color: var(--background);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  max-width: 100vw;
  width: 100%;
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--background);
  color: var(--text);
  overflow-x: hidden;
  max-width: 100vw;
  width: 100%;
  position: relative;
  box-sizing: border-box;
}

img,
picture,
svg,
video {
  max-width: 100%;
  height: auto;
  box-sizing: border-box;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  color: var(--navy-dark);
}

/* Tipografía */
h1,
.h1 {
  font-size: 22px;
  font-weight: 800;
  color: var(--navy-dark);
  line-height: 1.3;
}

h2,
.h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy-dark);
  line-height: 1.35;
}

h3,
.h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--navy-dark);
  line-height: 1.4;
}

p {
  color: var(--text-muted);
  line-height: 1.5;
  font-size: 13px;
}

/* 1. Barra Superior Institucional (Encabezado UAM) */
.app-header {
  background: linear-gradient(90deg, #072146 0%, #0A3663 100%);
  color: #FFFFFF;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 3px solid var(--gold-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: #FFFFFF;
  text-decoration: none;
}

.app-brand:hover {
  color: #FFFFFF;
  text-decoration: none;
}

.app-brand-logo {
  height: 38px !important;
  max-height: 38px !important;
  width: auto !important;
  max-width: 150px !important;
  object-fit: contain !important;
  display: block;
}

.hero-brand-logo {
  height: 44px !important;
  max-height: 44px !important;
  width: auto !important;
  max-width: 170px !important;
  object-fit: contain !important;
  display: block;
  flex-shrink: 0;
}

.brand-text-block {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #FFFFFF;
  text-transform: uppercase;
}

.brand-subtitle {
  font-size: 11px;
  color: #CBD5E1;
  font-weight: 500;
}

.header-utility {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.lang-badge {
  font-size: 11px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.15);
  color: #FFFFFF;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.25);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.header-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--gold-primary);
  color: var(--navy-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.user-name {
  color: #FFFFFF;
  font-weight: 600;
  font-size: 13px;
}

.btn-logout {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #FFFFFF;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}

.btn-logout:hover {
  background: #B91C1C;
  border-color: #B91C1C;
  color: #FFFFFF;
  text-decoration: none;
}

.mobile-menu-btn {
  display: none;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #FFFFFF;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
}

.mobile-menu-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.mobile-nav-drawer {
  display: none;
  background: #072146;
  border-bottom: 3px solid var(--gold-primary);
  padding: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  z-index: 99;
  position: relative;
  width: 100%;
  box-sizing: border-box;
}

.mobile-nav-drawer.open {
  display: block !important;
}

.mobile-nav-group {
  margin-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 10px;
}

.mobile-nav-group:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.mobile-nav-heading {
  display: block;
  font-size: 10.5px;
  font-weight: 800;
  color: var(--gold-primary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.mobile-nav-link {
  display: block;
  padding: 8px 12px;
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  text-decoration: none;
  margin-bottom: 4px;
}

.mobile-nav-link:hover,
.mobile-nav-link.active {
  background: rgba(255, 255, 255, 0.12);
  color: var(--gold-light);
  text-decoration: none;
}

.mobile-nav-link.highlight {
  color: var(--gold-light);
  font-weight: 700;
}

.mobile-nav-link.admin {
  color: #93C5FD;
}

.mobile-nav-link.teacher {
  color: #6EE7B7;
}

/* 2. Barra de Navegación DSpace / UAM */
.nav-bar {
  background: #FFFFFF;
  border-bottom: 1px solid var(--border);
  padding: 0 var(--space-4);
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  max-width: 100vw;
  width: 100%;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.nav-bar::-webkit-scrollbar {
  height: 3px;
}

.nav-bar::-webkit-scrollbar-thumb {
  background: var(--gold-primary);
  border-radius: 3px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  border-bottom: 3px solid transparent;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.nav-link:hover {
  background-color: var(--surface-alt);
  color: var(--brand);
  text-decoration: none;
}

.nav-link.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
  font-weight: 700;
  background-color: var(--brand-soft);
}

.nav-sep {
  height: 18px;
  width: 1px;
  background: var(--border);
  margin: 0 4px;
}

/* 3. Contenedor Principal */
.app-container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-6);
  flex: 1;
  box-sizing: border-box;
}

/* 4. Breadcrumbs */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.breadcrumbs a {
  color: var(--link);
  font-weight: 500;
}

.breadcrumbs-sep {
  color: var(--border);
}

/* 5. Command Bar */
.command-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.command-bar-title h1 {
  font-size: 18px;
  margin: 0;
  color: var(--navy-dark);
}

.command-bar-title p {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 3px 0 0 0;
}

.command-bar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* 6. Buscador Hero BiDi UAM */
.search-hero-uam {
  background: linear-gradient(135deg, #072146 0%, #0A3663 100%);
  border-radius: var(--radius);
  padding: 28px;
  color: #FFFFFF;
  margin-bottom: var(--space-5);
  border: 1px solid #083B75;
  box-shadow: 0 4px 12px rgba(7, 33, 70, 0.15);
}

.search-hero-uam h1 {
  color: #FFFFFF;
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 6px;
}

.search-hero-uam p {
  color: #E2E8F0;
  font-size: 13.5px;
  margin-bottom: var(--space-4);
  max-width: 800px;
}

.search-form-uam {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 900px;
}

.search-box-row {
  display: flex;
  align-items: stretch;
  background: #FFFFFF;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.search-field-select {
  background: #F8FAFC;
  border: none;
  border-right: 1px solid var(--border);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  outline: none;
  cursor: pointer;
  min-width: 160px;
}

.search-input-uam {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  padding: 10px 16px;
  color: var(--text);
  font-family: inherit;
}

.btn-search-uam {
  background: var(--gold-primary);
  color: var(--navy-dark);
  font-weight: 700;
  font-size: 13px;
  border: none;
  padding: 0 22px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s ease;
}

.btn-search-uam:hover {
  background: var(--gold-light);
}

.search-links-row {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  padding-left: 4px;
}

.search-links-row a {
  color: #F8FAFC;
  text-decoration: none;
}

.search-links-row a:hover {
  color: var(--gold-light);
  text-decoration: underline;
}

/* 7. Cintillo de Métricas Institucionales (BiDi Strip) */
.metrics-strip {
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1px;
  background-color: var(--border-subtle);
  overflow: hidden;
  margin-bottom: var(--space-5);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.metric-box {
  background: #FFFFFF;
  padding: 14px 18px;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.metric-box-val {
  font-size: 24px;
  font-weight: 800;
  color: var(--navy-primary);
  line-height: 1.1;
}

.metric-box-lbl {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 4px;
}

/* 8. Tarjeta Comunidades DSpace */
.communities-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.community-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--navy-primary);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.community-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08);
  border-top-color: var(--gold-primary);
  text-decoration: none;
}

.community-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--brand-soft);
  color: var(--navy-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.community-card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy-dark);
  margin-bottom: 6px;
}

.community-card-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 14px;
}

.community-card-footer {
  font-size: 12px;
  font-weight: 700;
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
  margin-top: auto;
}

/* 9. Layout de 2 Columnas Estilo DSpace (Novedades + Facetas) */
.dspace-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: var(--space-6);
  margin-bottom: var(--space-6);
  align-items: start;
  width: 100%;
  box-sizing: border-box;
}

.dspace-catalog-layout {
  grid-template-columns: 300px 1fr;
}

@media (max-width: 1024px) {

  .dspace-layout,
  .dspace-catalog-layout {
    grid-template-columns: 1fr !important;
  }
}

.catalog-filter-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  width: 100%;
}

.catalog-filter-field {
  width: auto;
  min-width: 150px;
  font-weight: 600;
}

.catalog-filter-q {
  flex: 1;
  min-width: 220px;
}

.catalog-filter-sort {
  width: auto;
  min-width: 170px;
}

.mobile-facet-btn {
  display: none;
}

/* Tarjetas de Novedades / Items Bibliográficos */
.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.item-card:hover {
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
  border-color: var(--navy-light);
}

.item-type-badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.item-type-book {
  background: #DBEAFE;
  color: #1E40AF;
  border: 1px solid #BFDBFE;
}

.item-type-thesis {
  background: #FEF3C7;
  color: #92400E;
  border: 1px solid #FDE68A;
}

.item-type-course {
  background: #DCFCE7;
  color: #166534;
  border: 1px solid #BBF7D0;
}

.item-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy-dark);
  line-height: 1.35;
  margin-bottom: 6px;
}

.item-title a {
  color: var(--navy-dark);
}

.item-title a:hover {
  color: var(--brand);
}

.item-author {
  font-size: 13px;
  color: #334155;
  margin-bottom: 8px;
}

.item-author strong {
  color: var(--navy-dark);
}

.item-summary {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 12px;
}

.item-meta-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: #64748B;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

.item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* 10. Barra Lateral de Facetas (Otras Opciones Relacionadas DSpace) */
.facet-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.facet-header {
  background: var(--navy-dark);
  color: #FFFFFF;
  padding: 12px 16px;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.facet-group {
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
}

.facet-group:last-child {
  border-bottom: none;
}

.facet-group-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--navy-primary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.facet-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.facet-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  line-height: 1.35;
}

.facet-link {
  color: var(--text);
  text-decoration: none;
  flex: 1;
  padding-right: 8px;
}

.facet-link:hover {
  color: var(--brand);
  text-decoration: underline;
}

.facet-count {
  background: var(--surface-alt);
  color: #475569;
  font-weight: 700;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
}

/* 11. Grids del Panel Administrativo (Anti-colapso garantizado) */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  width: 100%;
}

.stat-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius);
  padding: 16px 18px;
  text-decoration: none;
  min-height: 100px;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.stat-card:hover {
  background-color: var(--surface-alt);
  border-color: var(--brand);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
  text-decoration: none;
}

.stat-card-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  margin-bottom: 4px;
}

.stat-card-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--brand);
  line-height: 1.2;
}

.stat-card-link {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--link);
  margin-top: 8px;
}

/* 12. Botones Institucionales */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.btn-primary {
  background-color: var(--navy-primary);
  border-color: var(--navy-dark);
  color: #FFFFFF !important;
}

.btn-primary:hover {
  background-color: var(--navy-dark);
  text-decoration: none;
}

.btn-gold {
  background-color: var(--gold-primary);
  border-color: var(--gold-dark);
  color: var(--navy-dark) !important;
  font-weight: 700;
}

.btn-gold:hover {
  background-color: var(--gold-light);
  text-decoration: none;
}

.btn-outline {
  background-color: transparent;
  border-color: var(--border);
  color: var(--text) !important;
}

.btn-outline:hover {
  background-color: var(--surface-alt);
  border-color: var(--text-muted);
  text-decoration: none;
}

.btn-secondary {
  background-color: #F8FAFC;
  border-color: var(--border);
  color: var(--text) !important;
}

.btn-secondary:hover {
  background-color: #EEF2F6;
  text-decoration: none;
}

.btn-subtle {
  background-color: transparent;
  color: var(--link) !important;
  padding: 4px 8px;
}

.btn-subtle:hover {
  background-color: var(--brand-soft);
  text-decoration: none;
}

/* 13. Formularios */
.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
}

.form-control {
  width: 100%;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

.form-control:focus {
  outline: none;
  border-color: var(--navy-primary);
  box-shadow: 0 0 0 3px rgba(10, 54, 99, 0.15);
}

/* 14. Tablas */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 12.5px;
}

.table th {
  background-color: #F8FAFC;
  color: var(--navy-dark);
  font-weight: 700;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 10px 14px;
  border-bottom: 2px solid var(--border);
}

.table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text);
}

.table tr:hover td {
  background-color: #F8FAFC;
}

/* 15. Tarjeta Base */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: var(--space-5);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* 16. Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}

.badge-brand {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: #BFDBFE;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
  border-color: #BBF7D0;
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: #FDE68A;
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: #FECACA;
}

.badge-neutral {
  background: #F1F5F9;
  color: var(--text-muted);
  border-color: var(--border);
}

/* 17. Infobars */
.infobar {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: var(--space-4);
  border-left: 4px solid var(--brand);
}

.infobar-success {
  background: var(--success-bg);
  border: 1px solid #BBF7D0;
  border-left: 4px solid var(--success);
  color: var(--success);
}

.infobar-danger {
  background: var(--danger-bg);
  border: 1px solid #FECACA;
  border-left: 4px solid var(--danger);
  color: var(--danger);
}

.infobar-warning {
  background: var(--warning-bg);
  border: 1px solid #FDE68A;
  border-left: 4px solid var(--warning);
  color: var(--warning);
}

/* 18. Pie de Página Institucional */
.app-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: #FFFFFF;
  padding: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* 19. Autenticación / Login */
.auth-page {
  min-height: 100vh;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  background-color: #E2E8F0 !important;
  padding: 20px !important;
}

.auth-card-wrap {
  width: 100% !important;
  max-width: 440px !important;
  margin: 0 auto !important;
}

.login-header {
  background-color: #072146 !important;
  padding: 26px 20px 22px !important;
  text-align: center !important;
  border-bottom: 3px solid var(--gold-primary) !important;
  color: #FFFFFF !important;
  border-radius: var(--radius) var(--radius) 0 0;
}

.login-header-title {
  color: #FFFFFF !important;
  font-size: 16px !important;
  font-weight: 800 !important;
  margin-top: 6px !important;
}

.login-header-sub {
  color: #CBD5E1 !important;
  font-size: 12px !important;
  margin-top: 2px !important;
}

/* 20. Oferta Académica y Carreras (Bento Grid) */
.programs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-4);
  width: 100%;
  margin-bottom: var(--space-5);
}

.program-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--navy-primary);
  border-radius: var(--radius);
  padding: 18px;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 140px;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.program-card:hover {
  transform: translateY(-2px);
  border-top-color: var(--gold-primary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  text-decoration: none;
}

.program-card-badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--navy-primary);
  background: var(--brand-soft);
  border: 1px solid #BFDBFE;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.program-card-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--navy-dark);
  line-height: 1.35;
  margin-bottom: 8px;
}

.program-card-footer {
  font-size: 12px;
  font-weight: 600;
  color: var(--link);
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* 21. Responsividad Multi-dispositivo */
@media (max-width: 640px) {
  .app-header {
    padding: 0 var(--space-4);
  }

  .app-container {
    padding: var(--space-3) var(--space-4);
  }

  .brand-subtitle {
    display: none;
  }

  .header-user .user-name {
    display: none;
  }

  .search-box-row {
    flex-direction: column;
  }

  .search-field-select {
    border-right: none;
    border-bottom: 1px solid var(--border);
    width: 100%;
  }

  .btn-search-uam {
    padding: 12px;
    justify-content: center;
  }

  .metrics-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .communities-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .programs-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 641px) and (max-width: 1024px) {

  /* iPad / Tablet */
  .metrics-strip {
    grid-template-columns: repeat(3, 1fr);
  }

  .communities-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .programs-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ==========================================================================
   22. COMPONENTES BIDI UAM MODERNOS (NOTICIAS, SLIDER, DESTACADOS, DIVISIONES)
   ========================================================================== */

/* Grid Principal Superior BiDi: Noticias/Slider Izquierda + Destacados Derecha */
.bidi-hero-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: var(--space-5);
  margin-bottom: var(--space-6);
  align-items: start;
}

/* Cabeceras de Pestaña con Color de Acento BiDi UAM */
.bidi-tab-header {
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #FFFFFF;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bidi-tab-yellow {
  background: #F59E0B;
  color: #78350F;
}

.bidi-tab-teal {
  background: #0D9488;
  color: #FFFFFF;
}

.bidi-tab-blue {
  background: var(--navy-primary);
  color: #FFFFFF;
}

/* Carrusel / Slider de Noticias y Novedades con Imagen */
.bidi-slider-wrap {
  position: relative;
  background: #072146;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  min-height: 290px;
}

.bidi-slide {
  display: none;
  position: relative;
  min-height: 290px;
  background-size: cover;
  background-position: center;
}

.bidi-slide.active {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.bidi-slide-overlay {
  background: linear-gradient(180deg, rgba(7, 33, 70, 0.2) 0%, rgba(7, 33, 70, 0.88) 60%, rgba(7, 33, 70, 0.98) 100%);
  padding: 24px;
  color: #FFFFFF;
}

.bidi-slide-tag {
  display: inline-block;
  background: #E11D48;
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.bidi-slide-title {
  font-size: 20px;
  font-weight: 800;
  color: #FFFFFF;
  line-height: 1.25;
  margin-bottom: 8px;
}

.bidi-slide-summary {
  font-size: 13px;
  color: #E2E8F0;
  line-height: 1.45;
  margin-bottom: 14px;
  max-width: 640px;
}

.bidi-slide-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.bidi-slider-dots {
  display: flex;
  gap: 6px;
}

.bidi-slider-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  cursor: pointer;
  border: none;
  padding: 0;
  transition: all 0.2s ease;
}

.bidi-slider-dot.active {
  background: #F59E0B;
  width: 24px;
  border-radius: 5px;
}

/* Columna Derecha: Lista de Recursos Destacados */
.bidi-highlights-wrap {
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.bidi-highlight-list {
  list-style: none;
}

.bidi-highlight-item {
  border-bottom: 1px dashed var(--border-subtle);
  padding: 10px 16px;
  transition: background 0.15s ease;
}

.bidi-highlight-item:last-child {
  border-bottom: none;
}

.bidi-highlight-item:hover {
  background: var(--surface-alt);
}

.bidi-highlight-title {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--navy-dark);
  text-decoration: none;
}

.bidi-highlight-title:hover {
  color: var(--brand);
}

.bidi-highlight-desc {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.35;
  margin-top: 2px;
}

.bidi-highlight-btn {
  display: block;
  text-align: center;
  background: #F59E0B;
  color: #78350F;
  font-weight: 800;
  font-size: 12.5px;
  padding: 10px;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  transition: background 0.15s ease;
}

.bidi-highlight-btn:hover {
  background: #D97706;
  color: #FFFFFF;
  text-decoration: none;
}

/* 4 Iconos de Acceso Rápido BiDi UAM (2x2 Grid) */
.bidi-quick-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 18px;
}

.bidi-quick-card {
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
  gap: 10px;
  transition: all 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.bidi-quick-card:hover {
  transform: translateY(-2px);
  border-color: var(--navy-primary);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
  text-decoration: none;
}

.bidi-quick-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--navy-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.bidi-quick-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--navy-dark);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Tiras de 5 Divisiones Académicas en Colores Vivos (BiDi UAM Campus Strip) */
.bidi-division-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: var(--space-6);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.bidi-division-tile {
  padding: 24px 16px 20px;
  color: #FFFFFF !important;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-decoration: none;
  transition: filter 0.15s ease;
  min-height: 140px;
}

.bidi-division-tile:hover {
  filter: brightness(1.08);
  text-decoration: none;
}

.bidi-tile-sport {
  background-color: #65A30D !important;
}

.bidi-tile-business {
  background-color: #EA580C !important;
}

.bidi-tile-law {
  background-color: #7C3AED !important;
}

.bidi-tile-nutrition {
  background-color: #0284C7 !important;
}

.bidi-tile-education {
  background-color: #DC2626 !important;
}

.bidi-tile-icon {
  font-size: 32px;
  margin-bottom: 6px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.bidi-tile-title {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #FFFFFF;
  line-height: 1.2;
}

.bidi-tile-count {
  font-size: 22px;
  font-weight: 900;
  color: #FFFFFF;
  margin-top: 10px;
}

.bidi-tile-sub {
  font-size: 10px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
  letter-spacing: 0.04em;
}

/* Cuadrícula de Recomendaciones con Imágenes (Imagen 2) */
.bidi-recommendations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: var(--space-6);
}

.bidi-rec-card {
  position: relative;
  height: 140px;
  border-radius: var(--radius);
  overflow: hidden;
  background-size: cover;
  background-position: center;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px 16px;
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.bidi-rec-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.15);
  text-decoration: none;
}

.bidi-rec-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(7, 33, 70, 0.85) 0%, rgba(10, 54, 99, 0.7) 100%);
  z-index: 1;
}

.bidi-rec-content {
  position: relative;
  z-index: 2;
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}

.bidi-rec-tag {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--gold-light);
  letter-spacing: 0.04em;
}

.bidi-rec-title {
  font-size: 15px;
  font-weight: 800;
  color: #FFFFFF;
  line-height: 1.25;
}

.bidi-rec-desc {
  font-size: 11.5px;
  color: #E2E8F0;
  line-height: 1.35;
}

/* Ilustraciones de Métricas (Imagen 3) */
.bidi-illus-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
  margin-bottom: var(--space-6);
  padding: 20px 10px;
  background: #FFFFFF;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.bidi-illus-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 8px 12px;
}

.bidi-illus-icon {
  font-size: 32px;
  margin-bottom: 6px;
}

.bidi-illus-val {
  font-size: 18px;
  font-weight: 800;
  color: var(--navy-dark);
}

.bidi-illus-lbl {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.3;
}

/* Banner Destacado Tipo Emerald (Imagen 3) */
.bidi-banner-emerald {
  background: linear-gradient(90deg, #65A30D 0%, #84CC16 100%);
  color: #FFFFFF;
  border-radius: var(--radius);
  padding: 24px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 18px;
  margin-bottom: var(--space-6);
  box-shadow: 0 4px 12px rgba(101, 163, 13, 0.2);
}

.bidi-banner-emerald h3 {
  font-size: 22px;
  font-weight: 900;
  color: #FFFFFF;
  margin-bottom: 4px;
}

.bidi-banner-emerald p {
  color: #F7FEE7;
  font-size: 13.5px;
  margin: 0;
  max-width: 680px;
}

/* ==========================================================================
   23. RESPONSIVIDAD INTEGRAL MULTI-DISPOSITIVO (TABLET, IPAD, MÓVIL)
   ========================================================================== */

@media (max-width: 1024px) {
  .app-container {
    padding: var(--space-4);
  }

  .bidi-hero-grid {
    grid-template-columns: 1fr;
  }

  .bidi-division-strip {
    grid-template-columns: repeat(3, 1fr);
  }

  .metrics-strip {
    grid-template-columns: repeat(3, 1fr);
  }

  .communities-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .programs-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .bidi-recommendations-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .bidi-illus-strip {
    grid-template-columns: repeat(3, 1fr);
  }
}


@media (max-width: 768px) {

  /* Header compacto en móvil */
  .app-header {
    padding: 0 12px;
    height: 56px;
    min-height: 56px;
  }

  .app-brand {
    gap: 8px;
    max-width: calc(100% - 130px);
  }

  .app-brand-logo {
    height: 32px !important;
    max-height: 32px !important;
    max-width: 105px !important;
  }

  .brand-title {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .brand-subtitle {
    display: none !important;
  }

  .lang-badge {
    display: none !important;
  }

  .header-utility {
    gap: 4px;
  }

  .header-user {
    gap: 4px;
  }

  .user-details-block {
    display: none !important;
  }

  .logout-text {
    display: none !important;
  }

  .btn-logout {
    padding: 6px 8px;
  }

  .mobile-menu-btn {
    display: inline-flex !important;
  }

  /* Barra de Navegación de pestañas */
  .nav-bar {
    padding: 0 10px;
    gap: 2px;
  }

  .nav-link {
    padding: 8px 10px;
    font-size: 11.5px;
  }

  /* Buscador Hero */
  .search-hero-uam {
    padding: 16px;
    border-radius: var(--radius);
  }

  .hero-brand-logo {
    height: 32px !important;
    max-height: 32px !important;
    max-width: 115px !important;
  }

  .search-box-row {
    flex-direction: column;
  }

  .search-field-select {
    width: 100% !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border) !important;
    padding: 10px 12px;
  }

  .search-input-uam {
    width: 100% !important;
    padding: 12px 14px;
  }

  .btn-search-uam {
    width: 100% !important;
    justify-content: center;
    padding: 12px;
  }

  .search-links-row {
    flex-direction: column;
    gap: 6px;
  }

  /* Catálogo y Filtros */
  .dspace-catalog-layout {
    grid-template-columns: 1fr !important;
  }

  .catalog-filter-bar {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .catalog-filter-bar select,
  .catalog-filter-bar input,
  .catalog-filter-bar button,
  .catalog-filter-bar a {
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box;
  }

  .mobile-facet-btn {
    display: inline-flex !important;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 10px;
    font-size: 13px;
    font-weight: 700;
  }

  .dspace-catalog-layout .facet-panel {
    display: none;
  }

  .dspace-catalog-layout .facet-panel.facet-panel-open {
    display: block !important;
    margin-bottom: 20px;
  }

  /* Slider y BiDi components */
  .bidi-slide {
    min-height: 290px;
  }

  .bidi-slide-overlay {
    padding: 16px;
  }

  .bidi-slide-title {
    font-size: 16px;
  }

  .bidi-slide-summary {
    font-size: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .bidi-quick-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .bidi-division-strip {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .bidi-recommendations-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .bidi-illus-strip {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 14px 6px;
  }

  .bidi-banner-emerald {
    flex-direction: column;
    align-items: flex-start;
    padding: 16px;
    gap: 12px;
  }

  .bidi-banner-emerald .btn {
    width: 100%;
    text-align: center;
  }

  /* Admin y Tablas */
  .command-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px;
  }

  .command-bar-actions {
    flex-direction: column;
    width: 100%;
    gap: 8px;
  }

  .command-bar-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .programs-grid {
    grid-template-columns: 1fr;
  }

  .cms-tabs {
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .card {
    padding: 14px;
  }

  .app-container {
    padding: 10px;
  }
}

@media (max-width: 420px) {
  .bidi-division-strip {
    grid-template-columns: 1fr;
  }

  .bidi-quick-grid {
    grid-template-columns: 1fr;
  }

  .bidi-illus-strip {
    grid-template-columns: 1fr;
  }

  .metrics-strip {
    grid-template-columns: 1fr;
  }

  .app-brand {
    max-width: calc(100% - 95px);
  }
}