/* ==========================================================================
   AIPlatform Chatbot UI — tách từ inline <style> của Views/aiplatform/AIPlatform.html
   (giữ nguyên selector & giá trị). Riêng biệt với css/chat.css (UI Zalo/FB/chat cũ).
   ========================================================================== */
:root {
    --primary-color: #3B81F6;
    --bg-color: #ffffff;
    --text-color: #303235;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.chat-launcher {
    position: fixed;
    bottom: 0px;
    right: 0px;
    width: 60px;
    height: 60px;
    background-color: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: transform 0.3s;
}

.chat-launcher-icon {
    position: fixed;
    bottom: 0px;
    right: 0px;
    width: 60px;
    height: 60px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: transform 0.3s;
}

.chat-launcher:hover {
    transform: scale(1.1);
}

.chat-launcher img {
    width: 30px;
    height: 30px;
    filter: invert(1);
}

.chat-window {
    position: fixed;
    bottom: 0px;
    right: 0px;
    width: 380px;
    height: 600px;
    max-height: 80vh;
    background-color: var(--bg-color);
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    display: none;
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
    transition: width 0.3s ease, height 0.3s ease, bottom 0.3s ease, right 0.3s ease, max-height 0.3s ease;
}

    .chat-window.expanded {
        width: 800px;
        height: 80vh;
        max-height: 90vh;
        right: 50%;
        bottom: 50%;
        transform: translate(50%, 50%);
    }

@media (max-width: 850px) {
    .chat-window.expanded {
        width: 100%;
        height: 100%;
        right: 0;
        bottom: 0;
        border-radius: 0;
        transform: none;
    }
}

.chat-header {
    background-color: var(--primary-color);
    color: white;
    padding: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

    .chat-header h3 {
        margin: 0;
        font-size: 16px;
    }

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-btn {
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
}

    .header-btn:hover {
        opacity: 1;
    }

.chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background-color: #f3f4f6;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

    .message.bot {
        background-color: #ffffff;
        color: var(--text-color);
        align-self: flex-start;
        border: 1px solid #e5e7eb;
    }

    .message.user {
        background-color: var(--primary-color);
        color: white;
        align-self: flex-end;
    }

    .message img {
        max-width: 100%;
        border-radius: 8px;
        margin-top: 5px;
    }

    /* CSS Markdown */
    .message.bot p {
        margin: 0 0 8px 0;
    }

        .message.bot p:last-child {
            margin-bottom: 0;
        }

    .message.bot ul, .message.bot ol {
        margin: 5px 0;
        padding-left: 20px;
    }

    .message.bot pre {
        background: #f1f1f1;
        padding: 10px;
        border-radius: 6px;
        overflow-x: auto;
        font-family: monospace;
        margin: 8px 0;
    }

    .message.bot code {
        background: #f1f1f1;
        padding: 2px 4px;
        border-radius: 4px;
        font-family: monospace;
        color: #d63384;
    }

    .message.bot pre code {
        color: #333;
    }
    /* Link luôn mở tab mới - style rõ ràng */
    .message.bot a {
        color: #007bff;
        text-decoration: none;
    }

        .message.bot a:hover {
            text-decoration: underline;
        }

/* CSS CHO HIỆU ỨNG TYPING */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 0;
}

    .typing-indicator span {
        width: 8px;
        height: 8px;
        background-color: #90949c;
        border-radius: 50%;
        display: inline-block;
        animation: bounce 1.4s infinite ease-in-out both;
    }

        .typing-indicator span:nth-child(1) {
            animation-delay: -0.32s;
        }

        .typing-indicator span:nth-child(2) {
            animation-delay: -0.16s;
        }

        .typing-indicator span:nth-child(3) {
            animation-delay: 0s;
        }

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.chat-input-area {
    padding: 10px;
    background: white;
    border-top: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: 10px;
}

.upload-btn {
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
}

    .upload-btn:hover {
        background-color: #f0f0f0;
    }

    .upload-btn svg {
        width: 24px;
        height: 24px;
        fill: #666;
    }

.chat-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 10px;
    font-size: 14px;
    resize: none;
    height: 20px;
    max-height: 100px;
}

.send-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--primary-color);
}

    .send-btn svg {
        width: 24px;
        height: 24px;
        fill: currentColor;
    }

.preview-container {
    padding: 5px 15px;
    background: white;
    border-top: 1px solid #eee;
    display: none;
}

.preview-img {
    height: 50px;
    border-radius: 4px;
    border: 1px solid #ddd;
}
/* CSS KHI CHAT BỊ KHÓA */
.chat-input-area.locked .chat-input {
    background-color: #f5f5f5;
    color: #aaa;
    cursor: not-allowed;
}

.chat-input-area.locked .send-btn {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.chat-input-area.locked .upload-btn {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.remove-img {
    cursor: pointer;
    color: red;
    font-size: 12px;
    margin-left: 10px;
}

.chatbot-icon {
    width: 60px;
    height: 60px;
    object-fit: contain;
    pointer-events: none;
}
