/* Floating action button for WhatsApp Chat Simulator */
.ai-chat-fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background-color: #25D366; /* WhatsApp Green */
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    box-shadow: 0 4px 15px rgba(37, 211, 102, 0.4);
    cursor: pointer;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.ai-chat-fab:hover {
    transform: scale(1.1);
}

.ai-chat-fab svg {
    width: 32px;
    height: 32px;
    fill: currentColor;
}

/* Chat Modal Container */
.ai-chat-modal {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 350px;
    height: 500px;
    background-color: #E5DDD5; /* WhatsApp background */
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none; /* Hidden by default */
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
    transform-origin: bottom right;
    animation: chatPopUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    /* Pseudo Whatsapp background pattern */
    background-image: url('data:image/svg+xml,%3Csvg width=\"60\" height=\"60\" viewBox=\"0 0 60 60\" xmlns=\"http://www.w3.org/2000/svg\"%3E%3Cpath d=\"M54.627 0l.83.83-5.228 5.228-.83-.83 5.228-5.228zm-39.254 0l5.228 5.228-.83.83-5.228-5.228.83-.83z\" fill=\"%23cfc5bb\" fill-opacity=\"0.4\" fill-rule=\"evenodd\"/%3E%3C/svg%3E');
}

.ai-chat-modal.active {
    display: flex;
}

@keyframes chatPopUp {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Chat Header */
.ai-chat-header {
    background-color: #075E54;
    color: white;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    position: relative;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.ai-chat-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #fff;
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.ai-chat-header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ai-chat-header-info {
    flex-grow: 1;
}

.ai-chat-header-name {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    font-family: inherit;
}

.ai-chat-header-status {
    font-size: 12px;
    opacity: 0.8;
    margin: 2px 0 0 0;
}

.ai-chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0 5px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.ai-chat-close:hover {
    opacity: 1;
}

/* Messages Area */
.ai-chat-messages {
    flex-grow: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.2) transparent;
}

.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background-color: rgba(0,0,0,0.2);
    border-radius: 3px;
}

.chat-bubble {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
    position: relative;
    box-shadow: 0 1px 1px rgba(0,0,0,0.1);
    word-wrap: break-word;
    animation: fadeIn 0.3s ease-in-out;
}

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

.chat-bubble.bot {
    background-color: #fff;
    align-self: flex-start;
    border-top-left-radius: 0;
    color: #303030;
}

.chat-bubble.bot::before {
    content: '';
    position: absolute;
    top: 0;
    left: -8px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-top-color: #fff;
    border-right-color: #fff;
    border-left: 0;
    margin-top: 0;
    margin-bottom: -8px;
}

.chat-bubble.user {
    background-color: #DCF8C6;
    align-self: flex-end;
    border-top-right-radius: 0;
    color: #303030;
}

.chat-bubble.user::after {
    content: '';
    position: absolute;
    top: 0;
    right: -8px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-top-color: #DCF8C6;
    border-left-color: #DCF8C6;
    border-right: 0;
    margin-top: 0;
    margin-bottom: -8px;
}

.chat-timestamp {
    display: block;
    font-size: 10px;
    text-align: right;
    margin-top: 4px;
    opacity: 0.6;
}

/* Typing Indicator */
.typing-indicator {
    padding: 12px 16px;
    background-color: #fff;
    align-self: flex-start;
    border-radius: 12px;
    border-top-left-radius: 0;
    box-shadow: 0 1px 1px rgba(0,0,0,0.1);
    display: none;
    align-items: center;
    gap: 4px;
}

.typing-indicator.active {
    display: flex;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background-color: #90949c;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Input Area */
.ai-chat-input-area {
    background-color: #F0F0F0;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-chat-input {
    flex-grow: 1;
    background-color: #fff;
    border: none;
    border-radius: 20px;
    padding: 12px 16px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
    box-shadow: 0 1px 1px rgba(0,0,0,0.05);
}

.ai-chat-send {
    background-color: #00897B;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: background-color 0.2s;
}

.ai-chat-send:hover {
    background-color: #00796B;
}

.ai-chat-send svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    margin-left: -2px; /* slight visual offset for the paper plane */
}

/* Media Queries for Mobile */
@media (max-width: 480px) {
    .ai-chat-modal {
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
        transform-origin: center;
        animation: slideUp 0.3s ease-out forwards;
    }
    
    @keyframes slideUp {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }
    
    .ai-chat-header {
        border-radius: 0;
    }
    
    .ai-chat-fab {
        bottom: 20px;
        right: 20px;
    }
}

/* Suggested link inside chat */
.chat-product-link {
    display: inline-block;
    margin-top: 8px;
    background-color: #25D366;
    color: #fff !important;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 12px;
    font-weight: bold;
    font-size: 13px;
    text-align: center;
}

.chat-product-link:hover {
    background-color: #128C7E;
}
