#bcai-chatbot-root {
    position: fixed !important;
    bottom: 24px !important;
    right: 24px !important;
    z-index: 99999999 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
    -webkit-font-smoothing: antialiased;
}

/* Floating Launcher Button */
#bcai-launcher {
    width: 62px !important;
    height: 62px !important;
    min-width: 62px !important;
    min-height: 62px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #7c3aed 0%, #3b82f6 100%) !important;
    border: none !important;
    cursor: pointer !important;
    box-shadow: 0 10px 25px -3px rgba(124, 58, 237, 0.45), 0 4px 6px -4px rgba(59, 130, 246, 0.4) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1) !important;
    padding: 0 !important;
    position: relative !important;
    z-index: 99999999 !important;
}
#bcai-launcher:hover {
    transform: translateY(-3px) scale(1.08) !important;
    box-shadow: 0 16px 30px -4px rgba(124, 58, 237, 0.55) !important;
}
#bcai-launcher svg {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    fill: #ffffff !important;
}
#bcai-launcher.bcai-hidden { display: none !important; }

/* Custom Situation Action Button */
.bcai-custom-situation-btn {
    background-color: #242363 !important;
    color: #ffffff !important;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    letter-spacing: 1.8px !important;
    border-style: solid !important;
    border-width: 1px !important;
    border-color: #242363 !important;
    padding: 18px 24px !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 12px !important;
    text-transform: uppercase !important;
    box-shadow: 0 4px 14px rgba(36, 35, 99, 0.3) !important;
    transition: all 0.25s ease !important;
    text-decoration: none !important;
    line-height: 1.2 !important;
    width: auto !important;
    height: auto !important;
    box-sizing: border-box !important;
}
.bcai-custom-situation-btn:hover {
    background-color: #1a194a !important;
    border-color: #1a194a !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 18px rgba(36, 35, 99, 0.4) !important;
}
.bcai-custom-situation-btn svg.bcai-btn-icon {
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    max-width: 18px !important;
    min-height: 18px !important;
    max-height: 18px !important;
    fill: #ffffff !important;
    display: inline-block !important;
    margin-left: 8px !important;
    vertical-align: middle !important;
}

/* Main SaaS Chat Window */
#bcai-chat-window {
    display: none;
    width: var(--bcai-width, 410px);
    height: var(--bcai-height, 630px);
    max-height: calc(100vh - 40px);
    background: #ffffff;
    border-radius: var(--bcai-radius, 20px);
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    animation: bcai-slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    z-index: 99999999 !important;
}
#bcai-chat-window.bcai-active { display: flex !important; }

@keyframes bcai-slideUp {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* 1. Splash Screen View */
#bcai-splash-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    background: linear-gradient(180deg, #0284c7 0%, #0369a1 100%);
    color: #ffffff;
    padding: 36px 28px;
    text-align: center;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}
.bcai-splash-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255,255,255,0.15);
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.bcai-splash-close:hover { background: rgba(255,255,255,0.3); }

.bcai-splash-logo-container {
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 140px;
}
.bcai-splash-custom-logo {
    max-width: 220px;
    max-height: 120px;
    object-fit: contain;
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.2));
}
.bcai-splash-avatar-svg {
    width: 140px;
    height: 140px;
    animation: bcai-float 3s ease-in-out infinite;
}
@keyframes bcai-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}
.bcai-splash-title {
    font-size: 30px;
    font-weight: 800;
    margin: 16px 0 8px;
    letter-spacing: -0.5px;
    color: #ffffff;
}
.bcai-splash-desc {
    font-size: 13px;
    color: rgba(255,255,255,0.88);
    line-height: 1.5;
    margin: 0 0 24px;
}
.bcai-splash-btn {
    background: #0f172a;
    color: #ffffff;
    border: none;
    border-radius: 28px;
    padding: 14px 32px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.3);
    transition: transform 0.2s, background 0.2s;
}
.bcai-splash-btn:hover {
    background: #1e293b;
    transform: translateY(-2px);
}

/* 2. Chat Header */
.bcai-header {
    background: #0f172a;
    color: #ffffff;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.bcai-header-left { display: flex; align-items: center; gap: 12px; }
.bcai-avatar-badge {
    position: relative;
    width: 38px;
    height: 38px;
    background: rgba(255,255,255,0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    overflow: hidden;
}
.bcai-avatar-badge img { width: 100%; height: 100%; object-fit: cover; }
.bcai-status-beacon {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid #0f172a;
}
.bcai-title { font-weight: 700; font-size: 15px; margin: 0; color: #ffffff !important; line-height: 1.2; }
.bcai-subtitle { font-size: 12px; color: #94a3b8; margin: 2px 0 0; }
.bcai-close-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.bcai-close-btn:hover { background: rgba(255,255,255,0.3); transform: scale(1.05); }

.bcai-progress-track { height: 3px; background: rgba(15, 23, 42, 0.08); width: 100%; }
.bcai-progress-fill { height: 100%; background: var(--bcai-accent, #2563eb); width: 0%; transition: width 0.4s ease; }

.bcai-progress-pill-wrap { text-align: center; padding: 8px 0 4px; background: #fff; }
.bcai-progress-pill {
    background: #f1f5f9;
    color: #475569;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 12px;
    display: inline-block;
}

/* Chat Message Stream */
.bcai-messages-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    list-style: none;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}
.bcai-msg {
    max-width: 84%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.45;
    word-break: break-word;
}
.bcai-msg-bot {
    background: var(--bcai-bot-bubble, #f8fafc);
    color: var(--bcai-bot-text, #0f172a);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.bcai-msg-user {
    background: var(--bcai-user-bubble, #2563eb);
    color: var(--bcai-user-text, #ffffff);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* Quick Response Option Buttons */
.bcai-quick-options {
    padding: 8px 16px 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background: #ffffff;
    min-height: 40px;
}
.bcai-quick-btn {
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    color: #0f172a;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    transition: all 0.2s ease;
}
.bcai-quick-btn:hover {
    background: var(--bcai-primary, #7c3aed);
    color: #ffffff;
    border-color: var(--bcai-primary, #7c3aed);
    transform: translateY(-1px);
}

/* Lead Capture Form */
.bcai-lead-form {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #ffffff;
    border-top: 1px solid #f1f5f9;
}
.bcai-form-input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
}
.bcai-form-input:focus { border-color: var(--bcai-accent, #2563eb); }
.bcai-btn-submit {
    background: #0f172a;
    color: #ffffff;
    border: none;
    padding: 13px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: opacity 0.2s;
}
.bcai-btn-submit:hover { opacity: 0.92; }

/* Chat Input Bar */
.bcai-input-area {
    display: flex;
    padding: 12px 16px;
    border-top: 1px solid #e2e8f0;
    background: #ffffff;
    gap: 10px;
    align-items: center;
}
.bcai-chat-input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid #cbd5e1;
    border-radius: 24px;
    font-size: 13px;
    outline: none;
}
.bcai-chat-input:focus { border-color: var(--bcai-accent, #2563eb); }
.bcai-send-btn {
    background: #0f172a;
    color: #ffffff;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 8px rgba(15, 23, 42, 0.2);
    transition: transform 0.2s;
    padding: 0;
}
.bcai-send-btn:hover { transform: scale(1.08); }
.bcai-send-btn svg { width: 16px; height: 16px; fill: #ffffff; }

/* Urgent Distress Emergency Card */
.bcai-urgent-card {
    background: #fff5f5;
    border: 1px solid #fecaca;
    border-radius: 12px;
    padding: 16px;
    margin: 8px 0;
    animation: bcai-slideUp 0.3s ease;
}
.bcai-urgent-card h5 { margin: 0 0 6px; color: #b91c1c; font-size: 14px; font-weight: 800; }
.bcai-urgent-card p { margin: 0 0 12px; font-size: 12px; color: #475569; line-height: 1.4; }
.bcai-urgent-buttons { display: flex; gap: 8px; flex-direction: column; }
.bcai-urgent-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none !important;
    text-align: center;
}
.bcai-btn-call { background: #dc2626; color: #ffffff !important; }
.bcai-btn-email { background: #0f172a; color: #ffffff !important; }

/* Desktop / tablet: never wider or taller than the screen */
#bcai-chat-window {
    max-width: calc(100vw - 32px);
    box-sizing: border-box;
}
#bcai-conversation-view { min-height: 0; }
.bcai-messages-list { min-height: 0; -webkit-overflow-scrolling: touch; }

/* ===== Mobile: full-screen chat ===== */
@media (max-width: 600px) {
    #bcai-chatbot-root {
        bottom: 16px !important;
        right: 16px !important;
    }
    #bcai-launcher {
        width: 56px !important;
        height: 56px !important;
        min-width: 56px !important;
        min-height: 56px !important;
    }

    /* When chat is open, the root covers the whole screen */
    #bcai-chatbot-root.bcai-open {
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        margin: 0 !important;
        transform: none !important;
    }
    #bcai-chatbot-root.bcai-open #bcai-chat-window {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        border: none !important;
        margin: 0 !important;
        box-shadow: none !important;
        animation: none !important;
    }

    /* Splash screen */
    #bcai-splash-view {
        padding: calc(24px + env(safe-area-inset-top, 0px)) 20px calc(20px + env(safe-area-inset-bottom, 0px)) !important;
        justify-content: space-evenly !important;
    }
    .bcai-splash-close { top: calc(12px + env(safe-area-inset-top, 0px)) !important; right: 12px !important; }
    .bcai-splash-logo-container { min-height: 90px !important; margin-top: 20px !important; }
    .bcai-splash-custom-logo { max-width: 70vw !important; max-height: 100px !important; }
    .bcai-splash-avatar-svg { width: 110px !important; height: 110px !important; }
    .bcai-splash-title { font-size: 24px !important; line-height: 1.2 !important; margin: 12px 0 8px !important; }
    .bcai-splash-desc { font-size: 14px !important; margin-bottom: 16px !important; }
    .bcai-splash-btn { box-sizing: border-box !important; }

    /* Conversation */
    .bcai-header { padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 12px !important; }
    .bcai-title { font-size: 14px !important; }
    .bcai-messages-list { padding: 12px !important; }
    .bcai-msg { max-width: 88% !important; }
    .bcai-quick-options { padding: 6px 12px 10px !important; }
    .bcai-lead-form { padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px)) !important; }
    .bcai-input-area { padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)) !important; }

    /* 16px stops iPhone from zooming in when typing */
    .bcai-form-input,
    .bcai-chat-input { font-size: 16px !important; }

    .bcai-urgent-card { padding: 14px !important; }
    .bcai-urgent-btn { font-size: 13px !important; padding: 12px 10px !important; }
}

/* Stop the page behind from scrolling while chat is open on mobile */
@media (max-width: 600px) {
    html.bcai-chat-open,
    html.bcai-chat-open body {
        overflow: hidden !important;
        overscroll-behavior: none;
    }
}

/* Urgent card: keep long emails / labels inside the button */
.bcai-urgent-btn span { word-break: break-word; overflow-wrap: anywhere; }
.bcai-urgent-btn svg { flex-shrink: 0; }
