/* ============================================================
   Business Voicer — Frontend Chat Widget
   ============================================================ */

:root {
    --bv-c: #3B82F6;
    /* set dynamically by JS */
    --bv-c-dark: #2563EB;
    --bv-bg-w: #0d1117;
    --bv-glass: rgba(13, 17, 23, 0.95);
    --bv-border: rgba(255, 255, 255, 0.08);
    --bv-text: #f8fafc;
    --bv-muted: #94A3B8;
    --bv-font: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

/* Root container */
#bv-widget-root {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: var(--bv-font);
}

/* Floating bubble */
#bv-bubble {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bv-c), #8B5CF6);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 24px rgba(59, 130, 246, 0.45);
    transition: transform .25s ease, box-shadow .25s ease;
    position: relative;
    z-index: 1;
}

#bv-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 36px rgba(59, 130, 246, 0.65);
}

/* Unread pulse badge */
#bv-bubble.has-new::after {
    content: '';
    position: absolute;
    top: 3px;
    right: 3px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ef4444;
    border: 2px solid #0d1117;
    animation: bv-pulse 1.5s infinite;
}

@keyframes bv-pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.3);
        opacity: .6;
    }
}

/* Chat panel */
#bv-panel {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 360px;
    max-height: 560px;
    display: flex;
    flex-direction: column;
    background: var(--bv-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--bv-border);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    transform: scale(0.9) translateY(10px);
    opacity: 0;
    pointer-events: none;
    transform-origin: bottom right;
    transition: transform .25s cubic-bezier(.34, 1.56, .64, 1), opacity .2s ease;
}

#bv-panel.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* Header */
#bv-header {
    padding: 16px 18px;
    border-bottom: 1px solid var(--bv-border);
    flex-shrink: 0;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(139, 92, 246, 0.08));
}

#bv-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

#bv-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bv-c), #8B5CF6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.4);
}

#bv-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--bv-text);
    line-height: 1.2;
}

#bv-status {
    font-size: 0.75rem;
    color: var(--bv-muted);
    margin-top: 1px;
}

/* Messages area */
#bv-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

#bv-messages::-webkit-scrollbar {
    width: 4px;
}

#bv-messages::-webkit-scrollbar-track {
    background: transparent;
}

#bv-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* Message bubbles */
.bv-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.88rem;
    line-height: 1.55;
    word-break: break-word;
    animation: bv-msg-in .2s ease;
}

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

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

.bv-msg.ai {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--bv-border);
    color: var(--bv-text);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}

.bv-msg.user {
    background: linear-gradient(135deg, var(--bv-c), #7C3AED);
    color: #fff;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
    box-shadow: 0 2px 12px rgba(59, 130, 246, 0.3);
}

/* Typing indicator */
.bv-typing {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--bv-border);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}

.bv-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--bv-muted);
    animation: bv-bounce 1.2s infinite;
}

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

.bv-typing span:nth-child(3) {
    animation-delay: .4s;
}

@keyframes bv-bounce {

    0%,
    100% {
        transform: translateY(0);
        opacity: .5;
    }

    50% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

/* Lead capture form */
#bv-lead-form {
    padding: 14px 16px;
    border-top: 1px solid var(--bv-border);
    flex-shrink: 0;
    background: rgba(59, 130, 246, 0.04);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#bv-lead-msg {
    font-size: 0.82rem;
    color: var(--bv-muted);
}

#bv-lead-form input {
    width: 100%;
    padding: 9px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--bv-border);
    border-radius: 9px;
    color: var(--bv-text);
    font-size: 0.85rem;
    font-family: var(--bv-font);
    outline: none;
    transition: border-color .2s;
    box-sizing: border-box;
}

#bv-lead-form input:focus {
    border-color: var(--bv-c);
}

#bv-lead-submit {
    padding: 9px 14px;
    background: linear-gradient(135deg, var(--bv-c), #7C3AED);
    color: #fff;
    border: none;
    border-radius: 9px;
    font-family: var(--bv-font);
    font-weight: 600;
    font-size: 0.87rem;
    cursor: pointer;
    transition: opacity .2s;
    box-shadow: 0 2px 12px rgba(59, 130, 246, 0.3);
}

#bv-lead-submit:hover {
    opacity: .88;
}

/* Input row */
#bv-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--bv-border);
    flex-shrink: 0;
}

#bv-input {
    flex: 1;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--bv-border);
    border-radius: 12px;
    color: var(--bv-text);
    font-size: 0.88rem;
    font-family: var(--bv-font);
    outline: none;
    transition: border-color .2s;
}

#bv-input:focus {
    border-color: var(--bv-c);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

#bv-input::placeholder {
    color: var(--bv-muted);
}

#bv-send {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--bv-c), #7C3AED);
    border: none;
    border-radius: 10px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform .2s, box-shadow .2s;
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.3);
}

#bv-send:hover {
    transform: scale(1.08);
    box-shadow: 0 3px 16px rgba(59, 130, 246, 0.5);
}

/* Responsive: mobile */
@media (max-width: 420px) {
    #bv-panel {
        width: calc(100vw - 32px);
        right: 0;
    }

    #bv-widget-root {
        bottom: 16px;
        right: 16px;
    }
}