/* ═══════════════════════════════════════════
   Versich AI Chatbot Widget
   ═══════════════════════════════════════════ */

/* ── Variables ──────────────────────────── */
:root {
    --cb-primary: #226FC9;
    --cb-primary-dark: #1a5aa3;
    --cb-primary-light: #3d8ae6;
    --cb-gradient: linear-gradient(135deg, #226FC9 0%, #1a5aa3 100%);
    --cb-bg: #ffffff;
    --cb-surface: #f4f6f8;
    --cb-text: #1a1a2e;
    --cb-text-light: #6b7280;
    --cb-border: #e5e7eb;
    --cb-user-bubble: #226FC9;
    --cb-bot-bubble: #f0f2f5;
    --cb-radius: 16px;
    --cb-shadow: 0 8px 32px rgba(34, 111, 201, 0.18);
    --cb-shadow-btn: 0 4px 20px rgba(34, 111, 201, 0.35);
    --cb-z: 9999;
    --cb-font: "Public Sans", system-ui, -apple-system, sans-serif;
    --cb-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── FAB (Floating Action Button) ──────── */
#versich-chatbot-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--cb-gradient);
    border: none;
    cursor: pointer;
    z-index: var(--cb-z);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--cb-shadow-btn);
    transition: transform var(--cb-transition), box-shadow var(--cb-transition);
    animation: cb-pulse 2.5s infinite;
}

#versich-chatbot-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(34, 111, 201, 0.5);
    animation: none;
}

#versich-chatbot-fab svg {
    width: 26px;
    height: 26px;
    fill: #fff;
    transition: transform var(--cb-transition);
}

#versich-chatbot-fab.open svg.cb-icon-chat {
    display: none;
}
#versich-chatbot-fab.open svg.cb-icon-close {
    display: block;
}
#versich-chatbot-fab:not(.open) svg.cb-icon-close {
    display: none;
}

@keyframes cb-pulse {
    0%, 100% { box-shadow: var(--cb-shadow-btn); }
    50% { box-shadow: 0 4px 24px rgba(34, 111, 201, 0.55), 0 0 0 8px rgba(34, 111, 201, 0.1); }
}

/* ── Chat Window ───────────────────────── */
#versich-chatbot-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 380px;
    height: 520px;
    max-height: calc(100vh - 120px);
    background: var(--cb-bg);
    border-radius: var(--cb-radius);
    box-shadow: var(--cb-shadow);
    z-index: var(--cb-z);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.85) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: transform var(--cb-transition), opacity var(--cb-transition);
    font-family: var(--cb-font);
    border: 1px solid var(--cb-border);
}

#versich-chatbot-window.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* ── Header ────────────────────────────── */
.cb-header {
    background: var(--cb-gradient);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.cb-header-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.cb-header-avatar svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

.cb-header-avatar .cb-bot-logo {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.cb-header-info {
    flex: 1;
    min-width: 0;
}

.cb-header-title {
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.cb-header-subtitle {
    color: rgba(255, 255, 255, 0.8);
    font-size: 11.5px;
    font-weight: 400;
    margin-top: 1px;
}

.cb-header-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--cb-transition);
    flex-shrink: 0;
}

.cb-header-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.cb-header-close svg {
    width: 16px;
    height: 16px;
    fill: #fff;
}

/* ── Messages Area ─────────────────────── */
.cb-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--cb-surface);
    scroll-behavior: smooth;
}

.cb-messages::-webkit-scrollbar {
    width: 5px;
}
.cb-messages::-webkit-scrollbar-thumb {
    background: #c4c8cc;
    border-radius: 4px;
}

/* ── Message Bubbles ───────────────────── */
.cb-message {
    display: flex;
    gap: 8px;
    max-width: 88%;
    animation: cb-fadeIn 0.3s ease;
}

.cb-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.cb-message.assistant {
    align-self: flex-start;
}

.cb-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
}

.cb-message.user .cb-bubble {
    background: var(--cb-user-bubble);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.cb-message.assistant .cb-bubble {
    background: var(--cb-bg);
    color: var(--cb-text);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--cb-border);
}

.cb-bubble a {
    color: var(--cb-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.cb-bubble a:hover {
    color: var(--cb-primary-dark);
}

.cb-message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    margin-top: 2px;
}

.cb-message.assistant .cb-message-avatar {
    background: #fff;
    color: #fff;
    overflow: hidden;
    border: 1px solid var(--cb-border);
}

.cb-message.assistant .cb-message-avatar .cb-bot-logo {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.cb-message.user .cb-message-avatar {
    background: #e0e7ef;
    color: var(--cb-text);
}

/* ── Source Chips ───────────────────────── */
.cb-sources {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.cb-source-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #eef3fb;
    color: var(--cb-primary);
    font-size: 11.5px;
    font-weight: 500;
    border-radius: 20px;
    text-decoration: none;
    transition: background var(--cb-transition);
    border: 1px solid rgba(34, 111, 201, 0.15);
}

.cb-source-chip:hover {
    background: #dce6f7;
}

.cb-source-chip svg {
    width: 11px;
    height: 11px;
    fill: var(--cb-primary);
    flex-shrink: 0;
}

/* ── Typing Indicator ──────────────────── */
.cb-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}

.cb-typing-dots {
    display: flex;
    gap: 4px;
    padding: 10px 16px;
    background: var(--cb-bg);
    border-radius: 14px;
    border: 1px solid var(--cb-border);
}

.cb-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #b0b8c4;
    animation: cb-bounce 1.4s ease-in-out infinite;
}

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

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

/* ── Welcome Message ───────────────────── */
.cb-welcome {
    text-align: center;
    padding: 20px 10px 10px;
    color: var(--cb-text-light);
    font-size: 13px;
    line-height: 1.5;
}

.cb-welcome strong {
    color: var(--cb-text);
    display: block;
    font-size: 15px;
    margin-bottom: 4px;
}

/* ── Input Area ────────────────────────── */
.cb-input-area {
    padding: 12px 14px;
    border-top: 1px solid var(--cb-border);
    display: flex;
    gap: 8px;
    align-items: center;
    background: var(--cb-bg);
    flex-shrink: 0;
}

.cb-input {
    flex: 1;
    border: 1px solid var(--cb-border);
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 13.5px;
    font-family: var(--cb-font);
    outline: none;
    transition: border-color var(--cb-transition);
    background: var(--cb-surface);
    color: var(--cb-text);
}

.cb-input::placeholder {
    color: #9ca3af;
}

.cb-input:focus {
    border-color: var(--cb-primary-light);
    background: #fff;
}

.cb-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--cb-gradient);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--cb-transition), opacity var(--cb-transition);
    flex-shrink: 0;
}

.cb-send-btn:hover {
    transform: scale(1.08);
}

.cb-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.cb-send-btn svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

/* ── Footer ────────────────────────────── */
.cb-footer {
    padding: 6px 14px 8px;
    text-align: center;
    font-size: 10.5px;
    color: var(--cb-text-light);
    background: var(--cb-bg);
    flex-shrink: 0;
    border-top: 1px solid var(--cb-border);
}

/* ── Animations ────────────────────────── */
@keyframes cb-fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Lead Capture Form ─────────────────── */
.cb-lead-form {
    background: var(--cb-bg);
    border: 1px solid var(--cb-border);
    border-radius: 12px;
    padding: 16px;
    animation: cb-fadeIn 0.3s ease;
    margin-top: 4px;
}

.cb-lead-form-title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--cb-text);
    margin-bottom: 12px;
}

.cb-lead-field {
    margin-bottom: 8px;
}

.cb-lead-input {
    width: 100%;
    border: 1px solid var(--cb-border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    font-family: var(--cb-font);
    outline: none;
    transition: border-color var(--cb-transition);
    background: var(--cb-surface);
    color: var(--cb-text);
    box-sizing: border-box;
}

.cb-lead-input::placeholder {
    color: #9ca3af;
}

.cb-lead-input:focus {
    border-color: var(--cb-primary-light);
    background: #fff;
}

.cb-lead-input.cb-lead-required::placeholder {
    /* Subtle emphasis for required field */
}

.cb-lead-textarea {
    resize: vertical;
    min-height: 44px;
    max-height: 100px;
    line-height: 1.4;
}

.cb-lead-error {
    display: none;
    color: #dc2626;
    font-size: 11.5px;
    margin-top: 4px;
    padding-left: 4px;
}

.cb-lead-submit {
    width: 100%;
    padding: 9px 16px;
    border: none;
    border-radius: 8px;
    background: var(--cb-gradient);
    color: #fff;
    font-size: 13.5px;
    font-weight: 600;
    font-family: var(--cb-font);
    cursor: pointer;
    transition: transform var(--cb-transition), opacity var(--cb-transition);
    margin-top: 4px;
}

.cb-lead-submit:hover {
    transform: scale(1.02);
}

.cb-lead-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ── Contact CTA Buttons ───────────────── */
.cb-contact-cta {
    background: var(--cb-bg);
    border: 1px solid var(--cb-border);
    border-radius: 12px;
    padding: 12px 14px;
    animation: cb-fadeIn 0.35s ease;
    margin-top: 4px;
}

.cb-cta-label {
    font-size: 13px;
    color: var(--cb-text);
    margin-bottom: 10px;
    line-height: 1.45;
    font-weight: 500;
}

.cb-cta-row {
    display: flex;
    gap: 8px;
}

.cb-cta-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--cb-font);
    cursor: pointer;
    transition: all var(--cb-transition);
    justify-content: center;
    line-height: 1;
}

.cb-cta-btn.cb-cta-yes {
    flex: 1;
    border: none;
    background: var(--cb-gradient);
    color: #fff;
}

.cb-cta-btn.cb-cta-yes:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(34, 111, 201, 0.35);
}

.cb-cta-btn.cb-cta-no {
    flex: 0 0 auto;
    border: 1px solid var(--cb-border);
    background: transparent;
    color: var(--cb-text-light);
    font-weight: 500;
}

.cb-cta-btn.cb-cta-no:hover {
    background: var(--cb-surface);
    color: var(--cb-text);
    border-color: #d1d5db;
}

.cb-cta-icon {
    width: 14px;
    height: 14px;
    fill: currentColor;
    flex-shrink: 0;
}

/* ── Inline Email Capture ──────────────── */
.cb-inline-email {
    background: var(--cb-bg);
    border: 1px solid var(--cb-border);
    border-radius: 12px;
    padding: 14px 16px;
    animation: cb-fadeIn 0.35s ease;
    margin-top: 4px;
}

.cb-inline-email-label {
    font-size: 13px;
    color: var(--cb-text);
    margin-bottom: 10px;
    line-height: 1.45;
    font-weight: 500;
}

.cb-inline-email-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.cb-inline-email-input {
    flex: 1;
    border: 1px solid var(--cb-border);
    border-radius: 24px;
    padding: 9px 16px;
    font-size: 13px;
    font-family: var(--cb-font);
    outline: none;
    transition: border-color var(--cb-transition), background var(--cb-transition);
    background: var(--cb-surface);
    color: var(--cb-text);
}

.cb-inline-email-input::placeholder {
    color: #9ca3af;
}

.cb-inline-email-input:focus {
    border-color: var(--cb-primary-light);
    background: #fff;
}

.cb-inline-email-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.cb-inline-email-submit {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--cb-gradient);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--cb-transition), opacity var(--cb-transition);
    flex-shrink: 0;
}

.cb-inline-email-submit:hover {
    transform: scale(1.08);
}

.cb-inline-email-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.cb-inline-email-submit svg {
    width: 16px;
    height: 16px;
    fill: #fff;
}

.cb-inline-email-error {
    display: none;
    color: #dc2626;
    font-size: 11.5px;
    margin-top: 6px;
    padding-left: 4px;
}

/* ── Mobile (full-screen) ──────────────── */
@media (max-width: 480px) {
    #versich-chatbot-window {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    #versich-chatbot-fab {
        bottom: 16px;
        right: 16px;
    }
}
