/* ── VelksPos AI Chatbot Widget ──────────────────────────────────────────── */

:root {
    --vc-primary: var(--vp-dark, #0a1f44);
    --vc-accent:  var(--vp-blue, #1e90ff);
}

/* ── Floating bubble ───────────────────────────────────────────────────────── */

.vel-chat-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--vc-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 0;
    box-shadow: 0 4px 18px rgba(0,0,0,0.28);
    z-index: 99998;
    transition: transform .2s, box-shadow .2s;
}
.vel-chat-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(0,0,0,0.38);
}
.vel-chat-bubble svg { width: 26px; height: 26px; }

/* ── Voice-active pulsing ring ── */
@keyframes vel-pulse-ring {
    0%   { box-shadow: 0 0 0 0 rgba(255,255,255,0.55), 0 4px 18px rgba(0,0,0,0.28); }
    70%  { box-shadow: 0 0 0 10px rgba(255,255,255,0), 0 4px 18px rgba(0,0,0,0.28); }
    100% { box-shadow: 0 0 0 0 rgba(255,255,255,0), 0 4px 18px rgba(0,0,0,0.28); }
}
.vel-chat-bubble.vel-voice-active {
    animation: vel-pulse-ring 1.4s ease-out infinite;
}

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

.vel-chat-panel {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 360px;
    height: min(560px, calc(100dvh - 110px));
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(.95) translateY(10px);
    opacity: 0;
    pointer-events: none;
    transition: transform .22s ease, opacity .22s ease;
}
.vel-chat-panel.vel-chat-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* Header */
.vel-chat-header {
    background: var(--vc-primary);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.vel-chat-header-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--vc-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}
.vel-chat-header-info   { flex: 1; }
.vel-chat-header-name   { font-weight: 700; font-size: 14px; line-height: 1.2; }
.vel-chat-header-sub    { font-size: 11px; opacity: .7; margin-top: 1px; }
.vel-chat-header-close  {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    opacity: .65;
    padding: 4px;
    font-size: 22px;
    line-height: 1;
    flex-shrink: 0;
}
.vel-chat-header-close:hover { opacity: 1; }
.vel-chat-header-mute {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    opacity: .65;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.vel-chat-header-mute:hover { opacity: 1; }
.vel-chat-header-mute svg { width: 18px; height: 18px; }

/* Customer badge */
.vel-chat-customer-badge {
    margin: 8px 12px 0;
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 12px;
    color: #166534;
    display: none;
    flex-shrink: 0;
}
.vel-chat-customer-badge.vel-show { display: block; }

/* Messages */
.vel-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
}

.vel-chat-msg {
    max-width: 84%;
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.55;
    word-wrap: break-word;
}
.vel-chat-msg--bot {
    align-self: flex-start;
    background: #f1f5f9;
    color: #1e293b;
    border-bottom-left-radius: 3px;
}
.vel-chat-msg--user {
    align-self: flex-end;
    background: var(--vc-accent);
    color: #fff;
    border-bottom-right-radius: 3px;
}
.vel-chat-msg--system {
    align-self: center;
    background: #fef9c3;
    color: #713f12;
    font-size: 11px;
    padding: 5px 12px;
    border-radius: 20px;
    max-width: 92%;
    text-align: center;
}

/* Typing indicator */
.vel-chat-typing {
    align-self: flex-start;
    background: #f1f5f9;
    border-radius: 12px;
    border-bottom-left-radius: 3px;
    padding: 10px 14px;
    display: flex;
    gap: 4px;
    align-items: center;
}
.vel-chat-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
    animation: velTyping 1.2s infinite;
    display: block;
}
.vel-chat-typing span:nth-child(2) { animation-delay: .2s; }
.vel-chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes velTyping { 0%,60%,100%{opacity:.3} 30%{opacity:1} }

/* Escalate button */
.vel-chat-escalate-btn {
    display: block;
    margin: 4px 12px 8px;
    padding: 10px 14px;
    background: #dc2626;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    flex-shrink: 0;
    transition: background .15s;
}
.vel-chat-escalate-btn:hover { background: #b91c1c; color: #fff; }

/* Input area */
.vel-chat-input-area {
    border-top: 1px solid #e5e7eb;
    padding: 10px 12px;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    align-items: flex-end;
}
.vel-chat-input-area textarea {
    flex: 1;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    resize: none;
    max-height: 80px;
    font-family: inherit;
    line-height: 1.4;
    background: #fff;
}
.vel-chat-input-area textarea:focus { outline: none; border-color: var(--vc-accent); }
.vel-chat-send-btn {
    background: var(--vc-accent);
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .15s;
}
.vel-chat-send-btn:hover  { background: #1a7fe8; }
.vel-chat-send-btn svg    { width: 17px; height: 17px; }

/* ── Agent Assistant (inside CRM portal) ───────────────────────────────────── */

.vel-ai-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
    align-items: start;
}

.vel-ai-lookup-panel {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 20px;
}

.vel-ai-chat-panel {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 540px;
}

.vel-ai-chat-header {
    background: var(--vc-primary);
    color: #fff;
    padding: 13px 18px;
    font-weight: 700;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.vel-ai-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 400px;
    max-height: 460px;
}

.vel-ai-msg {
    max-width: 86%;
    padding: 9px 13px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.55;
}
.vel-ai-msg--user {
    align-self: flex-end;
    background: var(--vc-primary);
    color: #fff;
    border-bottom-right-radius: 3px;
}
.vel-ai-msg--ai {
    align-self: flex-start;
    background: #f1f5f9;
    color: #1e293b;
    border-bottom-left-radius: 3px;
}
.vel-ai-msg--system {
    align-self: center;
    background: #fef9c3;
    color: #713f12;
    font-size: 11px;
    padding: 5px 12px;
    border-radius: 20px;
    max-width: 90%;
    text-align: center;
}

.vel-ai-input-row {
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    align-items: flex-end;
    flex-shrink: 0;
}
.vel-ai-input-row textarea {
    flex: 1;
    resize: none;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 9px 11px;
    font-size: 13px;
    font-family: inherit;
    line-height: 1.4;
    max-height: 100px;
}
.vel-ai-input-row textarea:focus { outline: none; border-color: var(--vc-accent); }

/* Responsive */
@media (max-width: 900px) {
    .vel-ai-layout { grid-template-columns: 1fr; }
    .vel-chat-panel { right: 8px; left: 8px; width: auto; bottom: 90px; height: min(520px, calc(100dvh - 96px)); }
    .vel-chat-bubble { right: 16px; bottom: 90px; width: 64px; height: 64px; }
    .vel-chat-bubble svg { width: 30px; height: 30px; }
    /* shift up further when PWA install banner is visible */
    body.vel-pwa-banner-visible .vel-chat-bubble { bottom: 180px; }
    body.vel-pwa-banner-visible .vel-chat-panel  { bottom: 180px; }
}

/* ── New / Existing choice buttons ──────────────────────────────────────────── */

.vel-chat-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0;
    align-self: flex-start;
    max-width: 96%;
}

.vel-chat-choice-btn {
    background: #fff;
    border: 1.5px solid var(--vc-accent);
    color: var(--vc-accent);
    border-radius: 20px;
    padding: 7px 15px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, color .15s;
    font-family: inherit;
}
.vel-chat-choice-btn:hover {
    background: var(--vc-accent);
    color: #fff;
}

/* ── Identity verification form ─────────────────────────────────────────────── */

.vel-chat-identity-form {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-self: stretch;
    max-width: 94%;
}

.vel-chat-identity-form input {
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    background: #fff;
    transition: border-color .15s;
}
.vel-chat-identity-form input:focus {
    border-color: var(--vc-accent);
}

.vel-chat-identity-form button {
    background: var(--vc-accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 9px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: opacity .15s;
}
.vel-chat-identity-form button:hover    { opacity: .88; }
.vel-chat-identity-form button:disabled { opacity: .55; cursor: not-allowed; }

.vel-id-error {
    color: #dc2626;
    font-size: 11px;
    margin: 0;
    min-height: 14px;
    line-height: 1.4;
}

/* ── Mic / voice button ─────────────────────────────────────────────────────── */

.vel-chat-mic-btn {
    background: none;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .15s, color .15s, border-color .15s;
    padding: 0;
}
.vel-chat-mic-btn:hover   { border-color: var(--vc-accent); color: var(--vc-accent); }
.vel-chat-mic-btn svg     { width: 16px; height: 16px; }

.vel-mic-active {
    background: #fef2f2;
    border-color: #ef4444;
    color: #ef4444;
    animation: velMicPulse 1.5s infinite;
}
@keyframes velMicPulse { 0%,100%{opacity:1} 50%{opacity:.55} }

/* ── Intent action elements ─────────────────────────────────────────────────── */

.vel-intent-action {
    padding: 4px 0;
    align-self: flex-start;
}

.vel-intent-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 16px;
    background: var(--vc-accent);
    color: #fff;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: opacity .15s;
}
.vel-intent-link-btn:hover { opacity: .88; color: #fff; }
.vel-intent-link-btn svg   { width: 14px; height: 14px; flex-shrink: 0; }

/* ── Collect info form ───────────────────────────────────────────────────────── */

.vel-chat-collect-form {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-self: stretch;
    max-width: 94%;
}

.vel-collect-label {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
}

.vel-collect-row {
    display: flex;
    gap: 8px;
}

.vel-collect-input {
    flex: 1;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    background: #fff;
    transition: border-color .15s;
}
.vel-collect-input:focus { border-color: var(--vc-accent); }

.vel-collect-submit {
    background: var(--vc-accent);
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity .15s;
}
.vel-collect-submit:hover { opacity: .88; }
.vel-collect-submit svg   { width: 15px; height: 15px; }

/* ── Teaser popup ──────────────────────────────────────────────────────────── */

.vel-chat-teaser {
    position: fixed;
    bottom: 92px;
    right: 24px;
    z-index: 99997;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px 36px 12px 14px;
    max-width: 220px;
    box-shadow: 0 4px 18px rgba(0,0,0,.18);
    opacity: 0;
    transform: translateY(8px) scale(.96);
    pointer-events: none;
    transition: opacity .22s ease, transform .22s ease;
}
.vel-chat-teaser::after {
    content: '';
    position: absolute;
    bottom: -7px;
    right: 22px;
    width: 12px;
    height: 12px;
    background: #fff;
    border-right: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
    transform: rotate(45deg);
}
.vel-chat-teaser--show {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
.vel-chat-teaser-text {
    margin: 0;
    font-size: 13px;
    line-height: 1.45;
    color: #1e293b;
    cursor: pointer;
}
.vel-chat-teaser-close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: none;
    border: none;
    font-size: 16px;
    line-height: 1;
    color: #94a3b8;
    cursor: pointer;
    padding: 2px 4px;
}
.vel-chat-teaser-close:hover { color: #475569; }
