/* --- VARIABLES Y ESTILOS BASE --- */
:root {
  --primary-color: #d72631;
  /* Rojo (Acento) */
  --dark-bg: #1a1a1a;
  /* Fondo Oscuro */
  --card-bg: #222;
  /* Fondo de Tarjetas Oscuras */
  --text-light: #dcdcdc;
  /* Texto principal claro */
  --text-dark: #bbb;
  /* Texto secundario/links */
  --text-white: #fff;
  /* Blanco */
  --font-stack: "Montserrat", sans-serif;

  /* Variables dinámicas del carrusel */
  --testi-width: 320px;
  --testi-gap: 2rem;
}

@media (max-width: 600px) {
  :root {
    --testi-width: 240px;
    --testi-gap: 1rem;
  }
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
  /* Espacio para navbar fijo */
}

body {
  background-color: var(--dark-bg);
  color: var(--text-light);
  font-family: var(--font-stack);
  line-height: 1.6;
}

section {
  padding: 5rem 2rem;
  text-align: center;
}

section h2 {
  font-size: clamp(1.5rem, 8vw, 2.5rem);
  margin-bottom: clamp(1.5rem, 5vw, 3rem);
  color: var(--primary-color);
  text-transform: uppercase;
  letter-spacing: 2px;
}

/* --- CLASES REUTILIZABLES (BOTONES) --- */
.btn {
  display: inline-block;
  padding: 0.8rem 1.8rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 700;
  transition: all 0.3s ease;
  border: 2px solid transparent;
  cursor: pointer;
  background: none;
  font-size: 1rem;
}

.btn--primary {
  background-color: var(--primary-color);
  color: var(--text-white);
}

.btn--primary:hover {
  background-color: transparent;
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.btn--secondary {
  border: 2px solid #555;
  color: var(--text-light);
}

.btn--secondary:hover {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  color: var(--text-white);
}

.btn--cta {
  padding: 0.5rem 1rem;
  background: var(--text-white);
  color: var(--primary-color);
  text-transform: uppercase;
}

.btn--cta:hover {
  background-color: var(--primary-color);
  color: var(--text-white);
}

/* --- NAVBAR --- */
#navbar {
  position: fixed;
  width: 100%;
  top: 0;
  left: 0;
  background: rgba(17, 17, 17, 0.9);
  backdrop-filter: blur(10px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  z-index: 1000;
}

.logo {
  color: var(--primary-color);
  font-size: 2rem;
  font-weight: bold;
  text-decoration: none;
}

.nav-links {
  list-style: none;
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.nav-links a {
  color: var(--text-dark);
  text-decoration: none;
  transition: color 0.3s;
}

.nav-links a:hover {
  color: var(--primary-color);
}

.nav-links .btn--cta:hover {
  color: var(--text-white);
}

/* --- HERO --- */
#hero {
  height: 100vh;
  background: url("images/gimnasio-hero.webp") center/cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 0 2rem;
  overflow: hidden; /* Evita scroll horizontal del hero-overlay */
}

.hero-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
}

.hero-content {
  position: relative;
  z-index: 1;
}

.hero-content h1 {
  font-size: clamp(2.2rem, 10vw, 3.5rem);
  color: var(--text-white);
  text-shadow: 2px 2px 5px #000;
}

.hero-content p {
  font-size: 1.5rem;
  margin: 1rem 0 2rem;
}

/* --- SERVICIOS --- */
.main-container {
  max-width: 1200px;
  margin: 0 auto;
}

.services-grid {
  display: grid;
  /* Unificado para que coincida con Planes/Testimonios, min() asegura responsividad en móviles muy chicos */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 2rem;
}

.service-card {
  background: var(--card-bg);
  padding: 1.5rem;
  border-radius: 15px;
  transition: all 0.3s ease;
  /* Flexbox para alinear contenido (importante para botones) */
  display: flex;
  flex-direction: column;
  height: 100%;
}

.service-card:hover {
  transform: translateY(-10px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
}

.service-card img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 1rem;
}

.service-card h3 {
  margin-bottom: 0.5rem;
  color: var(--primary-color);
  font-size: 1.4rem;
}

.service-card p {
  margin-bottom: 1.5rem;
  /* Crece para empujar el botón hacia abajo */
  flex-grow: 1;
}

.service-card .btn {
  margin-top: auto;
  /* Alinea el botón al fondo */
}

/* --- PLANES (MEMBRESÍA) --- */
#planes {
  background-color: #111;
}

.plan-toggle {
  margin-bottom: 2rem;
}

.toggle-btn {
  padding: 0.7rem 1.5rem;
  margin: 0 0.5rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: var(--card-bg);
  color: var(--text-dark);
  font-weight: 700;
  transition: 0.3s;
}

.toggle-btn.active {
  background: var(--primary-color);
  color: var(--text-white);
}

.plans-grid {
  display: grid;
  /* Unificado para que coincida con Servicios/Testimonios */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 2rem;
  align-items: center;
}

.plan-card {
  background: var(--card-bg);
  padding: 2rem;
  border-radius: 15px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: 100%;
  /* Clave para la alineación */
  transition: transform 0.3s;
}

.plan-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
}

.plan-card h3 {
  color: var(--primary-color);
  font-size: 1.5rem;
}

.plan-card .price {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-white);
}

.plan-card p {
  flex-grow: 1;
}

.plan-card .btn {
  margin-top: auto;
}

.plan-premium {
  transform: scale(1.05);
  border: 2px solid var(--primary-color);
}

/* --- FAQ --- */
.faq-container {
  max-width: 800px;
  margin: 0 auto;
  text-align: left;
}

.faq-item {
  background: var(--card-bg);
  margin-bottom: 1rem;
  border-radius: 8px;
  cursor: pointer;
  overflow: hidden;
}

.faq-item h3 {
  color: var(--text-white);
  font-weight: 500;
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faq-item p {
  max-height: 0;
  overflow: hidden;
  padding: 0 1.5rem;
  transition:
    max-height 0.4s ease-out,
    padding 0.4s ease-out;
  color: var(--text-light);
}

.faq-item.active p {
  max-height: 200px;
  padding: 0 1.5rem 1.5rem;
}

.faq-toggle {
  font-size: 1.8rem;
  color: var(--primary-color);
  transition: transform 0.3s ease;
}

.faq-item.active .faq-toggle {
  transform: rotate(45deg);
}

/* --- TESTIMONIALS (Carrusel CSS) --- */
#testimonials {
  background-color: var(--dark-bg);
}

.testimonials-container {
  overflow: hidden;
  position: relative;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  /* Efecto de desvanecimiento en los bordes */
  -webkit-mask-image: linear-gradient(
    to right,
    transparent,
    black 15%,
    black 85%,
    transparent
  );
  mask-image: linear-gradient(
    to right,
    transparent,
    black 15%,
    black 85%,
    transparent
  );
}

.testimonials-track {
  display: flex;
  gap: var(--testi-gap);
  width: calc(var(--testi-width) * 12 + var(--testi-gap) * 11);
  animation: scroll 45s linear infinite;
  align-items: stretch;
}

/* Se elimina el :hover para que el carrusel no se detenga */

@keyframes scroll {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(calc((var(--testi-width) + var(--testi-gap)) * -6));
  }
}

.testimonial {
  flex-shrink: 0;
  width: var(--testi-width);
  /* Ancho fijo para el carrusel, alineado al mínimo de 300px */
  background: var(--card-bg);
  padding: 1.5rem;
  border-radius: 15px;
  text-align: center;
  color: var(--text-light);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.testimonial img {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 1rem;
  border: 3px solid var(--primary-color);
}

/* --- CONTACTO --- */
#contact {
  background-color: var(--dark-bg);
}

#contact form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 600px;
  margin: 0 auto;
}

#contact input,
#contact textarea {
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid #444;
  background-color: #2a2a2a;
  color: var(--text-white);
  font-size: 1rem;
}

#contact input:focus,
#contact textarea:focus {
  outline: none;
  border-color: var(--primary-color);
}

#contact input:not(:placeholder-shown):valid,
#contact textarea:not(:placeholder-shown):valid {
  border-color: #28a745;
  box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.2);
}

#contact input:not(:placeholder-shown):invalid,
#contact textarea:not(:placeholder-shown):invalid {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(215, 38, 49, 0.2);
}

/* --- FOOTER --- */
footer {
  background: var(--card-bg);
  color: var(--text-dark);
  padding: 2rem;
  text-align: center;
}

.footer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

/* Estilo para que la imagen sea interactiva */
.footer-content a {
  cursor: pointer;
}

.footer-content img {
  width: 120px;
  border-radius: 15px;
}

.footer-socials {
  display: flex;
  gap: 1rem;
}

.footer-socials img {
  width: 40px;
  cursor: pointer;
  transition: transform 0.3s;
}

.footer-socials img:hover {
  transform: scale(1.1);
}

.footer-legal ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem;
  padding: 0;
  margin-bottom: 1.5rem;
}

.footer-legal a {
  text-decoration: none;
  color: var(--text-light);
  transition: color 0.3s;
  font-weight: 500;
}

.footer-legal a:hover {
  color: var(--primary-color);
}

/* --- SCROLL TO TOP BUTTON --- */
#scroll-to-top {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999;
  background-color: var(--primary-color);
  color: var(--text-white);
  border: none;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  transition:
    opacity 0.3s,
    background-color 0.3s;
}

#scroll-to-top:hover {
  background-color: #a31c25;
}

#scroll-to-top.show {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* --- SCROLL REVEAL ANIMATIONS (Fade In) --- */
.scroll-reveal {
  opacity: 0;
  transform: translateY(20px);
  transition:
    opacity 0.6s ease-out,
    transform 0.6s ease-out;
  will-change: opacity, transform;
}

.scroll-reveal.active {
  opacity: 1;
  transform: translateY(0);
}

/* Animación de las tarjetas internas con delay */
.services-grid > *,
.plans-grid > *,
.testimonials-track > * {
  opacity: 0;
  transform: translateY(20px);
  transition:
    opacity 0.4s ease-out,
    transform 0.4s ease-out;
  will-change: opacity, transform;
}

.services-grid > *.active-item,
.plans-grid > *.active-item,
.testimonials-track > *.active-item {
  opacity: 1;
  transform: translateY(0);
}

/* --- MENÚ HAMBURGUESA Y RESPONSIVE --- */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  background: none;
  border: none;
  z-index: 1001;
}

.hamburger span {
  width: 25px;
  height: 3px;
  background: var(--text-white);
  display: block;
  border-radius: 2px;
}

@media (max-width: 900px) {
  .hamburger {
    display: flex;
  }

  .nav-links {
    display: none;
    flex-direction: column;
    gap: 1.5rem;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--card-bg);
    padding: 2rem 0;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
  }

  .nav-links.show {
    display: flex;
  }

  .hero-content h1 {
    font-size: 2.5rem;
  }

  .hero-content p {
    font-size: 1.2rem;
  }

  .plan-premium {
    transform: scale(1);
  }
}

@media (max-width: 600px) {
  section {
    padding: 3rem 1.5rem;
  }

  .hero-content p {
    font-size: 1.1rem;
  }

  #navbar {
    padding: 1rem 1.5rem;
  }

  .logo {
    font-size: 1.5rem;
  }

  .footer-legal ul {
    flex-direction: column;
    gap: 1rem;
  }
}

/* ============================================
   MEJORAS Y NUEVOS COMPONENTES
   ============================================ */

/* --- HAMBURGER → X ANIMATION --- */
.hamburger span {
  transition: all 0.3s ease-in-out;
}

.hamburger.active span:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}

.hamburger.active span:nth-child(2) {
  opacity: 0;
}

.hamburger.active span:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

/* --- LABELS DEL FORMULARIO --- */
#contact form label {
  display: block;
  text-align: left;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text-light);
  font-size: 0.95rem;
}

#contact form textarea {
  resize: vertical;
  min-height: 120px;
  font-family: var(--font-stack);
}

#form-status {
  text-align: center;
  font-weight: 600;
  font-size: 0.95rem;
  min-height: 1.5rem;
}

/* --- BARRA DE PROGRESO --- */
#progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background-color: var(--primary-color);
  z-index: 9999;
  width: 0%;
  transition: width 0.1s;
  border-radius: 0 2px 2px 0;
}

/* --- WHATSAPP FLOATING BUTTON --- */
#whatsapp-btn {
  position: fixed;
  bottom: 5rem;
  right: 1.5rem;
  z-index: 999;
  width: 56px;
  height: 56px;
  background-color: #25d366;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  text-decoration: none;
  box-shadow: 0 4px 20px rgba(37, 211, 102, 0.4);
  transition:
    transform 0.3s ease,
    box-shadow 0.3s ease;
}

#whatsapp-btn::before {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-color: #25d366;
  animation: waPulse 2s ease-out infinite;
  z-index: -1;
}

@keyframes waPulse {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }
  100% {
    transform: scale(1.8);
    opacity: 0;
  }
}

#whatsapp-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 25px rgba(37, 211, 102, 0.6);
}

.whatsapp-tooltip {
  position: absolute;
  right: 65px;
  background-color: #111;
  color: #fff;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  font-family: var(--font-stack);
}

.whatsapp-tooltip::after {
  content: "";
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-left-color: #111;
}

#whatsapp-btn:hover .whatsapp-tooltip {
  opacity: 1;
}

/* --- TOAST NOTIFICATIONS --- */
#toast-container {
  position: fixed;
  bottom: 2rem;
  left: 2rem;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.toast {
  background: rgba(34, 34, 34, 0.97);
  backdrop-filter: blur(10px);
  border-left: 5px solid var(--primary-color);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  padding: 1rem 1.5rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 280px;
  max-width: 380px;
  transform: translateX(-120%);
  opacity: 0;
  transition:
    transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    opacity 0.4s ease;
  color: var(--text-light);
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast.hide {
  transform: translateX(-120%);
  opacity: 0;
}

.toast-success {
  border-left-color: #28a745;
}
.toast-success .toast-icon {
  color: #28a745;
}
.toast-error {
  border-left-color: var(--primary-color);
}
.toast-error .toast-icon {
  color: var(--primary-color);
}

.toast-icon {
  font-size: 1.4rem;
  color: var(--primary-color);
}

.toast-message {
  flex-grow: 1;
  font-size: 0.9rem;
  font-weight: 600;
}

.toast-close {
  background: none;
  border: none;
  color: #888;
  font-size: 1rem;
  cursor: pointer;
  transition: color 0.3s;
}

.toast-close:hover {
  color: #fff;
}
