/* ===========================================
   VANTAGE AI CHAT WIDGET
   Dark glassmorphism floating chat panel
   With voice controls (TTS + STT)
   =========================================== */

/* === LAUNCHER BUTTON === */
.va-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    height: 60px;
    min-width: 60px;
    padding: 0 18px;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, #4338ca 0%, #6d28d9 50%, #a855f7 100%);
    box-shadow: 0 6px 22px rgba(67, 56, 202, 0.42), 0 0 44px rgba(168, 85, 247, 0.18);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    isolation: isolate;
}

/* Breathing outer ring — peripheral-vision signal without gaudiness */
.va-launcher::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 999px;
    border: 2px solid rgba(168, 139, 250, 0.55);
    opacity: 0;
    pointer-events: none;
    z-index: -1;
    animation: va-breath 3.6s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.va-launcher:hover {
    transform: translateY(-1px) scale(1.04);
    box-shadow: 0 10px 32px rgba(67, 56, 202, 0.55), 0 0 68px rgba(168, 85, 247, 0.28);
}

.va-launcher:focus-visible {
    outline: 2px solid #a5b4fc;
    outline-offset: 3px;
}

.va-launcher svg {
    width: 26px;
    height: 26px;
    fill: white;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.va-launcher.va-open svg {
    transform: rotate(90deg) scale(0.9);
}

.va-launcher.va-open::before {
    animation: none;
    opacity: 0;
}

/* Hover-expand label pill (desktop only) */
.va-launcher-label {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.88rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: #ffffff;
    max-width: 0;
    overflow: hidden;
    white-space: nowrap;
    opacity: 0;
    transform: translateX(4px);
    transition: max-width 0.32s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.2s ease,
                transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                margin 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    margin-left: 0;
}

.va-launcher:hover .va-launcher-label,
.va-launcher:focus-visible .va-launcher-label,
.va-launcher.va-show-label .va-launcher-label {
    max-width: 200px;
    opacity: 1;
    transform: translateX(0);
    margin-left: 2px;
}

.va-launcher.va-open .va-launcher-label {
    display: none;
}

@keyframes va-breath {
    0%, 100% { opacity: 0; transform: scale(1); }
    50% { opacity: 0.75; transform: scale(1.18); }
}

/* === FIRST-VISIT WELCOME BUBBLE === */
.va-welcome-bubble {
    position: fixed;
    bottom: 100px;
    right: 24px;
    z-index: 10000;
    max-width: 280px;
    padding: 14px 36px 14px 16px;
    background: rgba(15, 23, 42, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(168, 85, 247, 0.25);
    border-radius: 16px;
    box-shadow:
        0 14px 40px rgba(0, 0, 0, 0.45),
        0 0 0 1px rgba(255, 255, 255, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.86rem;
    line-height: 1.5;
    color: #e2e8f0;
    cursor: pointer;
    opacity: 0;
    transform: translateY(12px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.32s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

.va-welcome-bubble.va-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.va-welcome-bubble::after {
    content: '';
    position: absolute;
    bottom: -7px;
    right: 28px;
    width: 14px;
    height: 14px;
    background: inherit;
    border-right: 1px solid rgba(168, 85, 247, 0.25);
    border-bottom: 1px solid rgba(168, 85, 247, 0.25);
    transform: rotate(45deg);
}

.va-welcome-bubble strong {
    display: block;
    font-weight: 600;
    color: #f1f5f9;
    margin-bottom: 2px;
    background: linear-gradient(135deg, #a5b4fc, #c4b5fd);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.va-welcome-close {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s ease, color 0.2s ease;
}

.va-welcome-close:hover {
    background: rgba(255, 255, 255, 0.14);
    color: rgba(255, 255, 255, 0.9);
}

/* === CHAT PANEL === */
.va-panel {
    position: fixed;
    bottom: 92px;
    right: 24px;
    z-index: 10001;
    width: 380px;
    height: 520px;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow:
        0 24px 80px rgba(0, 0, 0, 0.5),
        0 0 1px rgba(255, 255, 255, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.va-panel.va-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* === HEADER === */
.va-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: rgba(15, 23, 42, 0.6);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.va-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.va-header-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22d3ee;
    box-shadow: 0 0 8px rgba(34, 211, 238, 0.6);
    animation: va-glow 2s ease-in-out infinite;
}

@keyframes va-glow {
    0%, 100% { box-shadow: 0 0 8px rgba(34, 211, 238, 0.6); }
    50% { box-shadow: 0 0 16px rgba(34, 211, 238, 0.9), 0 0 24px rgba(34, 211, 238, 0.3); }
}

.va-header h3 {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: #f1f5f9;
    margin: 0;
    letter-spacing: 0.02em;
}

.va-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.va-header-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.4);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.va-header-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.8);
}

.va-header-btn svg {
    width: 16px;
    height: 16px;
}

/* Voice toggle active state */
.va-voice-toggle.va-active {
    color: #22d3ee;
    background: rgba(34, 211, 238, 0.1);
}

.va-voice-toggle.va-active:hover {
    background: rgba(34, 211, 238, 0.15);
    color: #22d3ee;
}

.va-voice-toggle svg {
    fill: currentColor;
}

/* === MESSAGES === */
.va-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.va-messages::-webkit-scrollbar { width: 4px; }
.va-messages::-webkit-scrollbar-track { background: transparent; }
.va-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* Message wrapper (bubble + speaker btn) */
.va-msg-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    animation: va-fadeIn 0.3s ease;
}

.va-msg-wrapper-ai {
    align-self: flex-start;
    max-width: 90%;
}

/* Message bubbles */
.va-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.85rem;
    line-height: 1.55;
    animation: va-fadeIn 0.3s ease;
    word-wrap: break-word;
}

/* Messages inside wrappers don't need their own animation */
.va-msg-wrapper .va-msg {
    animation: none;
    max-width: none;
    flex: 1;
}

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

.va-msg-ai {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.07);
    color: #e2e8f0;
    border-bottom-left-radius: 4px;
}

.va-msg-user {
    align-self: flex-end;
    background: linear-gradient(135deg, #4338ca, #6d28d9);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

/* Speaker button on AI messages */
.va-speaker-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
    margin-bottom: 2px;
}

.va-speaker-btn:hover {
    background: rgba(34, 211, 238, 0.15);
    color: #22d3ee;
}

.va-speaker-btn svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

/* Typing indicator */
.va-typing {
    align-self: flex-start;
    display: flex;
    gap: 5px;
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.07);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    animation: va-fadeIn 0.3s ease;
}

.va-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    animation: va-bounce 1.4s ease-in-out infinite;
}

.va-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.va-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes va-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
    30% { transform: translateY(-6px); opacity: 0.8; }
}

/* === INPUT === */
.va-input-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: rgba(15, 23, 42, 0.5);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

/* Microphone button */
.va-mic-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    padding: 0;
}

.va-mic-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    color: rgba(255, 255, 255, 0.9);
    border-color: rgba(255, 255, 255, 0.2);
}

.va-mic-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* Recording state */
.va-mic-btn.va-recording {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    animation: va-record-pulse 1.5s ease-in-out infinite;
}

.va-mic-btn.va-recording:hover {
    background: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

@keyframes va-record-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
    50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

.va-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 10px 14px;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.85rem;
    color: #f1f5f9;
    outline: none;
    transition: border-color 0.2s ease;
    resize: none;
    min-height: 40px;
    max-height: 80px;
}

.va-input::placeholder {
    color: rgba(255, 255, 255, 0.25);
}

.va-input:focus {
    border-color: rgba(67, 56, 202, 0.5);
}

.va-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.va-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, #4338ca, #6d28d9);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.va-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 12px rgba(67, 56, 202, 0.4);
}

.va-send-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.va-send-btn svg {
    width: 16px;
    height: 16px;
    fill: white;
}

/* === FOOTER / REMAINING === */
.va-footer {
    text-align: center;
    padding: 6px 14px 10px;
    flex-shrink: 0;
}

.va-remaining {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.2);
}

/* === LIMIT REACHED CTA === */
.va-limit-cta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px 14px;
    background: rgba(15, 23, 42, 0.5);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.va-limit-cta p {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
    margin: 0;
}

.va-limit-cta a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    background: linear-gradient(135deg, #4338ca, #6d28d9);
    color: white;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 10px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.va-limit-cta a:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(67, 56, 202, 0.4);
}

/* === MESSAGE GROUP (bubble + actions + suggestions) === */
.va-msg-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    max-width: 100%;
    animation: va-fadeIn 0.3s ease;
}

/* === ACTION BUTTONS (primary/secondary CTAs) === */
.va-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-width: 100%;
    padding-left: 2px;
}

.va-action {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    padding: 8px 14px;
    border-radius: 999px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    max-width: 100%;
    text-overflow: ellipsis;
    overflow: hidden;
}

.va-action-primary {
    background: linear-gradient(135deg, #4338ca, #6d28d9);
    color: #ffffff;
    box-shadow: 0 2px 10px rgba(67, 56, 202, 0.35);
}

.va-action-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(67, 56, 202, 0.5);
}

.va-action-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: #c7d2fe;
    border-color: rgba(199, 210, 254, 0.25);
}

.va-action-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #e0e7ff;
    border-color: rgba(199, 210, 254, 0.4);
}

.va-action-external::after {
    content: '↗';
    font-size: 0.85em;
    opacity: 0.85;
    margin-left: 2px;
}

.va-action:focus-visible {
    outline: 2px solid #a5b4fc;
    outline-offset: 2px;
}

/* === QUICK-REPLY CHIPS (suggestions) === */
.va-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    max-width: 100%;
    padding-left: 2px;
}

.va-chip {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.74rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.75);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.va-chip:hover {
    background: rgba(67, 56, 202, 0.18);
    border-color: rgba(129, 140, 248, 0.4);
    color: #e0e7ff;
}

.va-chip:focus-visible {
    outline: 2px solid #a5b4fc;
    outline-offset: 2px;
}

/* === TARGET PULSE (deep-link arrival cue) === */
@keyframes va-target-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.55), 0 0 0 0 rgba(99, 102, 241, 0.0);
    }
    60% {
        box-shadow: 0 0 0 14px rgba(99, 102, 241, 0.0), 0 0 48px 4px rgba(99, 102, 241, 0.35);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.0), 0 0 0 0 rgba(99, 102, 241, 0.0);
    }
}

.va-target-pulse {
    animation: va-target-pulse 2.4s ease-out 1;
    scroll-margin-top: 88px;
    border-radius: 12px;
    position: relative;
}

/* === THINKING MESSAGE === */
.va-thinking-msg {
    font-style: italic;
    color: rgba(255, 255, 255, 0.45);
    background: rgba(255, 255, 255, 0.04);
}

/* === ERROR MESSAGE === */
.va-error {
    align-self: center;
    background: rgba(220, 38, 38, 0.15);
    color: #fca5a5;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 0.78rem;
    text-align: center;
    animation: va-fadeIn 0.3s ease;
}

/* === MOBILE === */
@media (max-width: 480px) {
    .va-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 85vh;
        border-radius: 20px 20px 0 0;
        transform: translateY(100%);
    }

    .va-panel.va-visible {
        transform: translateY(0);
    }

    .va-launcher {
        bottom: 16px;
        right: 16px;
        height: 56px;
        min-width: 56px;
        padding: 0;
    }

    /* Hide hover-expand label on mobile — no hover interaction */
    .va-launcher .va-launcher-label {
        display: none;
    }

    .va-welcome-bubble {
        right: 16px;
        bottom: 84px;
        max-width: calc(100% - 32px);
    }

    .va-welcome-bubble::after {
        right: 20px;
    }
}
