/* BOTÓN FLOTANTE DE WHATSAPP */
.whatsapp-float {
    position: fixed !important;
    bottom: 30px !important;
    right: 30px !important;
    width: 60px !important;
    height: 60px !important;
    min-width: 60px !important;
    max-width: 60px !important;
    min-height: 60px !important;
    max-height: 60px !important;
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%) !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-decoration: none !important;
    box-shadow: 0 8px 25px rgba(37, 211, 102, 0.3) !important;
    z-index: 999999 !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    overflow: hidden !important;
    cursor: pointer !important;
    opacity: 1 !important;
    visibility: visible !important;
    /* Asegurar forma circular perfecta */
    aspect-ratio: 1 / 1 !important;
    flex-shrink: 0 !important;
    /* Prevenir interferencias de otros estilos */
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    outline: none !important;
    font-family: inherit !important;
}

/* Icono de WhatsApp */
.whatsapp-icon {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 100% !important;
    transition: all 0.3s ease !important;
    position: relative !important;
    z-index: 2 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.whatsapp-icon i {
    font-size: 28px !important;
    color: white !important;
    transition: all 0.3s ease !important;
    opacity: 1 !important;
    visibility: visible !important;
    display: inline-block !important;
    line-height: 1 !important;
    font-weight: 400 !important;
    font-style: normal !important;
    font-variant: normal !important;
    text-rendering: auto !important;
    -webkit-font-smoothing: antialiased !important;
}

/* Texto que aparece al hacer hover */
.whatsapp-text {
    position: absolute !important;
    right: 70px !important;
    background: white !important;
    color: #128C7E !important;
    padding: 12px 20px !important;
    border-radius: 25px !important;
    white-space: nowrap !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15) !important;
    opacity: 0 !important;
    transform: translateX(10px) scale(0.8) !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    pointer-events: none !important;
    z-index: 999998 !important;
    visibility: hidden !important;
    /* Asegurar que el texto sea legible */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif !important;
    line-height: 1.2 !important;
    letter-spacing: 0 !important;
    text-align: center !important;
    margin: 0 !important;
    border: 1px solid rgba(0,0,0,0.1) !important;
}

.whatsapp-text span {
    color: #128C7E !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    display: inline-block !important;
    opacity: 1 !important;
    visibility: visible !important;
    margin: 0 !important;
    padding: 0 !important;
    text-decoration: none !important;
    font-family: inherit !important;
}

.whatsapp-text::after {
    content: '' !important;
    position: absolute !important;
    top: 50% !important;
    right: -8px !important;
    width: 0 !important;
    height: 0 !important;
    border: 8px solid transparent !important;
    border-left-color: white !important;
    transform: translateY(-50%) !important;
}

/* Efectos hover - Solo en dispositivos no táctiles */
@media (hover: hover) and (pointer: fine) {
    .whatsapp-float:hover {
        transform: scale(1.1) !important;
        box-shadow: 0 12px 35px rgba(37, 211, 102, 0.4) !important;
    }

    .whatsapp-float:hover .whatsapp-text {
        opacity: 1 !important;
        visibility: visible !important;
        transform: translateX(0) scale(1) !important;
    }

    .whatsapp-float:hover .whatsapp-icon i {
        transform: scale(1.1) !important;
    }
}

/* Efecto de pulsación - Manteniendo forma circular */
.whatsapp-float:active {
    transform: scale(0.95);
}

/* Asegurar forma circular en todos los estados */
.whatsapp-float,
.whatsapp-float:hover,
.whatsapp-float:active,
.whatsapp-float:focus {
    border-radius: 50% !important;
    aspect-ratio: 1 / 1;
}

/* Animación de entrada */
@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3) rotate(-360deg);
    }
    50% {
        opacity: 1;
        transform: scale(1.1);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.whatsapp-float {
    animation: bounceIn 0.8s ease-out;
}

/* Animación de pulso sutil */
@keyframes pulse {
    0% {
        box-shadow: 0 8px 25px rgba(37, 211, 102, 0.3);
    }
    50% {
        box-shadow: 0 8px 25px rgba(37, 211, 102, 0.5), 0 0 0 0 rgba(37, 211, 102, 0.4);
    }
    100% {
        box-shadow: 0 8px 25px rgba(37, 211, 102, 0.3), 0 0 0 20px rgba(37, 211, 102, 0);
    }
}

.whatsapp-float::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(37, 211, 102, 0.3);
    animation: pulse 2s infinite;
    z-index: -1;
}

/* Responsivo - Manteniendo forma circular perfecta */
@media (max-width: 768px) {
    .whatsapp-float {
        bottom: 20px;
        right: 20px;
        width: 55px;
        height: 55px;
        border-radius: 50% !important;
        /* Forzar mantener aspectos circulares */
        min-width: 55px;
        max-width: 55px;
        min-height: 55px;
        max-height: 55px;
    }
    
    .whatsapp-icon i {
        font-size: 24px;
    }
    
    .whatsapp-text {
        right: 65px;
        padding: 10px 16px;
        font-size: 13px;
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    
    /* Desactivar efectos hover en dispositivos táctiles */
    .whatsapp-float:hover {
        transform: none;
        width: 55px;
        height: 55px;
    }
    
    /* Mejorar el efecto de toque */
    .whatsapp-float:active {
        transform: scale(0.9);
        transition: transform 0.1s ease;
    }
}

@media (max-width: 480px) {
    .whatsapp-float {
        bottom: 15px;
        right: 15px;
        width: 50px;
        height: 50px;
        border-radius: 50% !important;
        /* Forzar mantener aspectos circulares */
        min-width: 50px;
        max-width: 50px;
        min-height: 50px;
        max-height: 50px;
    }
    
    .whatsapp-icon i {
        font-size: 22px;
    }
    
    .whatsapp-text {
        right: 60px;
        padding: 8px 14px;
        font-size: 12px;
    }
    
    /* Asegurar que no se deforme en pantallas muy pequeñas */
    .whatsapp-float:hover {
        transform: none;
        width: 50px;
        height: 50px;
    }
    
    .whatsapp-float:active {
        transform: scale(0.85);
    }
}

/* Específico para dispositivos táctiles */
@media (hover: none) and (pointer: coarse) {
    .whatsapp-float:hover {
        transform: none !important;
        box-shadow: 0 8px 25px rgba(37, 211, 102, 0.3) !important;
    }
    
    .whatsapp-float:active {
        transform: scale(0.9) !important;
        transition: transform 0.1s ease !important;
    }
    
    .whatsapp-text {
        opacity: 1 !important;
        transform: translateX(0) scale(1) !important;
    }
}

/* Corrección específica para iOS Safari */
@supports (-webkit-touch-callout: none) {
    .whatsapp-float {
        -webkit-transform-style: preserve-3d;
        transform-style: preserve-3d;
        will-change: transform;
    }
    
    .whatsapp-float:active {
        -webkit-transform: scale(0.9);
        transform: scale(0.9);
    }
    
    /* Evitar el efecto de "sticky hover" en iOS */
    .whatsapp-float:hover {
        -webkit-transform: none;
        transform: none;
    }
}

/* Asegurar que el círculo se mantenga perfecto en todos los navegadores */
.whatsapp-float::before,
.whatsapp-float::after {
    border-radius: 50% !important;
}

/* Efecto de brillo ocasional */
@keyframes shine {
    0% {
        background-position: -100% 0;
    }
    100% {
        background-position: 100% 0;
    }
}

.whatsapp-float::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    background-size: 200% 100%;
    animation: shine 3s infinite;
    pointer-events: none;
}

/* Asegurar que el botón no interfiera con el scroll */
html {
    scroll-behavior: smooth;
}

body {
    padding-bottom: 100px; /* Espacio para evitar que el contenido quede oculto detrás del botón */
}

/* Mejorar la accesibilidad */
.whatsapp-float:focus {
    outline: 3px solid rgba(37, 211, 102, 0.5);
    outline-offset: 2px;
}

.whatsapp-float:focus-visible {
    outline: 3px solid rgba(37, 211, 102, 0.5);
    outline-offset: 2px;
}

/* ESTILOS PARA LA SECCIÓN DE CÓDIGO COPIABLE */
.code-section {
    background: #f8f9fa;
    margin: 4rem 0 0 0;
    padding: 4rem 2rem;
    border-top: 3px solid #25D366;
}

.code-section .container {
    max-width: 1200px;
    margin: 0 auto;
}

.code-section h2 {
    text-align: center;
    color: #2c3e50;
    font-size: 2.5rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.code-section > .container > p {
    text-align: center;
    color: #666;
    font-size: 1.2rem;
    margin-bottom: 3rem;
}

.code-block {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    margin: 2rem 0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    border: 1px solid #e9ecef;
}

.code-block h3 {
    color: #25D366;
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.code-container {
    position: relative;
    background: #2d3748;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #4a5568;
}

.copy-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #4a5568;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    z-index: 10;
}

.copy-btn:hover {
    background: #25D366;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}

.copy-btn:active {
    transform: translateY(0);
}

pre {
    margin: 0;
    padding: 20px 60px 20px 20px;
    background: #2d3748;
    color: #e2e8f0;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

code {
    color: #e2e8f0;
    font-family: 'Courier New', monospace;
}

/* Syntax highlighting */
pre code {
    color: #e2e8f0;
}

/* Resaltar comentarios */
pre:contains("<!--"), 
pre:contains("/*") {
    color: #a0aec0;
}

.instructions {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2.5rem;
    border-radius: 15px;
    margin: 3rem 0;
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.3);
}

.instructions h3 {
    color: white;
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.instructions ol {
    padding-left: 1.5rem;
    margin-bottom: 2rem;
}

.instructions li {
    margin: 1rem 0;
    font-size: 1.1rem;
    line-height: 1.6;
}

.instructions strong {
    color: #ffd700;
    font-weight: 600;
}

.instructions code {
    background: rgba(255, 255, 255, 0.2);
    color: #ffd700;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.95em;
    font-weight: 600;
}

.example {
    background: rgba(255, 255, 255, 0.1);
    padding: 1.5rem;
    border-radius: 10px;
    border-left: 4px solid #ffd700;
    margin-top: 1.5rem;
}

.example h4 {
    color: #ffd700;
    margin-bottom: 1rem;
    font-size: 1.3rem;
    font-weight: 600;
}

.example p {
    margin: 0.5rem 0;
    font-size: 1.05rem;
}

.example code {
    background: rgba(255, 255, 255, 0.3);
    color: white;
    font-weight: bold;
}

/* Responsivo para la sección de código */
@media (max-width: 768px) {
    .code-section {
        padding: 2rem 1rem;
    }
    
    .code-section h2 {
        font-size: 2rem;
    }
    
    .code-block {
        padding: 1.5rem;
        margin: 1.5rem 0;
    }
    
    .copy-btn {
        position: static;
        display: block;
        margin-bottom: 1rem;
        width: fit-content;
    }
    
    pre {
        padding: 15px;
        font-size: 12px;
    }
    
    .instructions {
        padding: 2rem;
    }
    
    .instructions h3 {
        font-size: 1.5rem;
    }
    
    .instructions li {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .code-section h2 {
        font-size: 1.8rem;
    }
    
    .code-block h3 {
        font-size: 1.3rem;
    }
    
    pre {
        font-size: 11px;
        padding: 10px;
    }
    
    .instructions {
        padding: 1.5rem;
    }
    
    .example {
        padding: 1rem;
    }
}

/* ========================================
   PROTECCIÓN ESPECÍFICA PARA WORDPRESS
   ======================================== */

/* Prevenir interferencias de temas de WordPress */
body.wordpress .whatsapp-float,
body.wp-admin .whatsapp-float,
body[class*="theme-"] .whatsapp-float,
body[class*="wp-"] .whatsapp-float,
.whatsapp-float {
    position: fixed !important;
    opacity: 1 !important;
    visibility: visible !important;
    display: flex !important;
    transform: none !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    z-index: 999999 !important;
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%) !important;
    will-change: transform !important;
}

/* Protección contra efectos de scroll de WordPress */
.whatsapp-float {
    -webkit-transform: translateZ(0) !important;
    transform: translateZ(0) !important;
    -webkit-backface-visibility: hidden !important;
    backface-visibility: hidden !important;
    -webkit-perspective: 1000 !important;
    perspective: 1000 !important;
}

/* Prevenir que scripts de WordPress cambien la opacidad */
body.scrolled .whatsapp-float,
body.scroll-up .whatsapp-float,
body.scroll-down .whatsapp-float,
body.sticky-header .whatsapp-float,
body.header-hidden .whatsapp-float,
body.header-visible .whatsapp-float,
.whatsapp-float[style*="opacity"],
.whatsapp-float[style*="display"],
.whatsapp-float[style*="visibility"] {
    opacity: 1 !important;
    visibility: visible !important;
    display: flex !important;
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%) !important;
}

/* Protección específica contra plugins de WordPress comunes */
/* Elementor */
.elementor-page .whatsapp-float,
.elementor-editor-active .whatsapp-float {
    z-index: 999999 !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* WPBakery */
.wpb-js-composer .whatsapp-float,
.vc_row .whatsapp-float {
    z-index: 999999 !important;
    opacity: 1 !important;
}

/* Divi */
.et-db .whatsapp-float,
.et_pb_section .whatsapp-float {
    z-index: 999999 !important;
    opacity: 1 !important;
}

/* Avada */
.avada-page .whatsapp-float,
.fusion-body .whatsapp-float {
    z-index: 999999 !important;
    opacity: 1 !important;
}

/* Protección contra temas populares de WordPress */
/* Astra */
.ast-theme .whatsapp-float,
.astra-theme .whatsapp-float {
    opacity: 1 !important;
    z-index: 999999 !important;
}

/* OceanWP */
.oceanwp-theme .whatsapp-float {
    opacity: 1 !important;
    z-index: 999999 !important;
}

/* GeneratePress */
.generate-theme .whatsapp-float {
    opacity: 1 !important;
    z-index: 999999 !important;
}

/* Twenty Twenty series */
.twentytwenty .whatsapp-float,
.twentytwentyone .whatsapp-float,
.twentytwentytwo .whatsapp-float,
.twentytwentythree .whatsapp-float,
.twentytwentyfour .whatsapp-float {
    opacity: 1 !important;
    z-index: 999999 !important;
}

/* Protección contra animaciones de scroll de WordPress */
@media screen {
    .whatsapp-float {
        -webkit-animation-fill-mode: both !important;
        animation-fill-mode: both !important;
        -webkit-animation-duration: 0.8s !important;
        animation-duration: 0.8s !important;
        opacity: 1 !important;
    }
}

/* Override de jQuery fade/slide effects */
.whatsapp-float[style] {
    opacity: 1 !important;
    visibility: visible !important;
    display: flex !important;
}

/* Protección contra CSS de admin bar de WordPress */
.admin-bar .whatsapp-float {
    z-index: 999999 !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Protección específica para el scroll en WordPress */
html[data-scroll="up"] .whatsapp-float,
html[data-scroll="down"] .whatsapp-float,
body[data-scroll="up"] .whatsapp-float,
body[data-scroll="down"] .whatsapp-float,
.scroll-up .whatsapp-float,
.scroll-down .whatsapp-float {
    opacity: 1 !important;
    visibility: visible !important;
    display: flex !important;
    transform: none !important;
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%) !important;
}

/* FORZAR COLORES ESPECÍFICOS - MÁXIMA PRIORIDAD */
.whatsapp-float .whatsapp-icon i,
.whatsapp-float .whatsapp-icon i::before,
.whatsapp-float .fab,
.whatsapp-float .fa-whatsapp {
    color: white !important;
    background: transparent !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.whatsapp-float .whatsapp-text,
.whatsapp-float .whatsapp-text span {
    background: white !important;
    background-color: white !important;
    color: #128C7E !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Override de frameworks CSS (Bootstrap, Tailwind, etc.) */
.whatsapp-float {
    background-image: linear-gradient(135deg, #25D366 0%, #128C7E 100%) !important;
    background-clip: padding-box !important;
}

/* Protección contra reset CSS global */
.whatsapp-float,
.whatsapp-float *,
.whatsapp-float *::before,
.whatsapp-float *::after {
    box-sizing: border-box !important;
}

/* Asegurar colores en todos los estados posibles */
.whatsapp-float:link,
.whatsapp-float:visited,
.whatsapp-float:hover,
.whatsapp-float:active,
.whatsapp-float:focus {
    color: white !important;
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%) !important;
    text-decoration: none !important;
}

/* Asegurar que Font Awesome funcione */
.whatsapp-float .fab::before {
    font-family: "Font Awesome 6 Brands" !important;
    font-weight: 400 !important;
    display: inline-block !important;
    font-style: normal !important;
    font-variant: normal !important;
    text-rendering: auto !important;
    line-height: 1 !important;
}

/* Backup para el icono de WhatsApp si Font Awesome falla */
.whatsapp-float .fa-whatsapp::before {
    content: "\f232" !important;
}

/* REGLA FINAL - MÁXIMA PRIORIDAD */
.whatsapp-float {
    opacity: 1 !important;
    visibility: visible !important;
    display: flex !important;
    position: fixed !important;
    z-index: 999999 !important;
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%) !important;
    pointer-events: auto !important;
}
