/* Site Chatbot — floating launcher + responsive chat panel.
   Desktop: docked ~380px window anchored bottom-right.
   Phone:   full-screen floating sheet. */

.site-chat {
    --pc-brand: #16a34a;
    --pc-brand-dark: #15803d;
    --pc-bot-bg: #f3f0f5;
    --pc-bot-text: #2a2330;
    --pc-user-bg: #16a34a;
    --pc-user-text: #ffffff;
    --pc-panel-bg: #ffffff;
    --pc-radius: 18px;
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 99990;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

/* ---------- Launcher button ---------- */
.site-chat__launcher {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    padding: 0;
    border: none;
    cursor: pointer;
    background: var(--pc-brand);
    color: #fff;
    border-radius: 50%;
    box-shadow: 0 10px 26px rgba(22, 163, 74, 0.45);
    transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
    animation: pc-float 3.2s ease-in-out infinite;
}
/* gentle attention pulse ring */
.site-chat__launcher::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    animation: pc-pulse 2.6s ease-out infinite;
    pointer-events: none;
}
.site-chat__launcher:hover { background: var(--pc-brand-dark); transform: translateY(-3px) scale(1.06); animation-play-state: paused; }
.site-chat__launcher:focus-visible { outline: 3px solid rgba(22,163,74,.4); outline-offset: 3px; }
.site-chat__launcher-icon { position: relative; z-index: 1; flex: 0 0 auto; width: 28px; height: 28px; }
/* small round icon — no text label */
.site-chat__launcher-label { display: none; }
@keyframes pc-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes pc-pulse { 0% { box-shadow: 0 0 0 0 rgba(22,163,74,.45); } 70% { box-shadow: 0 0 0 16px rgba(22,163,74,0); } 100% { box-shadow: 0 0 0 0 rgba(22,163,74,0); } }

.site-chat.is-open .site-chat__launcher { display: none; }

/* The panel below sets display:flex, which (as author CSS) overrides the browser's
   [hidden]{display:none}. This rule restores the hidden attribute so closePanel()
   actually hides the box. */
.site-chat__panel[hidden] { display: none !important; }

/* ---------- Panel ---------- */
.site-chat__panel {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 110px);
    background: var(--pc-panel-bg);
    border-radius: var(--pc-radius);
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: pc-pop .18s ease-out;
}
@keyframes pc-pop { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

.site-chat__header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--pc-brand), var(--pc-brand-dark));
    color: #fff;
}
.site-chat__avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; flex: 0 0 auto;
}
.site-chat__titles { display: flex; flex-direction: column; line-height: 1.25; flex: 1 1 auto; min-width: 0; }
.site-chat__title { font-size: 15px; }
.site-chat__subtitle { font-size: 12px; opacity: .85; }
.site-chat__close {
    background: transparent; border: none; color: #fff; font-size: 26px;
    line-height: 1; cursor: pointer; padding: 0 4px; opacity: .9;
}
.site-chat__close:hover { opacity: 1; }

.site-chat__messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px;
    background: #faf8fb;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.site-chat__msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 16px;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    animation: pc-fade .15s ease-out;
}
@keyframes pc-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.site-chat__msg a { color: inherit; text-decoration: underline; }
.site-chat__msg--bot {
    align-self: flex-start;
    background: var(--pc-bot-bg);
    color: var(--pc-bot-text);
    border-bottom-left-radius: 5px;
}
.site-chat__msg--user {
    align-self: flex-end;
    background: var(--pc-user-bg);
    color: var(--pc-user-text);
    border-bottom-right-radius: 5px;
}
.site-chat__msg--user a { color: #fff; }

/* Quick-reply language chips */
.site-chat__chips { display: flex; flex-wrap: wrap; gap: 8px; align-self: flex-start; max-width: 100%; }
.site-chat__chip {
    border: 1px solid var(--pc-brand);
    color: var(--pc-brand);
    background: #fff;
    border-radius: 999px;
    padding: 7px 14px;
    font-size: 14px;
    cursor: pointer;
    transition: background .12s ease, color .12s ease;
}
.site-chat__chip:hover { background: var(--pc-brand); color: #fff; }

/* Typing indicator */
.site-chat__typing { align-self: flex-start; display: inline-flex; gap: 4px; padding: 12px 14px; background: var(--pc-bot-bg); border-radius: 16px; border-bottom-left-radius: 5px; }
.site-chat__typing span { width: 7px; height: 7px; border-radius: 50%; background: #b9aec2; animation: pc-bounce 1.2s infinite ease-in-out; }
.site-chat__typing span:nth-child(2) { animation-delay: .15s; }
.site-chat__typing span:nth-child(3) { animation-delay: .3s; }
@keyframes pc-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }

.site-chat__form { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid #eee; background: #fff; }
.site-chat__input {
    flex: 1 1 auto;
    border: 1px solid #ddd;
    border-radius: 999px;
    padding: 11px 16px;
    font-size: 15px;
    outline: none;
    background: #fff;
    color: #222;
}
.site-chat__input:focus { border-color: var(--pc-brand); box-shadow: 0 0 0 3px rgba(184,51,106,.12); }
.site-chat__send {
    flex: 0 0 auto;
    width: 42px; height: 42px;
    border: none; border-radius: 50%;
    background: var(--pc-brand); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; transition: background .12s ease;
}
.site-chat__send:hover { background: var(--pc-brand-dark); }
.site-chat__send:disabled { background: #d8c7d1; cursor: default; }

.site-chat__footnote { text-align: center; font-size: 11px; color: #9a93a0; padding: 0 12px 10px; background: #fff; }

.site-chat.is-ended .site-chat__form { display: none; }

/* ---------- Phone: full-screen floating sheet ---------- */
@media (max-width: 600px) {
    .site-chat { right: 16px; bottom: 16px; }
    .site-chat__panel {
        position: fixed;
        right: 0; left: 0; top: 0; bottom: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100%;
        height: 100dvh;
        max-height: none;
        border-radius: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .site-chat__panel, .site-chat__msg, .site-chat__typing span { animation: none; }
    .site-chat__launcher, .site-chat__launcher::before { animation: none; transition: none; }
}
