/**
 * Voice Assistant - Chat Interface Styles
 * Version 3.4.0 - Glass morphism + Plasma button + Waveform banners + Mute/Barge-in
 */

/* ══════════════════════════════════════════
   THEME VARIABLES (Glass Design)
   ══════════════════════════════════════════ */

:host, :host([theme="dark"]) {
    font-family: inherit;
    --va-primary: #6366f1;
    --va-primary-rgb: 99, 102, 241;
    --va-primary-soft: rgba(99, 102, 241, 0.12);

    --va-panel-bg: rgba(12, 12, 18, 0.82);
    --va-panel-blur: 28px;
    --va-glass: rgba(255, 255, 255, 0.055);
    --va-glass2: rgba(255, 255, 255, 0.035);
    --va-glass-border: rgba(255, 255, 255, 0.09);
    --va-glass-border-hover: rgba(255, 255, 255, 0.17);

    --va-text: #f0f0f5;
    --va-text-secondary: rgba(240, 240, 245, 0.58);
    --va-text-muted: rgba(240, 240, 245, 0.32);

    --va-msg-assistant-bg: var(--va-glass);
    --va-msg-assistant-border: var(--va-glass-border);
    --va-msg-user-bg: var(--va-primary);
    --va-msg-user-text: white;

    --va-input-bg: var(--va-glass2);
    --va-input-border: var(--va-glass-border);

    --va-success: #34d399;
    --va-success-soft: rgba(52, 211, 153, 0.12);
    --va-danger: #f87171;
    --va-danger-soft: rgba(248, 113, 113, 0.1);

    --va-shadow: 0 24px 64px rgba(0,0,0,0.4);
    --va-shadow-btn: 0 4px 24px rgba(var(--va-primary-rgb), 0.35);
}

:host([theme="light"]) {
    --va-panel-bg: rgba(255, 255, 255, 0.78);
    --va-glass: rgba(0, 0, 0, 0.03);
    --va-glass2: rgba(0, 0, 0, 0.025);
    --va-glass-border: rgba(0, 0, 0, 0.08);
    --va-glass-border-hover: rgba(0, 0, 0, 0.14);

    --va-text: #111827;
    --va-text-secondary: rgba(17, 24, 39, 0.55);
    --va-text-muted: rgba(17, 24, 39, 0.3);

    --va-msg-assistant-bg: rgba(0, 0, 0, 0.04);
    --va-msg-assistant-border: rgba(0, 0, 0, 0.06);

    --va-input-bg: rgba(0, 0, 0, 0.03);
    --va-input-border: rgba(0, 0, 0, 0.08);

    --va-success: #10b981;
    --va-success-soft: rgba(16, 185, 129, 0.1);
    --va-danger: #ef4444;
    --va-danger-soft: rgba(239, 68, 68, 0.08);

    --va-shadow: 0 24px 64px rgba(0,0,0,0.1), 0 0 0 1px rgba(0,0,0,0.04);
    --va-shadow-btn: 0 4px 20px rgba(var(--va-primary-rgb), 0.25);
}

/* Custom brand color — applied on top of dark or light */
:host {
    /* Ensure widget stacks above third-party badges (Trusted Shops, cookie banners) */
    /* position: relative + z-index creates a stacking context for all fixed children */
    position: relative;
    z-index: 2147483647;
    display: block;
    height: 0;
    overflow: visible;
    
    --va-primary: var(--va-brand, #667eea);
    --va-primary-rgb: var(--va-brand-rgb, 102, 126, 234);
    --va-primary-soft: rgba(var(--va-brand-rgb, 102, 126, 234), 0.12);

    /* User balloon: brand color */
    --va-msg-user-bg: var(--va-brand, #667eea);
    --va-msg-user-text: white;

    /* Assistant balloon: subtle brand tint */
    --va-msg-assistant-bg: rgba(var(--va-brand-rgb, 102, 126, 234), 0.08);
    --va-msg-assistant-border: rgba(var(--va-brand-rgb, 102, 126, 234), 0.12);

    /* Glass elements: brand-tinted */
    --va-glass: rgba(var(--va-brand-rgb, 102, 126, 234), 0.06);
    --va-glass2: rgba(var(--va-brand-rgb, 102, 126, 234), 0.04);
    --va-glass-border: rgba(var(--va-brand-rgb, 102, 126, 234), 0.12);
    --va-glass-border-hover: rgba(var(--va-brand-rgb, 102, 126, 234), 0.2);

    /* Input bar */
    --va-input-bg: rgba(var(--va-brand-rgb, 102, 126, 234), 0.05);
    --va-input-border: rgba(var(--va-brand-rgb, 102, 126, 234), 0.1);

    /* Shadows with brand glow */
    --va-shadow-btn: 0 4px 24px rgba(var(--va-brand-rgb, 102, 126, 234), 0.35);
}

/* Light + brand: softer tints to match lighter panel */
:host([theme="light"]) {
    --va-msg-assistant-bg: rgba(var(--va-brand-rgb, 102, 126, 234), 0.06);
    --va-msg-assistant-border: rgba(var(--va-brand-rgb, 102, 126, 234), 0.08);
    --va-glass: rgba(var(--va-brand-rgb, 102, 126, 234), 0.04);
    --va-glass2: rgba(var(--va-brand-rgb, 102, 126, 234), 0.03);
    --va-glass-border: rgba(var(--va-brand-rgb, 102, 126, 234), 0.08);
    --va-glass-border-hover: rgba(var(--va-brand-rgb, 102, 126, 234), 0.14);
    --va-shadow-btn: 0 4px 20px rgba(var(--va-brand-rgb, 102, 126, 234), 0.25);
}

/* ========================================
   FLOATING BUBBLE
   ======================================== */

.va-floating-bubble {
    position: fixed; bottom: 28px; right: 28px; z-index: 2147483647;
}

.va-floating-bubble.va-hidden { display: none; }

/* Plasma bubble sizing (56px) — centered with ring space */
.va-bubble-plasma-wrap {
    width: 56px; height: 56px; position: relative;
    display: flex; align-items: center; justify-content: center;
}

.va-bubble-plasma-wrap .va-plasma-btn {
    width: 56px !important; height: 56px !important;
    min-width: 56px !important; min-height: 56px !important;
    max-width: 56px !important; max-height: 56px !important;
    padding: 0 !important; margin: 0 !important;
    box-sizing: border-box !important;
    line-height: 1 !important;
    box-shadow: 0 4px 20px rgba(var(--va-primary-rgb), 0.4);
}

.va-bubble-plasma-wrap .va-plasma-btn:hover {
    transform: scale(1.07);
    box-shadow: 0 6px 28px rgba(var(--va-primary-rgb), 0.5);
}

/* Bubble icon size — see override after .va-plasma-btn rules */

/* 3 concentric rings — indigo sound wave propagation */
.va-bubble-ring {
    position: absolute; border-radius: 50%;
    pointer-events: none; z-index: 0;
    opacity: 0;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
}

.va-bubble-ring-1 {
    width: 56px; height: 56px;
    border: 2px solid rgba(var(--va-primary-rgb), 0.45);
    animation: va-wave-ring 3s cubic-bezier(0, 0, 0.2, 1) 0s infinite;
}
.va-bubble-ring-2 {
    width: 56px; height: 56px;
    border: 1.5px solid rgba(var(--va-primary-rgb), 0.3);
    animation: va-wave-ring 3s cubic-bezier(0, 0, 0.2, 1) 1s infinite;
}
.va-bubble-ring-3 {
    width: 56px; height: 56px;
    border: 1px solid rgba(var(--va-primary-rgb), 0.2);
    animation: va-wave-ring 3s cubic-bezier(0, 0, 0.2, 1) 2s infinite;
}

@keyframes va-wave-ring {
    0%   { transform: translate(-50%, -50%) scale(1);   opacity: 0.7; }
    100% { transform: translate(-50%, -50%) scale(2.0); opacity: 0; }
}

/* Tooltip (glass) */
.va-bubble-tooltip {
    position: absolute; bottom: 66px; right: 0;
    background: var(--va-panel-bg);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    color: var(--va-text); padding: 11px 26px 11px 18px;
    border-radius: 13px 13px 4px 13px;
    border: 1px solid var(--va-glass-border);
    font-size: 13px; font-weight: 500;
    box-shadow: var(--va-shadow); white-space: nowrap;
    opacity: 0; transform: translateY(6px) scale(0.96);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

.va-floating-bubble:hover .va-bubble-tooltip {
    opacity: 1; transform: translateY(0) scale(1); pointer-events: auto;
}

/* ========================================
   CHAT PANEL (Glass Morphism)
   ======================================== */

.va-chat-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.18); z-index: 2147483646;
}

.va-chat-modal {
    position: fixed; bottom: 24px; right: 24px;
    width: 380px; max-width: calc(100vw - 32px);
    height: min(620px, calc(100vh - 48px));
    z-index: 2147483647; border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--va-shadow);
    transform-origin: bottom right;
    border: 1px solid var(--va-glass-border);
    overscroll-behavior: contain;
}

.va-chat-container {
    display: flex; flex-direction: column;
    height: 100%;
    position: relative;
    background: var(--va-panel-bg);
    backdrop-filter: blur(var(--va-panel-blur));
    -webkit-backdrop-filter: blur(var(--va-panel-blur));
    overflow: hidden;
}

/* ── HEADER (glass) ── */
.va-chat-header {
    padding: 13px 14px;
    background: var(--va-glass);
    border-bottom: 1px solid var(--va-glass-border);
    display: flex; align-items: center; gap: 10px;
}

.va-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: rgba(99, 102, 241, 0.25);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.va-avatar svg {
    width: 30px; height: 30px;
    color: #a5b4fc; fill: none;
}

:host([theme="light"]) .va-avatar {
    background: rgba(99, 102, 241, 0.1);
}
:host([theme="light"]) .va-avatar svg {
    color: #6366f1;
}

.va-header-text { flex: 1; }

.va-header-title {
    font-size: 13.5px; font-weight: 700;
    color: var(--va-text); letter-spacing: -0.2px;
}

.va-header-status {
    font-size: 10.5px; color: var(--va-text-secondary);
    display: flex; align-items: center; gap: 4px;
}

.va-status-dot {
    width: 5px; height: 5px; border-radius: 50%;
    background: var(--va-success);
    box-shadow: 0 0 6px rgba(52, 211, 153, 0.5);
}

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

.va-hdr-btn {
    background: var(--va-glass);
    border: 1px solid var(--va-glass-border);
    border-radius: 50%; width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.2s; padding: 0;
}

.va-hdr-btn:hover {
    background: var(--va-glass-border);
    border-color: var(--va-glass-border-hover);
}

.va-hdr-btn svg {
    width: 13px; height: 13px;
    stroke: var(--va-text-secondary); fill: none; stroke-width: 2;
}

.va-hdr-btn:hover svg { stroke: var(--va-text); }

/* ── MUTE BUTTON ── */
.va-mute-btn.va-muted {
    background: var(--va-danger-soft);
    border-color: var(--va-danger);
}
.va-mute-btn.va-muted svg { stroke: var(--va-danger); }
.va-mute-btn.va-muted:hover { background: rgba(248, 113, 113, 0.18); }

/* ── TOASTS ── */
.va-toast {
    position: absolute; top: 58px; left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: 10px 18px; border-radius: 11px;
    font-size: 12.5px; font-weight: 600;
    display: flex; align-items: center; gap: 7px;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 10; white-space: nowrap; pointer-events: none;
}
.va-toast svg { width: 14px; height: 14px; fill: none; stroke-width: 2.5; }
.va-toast.va-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

.va-toast.va-toast-add {
    background: rgba(6, 78, 50, 0.92);
    border: 1px solid rgba(52, 211, 153, 0.5);
    color: #6ee7b7;
}
.va-toast.va-toast-add svg { stroke: #6ee7b7; }

.va-toast.va-toast-remove {
    background: rgba(85, 15, 15, 0.92);
    border: 1px solid rgba(248, 113, 113, 0.5);
    color: #fca5a5;
}
.va-toast.va-toast-remove svg { stroke: #fca5a5; }

.va-toast.va-toast-clear {
    background: rgba(80, 60, 5, 0.92);
    border: 1px solid rgba(251, 191, 36, 0.5);
    color: #fde68a;
}
.va-toast.va-toast-clear svg { stroke: #fde68a; }

/* Light theme toasts */
:host([theme="light"]) .va-toast.va-toast-add {
    background: rgba(220, 252, 231, 0.95);
    border: 1px solid rgba(34, 197, 94, 0.4);
    color: #15803d;
}
:host([theme="light"]) .va-toast.va-toast-add svg { stroke: #15803d; }

:host([theme="light"]) .va-toast.va-toast-remove {
    background: rgba(254, 226, 226, 0.95);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #b91c1c;
}
:host([theme="light"]) .va-toast.va-toast-remove svg { stroke: #b91c1c; }

:host([theme="light"]) .va-toast.va-toast-clear {
    background: rgba(254, 249, 195, 0.95);
    border: 1px solid rgba(234, 179, 8, 0.4);
    color: #a16207;
}
:host([theme="light"]) .va-toast.va-toast-clear svg { stroke: #a16207; }

/* ── MESSAGES ── */
.va-chat-messages {
    flex: 1; overflow-y: auto; padding: 14px;
    display: flex; flex-direction: column; gap: 8px;
    min-height: 140px;
}

.va-message {
    display: flex; max-width: 85%;
    animation: va-msg-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes va-msg-in {
    from { opacity: 0; transform: translateY(6px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.va-message-user    { align-self: flex-end; }
.va-message-assistant { align-self: flex-start; }

.va-message-content {
    padding: 10px 14px; font-size: 13px; line-height: 1.55;
}

.va-message-user .va-message-content {
    background: var(--va-msg-user-bg);
    color: var(--va-msg-user-text);
    border-radius: 14px 14px 4px 14px;
}

.va-message-assistant .va-message-content {
    background: var(--va-msg-assistant-bg);
    border: 1px solid var(--va-msg-assistant-border);
    color: var(--va-text);
    border-radius: 4px 14px 14px 14px;
}

.va-message-text { word-wrap: break-word; overflow-wrap: break-word; word-break: break-word; -webkit-hyphens: auto; hyphens: auto; }
.va-message-text strong { font-weight: 600; }

/* ── ONBOARDING CHIPS ── */
.va-chips {
    display: flex; flex-wrap: wrap; gap: 6px;
    padding: 0 14px 10px;
    animation: va-msg-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.va-chip {
    padding: 6px 13px; border-radius: 18px;
    background: var(--va-glass);
    border: 1px solid var(--va-glass-border);
    color: var(--va-text-secondary);
    font-family: inherit; font-size: 12px; font-weight: 500;
    cursor: pointer; transition: all 0.2s;
}

.va-chip:hover {
    background: var(--va-primary-soft);
    border-color: rgba(var(--va-primary-rgb), 0.25);
    color: var(--va-text);
    transform: translateY(-1px);
}

/* ── TYPING INDICATOR ── */
.va-typing-indicator .va-message-content { padding: 13px 16px; }

.va-typing-dots { display: flex; gap: 5px; }

.va-typing-dots span {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--va-text-secondary);
    animation: va-bounce 1.2s ease-in-out infinite;
}
.va-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.va-typing-dots span:nth-child(3) { animation-delay: 0.3s; }

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

/* ── FOOTER (banners + input, never covers messages) ── */
.va-chat-footer {
    flex-shrink: 0;
}

/* ── INPUT BAR ── */
.va-chat-input {
    padding: 10px 12px;
    background: var(--va-glass);
    border-top: 1px solid var(--va-glass-border);
    display: flex; align-items: center; gap: 8px;
}

.va-input-wrapper { flex: 1; display: flex; align-items: center; }

.va-text-input {
    flex: 1; padding: 9px 13px !important;
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid var(--va-glass-border) !important;
    border-radius: 11px !important; color: var(--va-text) !important;
    font-family: inherit; font-size: 13px; outline: none !important;
    transition: border-color 0.2s;
    box-shadow: none !important;
}

/* Light theme input */
:host([theme="light"]) .va-text-input {
    background: rgba(0, 0, 0, 0.04) !important;
}
.va-text-input::placeholder { color: var(--va-text-muted); }
.va-text-input:focus { border-color: rgba(var(--va-primary-rgb), 0.4); }

/* ========================================
   PLASMA VOICE BUTTON (in input bar)
   ======================================== */

.va-plasma-wrap {
    position: relative; width: 40px; height: 40px;
    flex-shrink: 0; cursor: pointer;
}
.va-plasma-wrap.va-disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.va-plasma-btn {
    width: 40px !important; height: 40px !important;
    min-width: 40px; min-height: 40px;
    max-width: 40px; max-height: 40px;
    border-radius: 50% !important;
    border: none !important; cursor: pointer; position: relative;
    display: grid; place-items: center;
    overflow: hidden; padding: 0 !important; margin: 0 !important;
    box-sizing: border-box !important;
    line-height: 1 !important;
    z-index: 2;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    /* iOS: prevent long-press context menu / text selection for hold-to-talk */
    touch-action: none; -webkit-touch-callout: none;
    -webkit-user-select: none; user-select: none;
}
/* All button children: never steal touch/click events */
.va-plasma-btn * { pointer-events: none !important; }
.va-plasma-btn:hover { transform: scale(1.06); }

.va-plasma-btn .va-icon-wrap {
    position: relative; z-index: 5;
    width: 30px; height: 30px; display: grid; place-items: center;
}

.va-plasma-btn .va-icon-wrap svg {
    width: 30px; height: 30px;
    color: white;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.4));
    display: block;
}

/* Bubble (closed orb): larger icon — 43px desktop */
.va-bubble-plasma-wrap .va-icon-wrap { width: 43px !important; height: 43px !important; }
.va-bubble-plasma-wrap .va-icon-wrap svg { width: 43px !important; height: 43px !important; }

.va-plasma-btn .va-icon-wrap .va-stop-icon {
    width: 12px; height: 12px; background: white;
    border-radius: 3px; filter: drop-shadow(0 1px 3px rgba(0,0,0,0.4));
}

.va-plasma-btn .va-icon-wrap .va-spinner {
    width: 20px; height: 20px;
    border: 2.5px solid rgba(255,255,255,0.2);
    border-top-color: white; border-radius: 50%;
    animation: va-spin 0.6s linear infinite;
}

@keyframes va-spin { to { transform: rotate(360deg); } }

/* Pulse ring — subtle glow, contained within input bar */
.va-pulse-ring {
    position: absolute; inset: -2px; border-radius: 50%;
    border: 1.5px solid; opacity: 0; z-index: 1; pointer-events: none;
}
.va-pulse-ring.va-active { animation: va-pulseRing 1.8s ease-out infinite; }
.va-pulse-ring.va-red   { border-color: var(--va-danger); }
.va-pulse-ring.va-green { border-color: var(--va-success); }

@keyframes va-pulseRing {
    0%   { transform: scale(1); opacity: 0.5; }
    100% { transform: scale(1.15); opacity: 0; }
}

/* Blob layer */
.va-plasma-btn .va-blob-layer {
    position: absolute; inset: 0; border-radius: 50%;
    overflow: hidden; filter: blur(5px) saturate(1.5);
}
.va-plasma-btn .va-blob {
    position: absolute; border-radius: 50%; mix-blend-mode: screen;
}

/* Speculars */
.va-plasma-btn .va-specular {
    position: absolute; border-radius: 50%; z-index: 2; pointer-events: none;
    background: radial-gradient(circle, rgba(255,255,255,0.25) 0%, transparent 65%);
}
.va-plasma-btn .va-spec1 { width:38%;height:28%;top:8%;left:14%; animation:va-specA 6s ease-in-out infinite; }
.va-plasma-btn .va-spec2 { width:22%;height:18%;top:56%;left:54%; opacity:0.5; animation:va-specB 7s ease-in-out infinite; }

@keyframes va-specA { 0%,100%{transform:translate(0,0)} 50%{transform:translate(5%,6%)} }
@keyframes va-specB { 0%,100%{transform:translate(0,0)} 50%{transform:translate(-6%,-4%)} }

/* IDLE: indigo */
.va-plasma-btn.va-state-idle {
    background: #110d28;
    box-shadow: 0 0 12px rgba(var(--va-primary-rgb), 0.4), 0 0 24px rgba(var(--va-primary-rgb), 0.15);
}
.va-plasma-btn.va-state-idle .va-blob:nth-child(1){width:65%;height:65%;top:8%;left:5%;background:radial-gradient(circle at 45% 45%,#7c7fff 0%,#6366f1 25%,transparent 60%);animation:va-bM1 4s ease-in-out infinite}
.va-plasma-btn.va-state-idle .va-blob:nth-child(2){width:55%;height:55%;top:28%;left:35%;background:radial-gradient(circle at 50% 50%,#b49aff 0%,#8b5cf6 25%,transparent 60%);animation:va-bM2 5s ease-in-out infinite}
.va-plasma-btn.va-state-idle .va-blob:nth-child(3){width:50%;height:50%;top:5%;left:42%;background:radial-gradient(circle at 40% 40%,#d4c4ff 0%,#a78bfa 20%,transparent 55%);animation:va-bM3 4.5s ease-in-out infinite}
.va-plasma-btn.va-state-idle .va-blob:nth-child(4){width:45%;height:45%;top:40%;left:8%;background:radial-gradient(circle at 55% 55%,#9da2ff 0%,#818cf8 25%,transparent 60%);animation:va-bM4 3.8s ease-in-out infinite}
.va-plasma-btn.va-state-idle .va-blob:nth-child(5){width:40%;height:40%;top:22%;left:28%;background:radial-gradient(circle at 50% 50%,#e8deff 0%,#c4b5fd 20%,transparent 55%);animation:va-bM5 5.5s ease-in-out infinite}

/* RECORDING: rosso */
.va-plasma-btn.va-state-recording {
    background:#1c0808;
    box-shadow: 0 0 16px rgba(248, 113, 113, 0.5), 0 0 32px rgba(248, 113, 113, 0.2);
}
@keyframes va-mic-pulse {
    0%,100% { opacity: 1; }
    50% { opacity: 0.85; }
}
.va-plasma-btn.va-state-recording .va-blob:nth-child(1){width:65%;height:65%;top:8%;left:5%;background:radial-gradient(circle at 45% 45%,#ff6b6b 0%,#ef4444 25%,transparent 60%);animation:va-bM1 2.5s ease-in-out infinite}
.va-plasma-btn.va-state-recording .va-blob:nth-child(2){width:55%;height:55%;top:28%;left:35%;background:radial-gradient(circle at 50% 50%,#ffb347 0%,#f97316 25%,transparent 60%);animation:va-bM2 3s ease-in-out infinite}
.va-plasma-btn.va-state-recording .va-blob:nth-child(3){width:50%;height:50%;top:5%;left:42%;background:radial-gradient(circle at 40% 40%,#ff4040 0%,#dc2626 20%,transparent 55%);animation:va-bM3 2.8s ease-in-out infinite}
.va-plasma-btn.va-state-recording .va-blob:nth-child(4){width:45%;height:45%;top:40%;left:8%;background:radial-gradient(circle at 55% 55%,#ffc078 0%,#fb923c 25%,transparent 60%);animation:va-bM4 2.2s ease-in-out infinite}
.va-plasma-btn.va-state-recording .va-blob:nth-child(5){width:40%;height:40%;top:22%;left:28%;background:radial-gradient(circle at 50% 50%,#ffcaca 0%,#fca5a5 20%,transparent 55%);animation:va-bM5 3.2s ease-in-out infinite}

/* PROCESSING: muted */
.va-plasma-btn.va-state-processing { background:#110d28; box-shadow: 0 0 12px rgba(var(--va-primary-rgb), 0.3), 0 0 24px rgba(var(--va-primary-rgb), 0.1); }
.va-plasma-btn.va-state-processing .va-blob:nth-child(1){width:65%;height:65%;top:8%;left:5%;background:radial-gradient(circle at 45% 45%,#7c7fff 0%,#6366f1 25%,transparent 60%);animation:va-bM1 6s ease-in-out infinite}
.va-plasma-btn.va-state-processing .va-blob:nth-child(2){width:55%;height:55%;top:28%;left:35%;background:radial-gradient(circle at 50% 50%,#b49aff 0%,#8b5cf6 25%,transparent 60%);animation:va-bM2 7s ease-in-out infinite}
.va-plasma-btn.va-state-processing .va-blob:nth-child(3){width:50%;height:50%;top:5%;left:42%;background:radial-gradient(circle at 40% 40%,#d4c4ff 0%,#a78bfa 20%,transparent 55%);animation:va-bM3 6.5s ease-in-out infinite}
.va-plasma-btn.va-state-processing .va-blob:nth-child(4){width:45%;height:45%;top:40%;left:8%;background:radial-gradient(circle at 55% 55%,#9da2ff 0%,#818cf8 25%,transparent 60%);animation:va-bM4 5.8s ease-in-out infinite}
.va-plasma-btn.va-state-processing .va-blob:nth-child(5){width:40%;height:40%;top:22%;left:28%;background:radial-gradient(circle at 50% 50%,#e8deff 0%,#c4b5fd 20%,transparent 55%);animation:va-bM5 7.5s ease-in-out infinite}

/* PLAYING: verde */
.va-plasma-btn.va-state-playing {
    background:#071c12;
    box-shadow: 0 0 12px rgba(52, 211, 153, 0.4), 0 0 24px rgba(52, 211, 153, 0.15);
}
.va-plasma-btn.va-state-playing .va-blob:nth-child(1){width:65%;height:65%;top:8%;left:5%;background:radial-gradient(circle at 45% 45%,#4ade80 0%,#22c55e 25%,transparent 60%);animation:va-bM1 3.5s ease-in-out infinite}
.va-plasma-btn.va-state-playing .va-blob:nth-child(2){width:55%;height:55%;top:28%;left:35%;background:radial-gradient(circle at 50% 50%,#34d399 0%,#10b981 25%,transparent 60%);animation:va-bM2 4s ease-in-out infinite}
.va-plasma-btn.va-state-playing .va-blob:nth-child(3){width:50%;height:50%;top:5%;left:42%;background:radial-gradient(circle at 40% 40%,#6ee7b7 0%,#34d399 20%,transparent 55%);animation:va-bM3 3.8s ease-in-out infinite}
.va-plasma-btn.va-state-playing .va-blob:nth-child(4){width:45%;height:45%;top:40%;left:8%;background:radial-gradient(circle at 55% 55%,#10b981 0%,#059669 25%,transparent 60%);animation:va-bM4 3s ease-in-out infinite}
.va-plasma-btn.va-state-playing .va-blob:nth-child(5){width:40%;height:40%;top:22%;left:28%;background:radial-gradient(circle at 50% 50%,#a7f3d0 0%,#6ee7b7 20%,transparent 55%);animation:va-bM5 4.5s ease-in-out infinite}

@keyframes va-bM1{0%,100%{transform:translate(0,0) scale(1)}25%{transform:translate(15%,20%) scale(1.1)}50%{transform:translate(-10%,15%) scale(0.95)}75%{transform:translate(20%,-10%) scale(1.05)}}
@keyframes va-bM2{0%,100%{transform:translate(0,0) scale(1)}25%{transform:translate(-20%,10%) scale(1.05)}50%{transform:translate(15%,-15%) scale(1.1)}75%{transform:translate(-5%,20%) scale(0.9)}}
@keyframes va-bM3{0%,100%{transform:translate(0,0) scale(1)}33%{transform:translate(10%,-20%) scale(1.15)}66%{transform:translate(-15%,10%) scale(0.9)}}
@keyframes va-bM4{0%,100%{transform:translate(0,0) scale(1)}20%{transform:translate(-10%,-15%) scale(1.05)}50%{transform:translate(20%,5%) scale(0.95)}80%{transform:translate(-5%,15%) scale(1.1)}}
@keyframes va-bM5{0%,100%{transform:translate(0,0) scale(1)}30%{transform:translate(15%,-10%) scale(0.95)}60%{transform:translate(-10%,-5%) scale(1.1)}}

/* ========================================
   WAVEFORM BANNERS
   ======================================== */

.va-waveform-banner {
    padding: 7px 14px; display: flex; align-items: center; gap: 8px;
    font-size: 11px; font-weight: 600;
}
.va-waveform-banner.va-wf-rec {
    background: var(--va-danger-soft);
    border-top: 1px solid rgba(248,113,113,0.08);
    color: var(--va-danger);
}
.va-waveform-banner.va-wf-play {
    background: var(--va-success-soft);
    border-top: 1px solid rgba(52,211,153,0.08);
    color: var(--va-success);
}

.va-wf-dot {
    width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
    animation: va-blink 1s step-end infinite;
}
.va-wf-rec .va-wf-dot { background: var(--va-danger); }
.va-wf-play .va-wf-dot { background: var(--va-success); }

@keyframes va-blink { 50% { opacity: 0; } }

.va-wf-bars { display: flex; align-items: center; gap: 1.5px; height: 22px; flex: 1; }
.va-wf-bars .va-bar { flex: 1; max-width: 3px; border-radius: 1.5px; }
.va-wf-rec  .va-wf-bars .va-bar { background: var(--va-danger); opacity: 0.65; }
.va-wf-play .va-wf-bars .va-bar { background: var(--va-success); opacity: 0.65; }

.va-wf-bars .va-bar:nth-child(1) {height:4px;animation:va-wr1 1.8s ease-in-out infinite}
.va-wf-bars .va-bar:nth-child(2) {height:7px;animation:va-wr2 1.4s ease-in-out infinite}
.va-wf-bars .va-bar:nth-child(3) {height:12px;animation:va-wr3 1.05s ease-in-out infinite}
.va-wf-bars .va-bar:nth-child(4) {height:8px;animation:va-wr4 1.25s ease-in-out infinite}
.va-wf-bars .va-bar:nth-child(5) {height:16px;animation:va-wr5 0.85s ease-in-out infinite}
.va-wf-bars .va-bar:nth-child(6) {height:10px;animation:va-wr6 1.15s ease-in-out infinite}
.va-wf-bars .va-bar:nth-child(7) {height:14px;animation:va-wr7 0.95s ease-in-out infinite}
.va-wf-bars .va-bar:nth-child(8) {height:6px;animation:va-wr8 1.6s ease-in-out infinite}
.va-wf-bars .va-bar:nth-child(9) {height:9px;animation:va-wr9 1.1s ease-in-out infinite}
.va-wf-bars .va-bar:nth-child(10){height:13px;animation:va-wr10 0.9s ease-in-out infinite}
.va-wf-bars .va-bar:nth-child(11){height:6px;animation:va-wr11 1.5s ease-in-out infinite}
.va-wf-bars .va-bar:nth-child(12){height:11px;animation:va-wr12 1.0s ease-in-out infinite}
.va-wf-bars .va-bar:nth-child(13){height:5px;animation:va-wr13 1.7s ease-in-out infinite}
.va-wf-bars .va-bar:nth-child(14){height:8px;animation:va-wr14 1.3s ease-in-out infinite}

@keyframes va-wr1 {0%,100%{height:4px}30%{height:9px}60%{height:5px}}
@keyframes va-wr2 {0%,100%{height:7px}20%{height:14px}50%{height:5px}80%{height:10px}}
@keyframes va-wr3 {0%,100%{height:12px}15%{height:17px}45%{height:7px}75%{height:14px}}
@keyframes va-wr4 {0%,100%{height:8px}25%{height:5px}55%{height:16px}85%{height:9px}}
@keyframes va-wr5 {0%,100%{height:16px}20%{height:8px}40%{height:18px}70%{height:6px}}
@keyframes va-wr6 {0%,100%{height:10px}35%{height:17px}65%{height:6px}}
@keyframes va-wr7 {0%,100%{height:14px}10%{height:7px}50%{height:18px}80%{height:10px}}
@keyframes va-wr8 {0%,100%{height:6px}40%{height:12px}70%{height:4px}}
@keyframes va-wr9 {0%,100%{height:9px}25%{height:16px}55%{height:5px}85%{height:13px}}
@keyframes va-wr10{0%,100%{height:13px}15%{height:6px}45%{height:18px}75%{height:8px}}
@keyframes va-wr11{0%,100%{height:6px}30%{height:12px}60%{height:4px}}
@keyframes va-wr12{0%,100%{height:11px}20%{height:17px}50%{height:7px}80%{height:14px}}
@keyframes va-wr13{0%,100%{height:5px}35%{height:10px}65%{height:3px}}
@keyframes va-wr14{0%,100%{height:8px}25%{height:14px}55%{height:5px}85%{height:11px}}

.va-wf-timer { font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; flex-shrink: 0; }

/* ========================================
   PRODUCT CARDS IN CHAT (Glass)
   ======================================== */

.va-product-card {
    background: var(--va-glass);
    border: 1px solid var(--va-glass-border);
    border-radius: 14px; overflow: hidden;
    max-width: 85%; align-self: flex-start;
    animation: va-msg-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.va-message:has(.va-product-card) { max-width: 85%; }
.va-message .va-product-card {
    display: flex; flex-direction: column; border-radius: 14px;
    overflow: hidden; padding: 0; gap: 0;
}
.va-message .va-product-card .va-product-card-image {
    display: block; width: 100%; height: 160px;
    object-fit: cover; border-radius: 0; order: -1;
}
.va-product-card .va-product-card-body { padding: 10px 12px; overflow: hidden; }
.va-product-card .va-product-card-name { font-weight: 600; font-size: 12px; color: var(--va-text); margin-bottom: 3px; line-height: 1.3; overflow-wrap: break-word; word-break: break-word; }
.va-product-card .va-product-card-price { font-weight: 700; font-size: 13.5px; color: var(--va-primary); margin-bottom: 6px; line-height: 1.3; }
.va-product-card .va-product-card-desc { font-size: 11.5px; color: var(--va-text-secondary); line-height: 1.45; margin-bottom: 8px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: break-word; word-break: break-word; }
.va-product-card .va-product-card-actions { display: flex; gap: 6px; }
.va-product-card-btn { flex: 1; padding: 7px; border: none; border-radius: 9px; font-size: 11.5px; font-weight: 600; cursor: pointer; text-align: center; transition: all 0.2s; }
.va-btn-add { background: var(--va-primary); color: white; }
.va-btn-add:hover { filter: brightness(1.12); }
.va-btn-add:disabled { background: var(--va-success); cursor: default; }
.va-btn-more { background: var(--va-glass); border: 1px solid var(--va-glass-border); color: var(--va-text-secondary); text-decoration: none; }
.va-btn-more:hover { background: var(--va-glass-border); color: var(--va-text); text-decoration: none; }

/* ========================================
   PRODUCT PAGE & INLINE BUTTONS
   ======================================== */

button.va-product-btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 18px; background: var(--va-primary); color: white;
    border: none; border-radius: 10px; font-size: 13px; font-weight: 600;
    cursor: pointer; margin: 10px 0; transition: all 0.2s;
}
button.va-product-btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
button.va-product-btn svg { flex-shrink: 0; stroke: white; fill: none; width: 18px; height: 18px; }

button.va-inline-btn {
    display: inline-flex; align-items: center; gap: 10px;
    padding: 12px 22px; background: var(--va-primary); color: white;
    border: none; border-radius: 50px; font-size: 14px; font-weight: 600;
    cursor: pointer; transition: all 0.3s; box-shadow: var(--va-shadow-btn);
}
button.va-inline-btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
button.va-inline-btn svg { stroke: white; fill: none; }

.va-inline-chat { border: 1px solid var(--va-glass-border); border-radius: 20px; overflow: hidden; max-width: 500px; }
.va-inline-chat .va-chat-messages { height: 400px; }

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

@media (max-width: 480px) {
    .va-floating-bubble { bottom: 90px; right: 16px; }
    .va-bubble-plasma-wrap { width: 50px; height: 50px; }
    .va-bubble-plasma-wrap .va-plasma-btn {
        width: 50px !important; height: 50px !important;
        min-width: 50px !important; min-height: 50px !important;
        max-width: 50px !important; max-height: 50px !important;
    }
    .va-bubble-plasma-wrap .va-icon-wrap { width: 38px !important; height: 38px !important; }
    .va-bubble-plasma-wrap .va-icon-wrap svg { width: 38px !important; height: 38px !important; }
    .va-plasma-btn .va-icon-wrap { width: 36px; height: 36px; }
    .va-plasma-btn .va-icon-wrap svg { width: 36px; height: 36px; }
    .va-avatar { width: 36px; height: 36px; }
    .va-avatar svg { width: 36px; height: 36px; }
    .va-bubble-ring-1, .va-bubble-ring-2, .va-bubble-ring-3 { width: 50px; height: 50px; }
    .va-bubble-tooltip { display: none; }
    .va-chat-modal {
        position: fixed; top: 0; right: 0; bottom: 0; left: 0;
        width: 100% !important; max-width: 100% !important;
        height: 100% !important;
        height: -webkit-fill-available !important; /* iOS Safari: fills exactly the visible area */
        max-height: -webkit-fill-available !important;
        border-radius: 0 !important; border: none !important;
        box-sizing: border-box !important;
        transform-origin: bottom center;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }
    .va-chat-container {
        height: 100%;
        height: -webkit-fill-available;
        border-radius: 0;
        overscroll-behavior: contain;
    }
    .va-chat-container::before {
        content: ''; position: absolute; top: 8px; left: 50%;
        transform: translateX(-50%); width: 36px; height: 4px;
        border-radius: 2px; background: var(--va-glass-border-hover); z-index: 5;
    }
    .va-chat-header { padding-top: 20px; }
    .va-chat-messages { flex: 1; }
    /* Match wrap to btn size so pulse ring centers correctly */
    .va-plasma-wrap {
        width: 44px !important; height: 44px !important;
    }
    .va-plasma-btn {
        width: 44px !important; height: 44px !important;
        min-width: 44px !important; min-height: 44px !important;
        max-width: 44px !important; max-height: 44px !important;
    }
    .va-text-input { font-size: 1rem; } /* 1rem = 16px; prevents iOS auto-zoom on focus */
    /* Mobile fonts — rem-based for accessibility (user system font settings apply) */
    .va-message-content { font-size: 1rem; line-height: 1.5; } /* 16px */
    .va-message-text { font-size: 1rem; }
    .va-chat-header .va-title { font-size: 1rem; }
    .va-product-card .va-product-card-name { font-size: 0.875rem; } /* 14px */
    .va-product-card .va-product-card-desc { font-size: 0.8125rem; } /* 13px */
    .va-product-card .va-product-card-price { font-size: 0.9375rem; } /* 15px */
    .va-product-card-btn { font-size: 0.8125rem; }
    .va-nav-button { font-size: 0.875rem; }
    .va-chip { font-size: 0.8125rem; }
}

/* ── VARIANT SELECTOR ── */
.va-variant-selector {
    padding: 12px; border-radius: 12px;
    background: var(--va-surface); border: 1px solid var(--va-border);
}
.va-vs-title {
    font-weight: 700; font-size: 13px; color: var(--va-text);
    margin-bottom: 2px;
}
.va-vs-product {
    font-size: 12px; color: var(--va-text-muted); margin-bottom: 10px;
    font-weight: 500;
}
.va-vs-preselected {
    display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px;
}
.va-vs-tag {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px; border-radius: 16px; font-size: 11.5px;
}
.va-vs-tag-done {
    background: rgba(var(--va-primary-rgb), 0.12); color: var(--va-primary);
}
.va-vs-group {
    margin-bottom: 10px;
}
.va-vs-label {
    font-size: 11.5px; font-weight: 600; color: var(--va-text-muted);
    margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.5px;
}
.va-vs-options {
    display: flex; flex-wrap: wrap; gap: 6px;
}
.va-vs-options.va-vs-compact {
    max-height: 140px; overflow-y: auto; padding-right: 4px;
}
.va-vs-option {
    padding: 6px 12px; border-radius: 16px; font-size: 12px;
    border: 1px solid var(--va-border); background: var(--va-bg);
    color: var(--va-text); cursor: pointer; transition: all 0.15s;
    white-space: nowrap;
}
.va-vs-option:hover {
    border-color: var(--va-primary); background: rgba(var(--va-primary-rgb), 0.06);
}
.va-vs-option.va-vs-selected {
    border-color: var(--va-primary); background: rgba(var(--va-primary-rgb), 0.15);
    color: var(--va-primary); font-weight: 600;
}
.va-vs-hint {
    font-size: 11px; color: var(--va-text-muted); margin: 8px 0 10px; font-style: italic;
}
.va-vs-confirm {
    width: 100%; padding: 10px; border: none; border-radius: 10px;
    background: var(--va-primary); color: #fff; font-weight: 700;
    font-size: 13px; cursor: pointer; transition: all 0.2s;
}
.va-vs-confirm:disabled {
    opacity: 0.4; cursor: not-allowed;
}
.va-vs-confirm:not(:disabled):hover {
    filter: brightness(1.1);
}

/* ── NAVIGATION BUTTON ── */
.va-nav-button-wrap {
    padding: 4px 14px 8px;
    animation: va-msg-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.va-nav-button {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 18px; border-radius: 20px;
    background: linear-gradient(135deg, rgba(var(--va-primary-rgb), 0.15), rgba(var(--va-primary-rgb), 0.08));
    border: 1px solid rgba(var(--va-primary-rgb), 0.3);
    color: var(--va-primary);
    font-family: inherit; font-size: 13px; font-weight: 600;
    cursor: pointer; transition: all 0.25s;
    backdrop-filter: blur(8px);
}
.va-nav-button:hover {
    background: linear-gradient(135deg, rgba(var(--va-primary-rgb), 0.25), rgba(var(--va-primary-rgb), 0.15));
    border-color: rgba(var(--va-primary-rgb), 0.5);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(var(--va-primary-rgb), 0.2);
}
.va-nav-button:active {
    transform: translateY(0);
}

/* ── NAVIGATION BUTTON ── */
.va-nav-button-wrap {
    padding: 4px 14px 8px;
    animation: va-msg-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.va-nav-button {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 18px; border-radius: 20px;
    background: linear-gradient(135deg, rgba(var(--va-primary-rgb), 0.15), rgba(var(--va-primary-rgb), 0.08));
    border: 1px solid rgba(var(--va-primary-rgb), 0.3);
    color: var(--va-primary);
    font-family: inherit; font-size: 13px; font-weight: 600;
    cursor: pointer; transition: all 0.25s;
    backdrop-filter: blur(8px);
}
.va-nav-button:hover {
    background: linear-gradient(135deg, rgba(var(--va-primary-rgb), 0.25), rgba(var(--va-primary-rgb), 0.15));
    border-color: rgba(var(--va-primary-rgb), 0.5);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(var(--va-primary-rgb), 0.2);
}
.va-nav-button:active {
    transform: translateY(0);
}

/* ========================================
   ORDER LOOKUP FORM
   ======================================== */

.va-order-form {
    padding: 14px !important; border-radius: 14px !important; width: 100%; box-sizing: border-box;
}
.va-order-form-wrap, .va-checkout-form-wrap {
    width: 85%;
}
.va-order-form-title {
    font-size: 15px; font-weight: 700; color: var(--va-text); margin-bottom: 2px;
}
.va-order-form-desc {
    font-size: 13.5px; color: var(--va-text-secondary); margin-bottom: 12px;
}
.va-order-field {
    margin-bottom: 10px;
}
.va-order-field label {
    display: block; font-size: 13.5px; font-weight: 600; color: var(--va-text-secondary); margin-bottom: 4px;
}
.va-order-optional {
    font-weight: 400; color: var(--va-text-muted);
}
.va-order-input {
    width: 100%; padding: 9px 12px; box-sizing: border-box;
    background: var(--va-glass2); border: 1px solid var(--va-glass-border);
    border-radius: 9px; color: var(--va-text);
    font-family: inherit; font-size: 13px; outline: none;
    transition: border-color 0.2s;
}
.va-order-input:focus {
    border-color: rgba(var(--va-primary-rgb), 0.5);
}
.va-order-input::placeholder {
    color: var(--va-text-muted);
}
.va-order-submit {
    width: 100%; padding: 11px; margin-top: 4px;
    background: var(--va-primary); color: white;
    border: none; border-radius: 9px;
    font-family: inherit; font-size: 14px; font-weight: 600;
    cursor: pointer; transition: all 0.2s;
}
.va-order-submit:hover { filter: brightness(1.1); }
.va-order-submit:disabled {
    opacity: 0.6; cursor: not-allowed; filter: none;
}

@media (max-width: 480px) {
    .va-order-input { font-size: 1rem; } /* Prevent iOS zoom */
}

/* ========================================
   SCROLLBAR + ACCESSIBILITY
   ======================================== */

.va-chat-messages::-webkit-scrollbar { width: 4px; }
.va-chat-messages::-webkit-scrollbar-track { background: transparent; }
.va-chat-messages::-webkit-scrollbar-thumb { background: var(--va-glass-border); border-radius: 2px; }

.va-plasma-btn:focus, .va-hdr-btn:focus {
    outline: 2px solid var(--va-primary); outline-offset: 2px;
}
.va-text-input:focus { outline: none; }

@media (prefers-reduced-motion: reduce) {
    .va-bubble-ring, .va-plasma-btn .va-blob, .va-plasma-btn .va-specular,
    .va-pulse-ring, .va-wf-bars .va-bar, .va-wf-dot, .va-typing-dots span { animation: none; }
    .va-plasma-btn, .va-chip, .va-hdr-btn { transition: none; }
}
