/* Chatbot Trigger Button */
.chatbot-toggler {
    position: fixed;
    bottom: 90px;
    /* Above mobile sticky bar */
    right: 30px;
    height: 60px;
    width: 60px;
    color: #fff;
    background: var(--color-primary);
    border: none;
    border-radius: 50%;
    outline: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 9998;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.chatbot-toggler:hover {
    transform: scale(1.1);
    background: var(--color-primary-light);
}

.chatbot-toggler span {
    position: absolute;
}

.show-chatbot .chatbot-toggler span:first-child,
.chatbot-toggler span:last-child {
    opacity: 0;
}

.show-chatbot .chatbot-toggler span:last-child {
    opacity: 1;
}

/* Chatbot Window */
.chatbot {
    position: fixed;
    right: 35px;
    bottom: 160px;
    width: 380px;
    background: #fff;
    border-radius: 15px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.5);
    transform-origin: bottom right;
    box-shadow: 0 0 128px 0 rgba(0, 0, 0, 0.1),
        0 32px 64px -48px rgba(0, 0, 0, 0.5);
    transition: all 0.1s ease;
    z-index: 9999;
}

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

/* Header */
.chatbot header {
    padding: 16px;
    background: var(--color-primary);
    text-align: center;
    position: relative;
}

.chatbot header h2 {
    color: #fff;
    font-size: 1.2rem;
    font-weight: 600;
}

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

/* Chat Box */
.chatbot .chatbox {
    overflow-y: auto;
    height: 400px;
    padding: 15px 20px 70px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.chatbox .chat {
    display: flex;
    list-style: none;
}

.chatbox .incoming span {
    width: 32px;
    height: 32px;
    color: #fff;
    background: var(--color-primary);
    text-align: center;
    line-height: 32px;
    border-radius: 4px;
    margin: 0 10px 7px 0;
    align-self: flex-end;
}

.chatbox .chat p {
    white-space: pre-wrap;
    word-wrap: break-word;
    padding: 12px 16px;
    border-radius: 10px 10px 10px 0;
    font-size: 0.95rem;
    background: #f2f2f2;
    color: #333;
    max-width: 75%;
}

.chatbox .outgoing {
    justify-content: flex-end;
    margin: 20px 0;
}

.chatbox .outgoing p {
    background: var(--color-primary);
    color: #fff;
    border-radius: 10px 10px 0 10px;
}

.chatbox .incoming p {
    border-radius: 10px 10px 10px 0;
}

.chatbox .incoming p.error {
    color: #721c24;
    background: #f8d7da;
    border-color: #f5c6cb;
}

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

.chat-input textarea {
    height: 55px;
    width: 100%;
    border: none;
    outline: none;
    resize: none;
    max-height: 180px;
    padding: 15px 15px 15px 0;
    font-size: 0.95rem;
    font-family: inherit;
}

.chat-input span {
    align-self: flex-end;
    color: var(--color-primary);
    cursor: pointer;
    height: 55px;
    display: flex;
    align-items: center;
    visibility: hidden;
    font-size: 1.35rem;
    transition: color 0.2s ease;
}

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

.chat-input span:hover {
    color: var(--color-accent);
}

/* Mobile Responsiveness */
@media (max-width: 490px) {
    .chatbot-toggler {
        right: 20px;
        bottom: 80px;
    }

    .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 span {
        display: block;
        /* Show close btn on mobile */
    }
}