/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600&display=swap');

/* Chatbot Toggler Button */
.chatbot-toggler {
    position: fixed;
    bottom: 30px;
    right: 35px;
    outline: none;
    border: none;
    height: 60px;
    width: 60px;
    display: flex;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.3);
    z-index: 9999;
}

.chatbot-toggler:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 12px 30px rgba(99, 102, 241, 0.4);
}

.chatbot-toggler span {
    color: #fff;
    font-size: 1.8rem;
    position: absolute;
    transition: all 0.3s ease;
}

.chatbot-toggler span:last-child,
body.show-chatbot .chatbot-toggler span:first-child {
    opacity: 0;
    transform: rotate(90deg);
}

body.show-chatbot .chatbot-toggler span:last-child {
    opacity: 1;
    transform: rotate(0);
}

/* Chatbot Window */
.chatbot {
    position: fixed;
    right: 35px;
    bottom: 100px;
    width: 380px;
    background: #fff;
    border-radius: 24px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9) translateY(20px);
    transform-origin: bottom right;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 9998;
    font-family: 'Outfit', sans-serif;
}

body.show-chatbot .chatbot {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1) translateY(0);
}

/* Header */
.chatbot header {
    background: linear-gradient(135deg, #6366f1 0%, #ec4899 100%);
    padding: 20px 0;
    position: relative;
    text-align: center;
    color: #fff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.chatbot header h2 {
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: -0.5px;
    margin: 0;
}

.chatbot header .close-btn {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #fff;
    cursor: pointer;
    display: none;
    /* Hidden on desktop since toggler handles closure */
}

/* Chatbox Area */
.chatbot .chatbox {
    overflow-y: auto;
    height: 400px;
    padding: 20px 20px 80px;
    background: #f8fafc;
}

.chatbox .chat {
    display: flex;
    list-style: none;
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chatbox .outgoing {
    justify-content: flex-end;
}

/* Avatars */
.chatbox .incoming span {
    width: 36px;
    height: 36px;
    color: #fff;
    cursor: default;
    text-align: center;
    line-height: 36px;
    align-self: flex-end;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border-radius: 12px;
    margin: 0 10px 4px 0;
    font-size: 1.2rem;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.2);
}

/* Message Bubbles */
.chatbox .chat p {
    white-space: pre-wrap;
    padding: 14px 18px;
    border-radius: 18px 18px 18px 4px;
    max-width: 80%;
    font-size: 0.95rem;
    line-height: 1.5;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.chatbox .outgoing p {
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    color: #fff;
    border-radius: 18px 18px 4px 18px;
    text-align: left;
}

.chatbox .incoming p {
    background: #fff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
}

.chatbox .incoming p.error {
    color: #ef4444;
    background: #fef2f2;
    border-color: #fecaca;
}

/* Input Area */
.chatbot .chat-input {
    display: flex;
    gap: 10px;
    position: absolute;
    bottom: 0;
    width: 100%;
    background: #fff;
    padding: 15px 20px;
    border-top: 1px solid #f1f5f9;
}

.chat-input textarea {
    height: 50px;
    width: 100%;
    border: none;
    outline: none;
    resize: none;
    max-height: 120px;
    padding: 12px 15px;
    font-size: 0.95rem;
    background: #f1f5f9;
    border-radius: 12px;
    font-family: 'Outfit', sans-serif;
    transition: all 0.2s;
}

.chat-input textarea:focus {
    background: #fff;
    box-shadow: 0 0 0 2px #6366f1;
}

.chat-input span {
    align-self: flex-end;
    color: #6366f1;
    cursor: pointer;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: hidden;
    font-size: 1.6rem;
    background: #e0e7ff;
    width: 50px;
    border-radius: 12px;
    transition: all 0.2s;
}

.chat-input textarea:valid~span {
    visibility: visible;
}

.chat-input span:hover {
    background: #6366f1;
    color: #fff;
}

/* Mobile Responsiveness */
@media (max-width: 490px) {
    .chatbot {
        right: 0;
        bottom: 0;
        height: 100%;
        border-radius: 0;
        width: 100%;
    }

    .chatbot .chatbox {
        height: 90%;
        padding: 25px 15px 100px;
    }

    .chatbot .chat-input {
        padding: 5px 15px;
    }

    .chatbot header {
        padding: 15px 0;
    }
}