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

/* ── Variables ──────────────────────────── */
:root {
    /* Brand palette (from the approved Versich color spec) */
    --cb-navy: #00204A;
    /* Header Color */
    --cb-primary: #1F79D8;
    --cb-primary-dark: #114B8A;
    --cb-primary-light: #1D88ED;
    --cb-primary-pale: #D3E8FF;
    --cb-gradient: linear-gradient(135deg, #1F79D8 0%, #114B8A 100%);
    --cb-error: #D82727;
    --cb-bg: #ffffff;
    --cb-surface: #F3F5FB;
    --cb-text: #1a1a2e;
    --cb-text-light: #6b7280;
    --cb-border: #e5e7eb;
    --cb-user-bubble: #1F79D8;
    --cb-radius: 16px;
    --cb-shadow: 0 8px 32px rgba(31, 121, 216, 0.18);
    --cb-shadow-btn: 0 4px 20px rgba(31, 121, 216, 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);
    --cb-width: 420px;
    --cb-width-expanded: 560px;
    --cb-height: 520px;
    --cb-height-expanded: 600px;
}

/* ── FAB (Floating Action Button) ──────── */
#versich-chatbot-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: transparent;
    border: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    outline: 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), opacity var(--cb-transition);
}

/* Shared pulse — one declaration, both floating states use it, instead
   of repeating the animation per-selector. */
#versich-chatbot-fab,
#versich-chatbot-minimized.visible {
    animation: cb-pulse 2.5s infinite;
}

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

#versich-chatbot-fab.open {
    animation: none;
    box-shadow: none;
}

#versich-chatbot-fab img.cb-icon-chat {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 50%;
    transition: transform var(--cb-transition);
}

#versich-chatbot-fab.open img.cb-icon-chat {
    display: none;
}

#versich-chatbot-fab.open .cb-minimize-icon {
    display: block;
}

#versich-chatbot-fab:not(.open) .cb-minimize-icon {
    display: none;
}

#versich-chatbot-fab .cb-minimize-icon {
    width: 56px;
    height: 56px;
}

@keyframes cb-pulse {

    0%,
    100% {
        box-shadow: var(--cb-shadow-btn);
    }

    50% {
        box-shadow: 0 4px 24px rgba(31, 121, 216, 0.55), 0 0 0 8px rgba(31, 121, 216, 0.1);
    }
}

#versich-chatbot-minimized {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: var(--cb-z);
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: var(--cb-shadow-btn);
    transition: transform var(--cb-transition);
}

#versich-chatbot-minimized.visible {
    display: flex;
}

#versich-chatbot-minimized:hover {
    transform: scale(1.08);
    animation: none;
}

#versich-chatbot-minimized img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 50%;
}

/* ── Chat Window ───────────────────────── */
#versich-chatbot-window {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: var(--cb-width);
    height: var(--cb-height);
    max-height: calc(100vh - 160px);
    max-width:calc(100vw - 48px);
    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), width var(--cb-transition), height 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;
}

#versich-chatbot-window.cb-expanded {
    width: var(--cb-width-expanded);
    /* max-height: calc(100vh - 160px), set on the base rule above, still
       applies here since we don't override it — so on a short viewport the
       browser caps this automatically and the window never grows past
       what actually fits, no manual screen-size check needed. */
    height: var(--cb-height-expanded);
}

/* ── CTA-centered mode ─────────────────────
   Opened via a page's own CTA (see ChatWidget.openFromCTA) instead of the FAB.
   `fixed` + `inset:0` + `margin:auto` centers it regardless of scroll; index.css re-declares this after us to win the ancestor-transform edge case via load order, so no `!important` here. */
#versich-chatbot-window.cb-docked {
    inset: 0;
    margin: auto;
    /* Frame/border styling for the docked window lives in index.css only (loads after this file) — don't redeclare box-shadow here, it would silently override or fight with that one. */
}

/* CTA entrance: rises from where the static preview card sat and settles with a slight overshoot; the 0.3s delay lets the hero's text-wipe (index.css) finish first. Class auto-removed on animationend (index.js). */
@keyframes cb-cta-pop {
    0% {
        transform: scale(0.9) translateY(64px);
        opacity: 0;
    }

    55% {
        transform: scale(1.015) translateY(-4px);
        opacity: 1;
    }

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

.cb-cta-pop {
    animation: cb-cta-pop 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.3s both;
}

#versich-chatbot-window button:hover {
    background-color: initial;
}

/* ── Header ────────────────────────────── */
.cb-header {
    background: var(--cb-bg);
    border-bottom: 1px solid var(--cb-border);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    position: relative;
}

.cb-header-avatar-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    border-radius: 50%;
}

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

#versich-chatbot-window .cb-header-avatar-btn:hover .cb-header-avatar {
    opacity: 0.85;
}

.cb-header-logo-img {
    width: 34px;
    height: 34px;
    object-fit: contain;
    display: block;
}

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

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

.cb-header-subtitle {
    color: var(--cb-text-light);
    font-size: 11.5px;
    font-weight: 400;
    margin-top: 1px;
}


.cb-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    position: relative;
}

.cb-header-icon-btn {
    background: none;
    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;
}

#versich-chatbot-window .cb-header-icon-btn:hover {
    background: var(--cb-surface);
}

/* Expand — your real expand.svg file, kept at its native brand color. */
.cb-header-icon-btn img.cb-expand-icon {
    width: 17px;
    height: 17px;
    object-fit: contain;
}

#cb-close-btn {
    padding: 0;
}

#cb-close-btn:hover {
    background: none;
    opacity: 0.85;
}

.cb-icon-close {
    width: 36px;
    height: 36px;
    object-fit: contain;
}

/* Expand button reflects state: pale-blue highlight once the window is expanded
   (there's no separate collapse asset, so the icon itself doesn't change) */
#cb-expand-toggle-btn.cb-active {
    background: var(--cb-primary-pale);
}

/* Custom tooltip (replaces the native title="" tooltip, which rendered as
   a clipped OS-default box). Positioned below the icon — the window's
   overflow: hidden would clip anything placed above the header. */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--cb-navy);
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    font-family: var(--cb-font);
    white-space: nowrap;
    padding: 5px 9px;
    border-radius: 6px;
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity var(--cb-transition), transform var(--cb-transition);
    z-index: 1;
}

[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateY(0);
}

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

.cb-messages::-webkit-scrollbar {
    width: 5px;
}

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

/* ── Greeting + Suggestions (empty state) ── */
.cb-greeting {
    padding: 20px 6px 10px;
    animation: cb-fadeIn 0.3s ease;
}

.cb-greeting-line1 {
    font-size: 22px;
    font-weight: 500;
    color: var(--cb-text-light);
    line-height: 1.3;
}

.cb-greeting-line2 {
    font-size: 22px;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 18px;
    background: linear-gradient(90deg, #01204A 0%, #1F79D8 25%, #1F79D8 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--cb-primary);
    /* fallback if background-clip: text isn't supported */
}

.cb-suggestions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cb-suggestion-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    background: #F5FAFF;
    border: 1px solid var(--cb-primary-pale);
    border-radius: 12px;
    padding: 12px 14px;
    font-family: var(--cb-font);
    font-size: 13px;
    font-weight: 500;
    color: var(--cb-text);
    cursor: pointer;
    transition: background var(--cb-transition), border-color var(--cb-transition), box-shadow var(--cb-transition), transform var(--cb-transition);
}

#versich-chatbot-window .cb-suggestion-btn:hover {
    background: var(--cb-primary-pale);
    border-color: var(--cb-primary-light);
    box-shadow: 0 4px 14px rgba(31, 121, 216, 0.12);
    transform: translateY(-1px);
}

.cb-suggestion-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cb-suggestion-icon-img {
    width: 16px;
    height: 16px;
    object-fit: contain;
}

.cb-suggestion-text {
    flex: 1;
    min-width: 0;
}

.cb-suggestion-chevron {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.cb-suggestion-arrow-img {
    width: 14px;
    height: 14px;
    object-fit: contain;
}

/* ── Date Divider ───────────────────────── */
.cb-date-divider {
    text-align: center;
    font-size: 11px;
    color: var(--cb-text-light);
    margin: 4px 0 2px;
}

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

.cb-message.user {
    align-self: flex-end;
    align-items: flex-end;
}

.cb-message.assistant {
    align-self: flex-start;
    align-items: 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;
}

.cb-message.assistant .cb-bubble {
    background: #F5FAFF;
    color: var(--cb-navy);
    border-radius: 18px;
    border: 1px solid var(--cb-primary-pale);
    box-shadow: none;
}

.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-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 10.5px;
    color: var(--cb-text-light);
    margin-top: 4px;
    padding-left: 2px;
}

.cb-meta-sparkle {
    width: 11px;
    height: 11px;
    object-fit: contain;
    flex-shrink: 0;
}

/* ── 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(31, 121, 216, 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-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 60px;
    height: 48px;
    background: #F5FAFF;
    border: 1px solid var(--cb-primary-pale);
    border-radius: 16px;
    box-shadow: var(--cb-shadow);
    box-sizing: border-box;
}

.cb-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--cb-primary-dark);
    animation: cb-bounce 1.4s ease-in-out infinite;
    flex-shrink: 0;
}

.cb-typing-dot:nth-child(2) {
    background: var(--cb-primary);
    animation-delay: 0.15s;
}

.cb-typing-dot:nth-child(3) {
    background: var(--cb-primary-light);
    opacity: 0.6;
    animation-delay: 0.3s;
}

@keyframes cb-bounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-5px);
    }
}

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

.cb-input-box {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1.5px solid var(--cb-primary-light);
    border-radius: 14px;
    padding: 5px 5px 5px 16px;
    background: var(--cb-bg);
    transition: border-color var(--cb-transition);
}

.cb-input-box:focus-within {
    border-color: var(--cb-primary);
}

.cb-input {
    flex: 1;
    min-width: 0;
    border: none;
    padding: 8px 0;
    font-size: 13.5px;
    font-family: var(--cb-font);
    outline: none;
    background: transparent;
    color: var(--cb-text);
}

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

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

#versich-chatbot-window .cb-send-btn:hover {
    transform: scale(1.08);
}

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

.cb-send-btn img.cb-send-icon {
    width: 37px;
    height: 37px;
    object-fit: contain;
}

/* ── Footer ────────────────────────────── */
.cb-footer {
    padding: 8px 14px 10px;
    text-align: center;
    font-size: 10.5px;
    color: var(--cb-text-light);
    background: var(--cb-bg);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.cb-footer-logo {
    height: 16px;
    width: auto;
    object-fit: contain;
    vertical-align: middle;
}

/* ── 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-textarea {
    resize: vertical;
    min-height: 44px;
    max-height: 100px;
    line-height: 1.4;
}

.cb-lead-error {
    display: none;
    color: var(--cb-error);
    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;
}

#versich-chatbot-window .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;
}

#versich-chatbot-window .cb-cta-btn.cb-cta-yes:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(31, 121, 216, 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;
}

#versich-chatbot-window .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;
}

#versich-chatbot-window .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: var(--cb-error);
    font-size: 11.5px;
    margin-top: 6px;
    padding-left: 4px;
}

/* ── Mobile (full-screen) ──────────────── */
@media (max-width: 480px) {
    #versich-chatbot-window {
        top: 0;
        left: 0;
        right: 0;
        bottom: auto;
        width: 100%;
        height: 100dvh;
        max-height: none;
        max-width: none;
        border-radius: 0;
    }

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

    #versich-chatbot-window .cb-header {
        position: sticky;
        top: 0;
        z-index: 2;
        flex-shrink: 0;
    }

    #versich-chatbot-window .cb-header-icon-btn#cb-expand-toggle-btn {
        display: none;
    }

    #versich-chatbot-window .cb-suggestion-chevron {
        display: none;
    }

    #versich-chatbot-window .cb-suggestion-text {
        white-space: normal;
        word-break: break-word;
    }
}