/* Nền tối che toàn màn hình */
.modal-overlay {
    display: none; /* Mặc định ẩn */
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;     
    background: rgba(0, 0, 0, 0.4);
    z-index: 9999;    
    justify-content: center; align-items: center;
    backdrop-filter: blur(1px);
    -webkit-backdrop-filter: blur(1px);    
}

/* Khung nội dung Modal */
.modal-container {
    background: white;
    width: fit-content; 
    min-width: 400px;
    max-width: 50%;
    height: auto;
    max-height: 80vh;
    
    border-radius: 15px;
    padding: 30px 5px 30px 30px; /* Nhường lề bên phải cho thanh cuộn */
    position: relative;   
    overflow: hidden; /* Dòng này quan trọng: chặn không cho container bị cuộn */
    
    display: flex;
    flex-direction: column;
    animation: modalZoom 0.35s ease;
  
}


/* animation */
@keyframes modalZoom {
    from {
        opacity: 0;

        transform:
            scale(0.85)
            translateY(20px);

        filter: blur(3px);
    }

    to {
        opacity: 1;

        transform:
            scale(1)
            translateY(0);

        filter: blur(0);
    }
}

/* vùng cuộn riêng */
/* 3. Vùng cuộn riêng cho nội dung (Dùng đúng class .modal-scroll của bạn) */
.modal-scroll {
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(80vh - 60px); /* Trừ đi phần padding trên dưới */
    padding-right: 10px;          /* Đẩy thanh cuộn vào trong, không dính sát viền */
    margin-top: 10px;             /* Né nút đóng ra */
}

/* 4. Tùy chỉnh thanh cuộn 3px mảnh đẹp cho .modal-scroll */
.modal-scroll::-webkit-scrollbar {
    width: 2px;
}

.modal-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.modal-scroll::-webkit-scrollbar-thumb {
    background: #aaaaaa;
    
}

.modal-scroll::-webkit-scrollbar-thumb:hover {
    background: #0c826f;
}

.close-btn {
    position: sticky;
    top: -10px; float: right;
    font-size: 35px; cursor: pointer; color: #999;
}

.nutclose {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: #ffffff;
    
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    border: 2px solid #ffffff;
    transition: all 0.2s ease;
    z-index: 1001;
}

.nutclose:hover {
    background-color: #d9383a; 
    border-color: #d9383a;
    transform: scale(1.1);
}

/* Thêm hiệu ứng click chuột vào đây */
.nutclose:active {
    transform: scale(0.95);
    opacity: 0.9;
}

/* Định dạng nội dung file docx sau khi render */
.docx-render-wrapper img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 20px auto;
    border-radius: 4px;
}

/* Khung nền tổng thể chứa cả icon và tiêu đề */
.sources-wrapper {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;               /* Dùng gap để tự tạo khoảng cách giữa các phần tử */
    margin-top: 10px;
}

/* Nhãn chữ "Nguồn:" */
.source-label {
    color: var(--primary-color);
    font-size: 14px;
    font-weight: 500;
    line-height: 1;         /* Đảm bảo khung chữ không bị dừa viền thừa */
}

/* Thẻ nút nguồn */
.source-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    
    background: color-mix(in srgb, #e2e8f0 30%, transparent);
    padding: 2px 10px 2px 2px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    
    /* BỎ margin-right và margin-bottom ở đây */
    margin: 7px 1px 0px 1px;
    
    color: #3d5064;
    font-size: 14px;
    text-decoration: none;
    transition: all 0.2s ease;
}

/* Phần khối trắng chứa icon riêng biệt */
.source-link svg {    
    background: color-mix(in srgb, #ffffff 90%, transparent);    
    padding: 3px;              /* Khoảng trống quanh icon */
    border-radius: 6px;         /* Bo góc ô trắng chứa icon */
    
    width: 16px !important;    /* Giữ nguyên kích thước hiển thị của icon */
    height: 16px !important;
    box-sizing: content-box;   /* Đảm bảo padding không làm méo hoặc mất icon */
    flex-shrink: 0;
    margin-right: 0 !important; /* Xóa margin cũ trong inline-style của SVG */
    transition: transform 0.2s ease;
}

.source-link:hover svg {
    transform: scale(1.1);
    background: color-mix(in srgb, var(--primary-color, #0c826f) 20%, transparent);
    background: color-mix(in srgb, #ffffff 50%, transparent);   
}

/* Hiệu ứng rê chuột */
.source-link:hover {    
    background: color-mix(in srgb, var(--primary-color, #0c826f) 7%, transparent);
    border: 1px solid color-mix(in srgb, var(--primary-color, #0c826f) 20%, transparent);
    color: var(--primary-color);
    transform: translateX(3px); /* Nhích nhẹ sang phải khi hover */
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.04);
}
