@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700&display=swap');

/* =============== VARIABLES GLOBALES (Opcional, pero útil) =============== */
:root {
  --primary-color: #6a1b9a; /* Morado principal */
  --secondary-color: #4a148c; /* Morado secundario */
  --accent-color: #ff6b35; /* Naranja acento */
  --accent-color-hover: #f7931e; /* Naranja acento hover */
  --text-color-light: white;
  --text-color-dark: #333;
  --card-bg-light: rgba(255, 255, 255, 0.95);
}

/* =============== CÓDIGO BASE =============== */
html {
  height: 100%;
  /* Color de fondo de último recurso, si todo lo demás falla o el video no carga */
  background-color: #121212;
}

body, html { /* html ya tiene height: 100% y background-color */
  margin: 0;
  padding: 0;
  font-family: 'Montserrat', sans-serif;
  height: 100%; /* body también necesita height 100% para ocupar el viewport */
  overflow-x: hidden; /* Prevenir scroll horizontal */
}

body {
  /* Hacemos el fondo del body transparente para que se vea el video de atrás */
  background-color: transparent;
}

/* =============== VIDEO DE FONDO =============== */
.video-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -10; /* Detrás de todo el contenido normal del body */
  pointer-events: none; /* No interferir con clicks */
  overflow: hidden;
  /* Opcional: un color de fondo aquí si el iframe del video no se carga y queda transparente */
  /* background-color: #000; */
}

#background-video {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100vw;
  height: 56.25vw; /* Proporción 16:9 (100 * 9 / 16) */
  min-height: 100vh;
  min-width: 177.77vh; /* Proporción 16:9 (100 * 16 / 9) */
  transform: translate(-50%, -50%);
  /* z-index dentro del .video-container, no necesita ser tan negativo si .video-container lo maneja.
     Pero -1 asegura que esté detrás del .video-overlay si ambos son hijos directos con position absolute.
     El z-index original de -10 también funciona bien aquí. */
  z-index: -1;
  border: none;
  outline: none;
}

.video-overlay {
  position: absolute; /* Se posiciona relativo al .video-container */
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6); /* Oscurecer el video para legibilidad */
  z-index: 0; /* Encima del #background-video pero dentro del .video-container */
  /* pointer-events: none; ya está en .video-container */
}

/* =============== HEADER =============== */
.main-header {
  z-index: 10; /* Sobre el video y overlay */
  position: relative; /* Necesario para que z-index funcione correctamente */
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  padding: 1.5rem;
  text-align: center;
  border-bottom: 2px solid rgba(var(--primary-color), 0.5);
}

.main-header img.logo {
  max-width: 200px;
  display: block;
  margin: 0 auto 1rem auto;
  filter: drop-shadow(2px 2px 8px rgba(255, 255, 255, 0.3));
  transition: transform 0.3s ease;
}

.main-header img.logo:hover {
  transform: scale(1.05);
}

.main-header h1 {
  color: var(--text-color-light);
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
  font-weight: 700;
  font-size: 2.2rem;
  margin: 0;
}

/* =============== CONTENIDO PRINCIPAL (MAIN) =============== */
main {
  z-index: 10; /* Sobre el video y overlay */
  position: relative; /* Necesario para que z-index funcione correctamente */
  padding: 2rem;
}

/* =============== FILTROS =============== */
.filtros {
  text-align: center;
  margin-bottom: 3rem;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  padding: 2rem;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.filtros input[type="text"] {
  padding: 1rem 1.5rem;
  width: 70%;
  max-width: 500px;
  border-radius: 50px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.9);
  font-size: 1rem;
  font-family: 'Montserrat', sans-serif;
  transition: all 0.3s ease;
  color: var(--text-color-dark);
}

.filtros input[type="text"]:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 20px rgba(106, 27, 154, 0.3);
  transform: scale(1.02);
}

.filtros input[type="text"]::placeholder {
  color: #666;
  font-style: italic;
}

.botones-filtro {
  margin-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
}

.botones-filtro button[data-area] {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: var(--text-color-light);
  border: none;
  padding: 0.8rem 1.8rem;
  border-radius: 25px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(106, 27, 154, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.botones-filtro button[data-area]:hover {
  background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(106, 27, 154, 0.5);
}

.botones-filtro button[data-area].active {
  background: linear-gradient(135deg, var(--accent-color), var(--accent-color-hover));
  box-shadow: 0 6px 20px rgba(255, 107, 53, 0.4);
}

/* =============== SECCIÓN DE LABORATORIOS (FLIP CARDS) =============== */
.laboratorios {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  perspective: 1000px;
}

.flip-card-container {
  height: 400px;
  width: 100%;
  margin: 0 auto;
  opacity: 0;
  transform: translateY(20px);
  animation: cardFadeInUp 0.5s ease forwards;
}

@keyframes cardFadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInUp { /* Esta animación se usa en JS al filtrar */
  from {
    opacity: 0;
    transform: translateY(50px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.flip-card {
  background-color: transparent;
  width: 100%;
  height: 100%;
  perspective: 1000px;
  cursor: pointer;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transform-style: preserve-3d;
}

.flip-card:hover .flip-card-inner,
.flip-card.mobile-flipped .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-card-front, .flip-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  box-sizing: border-box;
}

/* --- FRENTES DE TARJETAS POR CATEGORÍA --- */
.flip-card-front { /* Estilo por defecto si no hay categoría específica */
  background: linear-gradient(135deg, rgba(120, 120, 120, 0.1) 0%, var(--card-bg-light) 100%);
  border-left: 5px solid #888;
  color: var(--text-color-dark);
}

.flip-card-container.ingenieria .flip-card-front {
  background: linear-gradient(135deg, rgba(106, 27, 154, 0.1) 0%, var(--card-bg-light) 100%);
  border-left: 5px solid var(--primary-color);
}
.flip-card-container.ingenieria .flip-card-front h3 { color: var(--primary-color); }

.flip-card-container.biologicas .flip-card-front {
  background: linear-gradient(135deg, rgba(76, 175, 80, 0.1) 0%, var(--card-bg-light) 100%);
  border-left: 5px solid #4caf50;
}
.flip-card-container.biologicas .flip-card-front h3 { color: #4caf50; }

.flip-card-container.sociales .flip-card-front {
  background: linear-gradient(135deg, rgba(255, 107, 53, 0.1) 0%, var(--card-bg-light) 100%);
  border-left: 5px solid var(--accent-color);
}
.flip-card-container.sociales .flip-card-front h3 { color: var(--accent-color); }

.card-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

.flip-card-front h3 {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0.5rem 0 1rem 0;
  text-align: center;
  line-height: 1.3;
}

.card-category {
  background: linear-gradient(135deg, #555, #333); /* Default */
  color: var(--text-color-light);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: inline-block;
}
.flip-card-container.ingenieria .card-category { background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)); }
.flip-card-container.biologicas .card-category { background: linear-gradient(135deg, #4caf50, #388e3c); }
.flip-card-container.sociales .card-category { background: linear-gradient(135deg, var(--accent-color), var(--accent-color-hover)); }

.flip-indicator {
  margin-top: auto;
  color: #666;
  font-size: 0.8rem;
  opacity: 0.8;
}

.flip-arrow {
  font-size: 1.5rem;
  margin-top: 0.5rem;
  animation: rotateHint 2s infinite ease-in-out;
}

@keyframes rotateHint {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(360deg); }
}

/* --- REVERSOS DE TARJETAS POR CATEGORÍA --- */
.flip-card-back {
  color: var(--text-color-light);
  transform: rotateY(180deg);
  background: linear-gradient(135deg, #444, #222, #000); /* Default */
}

.flip-card-container.ingenieria .flip-card-back {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color), #2e0854);
}
.flip-card-container.biologicas .flip-card-back {
  background: linear-gradient(135deg, #4caf50, #388e3c, #2e7d32);
}
.flip-card-container.sociales .flip-card-back {
  background: linear-gradient(135deg, var(--accent-color), var(--accent-color-hover), #e65100);
}

.back-content {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
}

.flip-card-back h3 {
  color: var(--text-color-light);
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0 0 0.8rem 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.features {
  flex-grow: 1;
  width: 100%;
  margin: 0.8rem 0;
  overflow-y: auto;
  max-height: 120px;
}

.feature {
  background: rgba(255, 255, 255, 0.1);
  margin: 0.4rem 0;
  padding: 0.6rem;
  border-radius: 8px;
  backdrop-filter: blur(5px);
  font-size: 0.85rem;
  text-align: left;
  border-left: 3px solid var(--accent-color);
}
.flip-card-container.ingenieria .feature { border-left-color: var(--primary-color); } /* Ajuste de color */
.flip-card-container.biologicas .feature { border-left-color: #4caf50; } /* Ajuste de color */

.lab-stats {
  display: flex;
  justify-content: space-around;
  width: 100%;
  margin: 0.8rem 0;
  padding: 0.8rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.stat { text-align: center; }

.stat-number {
  display: block;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent-color); /* Default */
}
.flip-card-container.ingenieria .stat-number { color: var(--primary-color); } /* Ajuste de color */
.flip-card-container.biologicas .stat-number { color: #4caf50; } /* Ajuste de color */

.stat-label {
  font-size: 0.75rem;
  opacity: 0.9;
}

.access-btn {
  background: linear-gradient(45deg, var(--accent-color), var(--accent-color-hover), var(--accent-color), var(--accent-color-hover));
  background-size: 300% 300%;
  color: var(--text-color-light);
  text-decoration: none;
  padding: 0.8rem 1.5rem;
  border-radius: 50px;
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
  transition: all 0.4s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 0.85rem;
  margin-top: auto;
  position: relative;
  overflow: hidden;
  animation: gradientMove 4s ease infinite;
}

@keyframes gradientMove {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.access-btn:hover {
  transform: scale(1.05) translateY(-2px);
  box-shadow: 0 10px 25px rgba(255, 107, 53, 0.5);
  animation-duration: 1.5s;
}

.access-btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s ease, height 0.6s ease;
}
.access-btn:active::after {
  width: 200px;
  height: 200px;
}

/* =============== SECCIÓN DE FAQ =============== */
.faq {
  margin-top: 4rem;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
  color: var(--text-color-light);
  z-index: 10;
  position: relative;
}

.faq h2 {
  text-align: center;
  color: var(--text-color-light);
  font-size: 2rem;
  margin-bottom: 2rem;
}

.faq-item {
  margin-bottom: 1rem;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-radius: 15px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: background-color 0.3s ease;
}
.faq-item:hover { background: rgba(255, 255, 255, 0.15); }

.faq-question {
  cursor: pointer;
  font-weight: 600;
  background: none;
  border: none;
  color: var(--text-color-light);
  width: 100%;
  text-align: left;
  padding: 1.5rem;
  font-size: 1.1rem;
  transition: background-color 0.3s ease;
  position: relative;
}

.faq-question::after {
  content: '+';
  position: absolute;
  right: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.5rem;
  transition: transform 0.3s ease;
}

.faq-item.active .faq-question { background-color: rgba(255, 255, 255, 0.05); }
.faq-item.active .faq-question::after { transform: translateY(-50%) rotate(45deg); }

.faq-answer {
  display: none;
  padding: 0 1.5rem 1.5rem;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.6;
}

.faq-item.active .faq-answer {
  display: block;
  animation: fadeInAnswer 0.4s ease-out;
}

@keyframes fadeInAnswer {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* =============== MENSAJE DE NO RESULTADOS (desde JS) =============== */
#no-results-container {
  grid-column: 1 / -1; /* Ocupar todas las columnas si está dentro de .laboratorios */
  text-align: center;
  padding: 3rem;
  color: var(--text-color-light);
}
#no-results-container h3 { font-size: 1.5rem; margin-bottom: 0.5rem; }
#no-results-container p { font-size: 1rem; }

/* =============== DISEÑO RESPONSIVE =============== */
@media screen and (max-width: 768px) {
  .main-header h1 { font-size: 1.8rem; }
  main { padding: 1rem; }
  .filtros input[type="text"] { width: 90%; }
  .botones-filtro { flex-direction: column; align-items: center; }
  .botones-filtro button[data-area] { width: 80%; max-width: 300px; }
  .laboratorios { gap: 1.5rem; }
  .flip-card-container { height: 380px; }
  .flip-card-front h3, .flip-card-back h3 { font-size: 1.3rem; }
  .card-icon { font-size: 3rem; }
  .feature { font-size: 0.8rem; }
  .access-btn { padding: 0.7rem 1.2rem; font-size: 0.8rem; }
  .faq-question { font-size: 1rem; padding: 1.2rem; }
  .faq-question::after { font-size: 1.3rem; right: 1.2rem; }
  .faq-answer { padding: 0 1.2rem 1.2rem; }
}

@media screen and (max-width: 480px) {
  .main-header h1 { font-size: 1.6rem; }
  .main-header img.logo { max-width: 150px; }
  .filtros { padding: 1.5rem; }
  .flip-card-container { height: auto; min-height: 360px; }
  .flip-card-front, .flip-card-back { padding: 1.5rem; }
  .features { max-height: 100px; }
  .lab-stats { flex-direction: column; gap: 0.5rem; }
}
