/* ==========================================================================
   AI CHATBOT WIDGET STYLES (ChatBot.com Inspired Modern Neo-Design)
   ========================================================================== */

:root {
    --cb-primary: #4f46e5;
    --cb-primary-hover: #4338ca;
    --cb-primary-glow: rgba(79, 70, 229, 0.35);
    --cb-bg: #ffffff;
    --cb-surface: #f8fafc;
    --cb-surface-border: #e2e8f0;
    --cb-text-main: #0f172a;
    --cb-text-muted: #64748b;
    --cb-bot-bubble: #f1f5f9;
    --cb-bot-text: #1e293b;
    --cb-user-bubble: #4f46e5;
    --cb-user-text: #ffffff;
    --cb-radius: 18px;
    --cb-shadow: 0 20px 45px -10px rgba(15, 23, 42, 0.22), 0 8px 16px -4px rgba(15, 23, 42, 0.08);
}

/* Launcher Floating Button */
#ai-chatbot-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: var(--cb-primary);
    box-shadow: 0 10px 25px var(--cb-primary-glow), 0 4px 10px rgba(0, 0, 0, 0.1);
    border: 3px solid rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 999990;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    user-select: none;
}

#ai-chatbot-launcher:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 14px 32px var(--cb-primary-glow), 0 6px 14px rgba(0, 0, 0, 0.15);
}

#ai-chatbot-launcher svg {
    width: 30px;
    height: 30px;
    fill: #ffffff;
    transition: transform 0.3s ease;
}

#ai-chatbot-launcher .cb-launcher-close {
    display: none;
}

#ai-chatbot-launcher.active .cb-launcher-chat {
    display: none;
}

#ai-chatbot-launcher.active .cb-launcher-close {
    display: block;
}

/* Proactive Teaser Speech Bubble */
#ai-chatbot-teaser {
    position: fixed;
    bottom: 96px;
    right: 24px;
    max-width: 290px;
    background: #ffffff;
    border: 1px solid var(--cb-surface-border);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
    padding: 12px 14px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    z-index: 999989;
    cursor: pointer;
    font-family: inherit;
    animation: cb-teaser-pop 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    transition: transform 0.2s, box-shadow 0.2s;
}

#ai-chatbot-teaser:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.16);
}

@keyframes cb-teaser-pop {
    from { opacity: 0; transform: translateY(12px) scale(0.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.cb-teaser-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--cb-primary);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.cb-teaser-body {
    flex: 1;
}

.cb-teaser-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--cb-text-main);
    margin-bottom: 2px;
}

.cb-teaser-text {
    font-size: 12px;
    color: var(--cb-text-muted);
    line-height: 1.35;
}

.cb-teaser-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 16px;
    line-height: 1;
    padding: 0 2px;
    cursor: pointer;
}

.cb-teaser-close:hover {
    color: #ef4444;
}

/* Main Chat Container */
#ai-chatbot-container {
    position: fixed;
    bottom: 98px;
    right: 24px;
    width: 400px;
    max-width: calc(100vw - 32px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--cb-bg);
    border: 1px solid var(--cb-surface-border);
    border-radius: var(--cb-radius);
    box-shadow: var(--cb-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999991;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.96);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

#ai-chatbot-container.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

/* Header */
.cb-header {
    background: linear-gradient(135deg, var(--cb-primary) 0%, var(--cb-primary-hover) 100%);
    color: #ffffff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.cb-header-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cb-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    color: #ffffff;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.4);
}

.cb-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cb-header-info h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.2px;
    line-height: 1.2;
     color: #ffffff !important; 
}

.cb-header-info p {
    margin: 2px 0 0 0;
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 5px;
    color: #ffffff !important;
}

.cb-status-dot {
    width: 8px;
    height: 8px;
    background: #34d399;
    border-radius: 50%;
    display: inline-block;
}

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

.cb-header-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

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

/* Header Dropdown Menu */
.cb-dropdown-menu {
    display: none;
    position: absolute;
    top: 40px;
    right: 0;
    background: #ffffff;
    border: 1px solid var(--cb-surface-border);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    min-width: 190px;
    padding: 6px 0;
    z-index: 1000;
}

.cb-dropdown-menu.show {
    display: block;
    animation: cb-fade-in 0.2s ease;
}

.cb-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 13px;
    color: var(--cb-text-main);
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}

.cb-dropdown-item:hover {
    background: #f1f5f9;
    color: var(--cb-primary);
}

.cb-dropdown-divider {
    height: 1px;
    background: var(--cb-surface-border);
    margin: 4px 0;
}

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

.cb-message {
    display: flex;
    flex-direction: column;
    max-width: 84%;
    animation: cb-fade-in 0.25s ease forwards;
    position: relative;
}

@keyframes cb-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.cb-message.bot, .cb-message.agent, .cb-message.system {
    align-self: flex-start;
}

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

.cb-bubble {
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.5;
    border-radius: 16px;
    word-break: break-word;
}

.cb-bubble code {
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 5px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12.5px;
}

.cb-bubble pre {
    background: #1e293b;
    color: #f8fafc;
    padding: 10px 12px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 12px;
    margin: 6px 0;
}

.cb-bubble ul, .cb-bubble ol {
    margin: 6px 0;
    padding-left: 20px;
}

.cb-bubble li {
    margin-bottom: 3px;
}

.cb-message.bot .cb-bubble, .cb-message.agent .cb-bubble {
    background: var(--cb-bot-bubble);
    color: var(--cb-bot-text);
    border-bottom-left-radius: 4px;
    border: 1px solid #e2e8f0;
}

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

.cb-message.visitor .cb-bubble code {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.cb-message.system .cb-bubble {
    background: #fef3c7;
    color: #92400e;
    border: 1px dashed #f59e0b;
    font-size: 13px;
    border-radius: 12px;
}

/* Message Meta & Feedback Bar */
.cb-msg-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
    padding: 0 4px;
}

.cb-timestamp {
    font-size: 11px;
    color: var(--cb-text-muted);
}

.cb-message.visitor .cb-msg-meta {
    justify-content: flex-end;
}

.cb-feedback-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.cb-message:hover .cb-feedback-actions {
    opacity: 1;
}

.cb-feedback-btn {
    background: none;
    border: none;
    color: var(--cb-text-muted);
    padding: 2px 4px;
    font-size: 12px;
    cursor: pointer;
    border-radius: 4px;
    line-height: 1;
    transition: all 0.15s;
}

.cb-feedback-btn:hover {
    color: var(--cb-primary);
    background: rgba(79, 70, 229, 0.08);
}

.cb-feedback-btn.active {
    color: #10b981;
    font-weight: bold;
}

/* Quick Replies */
.cb-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.cb-quick-btn {
    background: #ffffff;
    border: 1px solid var(--cb-primary);
    color: var(--cb-primary);
    padding: 6px 13px;
    border-radius: 20px;
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.cb-quick-btn:hover {
    background: var(--cb-primary);
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px var(--cb-primary-glow);
}

/* Typing Indicator */
.cb-typing {
    display: none;
    align-self: flex-start;
    padding: 12px 16px;
    background: var(--cb-bot-bubble);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    border: 1px solid #e2e8f0;
}

.cb-typing.visible {
    display: flex;
    align-items: center;
    gap: 5px;
}

.cb-typing-dot {
    width: 6px;
    height: 6px;
    background: var(--cb-text-muted);
    border-radius: 50%;
    animation: cb-typing 1.4s infinite ease-in-out both;
}

.cb-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.cb-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes cb-typing {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1.1); opacity: 1; }
}

/* Lead Capture Form Card */
.cb-lead-card {
    background: #ffffff;
    border: 1px solid var(--cb-surface-border);
    border-radius: 14px;
    padding: 14px;
    margin-top: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.cb-lead-card h5 {
    margin: 0 0 10px 0;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--cb-text-main);
}

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

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

.cb-lead-field input:focus, .cb-lead-field textarea:focus {
    border-color: var(--cb-primary);
}

.cb-lead-submit {
    width: 100%;
    background: var(--cb-primary);
    color: #ffffff;
    border: none;
    padding: 9px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.cb-lead-submit:hover {
    background: var(--cb-primary-hover);
}

/* Footer / Input Bar */
.cb-footer {
    padding: 12px 14px;
    background: #ffffff;
    border-top: 1px solid var(--cb-surface-border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cb-input-wrap {
    display: flex;
    align-items: center;
    background: var(--cb-surface);
    border: 1px solid var(--cb-surface-border);
    border-radius: 24px;
    padding: 4px 6px 4px 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.cb-input-wrap:focus-within {
    border-color: var(--cb-primary);
    box-shadow: 0 0 0 3px var(--cb-primary-glow);
    background: #ffffff;
}

.cb-input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 14px;
    font-family: inherit;
    color: var(--cb-text-main);
}

.cb-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--cb-primary);
    border: none;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s, background 0.2s;
}

.cb-send-btn:hover {
    background: var(--cb-primary-hover);
    transform: scale(1.06);
}

.cb-send-btn svg {
    width: 17px;
    height: 17px;
    fill: #ffffff;
}

.cb-branding {
    text-align: center;
    font-size: 11px;
    color: var(--cb-text-muted);
}

.cb-branding a {
    color: var(--cb-text-muted);
    text-decoration: none;
    font-weight: 600;
}

@media (max-width: 480px) {
    #ai-chatbot-container {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }
}
