/**
 * WhatsApp floating widget — premium minimal UI
 * Self-contained; no preprocessors or external fonts required.
 */

/* -------------------------------------------------------------------------- */
/* Design tokens (easy to tweak for brand alignment)                          */
/* -------------------------------------------------------------------------- */
.wa-widget {
    --wa-green: #25d366;
    --wa-green-dark: #1da851;
    --wa-ink: #0f1419;
    --wa-muted: #5c6c7a;
    --wa-border: rgba(15, 20, 25, 0.08);
    --wa-card-bg: #ffffff;
    --wa-shadow-soft: 0 4px 24px rgba(15, 20, 25, 0.08), 0 12px 48px rgba(15, 20, 25, 0.06);
    --wa-shadow-lift: 0 8px 32px rgba(15, 20, 25, 0.12), 0 24px 64px rgba(15, 20, 25, 0.1);
    --wa-radius-card: 20px;
    --wa-wa-header: #075e54;
    --wa-wa-header-deep: #064942;
    --wa-chat-bg: #e5ddd5;
    --wa-radius-fab: 50%;
    --wa-font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --wa-z: 2147483000;
}

/* -------------------------------------------------------------------------- */
/* Root container — fixed layer above site chrome                             */
/* -------------------------------------------------------------------------- */
.wa-widget {
    position: fixed;
    right: max(20px, env(safe-area-inset-right));
    bottom: max(20px, env(safe-area-inset-bottom));
    z-index: var(--wa-z);
    font-family: var(--wa-font);
    -webkit-font-smoothing: antialiased;
    pointer-events: none;
}

.wa-widget > * {
    pointer-events: auto;
}

/* -------------------------------------------------------------------------- */
/* Backdrop — mobile-first focus; subtle on larger screens when open          */
/* -------------------------------------------------------------------------- */
.wa-widget__backdrop {
    position: fixed;
    inset: 0;
    z-index: -1;
    background: rgba(15, 20, 25, 0.35);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

.wa-widget--open .wa-widget__backdrop:not([hidden]) {
    opacity: 1;
    visibility: visible;
}

@media (min-width: 480px) {
    .wa-widget__backdrop {
        background: rgba(15, 20, 25, 0.12);
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
    }
}

/* -------------------------------------------------------------------------- */
/* FAB — WhatsApp green circle                                                  */
/* -------------------------------------------------------------------------- */
.wa-widget__fab {
    position: relative;
    width: 60px;
    height: 60px;
    border: none;
    border-radius: var(--wa-radius-fab);
    background: linear-gradient(145deg, var(--wa-green) 0%, var(--wa-green-dark) 100%);
    color: #fff;
    cursor: pointer;
    box-shadow: var(--wa-shadow-soft), 0 0 0 1px rgba(255, 255, 255, 0.12) inset;
    display: grid;
    place-items: center;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
}

.wa-widget__fab:hover {
    transform: scale(1.06);
    box-shadow: var(--wa-shadow-lift), 0 0 0 1px rgba(255, 255, 255, 0.15) inset;
}

.wa-widget__fab:active {
    transform: scale(0.96);
}

.wa-widget__fab:focus-visible {
    outline: 3px solid rgba(37, 211, 102, 0.45);
    outline-offset: 3px;
}

.wa-widget__fab-icon {
    width: 30px;
    height: 30px;
}

/* Pulse ring when notification badge visible (draws attention on first load) */
.wa-widget__fab--pulse::after {
    content: "";
    position: absolute;
    inset: -4px;
    border-radius: inherit;
    border: 2px solid var(--wa-green);
    opacity: 0.45;
    animation: wa-pulse 2s ease-out infinite;
    pointer-events: none;
}

@keyframes wa-pulse {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }
    70% {
        transform: scale(1.15);
        opacity: 0;
    }
    100% {
        transform: scale(1.15);
        opacity: 0;
    }
}

/* -------------------------------------------------------------------------- */
/* Notification bubble on FAB                                                 */
/* -------------------------------------------------------------------------- */
.wa-widget__fab-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 10px;
    min-height: 10px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ff3b30;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.wa-widget__fab-badge:not([hidden]) {
    display: block;
}

/* -------------------------------------------------------------------------- */
/* Panel — floating card (Intercom / Tidio inspired)                          */
/* -------------------------------------------------------------------------- */
.wa-widget__panel {
    position: absolute;
    right: 0;
    bottom: calc(60px + 16px);
    width: min(calc(100vw - 40px), 360px);
    max-height: min(70vh, 480px);
    transform-origin: bottom right;
    transform: translateY(12px) scale(0.94);
    opacity: 0;
    visibility: hidden;
    transition:
        transform 0.38s cubic-bezier(0.22, 1, 0.36, 1),
        opacity 0.32s ease,
        visibility 0.32s ease;
    filter: drop-shadow(0 0 1px rgba(15, 20, 25, 0.04));
}

.wa-widget--open .wa-widget__panel:not([hidden]) {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

.wa-widget__panel-inner {
    background: var(--wa-card-bg);
    border-radius: var(--wa-radius-card);
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: var(--wa-shadow-lift);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* -------------------------------------------------------------------------- */
/* Header — WhatsApp-style teal bar (FAB unchanged elsewhere)               */
/* -------------------------------------------------------------------------- */
.wa-widget__header {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 2.75rem 0.85rem 1rem;
    text-align: left;
    background: linear-gradient(180deg, var(--wa-wa-header) 0%, var(--wa-wa-header-deep) 100%);
    border-bottom: none;
}

.wa-widget__close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: rgba(255, 255, 255, 0.92);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: background 0.2s ease, color 0.2s ease;
}

.wa-widget__close:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

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

/* Avatar + online indicator */
.wa-widget__avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.wa-widget__avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    border: 2px solid rgba(255, 255, 255, 0.25);
}

.wa-widget__avatar img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 20%;
}

.wa-widget__avatar-status {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--wa-green);
    border: 2px solid var(--wa-wa-header-deep);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
}

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

.wa-widget__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #fff;
    line-height: 1.25;
}

.wa-widget__subtitle {
    margin: 0.2rem 0 0;
    font-size: 0.8125rem;
    color: rgba(255, 255, 255, 0.78);
    font-weight: 400;
    line-height: 1.35;
}

/* -------------------------------------------------------------------------- */
/* Body — chat wallpaper + bubble + CTA                                     */
/* -------------------------------------------------------------------------- */
.wa-widget__body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem 1rem 1.15rem;
    min-height: 0;
    background-color: var(--wa-chat-bg);
    background-image:
        radial-gradient(circle at 12% 18%, rgba(0, 0, 0, 0.04) 0%, transparent 28%),
        radial-gradient(circle at 88% 12%, rgba(0, 0, 0, 0.03) 0%, transparent 24%),
        radial-gradient(circle at 72% 88%, rgba(0, 0, 0, 0.035) 0%, transparent 32%),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72' viewBox='0 0 72 72'%3E%3Ccircle cx='8' cy='10' r='1.2' fill='%23000' fill-opacity='.055'/%3E%3Ccircle cx='38' cy='22' r='1' fill='%23000' fill-opacity='.045'/%3E%3Ccircle cx='58' cy='8' r='0.9' fill='%23000' fill-opacity='.05'/%3E%3Ccircle cx='24' cy='48' r='1.1' fill='%23000' fill-opacity='.04'/%3E%3Ccircle cx='62' cy='52' r='0.85' fill='%23000' fill-opacity='.055'/%3E%3C/svg%3E");
}

.wa-widget__bubble {
    position: relative;
    align-self: flex-start;
    max-width: 92%;
    padding: 0.65rem 2.75rem 0.55rem 0.75rem;
    background: #fff;
    border-radius: 0 10px 10px 10px;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
}

/* Speech-bubble tail */
.wa-widget__bubble::before {
    content: "";
    position: absolute;
    left: -6px;
    top: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 6px 8px 0;
    border-color: transparent #fff transparent transparent;
    filter: drop-shadow(-0.5px 0.5px 0 rgba(0, 0, 0, 0.04));
}

.wa-widget__bubble-line {
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.45;
    color: #1f2c34;
}

.wa-widget__bubble-line + .wa-widget__bubble-line {
    margin-top: 0.15rem;
}

.wa-widget__bubble-time {
    position: absolute;
    right: 0.45rem;
    bottom: 0.35rem;
    font-size: 0.6875rem;
    line-height: 1;
    color: rgba(0, 0, 0, 0.38);
    font-variant-numeric: tabular-nums;
}

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

.wa-widget__cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    width: 100%;
    padding: 0.85rem 1.25rem;
    border-radius: 9999px;
    border: none;
    background: linear-gradient(145deg, var(--wa-green) 0%, var(--wa-green-dark) 100%);
    color: #fff;
    font-size: 0.9375rem;
    font-weight: 700;
    font-family: inherit;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.wa-widget__cta:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.35);
    filter: brightness(1.02);
}

.wa-widget__cta:active {
    transform: translateY(0);
}

.wa-widget__cta:focus-visible {
    outline: 3px solid rgba(37, 211, 102, 0.45);
    outline-offset: 3px;
}

.wa-widget__cta-icon {
    flex-shrink: 0;
}

/* -------------------------------------------------------------------------- */
/* When panel open: nudge FAB slightly (optional polish)                      */
/* -------------------------------------------------------------------------- */
.wa-widget--open .wa-widget__fab {
    box-shadow: 0 2px 12px rgba(37, 211, 102, 0.35);
}

/* -------------------------------------------------------------------------- */
/* Reduced motion                                                             */
/* -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .wa-widget__fab,
    .wa-widget__panel,
    .wa-widget__backdrop,
    .wa-widget__cta,
    .wa-widget__close {
        transition-duration: 0.01ms !important;
    }

    .wa-widget__fab--pulse::after {
        animation: none;
    }
}

/* -------------------------------------------------------------------------- */
/* Small screens — stack panel above FAB with safe spacing                    */
/* -------------------------------------------------------------------------- */
@media (max-width: 379px) {
    .wa-widget__panel {
        width: calc(100vw - 24px);
        right: max(0px, calc(env(safe-area-inset-right) - 4px));
    }
}
