/* =====================================================================
   WHATSAPP · versión compacta y acotada para la comunidad
   =====================================================================
   El popup traía tres contactos con avatares grandes y textos sin recortar,
   así que se desbordaba:

   - en Y, porque crecía más que la ventana y el final quedaba fuera de
     pantalla, sin forma de llegar a él;
   - en X, porque el título es "Soporte {{ store_name }}" y los nombres de
     empresa largos ensanchaban la caja por encima del ancho del viewport.

   Aquí se arregla la geometría: la caja se limita con min() contra el
   viewport, el alto se topa con max-height y el que hace scroll es el
   contenedor de contactos, no la página. Los textos recortan con ellipsis
   en vez de empujar.

   Va después de plugin/whatsapp-chat-support.css y usa !important en las
   propiedades de geometría porque el plugin las fija a mano.
   ===================================================================== */

#wa-support {
    --wa-verde: #25d366;
    --wa-verde-oscuro: #128c7e;
    --wa-linea: #e6e9ef;
    --wa-texto: #172033;
    --wa-suave: #64748b;

    position: fixed !important;
    right: 22px !important;
    bottom: 22px !important;
    left: auto !important;
    top: auto !important;
    z-index: 10030;
}

/* El carrito manda cuando está abierto. */
body.store-cart-open #wa-support {
    z-index: 1000 !important;
    pointer-events: none;
}

/* ---------- Botón ---------- */

#wa-support .wcs_button {
    width: 56px !important;
    height: 56px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: var(--wa-verde);
    box-shadow: 0 12px 30px rgba(18, 140, 126, .28);
    cursor: pointer;
    transition: transform .2s ease, box-shadow .2s ease;
}

#wa-support .wcs_button:hover,
#wa-support .wcs_button:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 16px 34px rgba(18, 140, 126, .34);
    outline: none;
}

#wa-support .wcs_button img {
    width: 30px !important;
    height: 30px !important;
    display: block;
}

/* ---------- Popup: columna con un solo scroll interno ---------- */

#wa-support .wcs_popup {
    position: absolute !important;
    right: 0 !important;
    left: auto !important;
    /* Anclado al propio contenedor: así queda siempre justo encima del botón,
       mida lo que mida. Con un offset fijo, cualquier regla que cambiara el
       alto del botón hacía que el popup lo solapara. */
    bottom: calc(100% + 12px) !important;
    top: auto !important;

    /* Nunca más ancho que la ventana. */
    width: min(320px, calc(100vw - 24px)) !important;
    max-width: calc(100vw - 24px) !important;
    box-sizing: border-box;

    /* Nunca más alto que la ventana: el scroll va dentro. */
    max-height: min(72vh, calc(100vh - 130px)) !important;
    display: flex;
    flex-direction: column;
    overflow: hidden !important;

    margin: 0 !important;
    border: 1px solid var(--wa-linea);
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 20px 50px rgba(15, 23, 42, .2);

    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(10px) scale(.98);
    transform-origin: bottom right;
    transition: opacity .2s ease, visibility .2s ease, transform .2s ease;
}

#wa-support.wa-support-open .wcs_popup {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

/* ---------- Cabecera compacta ---------- */

#wa-support .wcs_popup_header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 44px 14px 14px !important;
    background: var(--wa-verde);
    color: #ffffff;
}

#wa-support .wcs_popup_header img {
    width: 34px !important;
    height: 34px !important;
    flex: 0 0 34px;
    padding: 6px;
    box-sizing: border-box;
    border-radius: 50%;
    background: rgba(255, 255, 255, .16);
}

#wa-support .wcs_popup_header_text {
    min-width: 0;
}

/* El titulo lleva el nombre de la empresa: recorta, no ensancha. */
#wa-support .wcs_popup_header_title {
    font-size: 14px;
    font-weight: 800;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#wa-support .wcs_popup_header_description {
    margin-top: 2px;
    font-size: 11px;
    line-height: 1.3;
    opacity: .94;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#wa-support .wcs_popup_close {
    position: absolute !important;
    top: 10px !important;
    right: 10px !important;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(0, 0, 0, .14);
    color: #ffffff;
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
}

/* ---------- Contactos: esto es lo único que hace scroll ---------- */

#wa-support .wcs_popup_person_container {
    flex: 1 1 auto;
    min-height: 0;
    padding: 10px !important;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    background: #f7f8fa;
}

#wa-support .wcs_popup_person_container::-webkit-scrollbar {
    width: 7px;
}

#wa-support .wcs_popup_person_container::-webkit-scrollbar-thumb {
    border-radius: 7px;
    background: #d6dae2;
}

#wa-support .wcs_popup_person {
    display: flex !important;
    align-items: center;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
    padding: 9px 11px !important;
    margin: 0 0 7px !important;
    border: 1px solid var(--wa-linea);
    border-radius: 13px;
    background: #ffffff;
    cursor: pointer;
    transition: border-color .18s ease, box-shadow .18s ease;
}

#wa-support .wcs_popup_person:last-child {
    margin-bottom: 0 !important;
}

#wa-support .wcs_popup_person:hover,
#wa-support .wcs_popup_person:focus-visible {
    border-color: rgba(37, 211, 102, .55);
    box-shadow: 0 8px 20px rgba(15, 23, 42, .07);
    outline: none;
}

#wa-support .wcs_popup_person_img {
    width: 38px !important;
    height: 38px !important;
    flex: 0 0 38px;
    margin: 0 !important;
    overflow: hidden;
    border-radius: 50%;
    background: #ecfdf3;
}

#wa-support .wcs_popup_person_img img {
    width: 100% !important;
    height: 100% !important;
    display: block;
    object-fit: cover;
}

#wa-support .wcs_popup_person_content {
    min-width: 0;
    flex: 1;
}

#wa-support .wcs_popup_person_name,
#wa-support .wcs_popup_person_description,
#wa-support .wcs_popup_person_status {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#wa-support .wcs_popup_person_name {
    font-size: 13px;
    font-weight: 800;
    color: var(--wa-texto);
    line-height: 1.25;
}

#wa-support .wcs_popup_person_description {
    margin-top: 1px;
    font-size: 11px;
    color: var(--wa-suave);
    line-height: 1.3;
}

#wa-support .wcs_popup_person_status {
    margin-top: 2px;
    font-size: 10px;
    font-weight: 700;
    color: #16a34a;
    line-height: 1.2;
}

/* ---------- Composer fijo abajo ---------- */

#wa-support .wcs_popup_input {
    flex: 0 0 auto;
    display: flex !important;
    align-items: center;
    gap: 8px;
    box-sizing: border-box;
    padding: 9px 10px !important;
    border-top: 1px solid var(--wa-linea);
    background: #ffffff;
}

#wa-support .wcs_popup_input input {
    min-width: 0;
    flex: 1;
    width: auto !important;
    height: 36px;
    padding: 0 11px;
    box-sizing: border-box;
    border: 1px solid var(--wa-linea);
    border-radius: 11px;
    background: #ffffff;
    color: var(--wa-texto);
    font-size: 12.5px;
}

#wa-support .wcs_popup_input input:focus {
    border-color: rgba(37, 211, 102, .55);
    outline: none;
}

#wa-support .wcs_popup_input i {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    background: var(--wa-verde);
    color: #ffffff;
    font-size: 13px;
    cursor: pointer;
}

#wa-support .wcs_popup_input i:hover {
    background: var(--wa-verde-oscuro);
}

/* ---------- Móvil: por encima del dock, y anclado al viewport ---------- */

@media (max-width: 767.98px) {
    #wa-support {
        right: 13px !important;
        bottom: calc(76px + env(safe-area-inset-bottom)) !important;
    }

    #wa-support .wcs_button {
        width: 50px !important;
        height: 50px !important;
    }

    #wa-support .wcs_button img {
        width: 26px !important;
        height: 26px !important;
    }

    #wa-support .wcs_popup {
        right: 0 !important;
        bottom: calc(100% + 10px) !important;
        width: min(320px, calc(100vw - 26px)) !important;
        max-height: min(62vh, calc(100vh - 215px)) !important;
    }
}

/* Pantallas muy bajas: deja respirar al listado. */
@media (max-height: 560px) {
    #wa-support .wcs_popup {
        max-height: calc(100vh - 96px) !important;
    }

    #wa-support .wcs_popup_header {
        padding: 10px 40px 10px 12px !important;
    }
}
