/* Pi Chatbot — panel shell: the fixed-position frame, its open/close animation, and the
   header row (icon/title/close/reset). Layout modeled on the Saigon House template
   (header/messages/footer), colors from chatbot-tokens.css. */

#pi-chatbot-panel {
    position: fixed;
    right: 88px; /* Left of the floating button cluster */
    /* Matches the EXACT bottom of #sh-floating-buttons (16px, floating-buttons.css) —
       the panel's bottom edge lines up with the button cluster's bottom instead of being
       offset arbitrarily. */
    bottom: 16px;
    width: min(420px, calc(100vw - 32px));
    height: min(640px, calc(100dvh - 88px));
    /* The 400px height floor exceeds the viewport height on a PHONE IN LANDSCAPE (~375px
       tall) — the @media max-width rule (chatbot-responsive.css) only gates on WIDTH, so
       it doesn't apply there (812px landscape width > 767px). Result: the header
       (containing the close/reset buttons) gets pushed above the screen and becomes
       unclickable. max-height wins over height in used-value resolution, so this one
       line blocks the whole bug class — no separate @media max-height rule needed. */
    max-height: calc(100dvh - 32px);
    background: color-mix(in srgb, var(--cb-dark, #0a0a0a) 85%, transparent);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--cb-border);
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), 0 0 50px var(--cb-accent-glow-dim);
    display: none;
    flex-direction: column;
    z-index: calc(var(--z-floating-btns, 55) + 1);
    overflow: hidden;
    font-family: var(--font-sans, system-ui, sans-serif);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

/* backdrop-filter unsupported (or disabled) -> the 85%-transparent background sits over
   the live page content behind it, making text nearly unreadable. Fallback to an opaque
   background. */
@supports not ((backdrop-filter: blur(20px)) or (-webkit-backdrop-filter: blur(20px))) {
    #pi-chatbot-panel {
        background: var(--cb-dark, #0a0a0a);
    }
}

@keyframes cb-slide-up {
    from { transform: translateY(24px) scale(0.96); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

#pi-chatbot-panel.is-open {
    display: flex;
    animation: cb-slide-up 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.pi-cb-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;
}

/* ── Header ── */
#pi-chatbot-panel .pi-cb-header {
    padding: 16px 18px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--cb-text) 3%, transparent) 0%, transparent 100%);
    border-bottom: 1px solid var(--cb-border);
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--cb-text);
}
#pi-chatbot-panel .pi-cb-icon {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--cb-accent-soft);
    border: 1px solid var(--cb-accent-ring);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cb-accent);
}
#pi-chatbot-panel .pi-cb-title {
    flex: 1;
    min-width: 0;
    font-weight: 700;
    font-size: 15px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--cb-text);
}
#pi-chatbot-panel .pi-cb-title small {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 400;
    font-size: 11px;
    margin-top: 2px;
    color: var(--cb-text-muted);
}
#pi-chatbot-panel .pi-cb-dot {
    width: 6px; height: 6px;
    background: var(--cb-online); /* = --color-success của theme */
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.8);
}
#pi-chatbot-panel .pi-cb-actions {
    display: flex;
    gap: 6px;
}
#pi-chatbot-panel .pi-cb-actions button {
    background: color-mix(in srgb, var(--cb-text) 5%, transparent);
    border: 1px solid color-mix(in srgb, var(--cb-text) 5%, transparent);
    color: var(--cb-text-muted);
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
#pi-chatbot-panel .pi-cb-actions button:hover {
    background: color-mix(in srgb, var(--cb-text) 10%, transparent);
    color: var(--cb-text);
    border-color: color-mix(in srgb, var(--cb-text) 10%, transparent);
}

/* Task 009: built-in launcher button — rendered by chatbot.js only when the
   theme doesn't provide its own toggle (no #sh-toggle or whatever the
   launcherSelector setting points to). Horeca never sees this; a site on a
   generic theme does. */
.pi-cb-launcher {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: var(--cb-z-index);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: var(--cb-accent);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.pi-cb-launcher:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
.pi-cb-launcher svg {
    width: 24px;
    height: 24px;
}

