/* Chatbot Floating Action Button */
.chatbot-fab {
    position: fixed;
    z-index: 999999;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
    background: linear-gradient(135deg, var(--chatbot-color, #38bdf8), #818cf8);
    color: #ffffff;
    font-size: 28px;
}

.chatbot-fab::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: inherit;
    filter: blur(12px);
    opacity: 0.6;
    z-index: -1;
    transition: opacity 0.3s ease;
}

.chatbot-fab:hover {
    transform: scale(1.08);
}

.chatbot-fab:hover::after {
    opacity: 0.9;
}

/* Pulse animation for unread/new state */
@keyframes pulse-ring {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 15px rgba(56, 189, 248, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(56, 189, 248, 0);
    }
}
.chatbot-fab.pulse {
    animation: pulse-ring 2s infinite;
}

/* Chatbot Window */
.chatbot-window {
    position: fixed;
    z-index: 999998;
    background: rgba(18, 18, 21, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transform: scale(0.5);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), opacity 0.3s ease;
    color: #fff;
    font-family: inherit;
}

.chatbot-window.open {
    transform: scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* Chat Header */
.chatbot-header {
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(255,255,255,0.05), rgba(255,255,255,0.01));
    border-bottom: 1px solid rgba(255,255,255,0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chatbot-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--chatbot-color, #38bdf8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    position: relative;
}

.chatbot-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.chatbot-online-dot {
    position: absolute;
    bottom: 2px;
    inset-inline-end: 2px;
    width: 12px;
    height: 12px;
    background: #10b981;
    border-radius: 50%;
    border: 2px solid #121215;
}

.chatbot-title {
    font-weight: 600;
    font-size: 1.1rem;
    margin: 0;
}

.chatbot-subtitle {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.6);
    margin: 0;
}

.chatbot-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.6);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
    padding: 0.5rem;
}

.chatbot-close:hover {
    color: #fff;
}

/* Chat Body */
.chatbot-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chatbot-body::-webkit-scrollbar {
    width: 6px;
}
.chatbot-body::-webkit-scrollbar-track {
    background: transparent;
}
.chatbot-body::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
}

/* Chat Messages */
.chat-bubble {
    max-width: 85%;
    padding: 1rem 1.25rem;
    border-radius: 20px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    animation: fade-in-up 0.3s ease;
}

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

.chat-bubble.assistant {
    align-self: flex-start;
    background: rgba(255,255,255,0.05);
    border-bottom-left-radius: 4px;
    color: #f4f4f5;
}

.chat-bubble.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--chatbot-color, #38bdf8), #818cf8);
    border-bottom-right-radius: 4px;
    color: #fff;
}

.chat-time {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.4);
    margin-top: 0.5rem;
    text-align: end;
}

.chat-bubble.assistant .chat-time {
    text-align: start;
}

/* Chat Input Area */
.chatbot-footer {
    padding: 1rem 1.5rem;
    background: rgba(255,255,255,0.02);
    border-top: 1px solid rgba(255,255,255,0.05);
}

.chat-input-wrapper {
    display: flex;
    gap: 0.75rem;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 99px;
    padding: 0.5rem 0.5rem 0.5rem 1.25rem;
    align-items: center;
}

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
}

.chat-input::placeholder {
    color: rgba(255,255,255,0.4);
}

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

.chat-send-btn:hover {
    transform: scale(1.05);
    background: #818cf8;
}

/* Lead Capture Form */
.chatbot-lead-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: rgba(255,255,255,0.03);
    padding: 1.5rem;
    border-radius: 16px;
    margin-top: 1rem;
}

.chatbot-lead-form input, .chatbot-lead-form textarea {
    width: 100%;
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: #fff;
    font-family: inherit;
    box-sizing: border-box;
}

.chatbot-lead-form textarea {
    resize: vertical;
    min-height: 80px;
}

.chatbot-lead-form button {
    background: linear-gradient(135deg, var(--chatbot-color, #38bdf8), #818cf8);
    color: #fff;
    border: none;
    padding: 0.75rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 0.5rem 1rem;
    align-items: center;
}
.typing-dot {
    width: 6px;
    height: 6px;
    background: rgba(255,255,255,0.6);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Desktop vs Mobile adjustments */
@media (min-width: 768px) {
    .chatbot-fab {
        width: 64px;
        height: 64px;
    }
    .chatbot-window {
        width: 400px;
        height: 600px;
        max-height: calc(100vh - 120px);
    }
    .chatbot-fab.right { inset-inline-end: 24px; bottom: 24px; }
    .chatbot-window.right { inset-inline-end: 24px; bottom: 100px; transform-origin: bottom right; }
    
    .chatbot-fab.left { inset-inline-start: 24px; bottom: 24px; }
    .chatbot-window.left { inset-inline-start: 24px; bottom: 100px; transform-origin: bottom left; }
}

@media (max-width: 767px) {
    .chatbot-fab {
        width: 56px;
        height: 56px;
    }
    .chatbot-window {
        width: calc(100vw - 32px);
        height: calc(100vh - 120px);
    }
    .chatbot-fab.right { inset-inline-end: 16px; bottom: 16px; }
    .chatbot-window.right { inset-inline-end: 16px; bottom: 84px; transform-origin: bottom right; }
    
    .chatbot-fab.left { inset-inline-start: 16px; bottom: 16px; }
    .chatbot-window.left { inset-inline-start: 16px; bottom: 84px; transform-origin: bottom left; }
}
