/* =========================================================================
   WhatsApp floating widget  ·  KapiHub
   Site-wide FAB that expands into an Apple-style chat card.
   Self-contained palette: rides --amber where store.css is loaded (themed
   pages), falls back cleanly on dark-only inner pages. Dual-theme aware.
   ========================================================================= */

.wa-widget {
    --wa-green: #25D366;
    --wa-green-d: #1EBE5B;
    --wa-accent: var(--amber, #F0A01A);
    --wa-card-bg: rgba(22, 22, 29, 0.82);
    --wa-card-bdr: rgba(255, 255, 255, 0.12);
    --wa-text: #F4EFE6;
    --wa-muted: #A69E92;
    --wa-bubble: rgba(255, 255, 255, 0.06);
    --wa-head: rgba(37, 211, 102, 0.14);

    position: fixed;
    right: max(20px, env(safe-area-inset-right));
    bottom: max(22px, env(safe-area-inset-bottom));
    z-index: 900;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 14px;
    font-family: 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* Lift above the cookie consent banner while it is on screen */
.wa-widget.has-cookie {
    bottom: max(112px, calc(env(safe-area-inset-bottom) + 96px));
}

/* ---- Floating action button ------------------------------------------- */
.wa-fab {
    position: relative;
    width: 60px;
    height: 60px;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    background: linear-gradient(145deg, var(--wa-green) 0%, var(--wa-green-d) 100%);
    color: #fff;
    box-shadow:
        0 10px 26px rgba(37, 211, 102, 0.38),
        0 4px 10px rgba(0, 0, 0, 0.30);
    display: grid;
    place-items: center;
    transition: transform .28s cubic-bezier(.34, 1.56, .64, 1),
                box-shadow .28s ease;
    -webkit-tap-highlight-color: transparent;
}
.wa-fab:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow:
        0 16px 34px rgba(37, 211, 102, 0.45),
        0 6px 14px rgba(0, 0, 0, 0.35);
}
.wa-fab:active { transform: scale(.96); }
.wa-fab:focus-visible {
    outline: none;
    box-shadow:
        0 0 0 4px rgba(37, 211, 102, 0.30),
        0 0 0 7px var(--wa-accent),
        0 10px 26px rgba(37, 211, 102, 0.38);
}

.wa-fab i {
    position: absolute;
    transition: opacity .22s ease, transform .28s cubic-bezier(.34, 1.56, .64, 1);
}
.wa-ico-open  { font-size: 30px; opacity: 1; transform: rotate(0) scale(1); }
.wa-ico-close { font-size: 24px; opacity: 0; transform: rotate(-90deg) scale(.6); }

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

/* Attention pulse ring (one calm, looping pulse) */
.wa-fab::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--wa-green);
    z-index: -1;
    animation: wa-pulse 2.6s ease-out infinite;
}
.wa-widget[data-state="open"] .wa-fab::after { animation: none; opacity: 0; }

@keyframes wa-pulse {
    0%   { transform: scale(1);   opacity: .55; }
    70%  { transform: scale(1.7); opacity: 0; }
    100% { transform: scale(1.7); opacity: 0; }
}

/* ---- Chat card -------------------------------------------------------- */
.wa-card {
    width: 320px;
    max-width: calc(100vw - 40px);
    border-radius: 22px;
    overflow: hidden;
    background: var(--wa-card-bg);
    border: 1px solid var(--wa-card-bdr);
    color: var(--wa-text);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    backdrop-filter: blur(18px) saturate(140%);
    box-shadow:
        0 24px 60px rgba(0, 0, 0, 0.55),
        0 2px 0 rgba(255, 255, 255, 0.04) inset;
    transform-origin: bottom right;
    transform: translateY(14px) scale(.94);
    opacity: 0;
    pointer-events: none;
    transition: opacity .24s ease,
                transform .30s cubic-bezier(.34, 1.4, .5, 1);
}
.wa-card[hidden] { display: none; }
.wa-widget[data-state="open"] .wa-card {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.wa-card-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 16px 14px;
    background: var(--wa-head);
    border-bottom: 1px solid var(--wa-card-bdr);
}
.wa-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.22);
    flex: 0 0 auto;
}
.wa-id { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.wa-name { font-weight: 600; font-size: 15px; letter-spacing: .2px; }
.wa-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--wa-muted);
}
.wa-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--wa-green);
    box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.6);
    animation: wa-dot 2s ease-out infinite;
}
@keyframes wa-dot {
    0%   { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.55); }
    70%  { box-shadow: 0 0 0 7px rgba(37, 211, 102, 0); }
    100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }
}
.wa-close {
    margin-left: auto;
    width: 30px; height: 30px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: var(--wa-text);
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 14px;
    transition: background .2s ease, transform .2s ease;
    flex: 0 0 auto;
}
.wa-close:hover { background: rgba(255, 255, 255, 0.16); transform: rotate(90deg); }
.wa-close:focus-visible { outline: 2px solid var(--wa-accent); outline-offset: 2px; }

.wa-card-body { padding: 18px 16px 8px; }
.wa-bubble {
    background: var(--wa-bubble);
    border: 1px solid var(--wa-card-bdr);
    border-radius: 4px 16px 16px 16px;
    padding: 12px 14px;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--wa-text);
}
.wa-bubble p { margin: 0; }
.wa-bubble-title { font-weight: 600; margin-bottom: 4px !important; }
.wa-bubble p + p { margin-top: 6px; color: var(--wa-muted); }

.wa-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    margin: 14px 16px 18px;
    padding: 13px 18px;
    border-radius: 14px;
    background: linear-gradient(145deg, var(--wa-green) 0%, var(--wa-green-d) 100%);
    color: #fff;
    font-weight: 600;
    font-size: 14.5px;
    text-decoration: none;
    box-shadow: 0 8px 20px rgba(37, 211, 102, 0.32);
    transition: transform .2s ease, box-shadow .2s ease, filter .2s ease;
}
.wa-cta i { font-size: 19px; }
.wa-cta:hover { transform: translateY(-2px); filter: brightness(1.04); box-shadow: 0 12px 26px rgba(37, 211, 102, 0.40); }
.wa-cta:active { transform: translateY(0); }
.wa-cta:focus-visible { outline: 2px solid var(--wa-accent); outline-offset: 3px; }

/* ---- Light theme overrides (themed pages with data-theme="light") ------ */
html[data-theme="light"] .wa-widget {
    --wa-card-bg: rgba(255, 255, 255, 0.86);
    --wa-card-bdr: rgba(20, 18, 14, 0.10);
    --wa-text: #1A1714;
    --wa-muted: #6B6258;
    --wa-bubble: rgba(20, 18, 14, 0.05);
    --wa-head: rgba(37, 211, 102, 0.12);
}
html[data-theme="light"] .wa-card {
    box-shadow: 0 24px 60px rgba(40, 30, 10, 0.20);
}
html[data-theme="light"] .wa-close { background: rgba(20, 18, 14, 0.06); }
html[data-theme="light"] .wa-close:hover { background: rgba(20, 18, 14, 0.12); }

/* ---- Mobile ----------------------------------------------------------- */
@media (max-width: 480px) {
    .wa-fab { width: 56px; height: 56px; }
    .wa-ico-open { font-size: 28px; }
    .wa-card { width: min(320px, calc(100vw - 32px)); }
}

/* ---- Reduced motion --------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .wa-fab,
    .wa-fab i,
    .wa-card,
    .wa-close,
    .wa-cta { transition: none; }
    .wa-fab::after,
    .wa-dot { animation: none; }
    .wa-fab::after { opacity: 0; }
}
