/* Global Styles */
body {
    font-family: 'Poppins', sans-serif;
}

img {
    image-rendering: auto;
    -ms-interpolation-mode: bicubic;
}

/* Hero Backgrounds */
.hero-bg {
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
}

/* Las clases .hero-bg-fisioterapia, .hero-bg-deportiva, etc. se han eliminado
   ya que ahora se usan etiquetas <img> para mejorar el rendimiento LCP. */

/* Service Cards (Modern Hover/Zoom Effect) */
.flip-card {
    background-color: transparent;
    width: 100%;
    height: 350px;
    perspective: 1000px;
    /* Keep for potential 3d effects, though not used for flip anymore */
    overflow: hidden;
    border-radius: 1rem;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    position: relative;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.5s ease;
    transform-style: flat;
    /* No longer 3D flip */
}

.flip-card-front {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    transition: transform 0.5s ease;
    color: white;
    /* Ensure front text is white */
}

.flip-card-back {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: auto;
    /* Adjust to content */
    max-height: 100%;
    background-color: rgba(0, 83, 109, 0.95);
    /* Dark Cyan background for readability */
    color: white;
    /* White text as requested */
    transform: translateY(100%);
    transition: transform 0.4s ease-in-out;
    padding: 1.5rem;
    flex-direction: column;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    border-top-left-radius: 1rem;
    border-top-right-radius: 1rem;
}

/* Force white text on children to override Tailwind utility classes */
.flip-card-back h3,
.flip-card-back p,
.flip-card-back span,
.flip-card-back a {
    color: white !important;
}

/* Service Cards (Modern Hover/Zoom Effect) - Solo en Escritorio */
@media (hover: hover) {
    .flip-card:hover .flip-card-front {
        transform: scale(1.05);
    }

    .flip-card:hover .flip-card-back {
        transform: translateY(0) !important;
        z-index: 50 !important;
        opacity: 1 !important;
        box-shadow: 0 0 30px rgba(6, 182, 212, 0.4);
    }

    .flip-card:hover .card-bg-overlay {
        opacity: 0.5;
    }
}

/* Card Border Animated Glow */
.flip-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 1rem;
    padding: 2px;
    background: linear-gradient(45deg, transparent, rgba(6, 182, 212, 0.5), transparent, rgba(6, 182, 212, 0.5), transparent);
    background-size: 200% 200%;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 10;
}

.flip-card:hover::after {
    opacity: 1;
    animation: border-rotate 3s linear infinite;
}

@keyframes border-rotate {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Estado activo para móviles/táctil */
.flip-card.active .flip-card-back {
    transform: translateY(0) !important;
    z-index: 50 !important;
    opacity: 1 !important;
}

/* On mobile, ensure the front doesn't block the back when active */
.flip-card.active .flip-card-front {
    opacity: 0.3;
}

.card-bg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to top, rgba(0, 83, 109, 0.8) 0%, rgba(0, 109, 135, 0.3) 100%);
    z-index: 1;
    transition: opacity 0.3s;
}

.flip-card:hover .card-bg-overlay {
    opacity: 0.7;
}

/* Carousel Styles */
.carousel-item {
    flex: 0 0 100%;
}

@media (min-width: 768px) {
    .carousel-item {
        flex: 0 0 50%;
    }
}

@media (min-width: 1024px) {
    .carousel-item {
        flex: 0 0 33.333%;
    }
}

/* Scroll Animations */
.scroll-animate {
    opacity: 0;
    transform: translateY(100px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.scroll-animate-in {
    opacity: 1;
    transform: translateY(0);
}

/* WhatsApp Button */
.whatsapp-float {
    position: fixed;
    width: 60px;
    height: 60px;
    bottom: 40px;
    right: 40px;
    background-color: #25d366;
    color: #FFF;
    border-radius: 50px;
    text-align: center;
    font-size: 30px;
    box-shadow: 2px 2px 20px rgba(0, 0, 0, 0.2);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.whatsapp-float:hover {
    background-color: #128C7E;
    transform: scale(1.1);
}

/* Benefits Cards Animation */
.benefit-card {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.benefit-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(6, 182, 212, 0.15), transparent);
    transition: left 0.6s ease;
    z-index: 1;
}

.benefit-card:hover {
    transform: translateY(-12px);
    box-shadow: 0 20px 40px rgba(6, 182, 212, 0.3);
}

.benefit-card:hover::before {
    left: 100%;
}

.benefit-card img {
    transition: all 0.4s ease;
}

.benefit-card:hover img {
    transform: scale(1.08);
    filter: brightness(1.1);
}

.benefit-card h3,
.benefit-card p {
    transition: all 0.3s ease;
    position: relative;
    z-index: 2;
}

.benefit-card:hover h3 {
    color: rgb(6, 182, 212);
    transform: translateY(-3px);
}

/* =========================================
   MEJORAS MÓVIL Y MARKETING (NUEVO)
   ========================================= */

/* 1. BARRA STICKY INFERIOR (Solo visible en móvil) */
@media (max-width: 767px) {

    /* Espacio extra al final de la web para que la barra no tape el footer */
    body {
        padding-bottom: 90px;
    }

    /* Ocultar el botón flotante original de WhatsApp para no duplicar */
    .whatsapp-float {
        display: none !important;
    }

    /* Ajuste para móviles modernos (iPhone X y superiores) */
    .safe-area-pb {
        padding-bottom: env(safe-area-inset-bottom, 20px);
    }
}

/* 2. TARJETAS DE SERVICIOS EN MÓVIL (Restaurado para que funcione el flip/slide) */
@media (max-width: 767px) {
    .flip-card {
        height: 400px !important; /* Aumentamos ligeramente la altura en móvil para el texto */
        touch-action: manipulation; /* Mejora la respuesta al toque */
    }

    .flip-card-back {
        /* Cubrir toda la tarjeta para evitar cortes de texto */
        top: 0 !important;
        bottom: 0 !important;
        height: 100% !important;
        transform: translateY(100%) !important;
        padding: 2rem !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        text-align: center !important;
    }

    .flip-card.active .flip-card-back {
        transform: translateY(0) !important;
        z-index: 100 !important;
    }

    /* Aseguramos visibilidad absoluta del contenido */
    .flip-card-back h3,
    .flip-card-back p {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
}

/* 3. ESTILOS PARA LA NUEVA SECCIÓN DE IA */
.ia-section-bg {
    background: linear-gradient(135deg, #0e7490 0%, #164e63 100%);
    position: relative;
    overflow: hidden;
}

/* Efecto de pulso para el botón de IA */
@keyframes pulse-ring {
    0% {
        transform: scale(0.8);
        opacity: 0.5;
    }

    100% {
        transform: scale(1.3);
        opacity: 0;
    }
}

.pulse-btn::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: inherit;
    border-radius: 50px;
    z-index: -1;

    animation: pulse-ring 2s infinite;
}

/* 4. ANIMACIÓN MARQUESINA VERTICAL (TESTIMONIOS) */
@keyframes scroll-vertical {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(-50%);
    }
}

.animate-marquee {
    animation: scroll-vertical 20s linear infinite;
}

/* Pausar animación al pasar el ratón (opcional, buena UX) */
.animate-marquee:hover {
    animation-play-state: paused;
}

/* Máscara de desvanecimiento para el contenedor de testimonios */
.mask-gradient-vertical {
    mask-image: linear-gradient(to bottom, transparent, black 15%, black 85%, transparent);
    -webkit-mask-image: linear-gradient(to bottom, transparent, black 15%, black 85%, transparent);
}

/* =========================================
   NUEVAS UTILIDADES PREMIUM
   ========================================= */

/* Glassmorphism */
.glass-header {
    background: rgba(14, 116, 144, 0.7); /* cyan-700 with opacity */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.glass-header-scrolled {
    background: rgba(14, 116, 144, 0.9);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

/* Text Gradient */
.text-gradient {
    background: linear-gradient(135deg, #ffffff 0%, #a5f3fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Section Dividers Container */
.section-divider {
    position: relative;
    width: 100%;
    line-height: 0;
    pointer-events: none;
}

.section-divider svg {
    display: block;
    width: 100%;
    height: 60px;
}

.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s cubic-bezier(0.15, 0.85, 0.35, 1);
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

/* Staggered entrance delays */
.delay-1 { transition-delay: 0.1s; }
.delay-2 { transition-delay: 0.2s; }
.delay-3 { transition-delay: 0.3s; }
.delay-4 { transition-delay: 0.4s; }

/* Progress Bar */
#scroll-progress-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

#scroll-progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(to right, #22d3ee, #0891b2);
    box-shadow: 0 0 10px rgba(34, 211, 238, 0.8);
    transition: width 0.1s ease-out;
}

/* IA Section Glow */
.ia-card-glow {
    position: relative;
}

.ia-card-glow::after {
    content: '';
    position: absolute;
    inset: -2px;
    background: linear-gradient(45deg, #06b6d4, #0891b2, transparent, #22d3ee);
    border-radius: 1.1rem;
    z-index: -1;
    opacity: 0.3;
    filter: blur(10px);
    animation: border-glow 6s linear infinite;
}

@keyframes border-glow {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

/* Botón Premium Hover & Shimmer */
.btn-premium {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.btn-premium::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transition: none;
}

.btn-premium:hover::before {
    left: 100%;
    transition: left 0.7s ease-in-out;
}

/* Periodic Shimmer for primary CTA */
.btn-shimmer-auto::before {
    animation: auto-shimmer 4s infinite;
}

@keyframes auto-shimmer {
    0% { left: -100%; }
    20% { left: 100%; }
    100% { left: 100%; }
}

.btn-premium:hover {
    box-shadow: 0 0 20px rgba(6, 182, 212, 0.6);
    transform: translateY(-2px) scale(1.02) !important;
}

/* =========================================
   GALERÍA MASONRY
   ========================================= */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 220px;
    gap: 12px;
}

@media (max-width: 767px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: 160px;
    }
    .gallery-item--tall {
        grid-row: span 1 !important;
    }
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    cursor: pointer;
}

.gallery-item--tall {
    grid-row: span 2;
}

.gallery-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.5s ease;
}

.gallery-item:hover .gallery-img {
    transform: scale(1.07);
}

.gallery-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 83, 109, 0.7) 0%, transparent 60%);
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 14px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-item:hover .gallery-overlay {
    opacity: 1;
}

/* =========================================
   MODAL PROFESIONALES
   ========================================= */
#professional-modal.open {
    display: flex !important;
}

#professional-modal.open #modal-panel {
    transform: scale(1) !important;
    opacity: 1 !important;
}