/* Chatbot Floating Button & Interface Styles */
:root {
    --chat-btn-size: 60px;
    --chat-width: 380px;
    --chat-height: 600px;
    --spacing: 24px;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Floating Toggle Button */
.chatbot-toggler {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: var(--chat-btn-size);
    height: var(--chat-btn-size);
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(226, 59, 46, 0.3);
    transition: var(--transition);
    z-index: 9999;
    border: none;
    outline: none;
}

.chatbot-toggler:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(226, 59, 46, 0.4);
}

.chatbot-toggler span {
    position: absolute;
    color: #fff;
    font-size: 1.5rem;
    transition: var(--transition);
}

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

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

/* Chatbot Interface */
.chatbot {
    position: fixed;
    right: 24px;
    bottom: 100px;
    width: var(--chat-width);
    height: var(--chat-height);
    background: var(--bg-surface);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.9);
    transition: var(--transition);
    transform-origin: bottom right;
    z-index: 9998;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--rule);
}

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

/* Adaptive positioning when Back to Top is visible */
body.has-back-to-top .chatbot-toggler {
    bottom: 90px;
    /* Shift up above the back-to-top button */
}

body.has-back-to-top .chatbot {
    bottom: 160px;
    /* Shift window up too */
}

/* Chat Header */
.chatbot header {
    background: var(--accent);
    border-bottom: 1px solid var(--rule);
    padding: 12px 20px;
    position: relative;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chatbot header .header-info {
    display: flex;
    flex-direction: column;
}

.chatbot header h2 {
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 2px 0;
}

.chatbot header .support-text {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.75rem;
    margin: 0;
    font-weight: 400;
}

.chatbot header .close-btn {
    color: #fff;
    cursor: pointer;
    font-size: 1.2rem;
    display: none;
    /* Hidden on desktop, useful for mobile */
}

/* Chat Messages */
.chatbox {
    overflow-y: auto;
    height: 100%;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--bg);
}

.chatbox::-webkit-scrollbar {
    width: 6px;
}

.chatbox::-webkit-scrollbar-track {
    background: var(--bg-muted);
}

.chatbox::-webkit-scrollbar-thumb {
    background: var(--rule);
    border-radius: 3px;
}

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

.chatbox .chat p {
    white-space: pre-wrap;
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 85%;
    font-size: 0.95rem;
    line-height: 1.5;
}

.chatbox .chat-incoming p {
    background: var(--bg-surface);
    color: var(--text);
    border: 1px solid var(--rule);
    border-bottom-left-radius: 4px;
}

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

.chatbox .chat-outgoing p {
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Chat Input */
.chat-input {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 16px 20px;
    border-top: 1px solid var(--rule);
    background: var(--bg-surface);
}

.chat-input textarea {
    height: 40px;
    width: 100%;
    border: 1px solid var(--rule);
    outline: none;
    resize: none;
    max-height: 180px;
    padding: 10px 15px;
    font-size: 0.95rem;
    border-radius: 20px;
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
}

.chat-input textarea:focus {
    border-color: var(--accent);
}

.chat-input span {
    align-self: flex-end;
    color: var(--accent);
    cursor: pointer;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    width: 40px;
    transition: transform 0.2s;
}

.chat-input span:hover {
    transform: scale(1.1);
}

/* Quick Actions */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.quick-action-btn {
    background: var(--bg-surface);
    border: 1px solid var(--rule);
    color: var(--text);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-action-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

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

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

    .chatbot header .close-btn {
        display: block;
    }

    .chatbot-toggler {
        right: 20px;
        bottom: 20px;
    }
}