/* =========================================================
   VB DYNAMICS AI CHAT
   Palette: deep signal navy + electric cyan (brand color),
   with a warm neutral canvas so message bubbles have room
   to breathe. One accent, used with intent.
   ========================================================= */

.vb-ai-chat {
    --vb-ai-primary: #0dcaf0;
    --vb-ai-primary-2: #2e6bff;
    --vb-ai-ink: #0b1220;
    --vb-ai-ink-soft: #16213a;
    --vb-ai-canvas: #f3f6f8;
    --vb-ai-surface: #ffffff;
    --vb-ai-border: rgba(11, 18, 32, 0.08);
    --vb-ai-text: #1c2333;
    --vb-ai-text-muted: #6b7280;
    --vb-ai-radius-lg: 20px;
    --vb-ai-radius-md: 14px;
    --vb-ai-shadow: 0 24px 60px -12px rgba(11, 18, 32, 0.28),
                     0 8px 24px -8px rgba(11, 18, 32, 0.16);

    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 99999;
    font-family: inherit;
}

.vb-ai-chat * {
    box-sizing: border-box;
}

/* =========================================================
   CHAT BUTTON
   ========================================================= */

.vb-ai-chat-toggle {
    width: 60px;
    height: 60px;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(155deg, var(--vb-ai-primary) 0%, var(--vb-ai-primary-2) 115%);
    color: var(--vb-ai-ink);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 12px 28px -6px rgba(46, 107, 255, 0.45);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
    position: relative;
}

.vb-ai-chat-toggle:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 16px 34px -6px rgba(46, 107, 255, 0.55);
}

.vb-ai-chat-toggle:focus-visible {
    outline: 2px solid var(--vb-ai-ink);
    outline-offset: 3px;
}

.vb-ai-chat-toggle svg {
    width: 26px;
    height: 26px;
    position: absolute;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.vb-ai-chat-toggle .vb-ai-icon-close {
    width: 22px;
    height: 22px;
    opacity: 0;
    transform: rotate(-45deg) scale(0.6);
}

.vb-ai-chat-toggle[aria-expanded="true"] .vb-ai-icon-chat {
    opacity: 0;
    transform: rotate(45deg) scale(0.6);
}

.vb-ai-chat-toggle[aria-expanded="true"] .vb-ai-icon-close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

/* Unread badge */

.vb-ai-chat-notification {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 19px;
    height: 19px;
    padding: 0 5px;
    background: #ff4757;
    border: 2px solid #fff;
    border-radius: 999px;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* =========================================================
   CHAT WINDOW
   ========================================================= */

.vb-ai-chat-window {
    position: absolute;
    right: 0;
    bottom: 76px;

    width: 380px;
    max-width: calc(100vw - 32px);
    height: 580px;
    max-height: calc(100vh - 112px);

    background: var(--vb-ai-surface);
    border-radius: var(--vb-ai-radius-lg);
    overflow: hidden;

    box-shadow: var(--vb-ai-shadow);

    display: flex;
    flex-direction: column;

    opacity: 0;
    visibility: hidden;
    transform: translateY(18px) scale(0.96);
    transform-origin: bottom right;

    transition:
        opacity 0.22s ease,
        transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
        visibility 0.22s ease;
}

.vb-ai-chat-window.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* =========================================================
   HEADER
   ========================================================= */

.vb-ai-chat-header {
    position: relative;
    background: linear-gradient(135deg, var(--vb-ai-ink) 0%, var(--vb-ai-ink-soft) 100%);
    color: #fff;
    padding: 17px 16px 15px;

    display: flex;
    align-items: center;
    justify-content: space-between;
}

.vb-ai-chat-header::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--vb-ai-primary), var(--vb-ai-primary-2));
}

.vb-ai-chat-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.vb-ai-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(155deg, var(--vb-ai-primary) 0%, var(--vb-ai-primary-2) 130%);
    color: var(--vb-ai-ink);

    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;

    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.vb-ai-chat-title {
    font-size: 14.5px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vb-ai-chat-status {
    margin-top: 3px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.62);

    display: flex;
    align-items: center;
    gap: 5px;
}

.vb-ai-chat-status-dot {
    width: 6px;
    height: 6px;
    background: #2ed573;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(46, 213, 115, 0.18);
}

.vb-ai-chat-close {
    width: 32px;
    height: 32px;
    border: 0;
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    cursor: pointer;
    border-radius: 9px;
    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.vb-ai-chat-close:hover {
    background: rgba(255, 255, 255, 0.14);
}

.vb-ai-chat-close:focus-visible {
    outline: 2px solid var(--vb-ai-primary);
    outline-offset: 2px;
}

.vb-ai-chat-close svg {
    width: 17px;
    height: 17px;
}

/* =========================================================
   MESSAGES
   ========================================================= */

.vb-ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px;

    background: var(--vb-ai-canvas);

    display: flex;
    flex-direction: column;
    gap: 3px;
}

.vb-ai-chat-messages::-webkit-scrollbar {
    width: 7px;
}

.vb-ai-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(11, 18, 32, 0.14);
    border-radius: 10px;
}

.vb-ai-message-row {
    display: flex;
    flex-direction: column;
    margin: 7px 0;
    max-width: 86%;
    animation: vbAiMessageIn 0.22s ease both;
}

.vb-ai-message-row.user {
    align-self: flex-end;
    align-items: flex-end;
}

.vb-ai-message-row.bot {
    align-self: flex-start;
    align-items: flex-start;
}

@keyframes vbAiMessageIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.vb-ai-message {
    font-size: 14px;
    line-height: 1.55;
    padding: 10px 13px;
    border-radius: var(--vb-ai-radius-md);
    word-wrap: break-word;
}

.vb-ai-message.bot {
    background: var(--vb-ai-surface);
    color: var(--vb-ai-text);
    border: 1px solid var(--vb-ai-border);
    border-bottom-left-radius: 4px;
}

.vb-ai-message.user {
    background: linear-gradient(135deg, var(--vb-ai-primary), var(--vb-ai-primary-2) 130%);
    color: var(--vb-ai-ink);
    font-weight: 500;
    border-bottom-right-radius: 4px;
}

.vb-ai-message a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.vb-ai-message-time {
    font-size: 10.5px;
    color: var(--vb-ai-text-muted);
    margin-top: 4px;
    padding: 0 3px;
}

/* =========================================================
   QUICK QUESTIONS
   ========================================================= */

.vb-ai-quick {
    padding: 0 16px 14px;
    background: var(--vb-ai-canvas);

    display: flex;
    gap: 7px;
    flex-wrap: wrap;
}

.vb-ai-quick button {
    border: 1px solid rgba(11, 18, 32, 0.12);
    background: var(--vb-ai-surface);
    color: var(--vb-ai-ink);

    border-radius: 999px;
    padding: 7px 12px;

    font-size: 11.5px;
    font-weight: 600;
    font-family: inherit;

    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.vb-ai-quick button:hover {
    background: var(--vb-ai-ink);
    border-color: var(--vb-ai-ink);
    color: #fff;
}

.vb-ai-quick button:focus-visible {
    outline: 2px solid var(--vb-ai-primary-2);
    outline-offset: 2px;
}

/* =========================================================
   TYPING INDICATOR
   ========================================================= */

.vb-ai-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 13px 14px;
}

.vb-ai-typing span {
    width: 6px;
    height: 6px;
    background: #9ca3af;
    border-radius: 50%;

    animation: vbAiTyping 1.2s infinite ease-in-out;
}

.vb-ai-typing span:nth-child(2) {
    animation-delay: 0.15s;
}

.vb-ai-typing span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes vbAiTyping {
    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-4px);
    }
}

/* =========================================================
   INPUT
   ========================================================= */

.vb-ai-chat-input-area {
    padding: 12px;
    background: var(--vb-ai-surface);
    border-top: 1px solid var(--vb-ai-border);
}

.vb-ai-chat-form {
    display: flex;
    align-items: center;
    gap: 8px;
}

.vb-ai-chat-input {
    flex: 1;
    min-width: 0;

    border: 1px solid rgba(11, 18, 32, 0.14);
    border-radius: 999px;
    background: var(--vb-ai-canvas);

    padding: 11px 15px;

    font-family: inherit;
    font-size: 14px;
    color: var(--vb-ai-text);

    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.vb-ai-chat-input::placeholder {
    color: var(--vb-ai-text-muted);
}

.vb-ai-chat-input:focus {
    background: var(--vb-ai-surface);
    border-color: var(--vb-ai-primary-2);
    box-shadow: 0 0 0 3px rgba(46, 107, 255, 0.12);
}

.vb-ai-chat-send {
    width: 42px;
    height: 42px;

    border: 0;
    border-radius: 50%;

    background: linear-gradient(155deg, var(--vb-ai-primary), var(--vb-ai-primary-2) 130%);
    color: var(--vb-ai-ink);

    display: flex;
    align-items: center;
    justify-content: center;

    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.vb-ai-chat-send:hover:not(:disabled) {
    transform: scale(1.06);
}

.vb-ai-chat-send:focus-visible {
    outline: 2px solid var(--vb-ai-ink);
    outline-offset: 2px;
}

.vb-ai-chat-send:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.vb-ai-chat-send svg {
    width: 17px;
    height: 17px;
}

/* =========================================================
   REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
    .vb-ai-chat-window,
    .vb-ai-chat-toggle,
    .vb-ai-chat-toggle svg,
    .vb-ai-message-row,
    .vb-ai-typing span {
        animation: none !important;
        transition: none !important;
    }
}

/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 576px) {

    .vb-ai-chat {
        right: 15px;
        bottom: 15px;
    }

    .vb-ai-chat-window {
        right: -1px;
        bottom: 72px;

        width: calc(100vw - 30px);
        height: min(620px, calc(100vh - 100px));

        border-radius: 18px;
    }

    .vb-ai-chat-toggle {
        width: 56px;
        height: 56px;
    }
}