/* Chatbot Toggle Button */
.chatbot-toggle-btn {
    position: fixed;
    bottom: 2rem;
    left: 2rem; /* Position on the left side */
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    font-size: 1.8rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 10px var(--shadow-medium);
    transition: background-color 0.3s ease, transform 0.3s ease;
    z-index: 950; /* Above back-to-top button */
}

.chatbot-toggle-btn:hover {
    background-color: var(--secondary-color);
    transform: scale(1.05);
}

/* Chatbot Container */
.chatbot-container {
    position: fixed;
    bottom: 90px; /* Adjust based on toggle button height + margin */
    left: 2rem;
    width: 350px;
    height: 450px;
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 25px var(--shadow-medium);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 960;
    transform: translateX(-150%); /* Start hidden off-screen */
    transition: transform 0.4s ease-out;
}

.chatbot-container.active {
    transform: translateX(0); /* Slide into view */
}

.chatbot-header {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-family-secondary);
    font-weight: 600;
    font-size: 1.1rem;
}

.chatbot-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.chatbot-close-btn:hover {
    transform: rotate(90deg);
}

.chatbot-messages {
    flex-grow: 1;
    padding: 1rem;
    overflow-y: auto;
    background-color: #f9f9f9;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.message {
    max-width: 80%;
    padding: 0.7rem 1rem;
    border-radius: 15px;
    font-size: 0.95rem;
    line-height: 1.4;
    word-wrap: break-word; /* Ensure long words wrap */
}

.bot-message {
    background-color: #e0e0e0;
    align-self: flex-start;
    border-bottom-left-radius: 5px; /* Flat corner on the side of origin */
}

.user-message {
    background-color: var(--primary-color);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 5px; /* Flat corner on the side of origin */
}

.chatbot-input {
    display: flex;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    background-color: #fff;
}

.chatbot-input input {
    flex-grow: 1;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 0.8rem 1rem;
    font-size: 1rem;
    outline: none;
    margin-right: 0.5rem;
}

.chatbot-input button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.chatbot-input button:hover {
    background-color: var(--secondary-color);
}

/* Responsive adjustments for chatbot */
@media (max-width: 768px) {
    .chatbot-toggle-btn {
        bottom: 1.5rem;
        left: 1.5rem;
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }

    .chatbot-container {
        width: calc(100% - 3rem); /* Full width minus margins */
        height: calc(100% - 190px); /* Adjust height for mobile */
        bottom: 80px;
        left: 1.5rem;
        right: 1.5rem;
        max-width: none; /* Remove max-width on mobile */
    }
}

@media (max-width: 480px) {
    .chatbot-container {
        width: 90%; /* A bit more margin */
        left: 5%;
        right: 5%;
    }
}