/* ============================================================
   BestiBest — Chat Widget (AI Concierge)
   ============================================================ */

.bb-chat {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ===== Toggle button (round, gold) ===== */
.bb-chat__toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--accent-gold, #F5A623);
    color: #121212;
    border: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(245, 166, 35, 0.40), 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    z-index: 2;
    overflow: hidden;
}
.bb-chat__toggle:hover {
    transform: scale(1.06) translateY(-2px);
    box-shadow: 0 12px 32px rgba(245, 166, 35, 0.55), 0 6px 16px rgba(0, 0, 0, 0.35);
}
.bb-chat__toggle:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 2px;
}

/* Pulse ring */
.bb-chat__toggle::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid var(--accent-gold, #F5A623);
    opacity: 0;
    animation: bb-chat-pulse 2.4s ease-out infinite;
}
@keyframes bb-chat-pulse {
    0%   { opacity: 0.55; transform: scale(0.8); }
    70%  { opacity: 0;    transform: scale(1.4); }
    100% { opacity: 0;    transform: scale(1.4); }
}

/* Icon swap */
.bb-chat__toggle-icon { transition: transform 0.25s ease, opacity 0.25s ease; position: absolute; }
.bb-chat__toggle-icon--chat   { transform: scale(1); opacity: 1; }
.bb-chat__toggle-icon--close  { transform: scale(0.5) rotate(-90deg); opacity: 0; }
.bb-chat[data-state="open"] .bb-chat__toggle-icon--chat   { transform: scale(0.5) rotate(90deg); opacity: 0; }
.bb-chat[data-state="open"] .bb-chat__toggle-icon--close  { transform: scale(1) rotate(0); opacity: 1; }
.bb-chat[data-state="open"] .bb-chat__toggle::before { animation: none; opacity: 0; }

/* ===== Peek bubble (proactive message) ===== */
.bb-chat__peek {
    position: absolute;
    bottom: calc(100% + 16px);
    right: 0;
    width: 280px;
    background: #1a1a1a;
    border: 1px solid var(--accent-gold, #F5A623);
    border-radius: 14px;
    padding: 16px 16px 14px 16px;
    color: var(--text-main, #F5F5F7);
    font-size: 0.875rem;
    line-height: 1.45;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45), 0 0 0 4px rgba(245, 166, 35, 0.08);
    animation: bb-chat-peek-in 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.bb-chat__peek[hidden] { display: none; }
.bb-chat__peek::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 22px;
    width: 14px;
    height: 14px;
    background: #1a1a1a;
    border-right: 1px solid var(--accent-gold, #F5A623);
    border-bottom: 1px solid var(--accent-gold, #F5A623);
    transform: rotate(45deg);
}
.bb-chat__peek-text {
    margin-bottom: 12px;
    color: var(--text-main, #F5F5F7);
}
.bb-chat__peek-text strong { color: var(--accent-gold, #F5A623); font-weight: 700; }
.bb-chat__peek-close {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: transparent;
    border: 0;
    color: var(--text-muted, #A1A1A6);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.15s ease, color 0.15s ease;
}
.bb-chat__peek-close:hover { background: rgba(255, 255, 255, 0.06); color: var(--text-main, #F5F5F7); }
.bb-chat__peek-cta {
    background: var(--accent-gold, #F5A623);
    color: #121212;
    border: 0;
    border-radius: 8px;
    padding: 8px 16px;
    font-weight: 600;
    font-size: 0.8125rem;
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.2s ease;
}
.bb-chat__peek-cta:hover { transform: translateY(-1px); }
@keyframes bb-chat-peek-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===== Chat panel ===== */
.bb-chat__panel {
    position: absolute;
    bottom: calc(100% + 16px);
    right: 0;
    width: 380px;
    height: 560px;
    max-height: calc(100vh - 120px);
    background: #1a1a1a;
    border: 1px solid var(--accent-gold, #F5A623);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), 0 0 0 6px rgba(245, 166, 35, 0.06);
    transform-origin: bottom right;
    animation: bb-chat-panel-in 0.32s cubic-bezier(0.22, 1, 0.36, 1);
    z-index: 1;
}
.bb-chat__panel[hidden] { display: none; }
@keyframes bb-chat-panel-in {
    from { opacity: 0; transform: scale(0.92) translateY(12px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Header */
.bb-chat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    background: linear-gradient(135deg, rgba(245, 166, 35, 0.10), transparent);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.bb-chat__brand { display: flex; align-items: center; gap: 12px; }
.bb-chat__avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--accent-gold, #F5A623);
    color: #121212;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.bb-chat__title {
    color: var(--text-main, #F5F5F7);
    font-weight: 700;
    font-size: 0.9375rem;
    line-height: 1.2;
}
.bb-chat__status {
    color: var(--text-muted, #A1A1A6);
    font-size: 0.75rem;
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.bb-chat__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #32d74b;
    box-shadow: 0 0 8px rgba(50, 215, 75, 0.6);
}
.bb-chat__close {
    background: transparent;
    border: 0;
    color: var(--text-muted, #A1A1A6);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    transition: background 0.15s ease, color 0.15s ease;
}
.bb-chat__close:hover { background: rgba(255, 255, 255, 0.06); color: var(--text-main, #F5F5F7); }

/* Messages */
.bb-chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
}
.bb-chat__messages::-webkit-scrollbar { width: 6px; }
.bb-chat__messages::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.10); border-radius: 3px; }

.bb-chat__msg { display: flex; max-width: 85%; }
.bb-chat__msg--user      { align-self: flex-end;   justify-content: flex-end; }
.bb-chat__msg--assistant { align-self: flex-start; justify-content: flex-start; }

.bb-chat__bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-wrap: break-word;
    word-break: break-word;
    animation: bb-chat-bubble-in 0.25s ease;
}
.bb-chat__msg--user .bb-chat__bubble {
    background: var(--accent-gold, #F5A623);
    color: #121212;
    border-bottom-right-radius: 4px;
}
.bb-chat__msg--assistant .bb-chat__bubble {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main, #F5F5F7);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-bottom-left-radius: 4px;
}
.bb-chat__bubble strong { color: var(--accent-gold, #F5A623); font-weight: 700; }
.bb-chat__msg--user .bb-chat__bubble strong { color: #121212; }
@keyframes bb-chat-bubble-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Typing dots */
.bb-chat__typing .bb-chat__bubble {
    display: inline-flex;
    gap: 4px;
    padding: 14px 16px;
}
.bb-chat__typing .bb-chat__bubble span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted, #A1A1A6);
    animation: bb-chat-typing 1.2s infinite ease-in-out both;
}
.bb-chat__typing .bb-chat__bubble span:nth-child(2) { animation-delay: 0.15s; }
.bb-chat__typing .bb-chat__bubble span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bb-chat-typing {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
    40%           { transform: scale(1);   opacity: 1; }
}

/* Form */
.bb-chat__form {
    display: flex;
    gap: 8px;
    padding: 12px 14px 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.20);
}
.bb-chat__input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main, #F5F5F7);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.15s ease, background 0.15s ease;
    min-width: 0;
}
.bb-chat__input::placeholder { color: var(--text-muted, #A1A1A6); }
.bb-chat__input:focus {
    outline: none;
    border-color: var(--accent-gold, #F5A623);
    background: rgba(255, 255, 255, 0.07);
}
.bb-chat__input:disabled { opacity: 0.5; }

.bb-chat__send {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: var(--accent-gold, #F5A623);
    color: #121212;
    border: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, opacity 0.15s ease;
}
.bb-chat__send:hover:not(:disabled) { transform: translateY(-1px); }
.bb-chat__send:disabled { opacity: 0.45; cursor: not-allowed; }

/* ===== Mobile (full-screen panel) ===== */
@media (max-width: 600px) {
    .bb-chat { bottom: 16px; right: 16px; }
    .bb-chat__toggle { width: 56px; height: 56px; }

    .bb-chat__panel {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        border-left: 0;
        border-right: 0;
        border-top: 0;
        bottom: auto;
        right: auto;
        animation: bb-chat-panel-in-mobile 0.3s ease;
    }
    @keyframes bb-chat-panel-in-mobile {
        from { opacity: 0; transform: translateY(20px); }
        to   { opacity: 1; transform: translateY(0); }
    }

    .bb-chat[data-state="open"] .bb-chat__toggle { display: none; }

    .bb-chat__peek {
        width: calc(100vw - 80px);
        max-width: 280px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bb-chat__toggle::before,
    .bb-chat__panel,
    .bb-chat__peek,
    .bb-chat__bubble { animation: none; }
    .bb-chat__messages { scroll-behavior: auto; }
}
