/* ================================
   IMPORTAR FUENTES
   ================================ */
@import url("https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap");

/* ================================
   VARIABLES DE COLOR Y TIPOGRAFÍA
   ================================ */
:root {
  /* Variables de color */
  --primary-color: #ab1738;
  --primary-dark: #8b1229;
  --primary-light: #c4355a;
  --accent-color: #0b1f4c;
  --success-color: #16a34a;
  --success-light: #22c55e;
  --background-gradient: #fff;
  --card-gradient: linear-gradient(135deg, #ffffff, #fafafa);
  --header-gradient: linear-gradient(90deg, #ab1738, #0b1f4c, #ab1738);
  --badge-gradient: linear-gradient(135deg, #fef2f2, #fecaca);
  --active-badge-gradient: linear-gradient(135deg, #f0fdf4, #dcfce7);
  --active-color: #16a34a;
  --active-light: #22c55e;
  --text-primary: #0b1f4c;
  --text-secondary: #6b7280;

  /* Variables de tipografía */
  --font-family-primary: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  --font-family-monospace: "Courier New", Monaco, "Consolas", monospace;

  /* Tamaños de fuente */
  --font-size-xs: 0.75rem; /* 12px */
  --font-size-sm: 0.875rem; /* 14px */
  --font-size-base: 1rem; /* 16px */
  --font-size-lg: 1.125rem; /* 18px */
  --font-size-xl: 1.25rem; /* 20px */
  --font-size-2xl: 1.5rem; /* 24px */
  --font-size-3xl: 1.875rem; /* 30px */
  --font-size-4xl: 2.25rem; /* 36px */
  --font-size-5xl: 3rem; /* 48px */

  /* Pesos de fuente */
  --font-weight-light: 300;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --font-weight-extrabold: 800;

  /* Alturas de línea */
  --line-height-tight: 1.25;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.625;
  --line-height-loose: 2;
}

/* ================================
   ESTILOS GLOBALES
   ================================ */
* {
  font-family: var(--font-family-primary);
}

/* Preservar fuentes para iconos */
.dashicons,
.dashicons-before:before,
.fa,
.fas,
.far,
.fal,
.fab,
.material-icons,
.material-symbols-outlined,
.ion,
.icon,
[class^="icon-"],
[class*=" icon-"],
[class^="dashicons-"],
[class*=" dashicons-"],
[class^="fa-"],
[class*=" fa-"],
.arrow {
  font-family: dashicons, "Font Awesome 5 Free", "Font Awesome 5 Pro",
    FontAwesome, "Ionicons", "Material Icons", "Material Symbols Outlined",
    serif !important;
}

/* ================================
   POPOVER STYLES
   ================================ */

.popover {
  color: var(--text-primary);
  max-width: 100% !important;
}

.popover .popover-header {
  background-color: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
}

.popover .popover-body {
  font-size: var(--font-size-sm);
  color: var(--text-primary);
}

/* ================================
   TABLAS
   ================================ */

.table-container {
  text-align: left;
  margin-top: 50px;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: center;
}

td {
  border: 1px solid #ccc;
  padding: 8px;
}

tbody tr:hover {
  background-color: #ffffdd;
}

/* ================================
   GALERÍA DE PROYECTOS COMPLETA
   ================================ */

.proyectos-galeria-completa {
  padding: 20px 0;
  max-width: 90%;
  margin: 0 auto;
}

/* ================================
   FILTROS Y BÚSQUEDA
   ================================ */

.proyectos-filtros {
  background: var(--card-gradient);
  border-radius: 16px;
  padding: 30px;
  margin-bottom: 30px;
  box-shadow: 0 4px 15px rgba(171, 23, 56, 0.08);
}

.filtros-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 30px;
  flex-wrap: wrap;
}

.busqueda-container {
  position: relative;
  flex: 1;
  max-width: 400px;
}

.busqueda-input {
  width: 100%;
  padding: 15px 20px 15px 50px;
  border: 2px solid #dee2e6;
  border-radius: 25px;
  font-size: var(--font-size-base);
  font-family: var(--font-family-primary);
  transition: all 0.3s ease;
  background: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.busqueda-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 4px 12px rgba(171, 23, 56, 0.15);
}

.busqueda-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--font-size-lg);
  color: var(--text-secondary);
  pointer-events: none;
}

.filtros-botones {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Hide native radio buttons */
.filtros-botones input[type="radio"] {
  display: none;
}

.filtro-btn {
  padding: 12px 24px;
  border: 2px solid #dee2e6;
  background: white;
  color: var(--text-secondary);
  border-radius: 25px;
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-sm);
  font-family: var(--font-family-primary);
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filtro-btn:hover {
  border-color: var(--primary-light);
  color: var(--primary-dark);
  background: linear-gradient(135deg, #fef2f2, #fecaca);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(171, 23, 56, 0.1);
}

.filtro-btn.active {
  background: var(--badge-gradient);
  border-color: var(--primary-light);
  color: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(171, 23, 56, 0.15);
}

/* ================================
   INFORMACIÓN DE RESULTADOS
   ================================ */

.resultados-info {
  margin-bottom: 25px;
  text-align: center;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 12px;
  border-left: 4px solid var(--primary-color);
  border-right: 4px solid var(--primary-color);
}

.contador-proyectos {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  font-weight: var(--font-weight-medium);
}

.numero-proyectos {
  font-weight: var(--font-weight-bold);
  color: var(--primary-color);
  font-size: var(--font-size-lg);
}

.no-resultados {
  text-align: center;
  padding: 60px 20px;
  background: #f8f9fa;
  border-radius: 16px;
  margin: 40px 0;
  border: 2px dashed #dee2e6;
}

.no-resultados p {
  font-size: var(--font-size-lg);
  color: var(--text-secondary);
  margin: 0;
  font-style: italic;
}

/* ================================
   GRID DE PROYECTOS
   ================================ */

.proyectos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 30px;
  padding: 20px;
}

/* ================================
   TARJETAS DE PROYECTO
   ================================ */

.proyecto-card {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(0, 0, 0, 0.05);
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 400px;
  opacity: 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
  box-sizing: border-box;
  /* Initially hidden for animation */
}

.proyecto-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 40px rgba(171, 23, 56, 0.12);
  border-color: var(--primary-color);
}

.proyecto-card.hover-effect {
  transform: translateY(-12px) scale(1.02);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
}

/* ================================
   HEADER DE TARJETA
   ================================ */

.proyecto-header {
  padding: 25px 25px 20px;
  display: flex;
  align-items: flex-start;
  gap: 20px;
  border-bottom: 1px solid #f0f0f0;
}

.proyecto-logo {
  flex-shrink: 0;
  width: 120px;
  height: 0;
  padding-bottom: 81.6px; /* 120px * 0.68 = 81.6px para mantener aspecto 500x340 */
  background: #f8f9fa;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 2px solid #e9ecef;
  position: relative;
}

.proyecto-logo img {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  border-radius: 8px;
}

.proyecto-info {
  flex: 1;
  min-width: 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
  overflow: hidden;
}

.proyecto-titulo {
  margin: 0 0 8px 0;
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  line-height: var(--line-height-tight);
  word-wrap: break-word;
  font-family: var(--font-family-primary);
}

.proyecto-descripcion-titulo {
  margin-bottom: 10px !important;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin: 4px 0 8px 0;
  font-weight: var(--font-weight-normal);
  font-style: italic;
  line-height: var(--line-height-tight);
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  word-break: break-word;
  max-width: 100%;
  overflow: hidden;
}

.proyecto-card:hover .proyecto-descripcion-titulo {
  color: var(--text-primary);
}

/* Improved header structure */
.proyecto-header-mejorado {
  margin-bottom: 12px;
}

.proyecto-acronimo {
  margin: 0 0 6px 0;
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  line-height: var(--line-height-tight);
  word-wrap: break-word;
  font-family: var(--font-family-primary);
}

.proyecto-descripcion-completa {
  margin: 0 0 8px 0;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: var(--line-height-normal);
  font-style: italic;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-clamp: 2;
  overflow: hidden;
}

.proyecto-referencia {
  display: inline-block;
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--primary-dark)
  );
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.proyecto-fechas {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-top: 8px;
}

.fecha-inicio,
.fecha-fin {
  font-weight: var(--font-weight-medium);
}

.separador {
  color: #999;
}

/* ================================
   DESCRIPCIÓN DE TARJETA
   ================================ */

.proyecto-descripcion {
  padding: 0 25px;
  flex: 1;
  display: flex;
  align-items: flex-start;
}

.proyecto-descripcion p {
  color: var(--text-secondary);
  line-height: var(--line-height-relaxed);
  margin: 0;
  font-size: var(--font-size-base);
}

/* ================================
   FOOTER DE TARJETA
   ================================ */

.proyecto-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-top: 1px solid #f0f0f0;
  background: #fafbfc;
  border-radius: 0 0 12px 12px;
  gap: 15px;
}

.proyecto-estado-info {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}

.proyecto-estado-info .estado {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 15px;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  width: fit-content;
}

.proyecto-estado-info .estado.activo {
  background: var(--active-badge-gradient);
  color: var(--active-color);
  border: 1px solid;
  border-color: var(--active-light);
}

.proyecto-estado-info .estado.finalizado {
  background: #f2f2f2;
  color: var(--text-secondary);
  border: 1px solid;
  border-color: #d1d1d1;
}

.proyecto-estado-info .programa-financiacion {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 15px;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #f0f4ff, #e0e7ff);
  color: var(--accent-color);
  border: 1px solid;
  border-color: var(--accent-color);
  width: fit-content;
}

/* ================================
   BOTÓN VER PROYECTO MEJORADO
   ================================ */
.btn-ver-proyecto {
  padding: 8px 16px;
  background: linear-gradient(135deg, #f8f9fa, #e9ecef);
  color: var(--primary-dark) !important;
  text-decoration: none;
  border: 1px solid var(--primary-light);
  border-radius: 20px;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  font-family: var(--font-family-primary);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.btn-ver-proyecto:hover {
  background: var(--badge-gradient);
  color: var(--primary-dark) !important;
  border-color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(171, 23, 56, 0.15);
}

.btn-ver-proyecto:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(171, 23, 56, 0.2);
}

.btn-ver-proyecto .arrow {
  font-style: normal;
  font-weight: bold;
  transition: transform 0.3s ease;
  margin-bottom: 0.2rem;
}

.btn-ver-proyecto:hover .arrow {
  transform: translateX(3px);
}

/* ================================
   PAGINACIÓN SIMPLE
   ================================ */

.paginacion-simple {
  margin-top: 40px;
  padding: 20px 0;
  text-align: center;
  border-top: 1px solid #e1e5e9;
}

.paginacion-info {
  margin-bottom: 15px;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

.paginacion-botones {
  display: flex;
  justify-content: center;
  gap: 15px;
  align-items: center;
}

.paginacion-btn {
  display: inline-block;
  padding: 10px 20px;
  background-color: var(--primary-color);
  color: white !important;
  text-decoration: none;
  border-radius: 5px;
  font-weight: var(--font-weight-medium);
  font-family: var(--font-family-primary);
  transition: all 0.3s ease;
  border: none;
  cursor: pointer;
}

.paginacion-btn:hover {
  background-color: var(--primary-dark);
  color: white;
  text-decoration: none;
  transform: translateY(-1px);
}

.paginacion-btn {
  background-color: var(--primary-color);
}

.paginacion-btn:hover {
  background-color: var(--primary-dark);
}

/* ================================
   RESPONSIVE DESIGN
   ================================ */

@media (max-width: 768px) {
  .proyectos-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 10px 5px;
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
    align-items: stretch;
  }

  .proyecto-card {
    min-height: 450px;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
    overflow: hidden;
    flex-shrink: 0;
  }

  .proyecto-header {
    padding: 20px 15px 15px;
    flex-direction: column;
    text-align: center;
    gap: 15px;
    align-items: center;
    justify-content: center;
  }

  .proyecto-info {
    text-align: center;
    width: 100%;
    max-width: 100%;
    padding: 0 10px;
    box-sizing: border-box;
    overflow: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
    flex-shrink: 1;
    min-width: 0;
  }

  .proyecto-logo {
    width: 100px;
    height: 0;
    padding-bottom: 68px; /* 100px * 0.68 = 68px para mantener aspecto 500x340 */
    margin: 0 auto;
  }

  .proyecto-titulo {
    font-size: var(--font-size-xl);
    text-align: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    word-break: break-word;
    max-width: 100%;
    margin: 0 auto 8px auto;
    padding: 0 5px;
    line-height: 1.2;
  }

  .proyecto-acronimo {
    font-size: var(--font-size-xl);
    text-align: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    word-break: break-word;
    max-width: 100%;
    margin: 0 auto 6px auto;
    padding: 0 5px;
    line-height: 1.2;
  }

  .proyecto-descripcion-completa {
    font-size: var(--font-size-sm);
    text-align: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    word-break: break-word;
    max-width: 100%;
    margin: 0 auto 8px auto;
    padding: 0 5px;
    line-height: 1.3;
  }

  .proyecto-descripcion {
    padding: 0 15px;
    text-align: center;
    min-height: 60px;
    width: 100%;
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    overflow: hidden;
  }

  .proyecto-descripcion p {
    text-align: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    word-break: break-word;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 0 5px;
    line-height: 1.4;
    box-sizing: border-box;
    overflow: hidden;
  }

  .proyecto-footer {
    padding: 15px 15px;
    flex-direction: column;
    gap: 15px;
    text-align: center;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .proyecto-estado-info {
    text-align: center;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
  }

  .btn-ver-proyecto {
    align-self: center;
    text-align: center;
  }

  .proyecto-descripcion-titulo {
    font-size: var(--font-size-sm);
    margin: 3px 0 6px 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    word-break: break-word;
    max-width: 100%;
    overflow: hidden;
  }

  /* Filtros responsive */
  .filtros-container {
    flex-direction: column;
    gap: 20px;
    text-align: center;
  }

  .busqueda-container {
    max-width: 100%;
  }

  .filtros-botones {
    justify-content: center;
  }

  .proyectos-filtros {
    padding: 20px;
  }

  /* Paginación responsive */
  .paginacion-botones {
    flex-direction: column;
    gap: 10px;
  }

  .paginacion-btn {
    width: 100%;
    max-width: 200px;
  }

  .paginacion-info {
    font-size: var(--font-size-xs);
  }
}

@media (max-width: 480px) {
  .proyecto-titulo {
    font-size: var(--font-size-lg);
    text-align: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    word-break: break-word;
    max-width: 100%;
    margin: 0 auto 6px auto;
    padding: 0 3px;
    line-height: 1.1;
  }

  .proyecto-acronimo {
    font-size: var(--font-size-lg);
    text-align: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    word-break: break-word;
    max-width: 100%;
    margin: 0 auto 4px auto;
    padding: 0 3px;
    line-height: 1.1;
  }

  .proyecto-descripcion-completa {
    font-size: var(--font-size-xs);
    -webkit-line-clamp: 1;
    line-clamp: 1;
    text-align: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    word-break: break-word;
    max-width: 100%;
    margin: 0 auto 6px auto;
    padding: 0 3px;
    line-height: 1.2;
  }

  .proyecto-header {
    padding: 15px 10px;
    text-align: center;
    align-items: center;
    justify-content: center;
  }

  .proyecto-info {
    text-align: center;
    width: 100%;
    padding: 0 5px;
    box-sizing: border-box;
    overflow: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  .proyecto-descripcion {
    padding: 0 10px;
    text-align: center;
  }

  .proyecto-descripcion p {
    text-align: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    word-break: break-word;
    max-width: 100%;
    margin: 0 auto;
    padding: 0 3px;
    line-height: 1.3;
    font-size: var(--font-size-sm);
  }

  .proyecto-footer {
    padding: 12px 10px;
    text-align: center;
    align-items: center;
    justify-content: center;
  }

  .filtro-btn {
    padding: 10px 18px;
    font-size: var(--font-size-sm);
  }

  .busqueda-input {
    padding: 12px 16px 12px 45px;
    font-size: var(--font-size-base);
  }

  .busqueda-icon {
    left: 15px;
    font-size: var(--font-size-base);
  }

  /* Asegurar que el contenedor de información del proyecto maneje bien el overflow en móviles */
  .proyecto-info {
    overflow: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
}
