﻿/* =========================
   AI CHAT – FLOATING WIDGET
   ========================= */

/* Chat Icon */
#chat-icon {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 55px;
    height: 55px;
    background: #007bff;
    color: #ffffff;
    border-radius: 50%;
    font-size: 26px;
    text-align: center;
    line-height: 55px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    z-index: 9999;
}

/* Chat Box */
#chat-box {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 320px;
    background: #ffffff;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-family: Arial, Helvetica, sans-serif;
    display: none;
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
    z-index: 10000;
}

/* Chat Header */
#chat-header {
    background: #007bff;
    color: #ffffff;
    padding: 10px 12px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Close Button */
#chat-close {
    cursor: pointer;
    font-size: 14px;
}

.chat-message {
    display: flex;
    width: 100%; /* 🔴 REQUIRED */
    margin-bottom: 10px;
    box-sizing: border-box;
}

/* Messages Area */
#chat-messages {
    height: 220px;
    overflow-y: auto;
    padding: 10px;
    font-size: 14px;
    background: #f9f9f9;
    /* 🔴 IMPORTANT FIX */
    display: block; /* NOT flex */
    width: 100%;
    box-sizing: border-box;
}

    /* User / AI message spacing */
    #chat-messages div {
        margin-bottom: 8px;
    }

/* Input Box */
#chat-input {
    width: 100%;
    border: none;
    border-top: 1px solid #ddd;
    outline: none;
    font-size: 14px;
    flex: 1;
    padding: 8px 10px;
    border: none;
    outline: none;
}

/* =========================
   TYPING / LOADER ANIMATION
   ========================= */

#chat-typing {
    padding: 8px 10px;
    display: none;
}

/* Typing dots */
.dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-right: 4px;
    background: #666;
    border-radius: 50%;
    animation: blink 1.4s infinite both;
}

    .dot:nth-child(1) {
        animation-delay: 0s;
    }

    .dot:nth-child(2) {
        animation-delay: 0.2s;
    }

    .dot:nth-child(3) {
        animation-delay: 0.4s;
    }

/* Keyframes */
@keyframes blink {
    0% {
        opacity: 0.2;
    }

    20% {
        opacity: 1;
    }

    100% {
        opacity: 0.2;
    }
}

/* =========================
   MOBILE RESPONSIVE
   ========================= */

@media (max-width: 480px) {
    #chat-box {
        width: 95%;
        right: 2.5%;
        bottom: 10px;
    }

    #chat-icon {
        right: 15px;
        bottom: 15px;
    }
}

/* Common bubble style */
.chat-bubble {
    display: inline-block; /* 🔴 NOT inline / inline-flex */
    max-width: 75%;
    padding: 8px 12px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    white-space: normal;
}
.chat-message.user {
    justify-content: flex-end;
}

    .chat-message.user .chat-bubble {
        background: #dcf8c6; /* WhatsApp green */
        border-bottom-right-radius: 4px;
    }
.chat-message.ai {
    justify-content: flex-start;
}

    .chat-message.ai .chat-bubble {
        background: #eeeeee;
        border-bottom-left-radius: 4px;
    }
.chat-message.typing {
    justify-content: flex-start;
}

    .chat-message.typing .chat-bubble {
        background: #eeeeee;
    }

/* Timestamp */
.chat-time {
    display: block;
    font-size: 11px;
    color: #777;
    margin-top: 4px;
    text-align: right;
}

/* AI timestamp aligns left */
.chat-message.ai .chat-time {
    text-align: left;
}

/* Input + Send button wrapper */
.chat-input-area {
    display: flex;
    align-items: center;
    border-top: 1px solid #ddd;
    padding: 6px;
}
/* Send Button */
#chat-send {
    background: #007bff;
    color: white;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    margin-left: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}
    #chat-send:disabled {
        background: #aaa;
        cursor: not-allowed;
    }