/* =========================================================================
   1. NÚT CHAT TRÒN (FLOATING BUTTON)
   ========================================================================= */
.floating-chat-btn {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 99998;
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background-color: #fff;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid #f1f1f1;
    transition: transform 0.3s ease;
}
.floating-chat-btn:hover { transform: scale(1.1); }
.floating-chat-btn img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; padding: 0px; border: solid 1px #00C853; }

/* =========================================================================
   2. KHUNG CỬA SỔ CHAT (CONTAINER)
   ========================================================================= */
.chat-window-container {
    position: fixed;
    bottom: 70px; /* Đẩy lên trên nút tròn */
    right: 90px;   /* Căn thẳng hàng với nút tròn */
    width: 520px;  /* Độ rộng tối ưu cho màn hình laptop */
    height: 600px;
    max-height: 80vh;
    max-width: 90vw;
    background-color: #fff;
    border-radius: 16px;
    box-shadow: 0 5px 40px rgba(0,0,0,0.2);
    z-index: 99999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased; /* Giúp chữ mềm mại hơn trên Mac/Chrome */
    -moz-osx-font-smoothing: grayscale;
    border: 1px solid #e5e7eb;
}

/* Hiệu ứng mở chat */
.chat-window-container.active { display: flex; animation: slideInUp 0.3s ease-out; }
@keyframes slideInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* Mobile Responsive */
@media (max-width: 600px) {
    .chat-window-container { width: 95% !important; right: 2.5%; bottom: 90px; height: 70vh !important; }
}

/* =========================================================================
   3. HEADER
   ========================================================================= */
.chat-header {
    background: linear-gradient(135deg, #00C853 0%, #00963e 100%); /* Gradient cho đẹp */
    color: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.chat-header-info { display: flex; align-items: center; gap: 12px; }
.chat-header-avatar { 
    width: 40px; height: 40px; 
    border-radius: 50%; 
    background: #fff; 
    padding: 0px; 
    border: 1px solid #00C853; 
    object-fit: cover;
}
.chat-header-title { font-weight: 600; font-size: 18px; letter-spacing: -0.3px; }
.chat-close-btn { 
    background: transparent; 
    border: none; 
    color: white; 
    /* font-size: 20px;  */
    cursor: pointer; 
    padding: 5px; 
    /* opacity: 0.8; 
    transition: opacity 0.2s; */
    margin-top: 6px;

}
.chat-close-btn:hover { opacity: 1; }

/* =========================================================================
   4. BODY (NỘI DUNG CHAT) - Đã chỉnh sửa để tin nhắn rộng hơn
   ========================================================================= */
.chat-body {
    flex-grow: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 20px 15px; /* Giảm padding 2 bên để tăng diện tích hiển thị */
    background-color: #fff;
    display: flex;
    flex-direction: column;
    gap: 15px; /* Khoảng cách giữa các tin nhắn */
    scroll-behavior: smooth;
}

/* Thanh cuộn mảnh đẹp */
.chat-body::-webkit-scrollbar { width: 8px; }
.chat-body::-webkit-scrollbar-track { background: transparent; }
.chat-body::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 10px; }
.chat-body::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* --- Dòng tin nhắn chung --- */
.message-row {
    display: flex;
    align-items: flex-start; /* Căn avatar xuống đáy */
    gap: 8px;
    width: 100%;
}

/* Tin nhắn của BOT */
.bot-msg { justify-content: flex-start; }
.bot-msg .msg-content { 
    max-width: 85%; /* Cho phép tin nhắn bot chiếm 85% chiều rộng */
}
.bot-msg .msg-bubble {
    background-color: white; 
    color: #1f2937;
    border-bottom-left-radius: 4px; /* Bo góc đặc trưng */
    font-size: 18px;
}
/* Container của 5 chấm */
.typing-indicator-5 {
    display: flex;
    align-items: center;
    gap: 4px; /* Khoảng cách giữa các chấm */
    padding: 10px 15px;
    background: #f1f0f0; /* Màu nền của bong bóng chat */
    border-radius: 20px;
    width: fit-content;
}

/* Style chung cho từng chấm (tương đương h-2 w-2 rounded-full) */
.t-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    /* Animation bounce vô tận 1 giây */
    animation: monBounce 1s infinite;
}

/* Định nghĩa màu sắc */
.t-dot.dot-1 { background-color: #bbf7d0; } 
.t-dot.dot-2 { background-color: #22c55e; } 
.t-dot.dot-3 { background-color: #3b82f6; } 
.t-dot.dot-4 { background-color: #93c5fd; } 
.t-dot.dot-5 { background-color: #bfdbfe; } 

/* Định nghĩa Delay (để tạo hiệu ứng sóng) */
.t-dot.dot-1 { animation-delay: -0.4s; }
.t-dot.dot-2 { animation-delay: -0.3s; }
.t-dot.dot-3 { animation-delay: -0.2s; }
.t-dot.dot-4 { animation-delay: -0.1s; }
.t-dot.dot-5 { animation-delay: 0s; }

/* Keyframes tạo hiệu ứng nhún (tương đương animate-bounce) */
@keyframes monBounce {
    0%, 100% {
        transform: translateY(-25%);
        animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
    }
    50% {
        transform: translateY(0);
        animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
    }
}
/* Tin nhắn của USER */
.user-msg { 
    justify-content: flex-end; 
    flex-direction: row;       
}
.user-msg .msg-content {
    max-width: 80%; 
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}
.user-msg .msg-bubble {
    background-color: #00C853;
    color: white;
    border-bottom-right-radius: 4px;
    text-align: left; /* Text bên trong vẫn căn trái cho dễ đọc */
}

/* Avatar Bot */
.msg-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    flex-shrink: 0;
    object-fit: cover;
    margin-bottom: 20px; /* Căn chỉnh với dòng cuối cùng của bubble */
    border: solid 1px #00C853;
}

/* Bong bóng chat */
.msg-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    /* line-height: 1.5; */
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    overflow-wrap: break-word; 
    word-break: break-word; 
    max-width: 100%;
}

/* Thời gian */
.msg-time {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    color: #9ca3af;
    margin-top: 4px;
    margin-left: 2px;
}
.user-msg .msg-time { margin-right: 2px; }
/* =========================================================================
   5. LOADING DOTS (3 chấm đang gõ)
   ========================================================================= */
.typing-indicator {
    display: flex; gap: 4px; padding: 12px 16px !important;
    background-color: #f3f4f6 !important;
    width: fit-content;
}
.typing-dot {
    width: 6px; height: 6px; background: #6b7280; 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); } }

/* =========================================================================
   6. FOOTER (NHẬP LIỆU)
   ========================================================================= */
.chat-footer {
    padding: 0; 
    background-color: #fff;
    border-top: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column; 
    flex-shrink: 0;
}

/* --- Hàng chứa nút bấm và input --- */
.chat-bottom-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 15px; 
    width: 100%;
}

.chat-input-area {
    font-size: 17px !important;
    flex: 1;
    background: #f3f4f6;
    border-radius: 24px;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    min-height: 44px;
    border: 1px solid transparent;
    transition: border-color 0.2s;
}

.chat-input {
    border: none; background: transparent; width: 100%; outline: none;
    font-size: 18px; color: #111827; resize: none; overflow: hidden;
    line-height: 1.4; height: 22px; padding: 0; margin: 0;
    font-family: 'Inter', sans-serif;
}
.chat-input::placeholder { color: #9ca3af; }

.chat-action-btn, .chat-attack-btn {
    /* Code cũ của bạn giữ nguyên */
    border: none; cursor: pointer;
    padding: 14px; border-radius: 50%; transition: all 0.2s;
    display: flex; align-items: center; justify-content: center;
}
.chat-action-btn { background: #00C853; color: white; }
.chat-attack-btn { background: white; color: #374151; }
.chat-action-btn:hover { background-color: #00b34a; } 
.chat-attack-btn:hover { background-color: #f3f4f6; }

/* =========================================================================
   TRẠNG THÁI DISABLED CỦA NÚT GỬI
   ========================================================================= */

/* Khi button có thuộc tính disabled */
.chat-action-btn:disabled,
.chat-action-btn[disabled] {
    background-color: #e4e6eb !important;
    color: #bcc0c4 !important;  
    cursor: default !important;
    box-shadow: none !important;
    transform: none !important;
    opacity: 1 !important;
}

.chat-action-btn:disabled:hover {
    background-color: #e4e6eb !important;
}

.chat-action-btn:disabled svg path {
    stroke: #bcc0c4; 
}

.attachment-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #f9fafb; 
    padding: 8px 15px;
    border-bottom: 1px solid #f3f4f6;
    font-size: 13px;
    color: #4b5563;
    animation: slideDown 0.2s ease-out;
}
.attach-info {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 85%;
}
.attach-info i { color: #6b7280; }
.attach-info strong { color: rgb(10, 10, 10); font-weight: 600; }

.attach-remove {
    cursor: pointer;
    color: #ef4444; /* Màu đỏ */
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.attach-remove:hover { background-color: #fee2e2; }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================================================
   7. MARKDOWN STYLES (ĐÃ TỐI ƯU CHO BẢNG GIÁ VÀNG)
   ========================================================================= */
.markdown-content { font-size: 14px; color: #374151; }

/* Container Bảng */
.markdown-content table {
    display: block; width: 100%; overflow-x: auto;
    border-collapse: collapse; margin: 10px 0;
    border: 1px solid #e5e7eb; border-radius: 8px;
    white-space: nowrap; background-color: #fff;
    -webkit-overflow-scrolling: touch;
}
/* Scrollbar bảng */
.markdown-content table::-webkit-scrollbar { height: 6px; }
.markdown-content table::-webkit-scrollbar-track { background: #f9fafb; }
.markdown-content table::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }

.markdown-content thead { background-color: #f9fafb; border-bottom: 2px solid #e5e7eb; }
.markdown-content th { padding: 10px 15px; font-weight: 600; text-align: left; color: #111827; border-right: 1px solid #e5e7eb; font-size: 13px; }
.markdown-content td { padding: 10px 15px; border-bottom: 1px solid #e5e7eb; border-right: 1px solid #e5e7eb; color: #4b5563; font-size: 13px; }
.markdown-content th:last-child, .markdown-content td:last-child { border-right: none; }
.markdown-content tr:nth-child(even) { background-color: #f9fafb; }
.markdown-content tr:hover { background-color: #f0fdf4; }

/* Text Styles */
.markdown-content p { margin: 0 0 8px 0; }
.markdown-content p:last-child { margin-bottom: 0; }
.markdown-content ul, .markdown-content ol { margin: 5px 0 10px 20px; padding: 0; }
.markdown-content li { margin-bottom: 4px; }
.markdown-content a {  
    font-weight: 600; 
    text-decoration: underline !important; /* Bắt buộc gạch chân */
    word-break: break-word; /* Xuống dòng nếu link quá dài */ 
    color: black;
}
.markdown-content a:hover { color: #00963e }
.markdown-content strong { font-weight: 700; color: #111827; }

/* Thêm vào file chatbot.css */

/* Khi đang xử lý (loading) */
.chat-action-btn.btn-send.loading {
    background-color: #ff4d4f; /* Màu đỏ giống trong ảnh */
    border-color: #ff4d4f;
}

.chat-action-btn.btn-send.loading:hover {
    background-color: #d9363e;
}

/* Ẩn hiện icon */
.chat-action-btn.btn-send .icon-stopness {
    display: none;
    color: white; /* Icon màu trắng */
}

.chat-action-btn.btn-send.loading .icon-send {
    display: none !important;
}

.chat-action-btn.btn-send.loading .icon-stopness {
    display: inline-block !important;
}

