/*
 * WhatsApp Contact Form
 * Estilos del frontend.
 * Todo con clases propias para evitar conflictos con otros estilos de la web.
 */

#whatsapp-contact-button.wa-contact-float {
    position: fixed;
    right: 15px;
    bottom: 90px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    z-index: 99998;
    cursor: pointer;
    text-decoration: none;
    overflow: visible;
    box-shadow: 0 4px 12px rgba(0,0,0,.25);
    background: #25D366;
}

#whatsapp-contact-button img {
    display: block;
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 50%;
}

/*
 * Etiqueta contextual del botón.
 * Información contextual del icono.
 */
.wa-contact-tooltip {
    position: absolute;
    right: 70px;
    top: 50%;
    transform: translateY(-50%) translateX(6px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    max-width: 220px;
    padding: 0 14px;
    background: #25D366;
    color: #0b0b0b;
    border-radius: 999px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
    font: 700 14px/1 Arial, sans-serif;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,.18);
}

#whatsapp-contact-button:hover .wa-contact-tooltip,
#whatsapp-contact-button:focus-visible .wa-contact-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(0);
}

#whatsapp-contact-form.wa-contact-form {
    position: fixed;
    right: 20px;
    bottom: 155px;
    width: 320px;
    background: #fff;
    border: 1px solid gainsboro;
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(0,0,0,.18);
    z-index: 99999;
    font-family: Arial, sans-serif;
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-y: auto;
    max-height: calc(100dvh - 170px);
}

#whatsapp-contact-form[hidden] {
    display: none !important;
}

.wa-contact-header {
    min-height: 76px;
    padding: 5px;
    background: #e8e7ff;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border-bottom: 1px solid #D4D4D4;
}

.wa-contact-logo {
    width: 56%;
    text-align: center;
    color: #243E90;
    font-size: 15px;
}

.wa-contact-logo [hidden] { display: none !important; }
.wa-contact-brand-fallback { display: block; font-size: 15px; font-weight: 700; line-height: 1.25; }
.wa-contact-logo img {
    display: block;
    max-width: 100%;
    max-height: 54px;
    margin: 10px auto;
}

.wa-contact-status {
    position: absolute;
    right: 5px;
    top: 5px;
    font-size: 12px;
    background: #f0f0f0;
    color: #6e6e6e;
    padding: 4px 8px;
    border-radius: 8px;
    line-height: 1;
    box-shadow: 0 7px 10px -9px #00000082;
    border: 1px solid #e5e5e5;
}

#wa-contact-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #48ff00;
    border-radius: 50%;
    margin-left: 4px;
}

.wa-contact-body {
    padding: 10px 16px;
    background-color: #fffaf2;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.wa-contact-title {
    text-align: center;
    font-weight: 700;
    margin: 0 0 10px;
    color: #243E90;
    line-height: 1.15;
    font-size: 12px;
}

.wa-contact-field {
    margin-bottom: 8px;
}

.wa-contact-field label {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 700;
    color: #222;
}

.wa-contact-field input,
.wa-contact-field textarea {
    width: 100%;
    padding: 5px 7px;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-sizing: border-box;
    background: #fff;
    font: 12px Arial, sans-serif;
    color: #222;
    outline: none;
}

.wa-contact-field input {
    height: 28px;
}

.wa-contact-field textarea {
    resize: none;
    min-height: 48px;
}

.wa-contact-field input:focus,
.wa-contact-field textarea:focus {
    border-color: #8da2df;
    box-shadow: 0 0 0 2px rgba(36,62,144,.08);
}

.wa-contact-hp {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.wa-contact-legal {
    margin-bottom: 8px;
    font-size: 10px;
    line-height: 1.35;
    color: #333;
}

/* Aceptación explícita de las condiciones antes de abrir WhatsApp. */
#whatsapp-contact-form .wa-contact-consent {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 10px 0 12px;
    color: #222;
    font: 11px/1.4 Arial, sans-serif;
}
#whatsapp-contact-form .wa-contact-consent input[type="checkbox"] {
    display: block;
    flex: 0 0 18px;
    width: 18px !important;
    height: 18px !important;
    min-height: 18px;
    margin: 0 !important;
    padding: 0 !important;
    appearance: auto;
    cursor: pointer;
    accent-color: #169d50;
}
#whatsapp-contact-form .wa-contact-consent input[type="checkbox"]:focus-visible {
    outline: 2px solid #2355ad;
    outline-offset: 2px;
}
#whatsapp-contact-form .wa-contact-consent label {
    display: block;
    flex: 1;
    cursor: pointer;
    font: inherit;
    color: inherit;
}
#whatsapp-contact-form .wa-contact-consent label span {
    color: #b82438;
    font-weight: 700;
}

.wa-contact-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.wa-contact-actions button {
    padding: 5px 14px;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    font: 12px Arial, sans-serif;
}

#wa-contact-cancel {
    color: red;
    background: transparent;
}

.wa-contact-actions button[type="submit"] {
    background: #25D366;
    color: #fff;
}

.wa-contact-actions button[type="submit"]:hover {
    background: #20bd5a;
}

@media (max-width: 480px) {
    #whatsapp-contact-button.wa-contact-float {
        right: 14px;
        bottom: 22px;
    }

    #whatsapp-contact-form.wa-contact-form {
        left: 12px;
        right: 12px;
        bottom: 92px;
        width: auto;
        max-width: none;
        max-height: calc(100dvh - 104px);
    }

    .wa-contact-tooltip {
        display: none;
    }
}

/*
 * Cambios de compatibilidad de estilos:
 * Ajustes de la ventana para mantener el aspecto compacto original en
 * móviles y escritorio. El diseño usa solamente estilos con prefijo propio.
 */
#whatsapp-contact-form.wa-contact-form {
    max-height: min(690px, calc(100dvh - 110px));
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}
#whatsapp-contact-form .wa-contact-close {
    position: absolute;
    left: 9px;
    top: 7px;
    z-index: 2;
    width: 25px;
    height: 25px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #364152;
    font: 22px/1 Arial, sans-serif;
    cursor: pointer;
}
#whatsapp-contact-form .wa-contact-close:hover,
#whatsapp-contact-form .wa-contact-close:focus-visible {
    background: rgba(0,0,0,.08);
}
#whatsapp-contact-form .wa-contact-legal-links {
    display: block;
    margin-top: 3px;
}
#whatsapp-contact-form .wa-contact-legal a {
    color: #243e90;
    text-decoration: underline;
    text-underline-offset: 2px;
}
@media (max-width: 480px) {
    #whatsapp-contact-form.wa-contact-form {
        max-height: calc(100dvh - 108px);
    }
}

/*
 * Ajustes visuales del formulario compacto.
 * Los estilos están aislados para reducir conflictos con la plantilla.
 */
#whatsapp-contact-form.wa-contact-form {
    right:16px; bottom:154px; width:min(350px, calc(100vw - 24px));
    max-height:min(590px, calc(100dvh - 118px)); border:0; border-radius:17px;
    box-shadow:0 14px 46px rgba(0,0,0,.35); color:#13202b;
    font:14px/1.4 Arial, Helvetica, sans-serif;
}
#whatsapp-contact-form .wa-contact-header {
    min-height:82px; padding:14px 45px 12px 16px; background:#e8e7ff; border-bottom:0;
}
#whatsapp-contact-form .wa-contact-logo { width:auto; max-width:168px; }
#whatsapp-contact-form .wa-contact-logo img {max-width:168px;max-height:53px;width:auto;height:auto;margin:0 auto;}
#whatsapp-contact-form .wa-contact-status {
    top:8px;right:9px;border:0;border-radius:999px;background:white;
    padding:3px 8px;box-shadow:none;font-size:11px;color:#4c5564;
}
#whatsapp-contact-form .wa-contact-body { padding:12px 16px 13px; background-color:#fbf8f1; }
#whatsapp-contact-form .wa-contact-title {
    text-align:center;font-size:13px;line-height:1.4;color:#254a98;margin:0 0 10px;
}
#whatsapp-contact-form .wa-contact-field {margin-bottom:9px;}
#whatsapp-contact-form .wa-contact-field label {
    font:bold 13px/1.4 Arial,Helvetica,sans-serif;color:#171717;margin:0 0 5px;
}
#whatsapp-contact-form .wa-contact-field input,
#whatsapp-contact-form .wa-contact-field textarea {
    display:block;box-sizing:border-box;width:100%;min-height:39px;height:auto;
    padding:10px 11px;border:1px solid #d1d5db;border-radius:9px;
    background:#fff;color:#171717;box-shadow:none;
    font:14px Arial,Helvetica,sans-serif;
}
#whatsapp-contact-form .wa-contact-field textarea {min-height:65px;resize:vertical;}
#whatsapp-contact-form .wa-contact-field input:focus,
#whatsapp-contact-form .wa-contact-field textarea:focus {
    border-color:#25d366;box-shadow:0 0 0 3px rgba(37,211,102,.15);
}
#whatsapp-contact-form .wa-contact-legal {margin:9px 0 12px;font-size:11px;line-height:1.5;color:#374151;}
#whatsapp-contact-form .wa-contact-actions {gap:12px;}
#whatsapp-contact-form .wa-contact-actions button {
    min-height:0;min-width:0;padding:11px 13px;border-radius:8px;
    font:bold 13px Arial,Helvetica,sans-serif;
}
#whatsapp-contact-form #wa-contact-cancel {color:#d73345;background:transparent;}
#whatsapp-contact-form .wa-contact-actions button[type=submit] {background:#20c963;color:#fff;}
#whatsapp-contact-form .wa-contact-actions button[type=submit]:hover {background:#11b954;}
#whatsapp-contact-form .wa-contact-close {top:9px;left:10px;}
@media(max-width:480px) {
    #whatsapp-contact-form.wa-contact-form {left:12px;right:12px;bottom:90px;width:auto;max-height:calc(100dvh - 108px);}
    #whatsapp-contact-form .wa-contact-body {padding:11px 13px;}
}
