/* --- Chat Widget Container --- */
.chat-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 2000;
    font-family: 'Open Sans', sans-serif;
}

/* --- Toggle Button (The Round Icon) --- */
#chat-toggle-btn {
    width: 60px;
    height: 60px;
    background-color: #386C47;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    font-size: 24px;
    transition: transform 0.3s ease, background 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

#chat-toggle-btn:hover {
    transform: scale(1.1);
    background-color: #2e583a;
}

/* Icon Switching Logic */
#chat-toggle-btn .fa-times {
    display: none;
}

/* State: When Chat is Open */
.chat-widget.active #chat-toggle-btn .fa-comment-dots {
    display: none;
}

.chat-widget.active #chat-toggle-btn .fa-times {
    display: block;
}

.chat-widget.active #chat-toggle-btn {
    transform: rotate(90deg);
    background-color: #9F7D4D;
}

/* --- Chat Box Window --- */
.chat-box-container {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 450px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;

    opacity: 0;
    transform: translateY(20px) scale(0.9);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    transform-origin: bottom right;
}

.chat-widget.active .chat-box-container {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* --- Header --- */
.chat-header {
    background: #386C47;
    padding: 15px;
    display: flex;
    align-items: center;
    color: white;
}

.chat-avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 12px;
    border: 2px solid white;
}

.chat-title h4 {
    margin: 0;
    font-size: 1rem;
    color: white;
    text-transform: capitalize;
}

.chat-title span {
    font-size: 0.75rem;
    color: #e0e0e0;
}

/* --- Body --- */
.chat-body {
    flex: 1;
    padding: 15px;
    background: #f9f9f9;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
}

/* Container for all messages */
.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Shared message bubble styles */
.chat-message {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 15px;
    font-size: 0.9rem;
    line-height: 1.4;
    word-wrap: break-word;
}

/* Bot message (left) */
.bot-message {
    background: #e8f5e9;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

/* User message (right) */
.user-message {
    background: #386C47;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

/* Typing indicator (bot) */
.typing-indicator {
    background: #e8f5e9;
    color: #333;
    align-self: flex-start;
    padding: 12px 15px;
    display: flex;
    gap: 4px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #386C47;
    border-radius: 50%;
    display: inline-block;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.6;
    }

    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* WhatsApp Button */
.whatsapp-btn {
    background: #25D366;
    color: white;
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    display: block;
    transition: 0.3s;
    text-decoration: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    margin-top: 5px;
}

.whatsapp-btn:hover {
    background: #1ebc57;
    transform: translateY(-2px);
}

/* --- Footer (Input) --- */
.chat-footer {
    padding: 15px;
    border-top: 1px solid #eee;
    background: white;
    display: flex;
    gap: 10px;
}

.chat-footer input {
    flex: 1;
    border: 1px solid #ddd;
    padding: 10px;
    border-radius: 20px;
    outline: none;
    font-family: inherit;
}

.chat-footer input:focus {
    border-color: #386C47;
}

.send-btn {
    background: #386C47;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn:hover {
    background: #2e583a;
}

/* Responsive */
@media (max-width: 480px) {
    .chat-box-container {
        width: 300px;
        right: -20px;
        bottom: 70px;
    }
}