/* CSS giữ nguyên từ code trước */
body {
    font-family: "Inter", sans-serif;
    overflow: hidden; 
}

/* ĐÃ LOẠI BỎ body::before (chứa hình nền) */

#dataTable {
    border-collapse: separate;
    border-spacing: 0;
}

#dataTable thead {
    position: sticky;
    top: 0;
    z-index: 100;
}

#dataTable th {
    background-color: rgba(243, 236, 224, 0.98);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 0 #e5e7eb;
    white-space: nowrap; /* SỬA LỖI: Ưu tiên KHÔNG xuống dòng cho tiêu đề */
}

#dataTable tbody tr {
    cursor: pointer;
    transition: all 0.2s ease;
}

#dataTable tbody tr.highlighted {
    background-color: #fef3c7 !important;
    box-shadow: 0 0 0 2px #d97706;
    transform: scale(1.01);
}

mark {
    background-color: #fef9c3;
    padding: 0 2px;
    border-radius: 2px;
    color: #5c5c5c;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}
::-webkit-scrollbar-thumb {
    background-color: rgba(120, 83, 36, 0.5);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background-color: rgba(120, 83, 36, 0.7);
}

#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9998;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s, visibility 0.3s;
}
#loading-overlay.visible {
    visibility: visible;
    opacity: 1;
}

.spinner {
    width: 56px;
    height: 56px;
    border: 6px solid #f3f3f3;
    border-top: 6px solid #a16207;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* SỬA LỖI: Tách riêng rule cho td và th */
#dataTable td {
     white-space: normal;     /* Cho phép nội dung ô (td) xuống dòng */
     word-break: break-word;  /* Cho phép bẻ từ */
}

#dataTable td, #dataTable th {
     /* Rule chung cho cả td và th (đã bỏ white-space) */
     padding: 8px 6px;
     vertical-align: top;
     font-size: 0.8rem;
}

#dataTable th:first-child, #dataTable td:first-child {
     text-align: center;
     width: 40px;
     white-space: nowrap;
}

#details-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    /* ĐÃ XOÁ: backdrop-filter: blur(5px); */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    padding: 10px;
    box-sizing: border-box;
}
#details-modal.active {
    opacity: 1;
    visibility: visible;
}
#modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-body {
    padding: 0;
    flex-grow: 1;
    overflow-y: auto;
    max-height: calc(90vh - 70px);
}
.details-container {
    padding: 16px 20px;
}
.detail-item {
    display: flex;
    padding: 12px 0;
    border-bottom: 1px solid #f3f4f6;
    align-items: flex-start;
    gap: 12px;
}
.detail-item:last-child {
    border-bottom: none;
}
.detail-icon {
    width: 24px;
    text-align: center;
    color: #a16207;
    flex-shrink: 0;
    font-size: 1.1rem;
}
.detail-label {
    font-weight: 600;
    color: #4b5563;
    width: 120px;
    flex-shrink: 0;
    font-size: 0.9rem;
}
.detail-value {
    flex-grow: 1;
    color: #1f2937;
    font-size: 0.9rem;
    line-height: 1.5;
}
.modal-close-btn {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: #6b7280;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}
.modal-close-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

.position-info {
    background: #fef3c7;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.875rem;
    color: #92400e;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.goto-btn {
    background: #d97706;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
    margin-left: auto;
}

.goto-btn:hover {
    background: #b45309;
}

.smooth-transition {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.data-source-selector {
    min-width: 140px;
}

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    max-height: 150px;
    overflow-y: auto;
    z-index: 99;
    margin-top: 2px;
}

.suggestion-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.8rem;
}

.compact-control {
    padding: 8px 10px;
    font-size: 0.875rem;
    border-radius: 8px;
}

.filters-toggle {
    background: transparent;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
}

.filters-toggle:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

/* Thêm phần tối ưu hiệu suất cho việc tải nhiều dòng */
#dataTable tbody {
    will-change: transform;
}

#tableBody tr {
    contain: layout style;
}

/* Nút Tải Thêm - ĐÃ DI CHUYỂN XUỐNG CUỐI BẢNG */
.load-more-btn {
    background: #16a34a;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(22, 163, 74, 0.2);
    display: block;
    margin: 20px auto;
    width: fit-content;
}

.load-more-btn:hover {
    background: #15803d;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
}

.load-more-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.load-more-text {
    font-size: 0.9rem;
    font-weight: 600;
}

/* Cải tiến nút Về đầu trang */
.back-to-top-btn {
    position: fixed;
    bottom: 30px;
    right: 20px;
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
    z-index: 1000;
    transition: all 0.3s ease;
    opacity: 0;
    visibility: hidden;
}

.back-to-top-btn.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top-btn:hover {
    transform: translateY(-3px) scale(1.1);
    box-shadow: 0 6px 16px rgba(220, 38, 38, 0.4);
    background: linear-gradient(135deg, #b91c1c, #991b1b);
}

.back-to-top-btn i {
    font-size: 1.2rem;
}

/* Footer cải tiến */
footer {
    flex-shrink: 0;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    text-align: center;
    font-size: 0.75rem;
    color: #6b7280;
    border-top: 1px solid #e5e7eb;
    margin-top: auto;
}

/* Main area improvement */
#data-section {
    flex-grow: 1;
    overflow: auto;
    background: white;
    display: flex;
    flex-direction: column;
}

#table-container {
    flex-grow: 1;
    overflow: auto;
}

/* Điều chỉnh cho mobile */
@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }
    
    .mobile-only {
        display: flex !important;
    }
    
    #table-container {
        margin: 0 -4px;
        padding-bottom: 10px;
    }
    
    .compact-control {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
    
    header .container {
        padding: 12px 16px;
    }
    
    #dataTable td, #dataTable th {
        padding: 8px 6px;
        font-size: 0.8rem;
    }
    
    #dataTable th:first-child, #dataTable td:first-child {
        width: 40px;
    }
    
    .data-source-selector {
        min-width: 140px;
    }

    /* Điều chỉnh nút cho mobile */
    .load-more-btn {
        margin: 15px auto;
        padding: 14px 20px;
        font-size: 0.9rem;
    }

    .back-to-top-btn {
        bottom: 20px;
        right: 15px;
        width: 45px;
        height: 45px;
    }

    footer {
        padding: 6px 12px;
        font-size: 0.7rem;
    }
}

@media (min-width: 769px) {
    .mobile-only {
        display: none !important;
    }
}
/* Thêm vào cuối file CSS */

/* SEO Optimization Styles */
.seo-hidden {
    position: absolute;
    left: -10000px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Print Styles for Better SEO */
@media print {
    .back-to-top-btn,
    .load-more-btn,
    .filters-toggle {
        display: none !important;
    }
    
    #dataTable {
        width: 100% !important;
        font-size: 12pt !important;
    }
    
    #dataTable th {
        background-color: #f8f9fa !important;
        color: #000 !important;
    }
}

/* Enhanced Focus for Accessibility */
button:focus,
select:focus,
input:focus {
    outline: 2px solid #dc2626;
    outline-offset: 2px;
}

/* High contrast support */
@media (prefers-contrast: high) {
    #dataTable th {
        background-color: #ffffff;
        border: 2px solid #000000;
    }
    
    .back-to-top-btn {
        border: 2px solid #000000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .smooth-transition {
        transition: none !important;
    }
    
    .spinner {
        animation: none !important;
    }
}