/* Mobile WhatsApp-style popup — mobile only, reusable */

.mobile-whatsapp-popup-overlay {
    position: fixed;
    inset: 0;
    z-index: 10005;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    padding-top: max(16px, env(safe-area-inset-top, 0px));
    padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, visibility 0.35s ease;
    pointer-events: none;
}

.mobile-whatsapp-popup-overlay.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.mobile-whatsapp-popup {
    position: relative;
    width: 100%;
    max-width: 360px;
    border-radius: 12px;
    overflow: hidden;
    background: #efeae2;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.22);
    transform: scale(0.92);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.34, 1.2, 0.64, 1),
                opacity 0.35s ease;
    min-height: 400px;            
    display: flex;
    flex-direction: column;
}

.mobile-whatsapp-popup-overlay.is-visible .mobile-whatsapp-popup {
    transform: scale(1);
    opacity: 1;
}

.mobile-whatsapp-popup__close {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 3;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s ease;
}

.mobile-whatsapp-popup__close:hover,
.mobile-whatsapp-popup__close:focus {
    background: rgba(0, 0, 0, 0.5);
    outline: none;
}

/* WhatsApp chat header */
.mobile-whatsapp-popup__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 48px 12px 16px;
    background: #008069;
    color: #fff;
}

.mobile-whatsapp-popup__avatar {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #25D366;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.mobile-whatsapp-popup__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mobile-whatsapp-popup__header-info {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.mobile-whatsapp-popup__name {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-whatsapp-popup__verified {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

/* Chat body */
.mobile-whatsapp-popup__body {
    padding: 20px 16px 16px;
    background: #efeae2 url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d4cdc4' fill-opacity='0.35'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    flex: 1;
    display: flex;
    flex-direction: column;
}

.mobile-whatsapp-popup__chat {
    margin-bottom: 16px;
}

.mobile-whatsapp-popup__bubble {
    position: relative;
    max-width: 92%;
    margin-bottom: 0;
    padding: 10px 12px 8px;
    background: #fff;
    border-radius: 0 8px 8px 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    font-size: 15px;
    line-height: 1.45;
    color: #111;
}

.mobile-whatsapp-popup__bubble::before {
    content: '';
    position: absolute;
    top: 0;
    left: -8px;
    width: 0;
    height: 0;
    border-top: 8px solid #fff;
    border-left: 8px solid transparent;
}

.mobile-whatsapp-popup__bubble + .mobile-whatsapp-popup__bubble--follow-up {
    margin-top: 8px;
}

.mobile-whatsapp-popup__bubble--follow-up {
    opacity: 0;
    transform: translateY(8px);
    max-height: 0;
    overflow: hidden;
    padding-top: 0;
    padding-bottom: 0;
    margin-top: 0;
    pointer-events: none;
    transition: opacity 0.35s ease, transform 0.35s ease, max-height 0.35s ease, padding 0.35s ease, margin 0.35s ease;
}

.mobile-whatsapp-popup-overlay.has-second-message .mobile-whatsapp-popup__bubble--follow-up {
    opacity: 1;
    transform: translateY(0);
    max-height: 200px;
    padding: 10px 12px 8px;
    margin-top: 8px;
    pointer-events: auto;
}

.mobile-whatsapp-popup__time {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: #8696a0;
    text-align: right;
}

/* Typing indicator — appears after the message */
.mobile-whatsapp-popup__typing {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 72px;
    margin-top: 8px;
    padding: 12px 14px;
    background: #fff;
    border-radius: 0 8px 8px 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.mobile-whatsapp-popup__typing::before {
    content: '';
    position: absolute;
    top: 0;
    left: -8px;
    width: 0;
    height: 0;
    border-top: 8px solid #fff;
    border-left: 8px solid transparent;
}

.mobile-whatsapp-popup-overlay.is-typing .mobile-whatsapp-popup__typing {
    opacity: 1;
    transform: translateY(0);
}

.mobile-whatsapp-popup__typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #90949c;
    animation: mobile-whatsapp-popup-typing 1.4s ease-in-out infinite;
}

.mobile-whatsapp-popup__typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.mobile-whatsapp-popup__typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes mobile-whatsapp-popup-typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

.mobile-whatsapp-popup__cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 13px 20px;
    border: none;
    border-radius: 24px;
    background: #25D366;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 4px 14px rgba(37, 211, 102, 0.35);
    transition: background 0.2s ease, transform 0.2s ease;
    margin-top: auto;
}

.mobile-whatsapp-popup__cta:hover,
.mobile-whatsapp-popup__cta:focus {
    background: #20ba5a;
    color: #fff;
    transform: translateY(-1px);
}

.mobile-whatsapp-popup__cta i {
    font-size: 20px;
}

body.mobile-whatsapp-popup-open {
    overflow: hidden;
}

@media (min-width: 992px) {
    .mobile-whatsapp-popup-overlay {
        display: none !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mobile-whatsapp-popup-overlay,
    .mobile-whatsapp-popup {
        transition: none;
    }

    .mobile-whatsapp-popup {
        transform: none;
        opacity: 1;
    }

    .mobile-whatsapp-popup__typing {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .mobile-whatsapp-popup__typing-dot {
        animation: none;
        opacity: 0.7;
    }

    .mobile-whatsapp-popup__bubble--follow-up {
        opacity: 1;
        transform: none;
        max-height: none;
        padding: 10px 12px 8px;
        margin-top: 8px;
        transition: none;
    }
}
