/*
|--------------------------------------------------------------------------
| VAPI Chat Widget — Text Q&A Assistant
|--------------------------------------------------------------------------
*/

/* ── Floating trigger button ─────────────────────────────── */

.vapi-chat-btn {
    position: fixed;
    bottom: 0;
    right: 155px;
    z-index: 10000;
    width: 38px;
    height: 39px;
    border-radius: 0;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--blue-600);
    color: var(--white);
    box-shadow: 0 4px 20px rgba(16, 82, 127, 0.35);
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}

.vapi-chat-btn:hover {
    background: var(--blue-700);
    transform: scale(1.07);
    box-shadow: 0 6px 28px rgba(16, 82, 127, 0.45);
}

.vapi-chat-btn:active {
    transform: scale(0.96);
}

.vapi-chat-btn svg {
    width: 20px;
    height: 20px;
    transition: transform 0.3s var(--ease);
}

.vapi-chat-btn.is-open svg {
    transform: rotate(90deg);
}

/* Icon swap */
.vapi-chat-btn .vapi-icon-close {
    display: none;
}

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

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

/* ── Chat panel ──────────────────────────────────────────── */

.vapi-panel {
    position: fixed;
    bottom: 52px;
    right: 155px;
    z-index: 9999;
    width: 380px;
    max-height: 520px;
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: 0 12px 48px rgba(15, 32, 67, 0.14), 0 0 0 1px rgba(15, 32, 67, 0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}

.vapi-panel.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Header */
.vapi-panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--blue-600);
    color: var(--white);
}

.vapi-panel-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.vapi-panel-avatar svg {
    width: 18px;
    height: 18px;
}

.vapi-panel-info h4 {
    font-family: var(--font-sans);
    font-size: var(--text-md);
    font-weight: 600;
    margin: 0;
    line-height: 1.2;
}

.vapi-panel-info p {
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    margin: 0;
    opacity: 0.75;
}

/* Messages area */
.vapi-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 280px;
    max-height: 340px;
    scroll-behavior: smooth;
}

.vapi-messages::-webkit-scrollbar {
    width: 4px;
}

.vapi-messages::-webkit-scrollbar-thumb {
    background: var(--gray-200);
    border-radius: 4px;
}

/* Message bubbles */
.vapi-msg {
    max-width: 85%;
    padding: 10px 14px;
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.5;
    border-radius: var(--radius-lg);
    word-wrap: break-word;
    animation: vapi-msg-in 0.25s var(--ease);
}

@keyframes vapi-msg-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.vapi-msg--assistant {
    align-self: flex-start;
    background: var(--gray-50);
    color: var(--gray-800);
    border-bottom-left-radius: 4px;
}

.vapi-msg--user {
    align-self: flex-end;
    background: var(--blue-600);
    color: var(--white);
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.vapi-typing {
    display: none;
    align-self: flex-start;
    padding: 10px 14px;
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    border-bottom-left-radius: 4px;
}

.vapi-typing.is-visible {
    display: flex;
    gap: 4px;
    align-items: center;
}

.vapi-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
    background: var(--gray-400);
    animation: vapi-bounce 1.2s infinite;
}

.vapi-typing-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.vapi-typing-dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes vapi-bounce {

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

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

/* Welcome message */
.vapi-welcome {
    text-align: center;
    padding: 20px 0;
}

.vapi-welcome p {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    color: var(--gray-400);
    margin: 0;
}

/* Input area */
.vapi-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--gray-100);
    background: var(--white);
}

.vapi-input {
    flex: 1;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-family: var(--font-sans);
    font-size: var(--text-base);
    color: var(--gray-800);
    outline: none;
    transition: border-color 0.2s ease;
    resize: none;
    line-height: 1.4;
    max-height: 80px;
}

.vapi-input::placeholder {
    color: var(--gray-400);
}

.vapi-input:focus {
    border-color: var(--blue-500);
}

.vapi-send-btn {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: var(--radius-full);
    background: var(--blue-600);
    color: var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s ease, transform 0.15s ease;
}

.vapi-send-btn:hover {
    background: var(--blue-700);
}

.vapi-send-btn:active {
    transform: scale(0.92);
}

.vapi-send-btn:disabled {
    background: var(--gray-200);
    cursor: not-allowed;
}

.vapi-send-btn svg {
    width: 18px;
    height: 18px;
}

/* ── Mobile ──────────────────────────────────────────────── */

@media (max-width: 768px) {
    .vapi-chat-btn {
        width: 48px;
        height: 48px;
        bottom: 20px;
        right: 20px;
    }

    .vapi-chat-btn svg {
        width: 22px;
        height: 22px;
    }

    .vapi-panel {
        left: 12px;
        right: 12px;
        bottom: 80px;
        width: auto;
        max-height: 70vh;
    }
}