/* Chatbot Container */
.saas-chatbot-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: 'Inter', sans-serif;
}

/* Chat Toggle Button */
.saas-chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(var(--primary-rgb, 46, 125, 50), 0.3);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: none;
    outline: none;
}
.saas-chatbot-toggle:hover {
    transform: scale(1.05);
    background: var(--primary-hover);
}

/* Chat Window */
.saas-chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: var(--saas-bg-main);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--saas-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    transform-origin: bottom right;
}

.saas-chatbot-window.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Header */
.saas-chatbot-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.saas-chatbot-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 1.05rem;
}
.saas-chatbot-header-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
}
.saas-chatbot-header-close:hover {
    opacity: 1;
}

/* Body / Messages Area */
.saas-chatbot-body {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    background: var(--saas-bg-subtle);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Scrollbar */
.saas-chatbot-body::-webkit-scrollbar {
    width: 6px;
}
.saas-chatbot-body::-webkit-scrollbar-track {
    background: transparent;
}
.saas-chatbot-body::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.1);
    border-radius: 10px;
}

/* Message Bubbles */
.saas-chat-msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
}
.saas-chat-msg.bot {
    align-self: flex-start;
    background: white;
    color: var(--saas-text-main);
    border: 1px solid var(--saas-border);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}
.saas-chat-msg.user {
    align-self: flex-end;
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 5px rgba(var(--primary-rgb, 46,125,50), 0.2);
}

/* Input Area */
.saas-chatbot-footer {
    padding: 16px;
    background: var(--saas-bg-main);
    border-top: 1px solid var(--saas-border);
    display: flex;
    gap: 8px;
    align-items: center;
}
.saas-chatbot-input {
    flex-grow: 1;
    border: 1px solid var(--saas-border);
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 0.9rem;
    background: var(--saas-bg-subtle);
    outline: none;
    transition: border-color 0.2s;
}
.saas-chatbot-input:focus {
    border-color: var(--primary);
}
.saas-chatbot-send {
    background: var(--primary);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}
.saas-chatbot-send:hover {
    background: var(--primary-hover);
}

/* Typing Indicator */
.saas-chat-typing {
    display: none;
    align-self: flex-start;
    background: white;
    border: 1px solid var(--saas-border);
    padding: 12px 16px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}
.saas-chat-typing.active {
    display: flex;
    gap: 4px;
}
.saas-chat-typing span {
    width: 6px;
    height: 6px;
    background: var(--saas-text-muted);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}
.saas-chat-typing span:nth-child(1) { animation-delay: -0.32s; }
.saas-chat-typing span:nth-child(2) { animation-delay: -0.16s; }
@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Mobile responsive */
@media (max-width: 480px) {
    .saas-chatbot-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        transform: translateY(100%);
    }
}
