/* ============================================================
   WhatsApp Floating Chat Widget — Brand teal header + WA bubble
   ============================================================ */

.wa-widget {
    position: fixed;
    bottom: 28px;
    left: 28px;
    z-index: 9998;
    font-family: var(--font-body, 'Nunito Sans', system-ui, sans-serif);
}

/* ---------- Floating toggle button ---------- */
.wa-widget__toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border: none;
    border-radius: 50%;
    background: #25D366;
    color: #ffffff;
    cursor: pointer;
    box-shadow:
        0 10px 28px rgba(37, 211, 102, 0.45),
        0 2px 6px rgba(0, 0, 0, 0.12);
    transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.wa-widget__toggle:hover {
    transform: translateY(-2px) scale(1.04);
    background: #1ebe5b;
    box-shadow:
        0 14px 32px rgba(37, 211, 102, 0.55),
        0 3px 8px rgba(0, 0, 0, 0.16);
}

.wa-widget__toggle:focus-visible {
    box-shadow:
        0 0 0 3px rgba(255, 255, 255, 0.85),
        0 0 0 6px rgba(37, 211, 102, 0.55);
}

/* Pulse ring */
.wa-widget__toggle::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(37, 211, 102, 0.55);
    animation: wa-pulse 2.4s ease-out infinite;
    z-index: -1;
    opacity: 0;
    pointer-events: none;
}

@keyframes wa-pulse {
    0%   { transform: scale(0.92); opacity: 0.7; }
    70%  { transform: scale(1.4);  opacity: 0;   }
    100% { transform: scale(1.4);  opacity: 0;   }
}

.wa-widget__toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, opacity 0.2s ease;
}

.wa-widget__toggle-icon--close {
    position: absolute;
    inset: 0;
    margin: auto;
    opacity: 0;
    transform: rotate(-90deg) scale(0.7);
    width: 24px;
    height: 24px;
}

.wa-widget[data-state="open"] .wa-widget__toggle-icon--wa {
    opacity: 0;
    transform: rotate(90deg) scale(0.7);
}

.wa-widget[data-state="open"] .wa-widget__toggle-icon--close {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

.wa-widget[data-state="open"] .wa-widget__toggle::before {
    animation: none;
    opacity: 0;
}

/* ---------- Chat panel ---------- */
.wa-widget__panel {
    position: absolute;
    bottom: calc(100% + 16px);
    left: 0;
    width: min(360px, calc(100vw - 56px));
    background: #ffffff;
    border-radius: 18px;
    overflow: hidden;
    box-shadow:
        0 24px 64px rgba(13, 35, 30, 0.28),
        0 6px 16px rgba(13, 35, 30, 0.12);
    transform: translateY(16px) scale(0.96);
    transform-origin: bottom left;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.22s ease,
                visibility 0s linear 0.22s;
}

.wa-widget[data-state="open"] .wa-widget__panel {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.24s ease,
                visibility 0s;
}

/* ---------- Header (brand teal) ---------- */
.wa-widget__header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 18px 20px;
    background: linear-gradient(180deg, #1F5A57 0%, #14403E 100%);
    color: #ffffff;
}

.wa-widget__avatar {
    flex: 0 0 auto;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    background: #ffffff;
    border: 2px solid rgba(255, 255, 255, 0.85);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.wa-widget__avatar img {
    width: 78%;
    height: 78%;
    object-fit: contain;
    display: block;
}

.wa-widget__heading {
    flex: 1 1 auto;
    min-width: 0;
}

.wa-widget__name {
    margin: 0 0 2px;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.2;
    color: #ffffff;
    letter-spacing: 0.01em;
}

.wa-widget__status {
    margin: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.78);
    line-height: 1;
}

.wa-widget__dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #41D67C;
    box-shadow: 0 0 0 2px rgba(65, 214, 124, 0.25);
}

.wa-widget__close {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.wa-widget__close:hover {
    background: rgba(255, 255, 255, 0.24);
    transform: scale(1.05);
}

.wa-widget__close:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.85);
    outline-offset: 2px;
}

/* ---------- Body (chat texture) ---------- */
.wa-widget__body {
    padding: 22px 18px 20px;
    background:
        radial-gradient(circle at 12px 12px, rgba(0,0,0,0.04) 1px, transparent 1.5px) 0 0/22px 22px,
        #E6DDD2;
    min-height: 130px;
}

.wa-widget__bubble-msg {
    position: relative;
    background: #ffffff;
    border-radius: 14px;
    padding: 14px 16px 22px;
    box-shadow: 0 1px 1.5px rgba(13, 35, 30, 0.08);
    max-width: 100%;
}

.wa-widget__bubble-msg::before {
    content: '';
    position: absolute;
    top: 0;
    left: -7px;
    width: 14px;
    height: 14px;
    background: #ffffff;
    clip-path: polygon(100% 0, 0 0, 100% 100%);
}

.wa-widget__bubble-msg p {
    margin: 0;
    font-size: 14.5px;
    line-height: 1.5;
    color: #14212d;
    font-weight: 400;
}

.wa-widget__wave {
    display: inline-block;
    transform-origin: 70% 70%;
    animation: wa-wave 2.2s ease-in-out 1s infinite;
}

@keyframes wa-wave {
    0%, 60%, 100% { transform: rotate(0deg); }
    10%           { transform: rotate(14deg); }
    20%           { transform: rotate(-8deg); }
    30%           { transform: rotate(14deg); }
    40%           { transform: rotate(-4deg); }
    50%           { transform: rotate(10deg); }
}

.wa-widget__time {
    position: absolute;
    bottom: 6px;
    right: 10px;
    font-size: 11px;
    color: rgba(20, 33, 45, 0.45);
    font-weight: 500;
}

/* ---------- Footer CTA ---------- */
.wa-widget__footer {
    padding: 14px 16px 18px;
    background: #f5f1ea;
    border-top: 1px solid rgba(20, 33, 45, 0.05);
}

.wa-widget__cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px 18px;
    background: #25D366;
    color: #ffffff;
    border-radius: 999px;
    text-decoration: none;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.01em;
    box-shadow: 0 6px 14px rgba(37, 211, 102, 0.32);
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.wa-widget__cta:hover {
    background: #1ebe5b;
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(37, 211, 102, 0.42);
    color: #ffffff;
}

.wa-widget__cta:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

.wa-widget__cta svg {
    flex: 0 0 auto;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .wa-widget__toggle,
    .wa-widget__panel,
    .wa-widget__cta,
    .wa-widget__close,
    .wa-widget__toggle-icon {
        transition: none !important;
    }
    .wa-widget__toggle::before,
    .wa-widget__wave {
        animation: none !important;
    }
}

/* ---------- Mobile ---------- */
@media (max-width: 480px) {
    .wa-widget {
        bottom: 20px;
        left: 20px;
    }
    .wa-widget__toggle {
        width: 58px;
        height: 58px;
    }
    .wa-widget__panel {
        width: min(340px, calc(100vw - 32px));
    }
}

/* ---------- Legacy class shim — old markup hidden if it still ships ---------- */
.whatsapp-float { display: none !important; }

/* ============================================================
   Scroll-to-top button — fixed bottom-right
   ============================================================ */
.scroll-top {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9998;
    width: 64px;
    height: 64px;
    border: none;
    border-radius: 50%;
    background: var(--color-night, #1a2332);
    color: var(--color-accent-gold, #C9A961);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 10px 28px rgba(26, 35, 50, 0.35),
        0 2px 6px rgba(0, 0, 0, 0.14);
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: opacity 0.3s ease, visibility 0s linear 0.3s,
                transform 0.3s ease, box-shadow 0.25s ease, background 0.25s ease;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.scroll-top.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition: opacity 0.3s ease, visibility 0s,
                transform 0.3s ease, box-shadow 0.25s ease, background 0.25s ease;
}

.scroll-top:hover {
    background: var(--color-accent-gold, #C9A961);
    color: var(--color-night, #1a2332);
    transform: translateY(-3px);
    box-shadow:
        0 14px 32px rgba(201, 169, 97, 0.45),
        0 3px 8px rgba(0, 0, 0, 0.16);
}

.scroll-top:focus-visible {
    box-shadow:
        0 0 0 3px rgba(255, 255, 255, 0.85),
        0 0 0 6px rgba(201, 169, 97, 0.55);
}

@media (max-width: 480px) {
    .scroll-top {
        bottom: 20px;
        right: 20px;
        width: 54px;
        height: 54px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .scroll-top { transition: none !important; }
}
