/* assets/css/chatbot.css */

/* ============================================================
   CHATBOT TRIGGER BUTTON
   ============================================================ */

.chatbot-trigger {
    position: fixed;
    bottom: 75px;
    right: 17px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #4CAF50;
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    z-index: 9999;
}

.chatbot-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.25);
}

.chatbot-trigger.active {
    transform: rotate(90deg);
    background: #f44336;
    display: none;
}

/* ============================================================
   MAIN CHATBOT CONTAINER
   ============================================================ */

.chatbot-container {
    position: fixed;
    bottom: 73px;
    right: 17px;
    width: 380px;
    height: 550px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    z-index: 9998;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    animation: slideIn 0.3s ease;
}

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

/* ============================================================
   HEADER SECTION
   ============================================================ */

.chatbot-header {
    background: #4CAF50;
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chatbot-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar {
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.chatbot-agent-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chatbot-title h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chatbot-title p {
    margin: 0;
    font-size: 12px;
    opacity: 0.9;
}

.chatbot-header-actions {
    display: flex;
    gap: 8px;
}

.chatbot-header-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: background 0.2s;
}

.chatbot-header-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ============================================================
   MESSAGES AREA
   ============================================================ */

.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f5f5f5;
}

/* Individual Messages */
.message {
    margin-bottom: 15px;
    max-width: 85%;
    clear: both;
}

.message.user {
    float: right;
}

.message.bot {
    float: left;
}

.message.system {
    float: none;
    margin: 10px auto;
    text-align: center;
    max-width: 100%;
}

.message.typing {
    background: transparent !important;
}

/* Message Content */
.message-content {
    padding: 10px 15px;
    border-radius: 18px;
    background: white;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message.user .message-content {
    background: #4CAF50;
    color: white;
}

.message.system .message-content {
    background: #e0e0e0;
    color: #333;
    font-style: italic;
}

.message.bot .message-content {
    line-height: 1.6;
    font-size: 14px;
}

.message.bot .message-content strong {
    color: #2e7d32;
    font-weight: 600;
}

.message.bot .message-content br {
    display: block;
    content: "";
    margin-top: 6px;
}

/* Agent Name */
.agent-name {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
    color: #4CAF50;
}

/* Message Time */
.message-time {
    font-size: 10px;
    color: #999;
    margin-top: 4px;
    text-align: right;
}

/* Message Similarity Score */
.message-similarity {
    font-size: 0.7em;
    color: #888;
    margin-top: 2px;
}

/* ============================================================
   SOURCE INDICATORS (Colored borders for different sources)
   ============================================================ */

.message.source-history {
    opacity: 0.9;
}

.message.source-product_inquiry .message-content {
    border-left: 3px solid #4CAF50;
    padding-left: 8px;
}

.message.source-offers .message-content {
    border-left: 3px solid #FF9800;
    padding-left: 8px;
}

.message.source-cerebras_api .message-content {
    border-left: 3px solid #2196F3;
    padding-left: 8px;
}

.message.source-flow_lead_collection .message-content {
    border-left: 3px solid #9C27B0;
    padding-left: 8px;
}

.message.source-flow_order .message-content {
    border-left: 3px solid #FF5722;
    padding-left: 8px;
}

/* ============================================================
   SOURCE INDICATOR TAGS (Small badges)
   ============================================================ */

.source-indicator {
    font-size: 10px;
    margin-top: 4px;
    margin-bottom: 2px;
    padding: 2px 8px;
    border-radius: 12px;
    display: inline-block;
    font-weight: 500;
    opacity: 0.8;
}

.source-indicator.offers {
    background: #fff3e0;
    color: #e65100;
    border: 1px solid #ffe0b2;
}

.source-indicator.missed {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

.source-indicator.products {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.source-indicator.cache {
    background: #e3f2fd;
    color: #1565c0;
    border: 1px solid #bbdefb;
}

.source-indicator.api {
    background: #f3e5f5;
    color: #7b1fa2;
    border: 1px solid #e1bee7;
}

.message.bot:hover .source-indicator {
    opacity: 1;
    transition: opacity 0.2s ease;
}

.cache-indicator {
    font-size: 10px;
    color: #888;
    margin-top: 2px;
    text-align: right;
    opacity: 0.7;
}

/* ============================================================
   QUICK REPLIES SECTION
   ============================================================ */

.quick-replies {
    padding: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background: white;
    border-top: 1px solid #eee;
}

.quick-reply-btn {
    padding: 8px 15px;
    background: #f0f0f0;
    border: none;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.quick-reply-btn:hover {
    background: #e0e0e0;
}

/* ============================================================
   INPUT AREA
   ============================================================ */

.chatbot-input {
    display: flex;
    padding: 15px;
    background: white;
    border-top: 1px solid #eee;
    gap: 8px;
}

.chatbot-input input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 25px;
    outline: none;
    font-size: 14px;
}

.chatbot-input input:focus {
    border-color: #4CAF50;
}

.chatbot-input button {
    width: 45px;
    height: 45px;
    border: none;
    border-radius: 50%;
    background: #4CAF50;
    color: white;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.chatbot-input button:hover {
    background: #45a049;
}

.chatbot-input button.voice-btn {
    background: #2196F3;
}

.chatbot-input button.voice-btn:hover {
    background: #1e88e5;
}

.chatbot-input button.voice-btn.listening {
    background: #f44336;
    animation: pulse 1s infinite;
}

#chatbot-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================================
   TYPING INDICATOR
   ============================================================ */

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px 15px;
    background: white;
    border-radius: 18px;
    width: fit-content;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

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

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

/* ============================================================
   LINK STYLES
   ============================================================ */

.message.bot .message-content a.product-link {
    display: inline-block;
    background: #4CAF50;
    color: white !important;
    padding: 7px 14px;
    border-radius: 20px;
    text-decoration: none;
    margin: 8px 0;
    font-weight: 500;
    transition: background 0.2s;
}

.message.bot .message-content a.product-link:hover {
    background: #388e3c;
}

.message.bot .message-content a.whatsapp-link {
    display: inline-block;
    background: #25D366;
    color: white !important;
    padding: 7px 14px;
    border-radius: 20px;
    text-decoration: none;
    margin: 8px 0;
    font-weight: 500;
    transition: background 0.2s;
}

.message.bot .message-content a.whatsapp-link:hover {
    background: #128C7E;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

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

/* ============================================================
   RESPONSIVE DESIGN
   ============================================================ */

@media screen and (max-width: 480px) {
    .chatbot-container {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }
    
    .chatbot-trigger {
        bottom: 70px;
        right: 16px;
    }
}

@media screen and (max-height: 600px) {
    .chatbot-container {
        height: 100%;
        bottom: 0;
    }
}