/* public/css/style.css */

/* --- Bố cục tổng thể (Layout Grid) --- */
.subject-container {
    padding: 30px;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 24px;
    background: linear-gradient(to bottom, rgba(230, 243, 254, 0) 10%, #E6F3FE 30%);
    transition: grid-template-columns 0.3s ease;
}

[data-theme="dark"] .subject-container  {
    background: none;
}

/* --- Sidebar / Bộ lọc --- */
.sidebar {
    background-color: var(--bg-card);
    border: 1.5px solid var(--border-subtle);
    border-radius: 16px;
    padding: 24px;
    height: fit-content;
    width: 320px;
    box-sizing: border-box;
    overflow: hidden;
    flex-shrink: 0;
    pointer-events: auto;
    transition: width 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), 
                padding 0.3s ease, 
                opacity 0.2s ease, 
                border-color 0.3s ease,
                margin-right 0.3s ease;
}

.sidebar.collapsed {
    width: 0;
    padding-left: 0;
    padding-right: 0;
    opacity: 0;
    border-color: transparent;
    margin-right: -24px;
    pointer-events: none;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 12px;
    white-space: nowrap;
}

.sidebar-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Nút thu gọn / Đóng bộ lọc nhanh nằm ngay trong bộ lọc */
.btn-close-sidebar {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    transition: background-color 0.2s, color 0.2s;
}

.btn-close-sidebar:hover {
    background-color: var(--border-subtle);
    color: var(--accent-red);
}

.sidebar-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.return-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;

    width: fit-content;
    padding: 8px 12px;

    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;

    border-radius: 999px;
    transition: all .25s ease;
}

.return-btn:hover {
    color: var(--primary);
    transform: translateX(-2px);
}

.return-btn svg {
    width: 16px;
    height: 16px;
    transition: transform .25s ease;
}

.return-btn:hover {
    color: var(--primary);
    background: var(--border-subtle);
}

.return-btn:hover svg {
    transform: translateX(-4px);
}

.return-btn:active {
    transform: scale(.98);
}

.sidebar-header h2 {
    font-size: var(--font-size-md);
    margin: 0;
    font-weight: 700;
}

.btn-reset {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: var(--font-size-xs);
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.2s ease;
}

.btn-reset:hover {
    color: var(--accent-red);
}

.filter-group {
    margin-bottom: 24px;
    white-space: nowrap;
}

.filter-group:not(:last-child) {
    border-bottom: 1px dashed var(--border-subtle);
    padding-bottom: 20px;
}

.sidebar-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.filter-group {
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
}

.filter-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--font-size-md);
    font-weight: 600;
    margin-bottom: 16px;
}

.filter-title svg {
    width: 16px;
    height: 16px;
    transition: transform 0.3s ease;
}

.filter-group:hover .filter-title svg {
    transform: rotate(15deg) scale(1.1);
}

.filter-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.checkbox-label,
.radio-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: var(--font-size-base);
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s ease, transform 0.1s ease;
}

.checkbox-label:hover,
.radio-label:hover {
    color: var(--primary);
    transform: translateX(3px);
}

.checkbox-label input,
.radio-label input {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.checkbox-label input:hover,
.radio-label input:hover {
    transform: scale(1.2);
}

/* --- Khu vực nội dung chính --- */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Thanh tìm kiếm & Sắp xếp */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    width: 100%;
}

.btn-toggle-filter {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1.5px solid var(--border-subtle);
    border-radius: 20px;
    background-color: var(--bg-card);
    color: var(--text-main);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    outline: none;
}

.btn-toggle-filter:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: scale(1.05);
}

.btn-toggle-filter:active {
    transform: scale(0.95);
}

.btn-toggle-filter svg {
    width: auto;
    height: 20px;
}

.search-container {
    position: relative;
    flex: 1;
    min-width: 240px;
}

.search-input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    border: 1.5px solid var(--border-subtle);
    border-radius: 20px;
    background-color: var(--bg-card);
    color: var(--text-main);
    font-size: var(--font-size-sm);
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.sort-container {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap;
    justify-content: space-between;
}

.result-count {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap; /* Tránh vỡ chữ thông báo kết quả */
}

.sort-label {
    white-space: nowrap; /* Tránh vỡ chữ "Sắp xếp theo:" */
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

.sort-select {
    padding: 8px 16px;
    border: 1.5px solid var(--border-subtle);
    border-radius: 20px;
    background-color: var(--bg-card);
    color: var(--text-main);
    font-size: var(--font-size-sm);
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.sort-select:focus {
    border-color: var(--primary);
}

/* Khung hiển thị danh sách dạng lưới */
.doc-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    min-height: 400px;
    scroll-margin-top: 100px; 
}

/* Tablet */
@media (max-width: 992px) {
    .doc-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile */
@media (max-width: 576px) {
    .doc-grid {
        grid-template-columns: 1fr;
    }
}

/* --- Thiết kế Thẻ tài liệu (Card Component) --- */
.doc-card-2 {
    background-color: var(--bg-card);
    border: 2px solid var(--primary);
    border-radius: 24px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    font-family: var(--font-family);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
}

.doc-card-2:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
}

/* Phần hiển thị ảnh xem trước được tối ưu hóa thẩm mỹ */
.card-preview {
    position: relative;
    height: 200px;
    border-bottom: 2px solid var(--primary);
    overflow: hidden;
    background-color: #f7fafc;
}

/* Tạo lớp phủ bóng mờ nhẹ để nhãn đè lên ảnh trông hài hòa và rõ chữ */
.card-preview::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.35) 0%, rgba(0, 0, 0, 0) 40%);
    pointer-events: none;
    z-index: 2;
}

.preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    aspect-ratio: 16/9;
    transition: transform 0.4s ease;
}

.doc-card-2:hover .preview-img {
    transform: scale(1.05);
}

/* Nhãn đè góc trên của ảnh preview */
.badge-featured {
    position: absolute;
    top: 12px;
    left: 12px;
    background-color: var(--accent-yellow);
    color: #333333;
    font-size: var(--font-size-xs);
    font-weight: 700;
    padding: 6px 12px;
    /* border: 1.5px solid var(--primary); */
    border-radius: 12px;
    /* box-shadow: 2px 2px 0px var(--primary); */
    z-index: 10;
    animation: gentle-bounce 3s infinite ease-in-out;
}

.badge-grade {
    position: absolute;
    top: 12px;
    right: 12px;
    background-color: var(--accent-yellow);
    color: #333333;
    font-size: var(--font-size-xs);
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 12px;
    z-index: 10;
}

/* Nhãn định dạng file (Tinh chỉnh độ cao và đổ bóng) */
.format-pills {
    position: absolute;
    bottom: 12px; /* Đẩy cao hơn một chút để cân đối với viền dưới */
    left: 12px;
    display: flex;
    gap: 6px;
    z-index: 10;
}

.format-pill {
    font-size: var(--font-size-xs);
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.95);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.format-pdf {
    color: var(--accent-red);
    border: 1.5px solid var(--accent-red);
}

.format-word {
    color: var(--accent-blue);
    border: 1.5px solid var(--accent-blue);
}

.format-ppt {
    color: var(--accent-orange);
    border: 1.5px solid var(--accent-orange);
}

/* Phần thân chứa thông tin */
.card-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* Nhãn chuyên môn (Môn học & Loại bài giảng) */
.tag-pills {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.tag-pill {
    font-size: var(--font-size-xs);
    font-weight: 600;
    padding: 3px 12px;
    border-radius: 20px;
    color: #ffffff;
}

.tag-subject {
    background-color: var(--accent-blue);
}

.tag-category {
    background-color: var(--accent-purple);
}

/* Tiêu đề & mô tả */
.card-title {
    font-size: var(--font-size-base);
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 8px 0;
    line-height: 1.4;
    text-transform: uppercase;
}

.card-desc {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    margin: 0 0 16px 0;
    line-height: 1.4;
}

/* Thống kê tương tác & Giá bán */
.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.card-stats {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-main);
    font-size: var(--font-size-sm);
    font-weight: 600;
}

.stat-icon {
    width: 18px;
    height: 18px;
    transition: transform 0.3s ease;
}

.doc-card-2:hover .stat-icon {
    transform: scale(1.15);
}

.card-price {
    font-size: var(--font-size-md);
    font-weight: 700;
    color: var(--accent-red);
}

/* Nút hành động */
.card-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 16px;
}

.card-actions .btn {
    width: 100%;
    min-height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.25;
    cursor: pointer;
    text-decoration: none;
}

.card-actions .btn-icon {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
}

.card-actions .btn-preview {
    background-color: var(--accent-orange);
    color: #ffffff;
    border: none;
}

.card-actions .btn-preview svg {
    width: 20px;
    height: 20px;
}

.card-actions .btn-preview:hover {
    opacity: 0.7;
}

.card-actions .btn-preview:disabled {
    color: #8a8fa3;
    background: #f1f2f5;
    border-color: #d5d8e0;
    cursor: not-allowed;
    opacity: 0.75;
}

.card-actions .btn-buy-now {
    background-color: var(--accent-green);
    color: #ffffff;
    border: none;
}

.card-actions .btn-buy-now svg {
    width: 20px;
    height: 20px;
}

.card-actions .btn-buy-now:hover {
    opacity: 0.7;
}

.card-actions .btn-buy-now:disabled {
    color: #8a8fa3;
    background: #f1f2f5;
    border-color: #d5d8e0;
    cursor: not-allowed;
    opacity: 0.75;
}

.card-actions .btn-add-cart {
    background-color: var(--accent-blue);
    color: #ffffff;
    border: none;
}

.card-actions .btn-add-cart svg {
    width: 20px;
    height: 20px;
}

.card-actions .btn-add-cart:hover {
    opacity: 0.7;
}

.card-actions .btn-add-cart:disabled {
    color: #8a8fa3;
    background: #f1f2f5;
    border-color: #d5d8e0;
    cursor: not-allowed;
    opacity: 0.75;
}

/* ==========================================
   TRẠNG THÁI KHÓA CUỘN NỀN TRANG
   ========================================== */
.preview-modal-open {
    overflow: hidden;
}

/* ==========================================
   CSS CHO MODAL XEM TRƯỚC TÀI LIỆU (GENERAL)
   ========================================== */
.doc-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    overflow: hidden;
    align-items: center;
    justify-content: center;
}

.doc-modal.active {
    display: flex;
}

.doc-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
}

.doc-modal-container {
    position: relative;
    z-index: 1;
    width: min(920px, calc(100% - 30px));
    max-height: calc(100vh - 40px);
    margin: 20px auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.35);
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Header */
.doc-modal-header {
    padding: 16px 24px;
    background-color: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.doc-modal-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.doc-modal-badge {
    background-color: #fee2e2;
    color: #ef4444;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
    text-transform: uppercase;
    white-space: nowrap;
}

.doc-modal-title {
    font-size: 1.1rem;
    color: #1e293b;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 550px;
}

.doc-modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: #94a3b8;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
    padding: 0;
    margin-left: 16px;
}

.doc-modal-close:hover {
    color: #475569;
}

/* Body */
.doc-modal-body {
    position: relative;
    flex: 1;
    height: 65vh;
    min-height: 400px;
    padding: 0;
    overflow: hidden;
    background-color: #525659; /* Đổi sang màu nền tối để đồng bộ với thanh lề của trình đọc PDF */
}

/* Định dạng cho Iframe Viewer PDF */
#modal-pdf-viewer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    z-index: 1; /* Nằm dưới Loading indicator */
    background-color: #525659;
    display: block;
}

/* Ẩn iframe khi chưa tải xong nguồn src */
#modal-pdf-viewer[src=""],
#modal-pdf-viewer:not([src]) {
    display: none;
}

/* Trang tài liệu dạng ảnh (nếu hiển thị cuộn dọc thay vì iframe) */
.doc-modal-pages {
    width: 100%;
    max-width: 720px;
    height: 100%;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.preview-page-wrapper {
    position: relative;
    background-color: #ffffff;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

.preview-page-img {
    width: 100%;
    display: block;
    height: auto;
    user-select: none;
    -webkit-user-drag: none;
}

/* Tag số trang ở góc mỗi ảnh */
.page-number-tag {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background-color: rgba(15, 23, 42, 0.7);
    color: #ffffff;
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 4px;
    pointer-events: none;
}

/* Bộ chỉ báo Loading */
.doc-modal-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2; /* Đảm bảo luôn nằm trên Iframe khi đang tải */
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none; /* Tránh cản trở tương tác chuột */
    background-color: rgba(244, 246, 250, 0.9); /* Tạo một lớp nền mờ nhẹ phía sau chữ để dễ đọc hơn */
    padding: 20px 30px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.spinner {
    border: 4px solid #e2e8f0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border-left-color: #2563eb;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

.doc-modal-loading p {
    margin: 0;
    font-size: 0.9rem;
    color: #475569;
    font-weight: 500;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Footer */
.doc-modal-footer {
    padding: 16px 24px;
    background-color: #ffffff;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.doc-modal-footer-text {
    display: flex;
    flex-direction: column;
}

.doc-modal-footer-text strong {
    margin: 0;
    font-weight: 600;
    color: #334155;
    font-size: 0.95rem;
}

.doc-modal-footer-text span {
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 2px;
}

.btn-modal-action {
    background-color: #ff5722;
    color: #ffffff;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s;
    white-space: nowrap;
}

.btn-modal-action:hover {
    background-color: #e64a19;
}

/* ==========================================
   SLIDER TÀI LIỆU (NẾU SỬ DỤNG TRONG BODY)
   ========================================== */
.document-image-slider {
    width: 100%;
    padding: 24px;
    box-sizing: border-box;
    user-select: none;
}

.document-slider-main {
    position: relative;
    display: flex;
    align-items: center;
}

.document-slider-stage {
    position: relative;
    width: 100%;
    height: 480px;
    overflow: hidden;
    border: 1px solid #e2e7ef;
    border-radius: 14px;
    background: #f4f6f9;
    box-shadow: 0 8px 25px rgba(20, 35, 70, 0.08);
}

#document-slider-main-image {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    background: #f4f6f9;
    opacity: 1;
    transform: translateX(0) scale(1);
    transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease;
    will-change: transform, opacity;
}

#document-slider-main-image.slide-out-left {
    opacity: 0;
    transform: translateX(-45px) scale(0.985);
}

#document-slider-main-image.slide-out-right {
    opacity: 0;
    transform: translateX(45px) scale(0.985);
}

#document-slider-main-image.slide-from-right {
    opacity: 0;
    transform: translateX(45px) scale(0.985);
    transition: none;
}

#document-slider-main-image.slide-from-left {
    opacity: 0;
    transform: translateX(-45px) scale(0.985);
    transition: none;
}

.document-slider-arrow {
    position: absolute;
    top: 50%;
    z-index: 10;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(20, 35, 70, 0.78);
    color: #fff;
    font-size: 24px;
    line-height: 44px;
    cursor: pointer;
    transform: translateY(-50%);
    opacity: 0.82;
    backdrop-filter: blur(5px);
    transition: background 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
}

.document-slider-arrow:hover {
    opacity: 1;
    background: rgba(20, 35, 70, 0.95);
    transform: translateY(-50%) scale(1.08);
}

.document-slider-arrow:active {
    transform: translateY(-50%) scale(0.94);
}

.slider-prev {
    left: 16px;
}

.slider-next {
    right: 16px;
}

#document-slider-counter {
    position: absolute;
    right: 16px;
    bottom: 16px;
    z-index: 5;
    min-width: 58px;
    padding: 6px 12px;
    border-radius: 18px;
    background: rgba(0, 0, 0, 0.68);
    color: #fff;
    font-size: 13px;
    text-align: center;
    backdrop-filter: blur(5px);
}

.document-slider-thumbnails {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    padding: 5px 2px 10px;
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: thin;
}

.document-slider-thumbnail {
    flex: 0 0 92px;
    height: 72px;
    padding: 3px;
    overflow: hidden;
    border: 2px solid transparent;
    border-radius: 9px;
    background: #fff;
    cursor: pointer;
    opacity: 0.62;
    transform: translateY(0);
    transition: opacity 0.25s ease, border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.document-slider-thumbnail:hover {
    opacity: 1;
    transform: translateY(-3px);
}

.document-slider-thumbnail.active {
    opacity: 1;
    border-color: #2563eb;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.22);
}

.document-slider-thumbnail img {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 5px;
    object-fit: cover;
}

.document-slider-thumbnails::-webkit-scrollbar {
    height: 6px;
}

.document-slider-thumbnails::-webkit-scrollbar-thumb {
    border-radius: 10px;
    background: #c5ccd8;
}

.document-slider-thumbnails::-webkit-scrollbar-track {
    background: transparent;
}

.document-preview-empty {
    margin: 24px 0;
    padding: 50px 20px;
    border: 1px dashed #ccd2da;
    border-radius: 10px;
    background: #f8f9fa;
    color: #777;
    text-align: center;
}

/* ==========================================
   THIẾT KẾ ĐÁP ỨNG (RESPONSIVE)
   ========================================== */
@media (max-width: 768px) {
    .doc-modal-title {
        max-width: 280px;
    }

    .doc-modal-header {
        padding: 12px 16px;
    }

    .doc-modal-footer {
        padding: 12px 16px;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .doc-modal-footer-text {
        text-align: center;
    }

    .btn-modal-action {
        justify-content: center;
    }

    /* Slider trên mobile */
    .document-slider-stage {
        height: 380px;
        border-radius: 10px;
    }

    .document-slider-arrow {
        width: 38px;
        height: 38px;
        font-size: 20px;
        line-height: 38px;
    }

    .slider-prev {
        left: 9px;
    }

    .slider-next {
        right: 9px;
    }

    .document-slider-thumbnail {
        flex-basis: 76px;
        height: 60px;
    }
}

@media (max-width: 576px) {
    .doc-modal-container {
        width: 100%;
        height: 100%;
        max-height: none;
        margin: 0;
        border-radius: 0;
    }

    .doc-modal-body {
        height: auto;
        min-height: 0;
        flex: 1;
    }

    .document-slider-stage {
        height: 280px;
    }
}

/* Chế độ giảm chuyển động */
@media (prefers-reduced-motion: reduce) {
    #document-slider-main-image,
    .document-slider-arrow,
    .document-slider-thumbnail,
    .doc-modal-container {
        transition: none;
        animation: none;
    }

    .document-slider-thumbnails {
        scroll-behavior: auto;
    }
}


/* --- Phân trang (Pagination) --- */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 32px;
}

.page-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    text-decoration: none;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s, color 0.2s, transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.page-item.active {
    background-color: var(--primary);
    color: white;
    font-weight: bold;
}

.page-item:hover:not(.active) {
    background-color: var(--border-subtle);
    transform: translateY(-2px);
}

/* --- Hiệu ứng hoạt họa (Animations) --- */
@keyframes gentle-bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-4px);
    }
}

/* --- Khả năng hiển thị thích ứng (Responsive) --- */
@media (max-width: 992px) {
    .btn-close-sidebar,
    .btn-toggle-filter {
        display: flex;
    }

    .subject-container {
        grid-template-columns: 1fr;
        padding: 20px 16px;
        gap: 16px;
    }

    .sidebar {
        width: 100%;
        transition: max-height 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), 
                    padding 0.3s ease, 
                    opacity 0.2s ease, 
                    border-color 0.3s ease, 
                    margin-top 0.3s ease;
    }

    .sidebar.collapsed {
        width: 100%;
        max-height: 0;
        padding-top: 0;
        padding-bottom: 0;
        opacity: 0;
        border-color: transparent;
        margin-right: 0px;
        margin-top: -16px;
        pointer-events: none;
    }
}

@media (max-width: 768px) {
    /* Đưa thanh tìm kiếm và bộ lọc sắp xếp thành 2 dòng riêng biệt để chống tràn chữ */
    .top-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .search-container {
        max-width: 100%;
        width: 100%;
    }

    .sort-container {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        width: 100%;
    }
}

@media (max-width: 992px) {
    .sidebar {
        /* Đưa các thuộc tính ẩn/gập của class .collapsed vào đây */
        display: none; /* hoặc height: 0; tùy cấu trúc của bạn */
    }
    
    /* Khi người dùng chủ động bấm mở bộ lọc, ta mới dùng JS thêm class .show hoặc .active */
    .sidebar.active {
        display: block; 
    }
}

/* Trạng thái trên Desktop (> 992px) */
@media (min-width: 993px) {
    .sidebar {
        display: block; /* Luôn hiện trên desktop */
    }
}