/* ------------------------------------------------------------------
   Chat assistant widget (bottom right)
   ------------------------------------------------------------------ */

.vr-chat {
    --vc-accent: #0f9d76;
    --vc-bg: #fff;
    --vc-text: #1f2937;
    --vc-muted: #6b7280;
    --vc-border: #e5e7eb;
    --vc-bot-bg: #f3f4f6;

    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1040;
    font-size: 14px;
}

[data-bs-theme="dark"] .vr-chat {
    --vc-bg: #16181d;
    --vc-text: #e5e7eb;
    --vc-muted: #9ca3af;
    --vc-border: #2b2f36;
    --vc-bot-bg: #21252c;
}

/* --- Launcher ------------------------------------------------------ */

.vr-chat-launcher {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    margin-left: auto;
    border: 0;
    border-radius: 50%;
    background: var(--vc-accent);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
    color: #fff;
    cursor: pointer;
    transition: transform .2s ease, box-shadow .2s ease;
}

.vr-chat-launcher:hover {
    transform: scale(1.06);
    box-shadow: 0 10px 28px rgba(0, 0, 0, .28);
}

.vr-chat-icon-close {
    display: none;
}

.vr-chat.is-open .vr-chat-icon-open {
    display: none;
}

.vr-chat.is-open .vr-chat-icon-close {
    display: block;
}

/* --- Panel --------------------------------------------------------- */

.vr-chat-panel {
    position: absolute;
    right: 0;
    bottom: 70px;
    display: flex;
    flex-direction: column;
    width: 370px;
    max-width: calc(100vw - 40px);
    height: 520px;
    max-height: calc(100vh - 130px);
    overflow: hidden;
    border: 1px solid var(--vc-border);
    border-radius: 14px;
    background: var(--vc-bg);
    box-shadow: 0 20px 50px rgba(0, 0, 0, .22);
    color: var(--vc-text);
    opacity: 0;
    transform: translateY(12px) scale(.98);
    transform-origin: bottom right;
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
}

.vr-chat.is-open .vr-chat-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* --- Header -------------------------------------------------------- */

.vr-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .875rem 1rem;
    background: var(--vc-accent);
    color: #fff;
}

.vr-chat-header-info {
    display: flex;
    align-items: center;
    gap: .625rem;
    min-width: 0;
}

.vr-chat-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .2);
}

.vr-chat-title {
    display: block;
    font-size: .9375rem;
    font-weight: 700;
    line-height: 1.2;
}

.vr-chat-status {
    display: block;
    font-size: .6875rem;
    opacity: .85;
}

.vr-chat-header-actions {
    display: flex;
    gap: .25rem;
}

.vr-chat-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #fff;
    opacity: .85;
    cursor: pointer;
    transition: background .2s ease, opacity .2s ease;
}

.vr-chat-icon-btn:hover {
    background: rgba(255, 255, 255, .18);
    opacity: 1;
}

/* --- Messages ------------------------------------------------------ */

.vr-chat-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1rem;
    scroll-behavior: smooth;
}

.vr-chat-msg {
    display: flex;
    margin-bottom: .625rem;
}

.vr-chat-msg.is-user {
    justify-content: flex-end;
}

.vr-chat-bubble {
    max-width: 82%;
    padding: .625rem .875rem;
    border-radius: 14px;
    background: var(--vc-bot-bg);
    font-size: .8125rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.vr-chat-msg.is-bot .vr-chat-bubble {
    border-bottom-left-radius: 4px;
}

.vr-chat-msg.is-user .vr-chat-bubble {
    border-bottom-right-radius: 4px;
    background: var(--vc-accent);
    color: #fff;
}

.vr-chat-msg.is-error .vr-chat-bubble {
    background: rgba(220, 53, 69, .1);
    color: #dc3545;
}

/* --- Typing indicator ---------------------------------------------- */

.vr-chat-typing {
    display: flex;
    gap: 4px;
    padding: .75rem .875rem;
}

.vr-chat-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--vc-muted);
    animation: vrChatBounce 1.3s infinite ease-in-out;
}

.vr-chat-typing span:nth-child(2) { animation-delay: .18s; }
.vr-chat-typing span:nth-child(3) { animation-delay: .36s; }

@keyframes vrChatBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .45; }
    30%           { transform: translateY(-5px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .vr-chat-typing span { animation: none; }
    .vr-chat-panel { transition: opacity .01ms; }
}

/* --- Suggestions --------------------------------------------------- */

.vr-chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: .375rem;
    margin-top: .75rem;
}

.vr-chat-chip {
    padding: .375rem .75rem;
    border: 1px solid var(--vc-border);
    border-radius: 100px;
    background: transparent;
    color: var(--vc-text);
    font-size: .75rem;
    cursor: pointer;
    transition: all .2s ease;
}

.vr-chat-chip:hover {
    border-color: var(--vc-accent);
    color: var(--vc-accent);
}

/* --- Footer -------------------------------------------------------- */

.vr-chat-footer {
    padding: .75rem 1rem .875rem;
    border-top: 1px solid var(--vc-border);
}

.vr-chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: .5rem;
}

.vr-chat-input {
    flex: 1 1 auto;
    min-width: 0;
    max-height: 110px;
    padding: .5625rem .75rem;
    border: 1px solid var(--vc-border);
    border-radius: 10px;
    background: transparent;
    color: var(--vc-text);
    font-family: inherit;
    font-size: .8125rem;
    line-height: 1.5;
    resize: none;
    outline: none;
}

.vr-chat-input:focus {
    border-color: var(--vc-accent);
}

.vr-chat-input:disabled {
    opacity: .6;
}

.vr-chat-send {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 10px;
    background: var(--vc-accent);
    color: #fff;
    cursor: pointer;
    transition: opacity .2s ease;
}

.vr-chat-send:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.vr-chat-disclaimer {
    margin: .5rem 0 0;
    color: var(--vc-muted);
    font-size: .6875rem;
    text-align: center;
}

/* --- RTL ----------------------------------------------------------- */

html[dir="rtl"] .vr-chat {
    right: auto;
    left: 20px;
}

html[dir="rtl"] .vr-chat-panel {
    right: auto;
    left: 0;
    transform-origin: bottom left;
}

/* --- Small screens -------------------------------------------------- */

@media (max-width: 575.98px) {
    .vr-chat {
        right: 14px;
        bottom: 14px;
    }

    .vr-chat-panel {
        width: calc(100vw - 28px);
        height: min(76vh, 520px);
    }
}

/* ------------------------------------------------------------------
   Sharing the bottom-right corner with the theme's scroll-to-top button

   That button is position:fixed at bottom:2rem/right:1rem with
   z-index:9999, so it lands straight on top of the chat launcher.
   The class below is added by chatbot.js only when the widget is on
   the page, so themes without the assistant are untouched.
   ------------------------------------------------------------------ */

.has-vr-chat .btn-scroll-up {
    right: 27px;                    /* centred against the 56px launcher */
    bottom: 5.75rem;                /* clears the launcher plus a gap */
    z-index: 1039;                  /* never above the chat panel */
    transition: bottom .2s ease, opacity .2s ease, visibility .2s ease;
}

/* The open panel is 520px tall, so the button would sit on top of it */
.has-vr-chat.vr-chat-open .btn-scroll-up {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.vr-chat {
    z-index: 1040;
}

html[dir="rtl"] .has-vr-chat .btn-scroll-up {
    right: auto;
    left: 27px;
}

@media (max-width: 575.98px) {
    .has-vr-chat .btn-scroll-up {
        right: 21px;
        bottom: 5.25rem;
    }

    html[dir="rtl"] .has-vr-chat .btn-scroll-up {
        right: auto;
        left: 21px;
    }
}
