﻿/* --- THT AI GLOBAL VARIABLES --- */
:root {
    --primary-tht: #1A59A8;
    --sidebar-bg: #0A2540;
    --sidebar-width: 280px;
    --z-sidebar: 9999;
    --z-overlay: 9998;
}

/* --- LAYOUT BASE --- */
#sidebar {
    width: var(--sidebar-width);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--sidebar-bg);
    z-index: var(--z-sidebar);
}

/* --- MOBILE RESPONSIVE (FIX LỖI MỜ & HIỂN THỊ) --- */
@media (max-width: 768px) {
    #sidebar {
        position: fixed !important;
        left: -280px; /* Ẩn mặc định */
        top: 0;
        bottom: 0;
    }

        #sidebar.open {
            left: 0 !important;
            box-shadow: 20px 0 50px rgba(0,0,0,0.5);
        }

    /* Lớp nền tối cho Mobile */
    #sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: var(--z-overlay);
    }

    #sidebar.open + #sidebar-overlay {
        display: block;
    }
}

/* --- DESKTOP LOGIC (COLLAPSED) --- */
@media (min-width: 769px) {
    #sidebar.collapsed {
        width: 0;
        opacity: 0;
        pointer-events: none;
        padding: 0;
    }
}

/* --- TYPOGRAPHY & MESSAGES --- */
.prose-content {
    font-size: 16px;
    line-height: 1.8;
    color: #334155 !important; /* Đảm bảo chữ rõ nét */
    width: 100%;
}

/* Bong bóng chat AI */
.ai-bubble {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

/* Bong bóng chat User */
.user-bubble {
    background: var(--primary-tht);
    color: #ffffff !important;
    box-shadow: 0 10px 15px -3px rgba(26, 89, 168, 0.2);
    word-break: break-word;
}

    .user-bubble * {
        color: #ffffff !important;
    }

/* Active State Sidebar */
.session-item.active {
    background: rgba(255, 255, 255, 0.15);
    border-left: 4px solid #38bdf8 !important;
    color: white !important;
}

/* --- SCROLLBAR (GIỮ NGUYÊN STYLE GỐC) --- */
#sidebar-content::-webkit-scrollbar {
    width: 4px;
}

#sidebar-content::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
}

#chat-box::-webkit-scrollbar {
    width: 6px;
}

#chat-box::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 10px;
}

/* --- CHAT BOX LAYOUT --- */
#chat-box {
    height: calc(100vh - 170px);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    scroll-behavior: smooth;
}

    /* Căn giữa màn hình chào mừng khi chưa có chat */
    #chat-box:not(:has(.message-in)) {
        justify-content: center;
        align-items: center;
    }

/* --- FORMAT NỘI DUNG AI (PROSE/MARKDOWN) --- */
.prose-content h1, .prose-content h2, .prose-content h3 {
    color: #0F172A;
    font-weight: 700;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    display: block;
}

.prose-content h1 {
    font-size: 1.2rem;
}

.prose-content h2 {
    font-size: 1.1rem;
    border-left: 5px solid #1A59A8;
    padding-left: 15px;
    margin-left: -5px;
    background: #f8fafc;
    padding-top: 5px;
    padding-bottom: 5px;
}

.prose-content h3 {
    font-size: 1rem;
}

.prose-content p {
    margin-bottom: 0.7rem;
}

.prose-content ul, .prose-content ol {
    margin-bottom: 1.2rem;
    padding-left: 1.8rem;
    display: block;
}

.prose-content ul {
    list-style-type: disc;
}

.prose-content ol {
    list-style-type: decimal;
}

.prose-content li {
    margin-bottom: 0.6rem;
    display: list-item;
}

.prose-content strong {
    color: #1A59A8;
    font-weight: 600;
}

/* Code block */
.prose-content pre {
    background: #1e293b;
    color: #f8fafc;
    padding: 1.25rem;
    border-radius: 0.75rem;
    margin: 1.5rem 0;
    overflow-x: auto;
    font-family: 'Consolas', monospace;
}

.prose-content code {
    background: #f1f5f9;
    color: #e11d48;
    padding: 0.2rem 0.4rem;
    border-radius: 0.3rem;
    font-size: 0.9em;
}

.prose-content pre code {
    background: transparent;
    color: inherit;
    padding: 0;
}

/* --- ANIMATION & TRANSITIONS --- */
.message-in {
    animation: fadeIn 0.4s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- FILE &VISION UI UPDATES --- */

/* Vùng kéo thả file */
#dropZone {
    transition: all 0.2s ease;
}

    #dropZone.border-blue-500 {
        border-style: dashed !important;
        border-width: 2px !important;
        background-color: rgba(56, 189, 248, 0.05);
    }

/* Hiển thị file preview đang chờ gửi */
#filePreviewContainer:empty {
    display: none;
}

.animate-in {
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Link tải file trong bong bóng chat */
.user-bubble a {
    text-decoration: none !important;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
}

    .user-bubble a:hover {
        transform: translateY(-2px);
        background: rgba(255, 255, 255, 0.25) !important;
    }

/* Icon download shadow */
.fa-file-arrow-down {
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}
