@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');

:root {
    --color-primary: #3498db; /* Blue */
    --color-primary-hover: #2980b9;
    --color-secondary: #6c757d; /* Gray */
    --color-secondary-hover: #5a6268;
    --color-success: #28a745;
    --color-danger: #dc3545; /* Red */
    --color-warning: #ffc107;
    --color-info: #17a2b8;
    --color-light: #f8f9fa;
    --color-dark: #343a40;

    --bg-light: #f7f7f7; /* Light mode main background */
    --bg-dark: #1f2937; /* Dark mode main background */
    --text-light: #2c3e50; /* Light mode text */
    --text-dark: #ecf0f1; /* Dark mode text */
    --border-light: #e0e0e0;
    --border-dark: #4b5563;
    --card-bg-light: #ffffff;
    --card-bg-dark: #2d3748;
    --input-bg-light: #ffffff;
    --input-bg-dark: #374151;
    --placeholder-light: #9ca3af;
    --placeholder-dark: #6b7280;
}

/* Base styles and dark mode toggle */
body {
    font-family: 'Roboto', sans-serif;
    margin: 0;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: var(--bg-light);
    color: var(--text-light);
    transition: background-color 0.3s ease, color 0.3s ease;
}

body.dark {
    background-color: var(--bg-dark);
    color: var(--text-dark);
}

/* Reset and basic utilities */
*, ::before, ::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    border: 0 solid var(--border-light);
}
body.dark *, body.dark ::before, body.dark ::after {
    border-color: var(--border-dark);
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    cursor: pointer;
    background: none;
    border: none;
    font-family: inherit;
    color: inherit;
    padding: 0;
}

input, textarea {
    font-family: inherit;
    color: inherit;
    background-color: var(--input-bg-light);
    border: 1px solid var(--border-light);
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease-in-out;
}
body.dark input, body.dark textarea {
    background-color: var(--input-bg-dark);
    border-color: var(--border-dark);
}
input::placeholder, textarea::placeholder {
    color: var(--placeholder-light);
}
body.dark input::placeholder, body.dark textarea::placeholder {
    color: var(--placeholder-dark);
}
input:focus, textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.flex-1 { flex: 1 1 0%; }
.flex-col { flex-direction: column; }
.flex-shrink-0 { flex-shrink: 0; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.w-full { width: 100%; }
.max-w-\[520px\] { max-width: 520px; }
.min-w-0 { min-width: 0; }
.h-6 { height: 1.5rem; }
.h-\[62px\] { height: 62px; }
.w-\[349px\] { width: 349px; }
.object-contain { object-fit: contain; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.rounded-full { border-radius: 9999px; }
.rounded-lg { border-radius: 0.5rem; }
.border { border-width: 1px; }
.border-b { border-bottom-width: 1px; }
.border-gray-100 { border-color: #f3f4f6; }
.border-gray-300 { border-color: #d1d5db; }
.dark\:border-gray-800 { border-color: var(--border-dark); } /* Custom */
.dark\:border-gray-700 { border-color: #374151; }
.dark\:border-gray-600 { border-color: #4b5563; }
.shadow-\[0_2px_10px_rgba\(0,0,0,0\.04\)\] { box-shadow: 0 2px 10px rgba(0,0,0,0.04); }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-gray-400 { color: #9ca3af; }
.text-gray-500 { color: #6b7280; }
.text-gray-600 { color: #4b5563; }
.text-gray-700 { color: #374151; }
.text-blue-500 { color: #3b82f6; }
.text-blue-600 { color: #2563eb; }
.text-yellow-600 { color: #d97706; }
.dark\:text-gray-200 { color: #e5e7eb; }
.dark\:text-gray-300 { color: #d1d5db; }
.dark\:placeholder-gray-500 { color: #6b7280; }
.focus\:outline-none:focus { outline: none; }
.focus\:ring-2:focus { --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color); --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color); box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000); }
.focus\:ring-blue-500:focus { --tw-ring-color: #3b82f6; }
.hover\:text-blue-600:hover { color: #2563eb; }
.hover\:bg-gray-100:hover { background-color: #f3f4f6; }
.dark\:hover\:bg-gray-800:hover { background-color: #1f2937; }
.transition-colors { transition-property: color, background-color, border-color, text-decoration-color, fill, stroke; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 0.15s; }
.transition-transform { transition-property: transform; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 0.15s; }
.top-0 { top: 0; }
.z-50 { z-index: 50; }
.z-10 { z-index: 10; }
.relative { position: relative; }
.absolute { position: absolute; }
.sticky { position: sticky; }
.-translate-y-1\/2 { transform: translateY(-50%); }
.right-3 { right: 0.75rem; }
.top-1\/2 { top: 50%; }
.bg-white { background-color: #fff; }
.dark\:bg-gray-900 { background-color: #111827; }
.cursor-pointer { cursor: pointer; }
.animate-pulse { animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }
@keyframes pulse {
    50% { opacity: .5; }
}
.text-white { color: #fff; }
.animate-in { animation: fadeIn 0.3s ease-out; } /* Custom */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-0.5rem); }
    to { opacity: 1; transform: translateY(0); }
}
.slide-in-from-top-2 { animation: slideInFromTop 0.5s ease-out; } /* Custom */
@keyframes slideInFromTop {
    from { transform: translateY(-0.5rem); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.animate-marquee { animation: marquee linear infinite; } /* Custom, duration set inline */
@keyframes marquee {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); } /* Half width, as content is duplicated */
}
.whitespace-nowrap { white-space: nowrap; }
.overflow-hidden { overflow: hidden; }
.font-medium { font-weight: 500; }
.md\:text-base { font-size: 1rem; line-height: 1.5rem; }
.p-1 { padding: 0.25rem; }

/* Custom scrollbar for category tabs */
.hide-scrollbar::-webkit-scrollbar { display: none; }
.hide-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* Dropdown styling */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background-color: var(--card-bg-light);
    border: 1px solid var(--border-light);
    border-radius: 0.375rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    min-width: 160px;
    padding: 0.5rem 0;
    z-index: 20;
    opacity: 0;
    visibility: hidden;
    transform: translateY(0.5rem);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}
body.dark .dropdown-menu {
    background-color: var(--card-bg-dark);
    border-color: var(--border-dark);
}

.dropdown:hover .dropdown-menu,
.dropdown.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--text-light);
    font-size: 0.875rem;
    white-space: nowrap;
}
body.dark .dropdown-item {
    color: var(--text-dark);
}

.dropdown-item:hover {
    background-color: #f3f4f6;
    color: var(--color-primary);
}
body.dark .dropdown-item:hover {
    background-color: #2d3748;
}

/* Category Navigation */
.category-nav-wrapper {
    position: relative;
}

.category-nav-wrapper .nav-scroll-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 36px; /* w-9 */
    height: 36px; /* h-9 */
    border-radius: 9999px; /* rounded-full */
    background-color: var(--card-bg-light);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); /* shadow-lg */
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease, background-color 0.2s ease;
}
body.dark .category-nav-wrapper .nav-scroll-btn {
    background-color: var(--card-bg-dark);
    border-color: var(--border-dark);
}

.category-nav-wrapper:hover .nav-scroll-btn {
    opacity: 1;
}

.category-nav-wrapper .nav-scroll-btn:hover {
    background-color: #f9fafb;
}
body.dark .category-nav-wrapper .nav-scroll-btn:hover {
    background-color: #2d3748;
}

.category-nav-wrapper .nav-scroll-btn.left-0 { left: 0; }
.category-nav-wrapper .nav-scroll-btn.right-0 { right: 0; }
.category-nav-wrapper .nav-scroll-btn i {
    color: var(--text-light); /* text-gray-700 */
    font-size: 0.75rem;
}
body.dark .category-nav-wrapper .nav-scroll-btn i {
    color: var(--text-dark);
}

.category-nav-wrapper .nav-scroll-btn.left-0 i { transform: rotate(90deg); }
.category-nav-wrapper .nav-scroll-btn.right-0 i { transform: rotate(-90deg); }


.category-tab, .subcategory-tab {
    padding: 0.5rem 0.75rem; /* px-3 py-2 */
    font-size: 0.875rem; /* text-sm */
    font-weight: 500; /* font-medium */
    white-space: nowrap;
    transition: all 0.2s ease-in-out;
    border-bottom: 2px solid transparent;
    color: var(--text-light);
}
body.dark .category-tab, body.dark .subcategory-tab {
    color: var(--text-dark);
}

.category-tab:hover, .subcategory-tab:hover {
    color: var(--color-primary);
}

.category-tab.active, .subcategory-tab.active {
    color: var(--color-primary);
    border-color: var(--color-primary);
}

/* * MAIN CONTENT GRID (Dùng cho cấu trúc HTML mới)
 * Loại bỏ class .grid cũ và thay bằng .resources-grid
 */
.resources-grid {
    display: grid;
    /* Cấu hình cột linh hoạt: Tối thiểu 200px, tự động lấp đầy khoảng trống */
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem; /* gap-6 */
}
/* Xóa các @media query cho .grid cũ */


/* ----------------------------------
 * MATERIAL CARD STYLES
 * ---------------------------------- */
.material-card {
    background-color: var(--card-bg-light);
    border-radius: 0.5rem; /* rounded-lg */
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow: hidden;
    position: relative;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    text-align: center;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}
body.dark .material-card {
    background-color: var(--card-bg-dark);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.material-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}
body.dark .material-card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.material-image-wrapper {
    position: relative;
    height: 180px; /* Adjust as needed */
    width: 100%;
    margin-bottom: 0.5rem;
    overflow: hidden;
    border-radius: 0.375rem;
}
/* Định nghĩa lại .material-image-wrapper bị lặp ở cuối file */
.material-image-wrapper {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
}

.material-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}
.material-card:hover .material-image {
    transform: scale(1.05);
}

.material-overlay {
    /* Hợp nhất các định nghĩa overlay bị lặp */
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: 0.25s ease;
    z-index: 2;
}
.material-card:hover .material-overlay {
    opacity: 1;
}

.material-button {
    background-color: var(--color-primary);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 0.2s ease;
}
.material-button:hover {
    background-color: var(--color-primary-hover);
}

.material-title {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 0.25rem;
}
body.dark .material-title {
    color: var(--text-dark);
}

.material-subtitle {
    font-size: 0.75rem;
    color: var(--placeholder-light);
}
body.dark .material-subtitle {
    color: var(--placeholder-dark);
}

/* BADGE BẢN QUYỀN */
.badge-copyright {
    position: absolute;
    top: 8px;
    left: 8px;
    background: linear-gradient(135deg, #ff6a00, #ff9500);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 999px;
    z-index: 3;
    pointer-events: none;
}

/* ----------------------------------
 * UTILITY STYLES
 * ---------------------------------- */

/* Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.25rem;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}
.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.btn-primary {
    background-color: var(--color-primary);
    color: white;
}
.btn-primary:hover {
    background-color: var(--color-primary-hover);
}

.btn-secondary {
    background-color: var(--color-secondary);
    color: white;
}
.btn-secondary:hover {
    background-color: var(--color-secondary-hover);
}

.btn-success {
    background-color: var(--color-success);
    color: white;
}
.btn-success:hover {
    background-color: #1e7e34;
}

/* Empty Message */
.empty-message {
    /* Đảm bảo style không bị conflict với Tailwind's hidden */
    display: flex !important; /* Mặc định là flex (để hiển thị trung tâm nếu cần) */
    justify-content: center;
    align-items: center;
    color: var(--text-light);
    background-color: transparent;
    text-align: center;
    padding: 2rem;
    font-weight: 500;
    font-size: 1.125rem;
}
body.dark .empty-message {
    color: var(--text-dark);
}


/* ----------------------------------
 * MODAL STYLES
 * ---------------------------------- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s;
}

.modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--card-bg-light);
    border-radius: 0.75rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    position: relative;
    padding: 2rem;
    max-width: 480px;
    width: 90%;
    transform: translateY(-20px);
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}
body.dark .modal-content {
    background-color: var(--card-bg-dark);
}
.modal-overlay.visible .modal-content {
    transform: translateY(0);
    opacity: 1;
}

.modal-content.bind-accounts-modal-content {
    max-width: 1000px;
}

.modal-close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-light);
    cursor: pointer;
    transition: color 0.2s ease;
}
body.dark .modal-close-btn {
    color: var(--text-dark);
}
.modal-close-btn:hover {
    color: var(--color-danger);
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    text-align: center;
    color: var(--text-light);
}
body.dark .modal-title {
    color: var(--text-dark);
}

.modal-subtitle {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--text-light);
}
body.dark .modal-subtitle {
    color: var(--text-dark);
}

.modal-form .form-group {
    margin-bottom: 1rem;
    position: relative;
}

.modal-form .input-icon-wrapper {
    position: relative;
}

.modal-form .input-icon-wrapper .icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--placeholder-light);
}
body.dark .modal-form .input-icon-wrapper .icon {
    color: var(--placeholder-dark);
}

.modal-form .input-field {
    width: 100%;
}

.error-message {
    color: var(--color-danger);
    font-size: 0.8rem;
    margin-top: 0.25rem;
    height: 1rem; /* Reserve space to prevent layout shifts */
}

.form-message {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.9rem;
}
.form-message.success {
    color: var(--color-success);
}
.form-message.error {
    color: var(--color-danger);
}


/* Bind Accounts Modal Styling */
.bind-accounts-modal-content .modal-title,
.bind-accounts-modal-content .modal-close-btn {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: var(--card-bg-light);
    padding: 2rem 2rem 0;
    margin: -2rem -2rem 0;
    border-top-left-radius: 0.75rem;
    border-top-right-radius: 0.75rem;
}
body.dark .bind-accounts-modal-content .modal-title,
body.dark .bind-accounts-modal-content .modal-close-btn {
    background-color: var(--card-bg-dark);
}

.bind-accounts-modal-content .modal-close-btn {
    padding: 1rem;
    top: 1rem;
    right: 1rem;
}

.bind-accounts-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.bind-card, .register-new-platform-card {
    background-color: var(--card-bg-light);
    border: 1px solid var(--border-light);
    border-radius: 0.75rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
body.dark .bind-card, body.dark .register-new-platform-card {
    background-color: var(--card-bg-dark);
    border-color: var(--border-dark);
}

.bind-card .card-header, .register-new-platform-card .card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background-color: #f9fafb; /* light-50 */
    border-bottom: 1px solid var(--border-light);
}
body.dark .bind-card .card-header, body.dark .register-new-platform-card .card-header {
    background-color: #374151; /* dark-700 */
    border-bottom-color: var(--border-dark);
}

.bind-card .platform-icon {
    width: 2rem;
    height: 2rem;
    object-fit: contain;
    font-size: 2rem;
    color: var(--color-primary);
}

.bind-card .card-title, .register-new-platform-card .card-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-light);
}
body.dark .bind-card .card-title, body.dark .register-new-platform-card .card-title {
    color: var(--text-dark);
}

.bind-card .card-body {
    padding: 1.5rem;
    flex-grow: 1;
}

.bind-card .card-body label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-light);
    margin-bottom: 0.25rem;
}
body.dark .bind-card .card-body label {
    color: var(--text-dark);
}

.bind-card .card-footer {
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    background-color: #f9fafb; /* light-50 */
    border-top: 1px solid var(--border-light);
}
body.dark .bind-card .card-footer {
    background-color: #2d3748;
    border-color: var(--border-dark);
}

.bind-card .card-footer .btn {
    width: auto;
}

.register-new-platform-card .table-container {
    overflow-x: auto;
}

.register-new-platform-card table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.register-new-platform-card th, .register-new-platform-card td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}
body.dark .register-new-platform-card th, body.dark .register-new-platform-card td {
    border-bottom-color: var(--border-dark);
}

.register-new-platform-card th {
    background-color: #e5e7eb;
    font-weight: 600;
    color: var(--text-light);
}
body.dark .register-new-platform-card th {
    background-color: #3d4653;
    color: var(--text-dark);
}

.register-new-platform-card tbody tr:nth-child(even) {
    background-color: #fdfdfd;
}
body.dark .register-new-platform-card tbody tr:nth-child(even) {
    background-color: #2f3844;
}

/* ----------------------------------
 * MEDIA QUERIES (RESPONSIVENESS)
 * ---------------------------------- */

@media (max-width: 768px) {
    /* Điều chỉnh cho modal Liên kết Tài khoản */
    .modal-content.bind-accounts-modal-content {
        width: 100%;
        max-width: 100%;
        margin: 1rem;
        padding: 1.5rem;
        max-height: 90vh;
        overflow-y: auto;
    }

    /* Điều chỉnh lưới Liên kết Tài khoản cho mobile */
    .bind-accounts-grid {
        grid-template-columns: 1fr;
    }

    /* Ẩn scrollbar cho Chrome, Edge, Safari */
    ::-webkit-scrollbar {
        width: 0;
        height: 0;
    }

    /* Ẩn scrollbar cho Firefox */
    html {
        scrollbar-width: none;
    }

    /* Ẩn scrollbar cho IE, Edge cũ */
    body {
        -ms-overflow-style: none;
    }
}

/* Xóa các style Admin Panel không cần thiết */

/* Ẩn/Hiện nội dung tab */
.tab-content .content {
    display: none;           /* ẩn tất cả nội dung */
    opacity: 0;
    transition: opacity 0.5s ease-in-out; /* hiệu ứng mờ dần */
}

.tab-content .content.active {
    display: block;          /* hiển thị nội dung hiện tại */
    opacity: 1;              /* mờ → hiện */
}

/* PHÂN TRANG (PAGINATION) STYLES */
#pagination button {
    min-width: 40px;
    height: 40px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    color: var(--text-color);
    padding: 8px 12px;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

/* Hiệu ứng Hover (chế độ sáng) */
#pagination button:hover:not(:disabled):not(.active) {
    background-color: #e5e7eb;
}

/* Hiệu ứng Hover (chế độ tối) */
.dark #pagination button:hover:not(:disabled):not(.active) {
    background-color: #3e4c5f;
}

/* Nút trang đang hoạt động (Active Page) */
#pagination button.active {
    background-color: var(--color-primary) !important;
    color: white !important;
    border-color: var(--color-primary) !important;
}

/* Nút bị vô hiệu hóa (Disabled - Trước/Sau ở trang đầu/cuối) */
#pagination button:disabled {
    cursor: not-allowed;
    background-color: #f3f4f6;
    color: #9ca3af;
    border-color: #f3f4f6;
    opacity: 0.6;
}
.dark #pagination button:disabled {
    background-color: #374151;
    color: #4b5563;
    border-color: #374151;
}
/* Lớp phủ chặn tương tác khi chưa đăng nhập */
.unauthorized-overlay {
    position: absolute;
    inset: 0; /* Đảm bảo lớp phủ che phủ toàn bộ material-card */
    background: rgba(0, 0, 0, 0.65); /* Màu đen trong suốt */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10; /* Đặt trên hình ảnh và nút khác */
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none; /* Rất quan trọng: Mặc định không chặn tương tác */
    border-radius: 12px; /* Đồng nhất với ảnh */
}

/* Hiển thị lớp phủ và chặn sự kiện chuột khi cần */
.unauthorized-overlay.visible {
    opacity: 1;
    pointer-events: auto; /* Chặn click khi lớp phủ hiển thị */
}

/* Ẩn hiệu ứng hover mặc định khi lớp phủ chặn đang hiển thị */
.material-card:has(.unauthorized-overlay.visible):hover {
    transform: none;
    box-shadow: none;
}
/* Đảm bảo khu vực nội dung chính sử dụng màu nền đồng nhất */
.main-content-area {
    /* Đảm bảo khu vực này luôn sử dụng màu nền chính của trang */
    background-color: var(--bg-main);

    /* Thiết lập padding-bottom để tạo khoảng trống dưới cùng */
    padding-bottom: 3rem;
}

/* Resources Grid: Đảm bảo nó có chiều cao tối thiểu để ngăn collapse */
.resources-grid {
    /* ... Giữ nguyên các thuộc tính khác ... */
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;

    /* [QUAN TRỌNG] Đảm bảo khu vực lưới luôn có chiều cao. */
    min-height: 40vh;
}

/* Empty Message: Đảm bảo nó chiếm đủ không gian khi hiển thị */
.empty-message {
    /* ... Giữ nguyên các thuộc tính khác ... */

    /* Đảm bảo nó chiếm toàn bộ chiều rộng của lưới */
    grid-column: 1 / -1;

    align-items: center;
    justify-content: center;

    /* [THÊM HOẶC CHỈNH SỬA] Chiều cao và nền */
    min-height: 250px;
    background-color: var(--bg-card); /* Sử dụng màu card để nó nổi bật một chút so với nền chính */
    border: 1px dashed var(--border-color);
    border-radius: 0.75rem;
}
/* Thiết lập lớp phủ loading */
.loading-overlay {
    position: absolute; /* Quan trọng: Đảm bảo nó che phủ iframe */
    top: 90px; /* Điều chỉnh dựa trên chiều cao của nút "Đóng Công cụ" */
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10; /* Cao hơn iframe */
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.9); /* Nền sáng */
    /* Tối ưu hóa cho chế độ tối */
    background-color: var(--bg-color-primary, #ffffff); /* Dùng biến CSS của Tailwind */
    color: var(--text-color-primary, #1f2937);
    border-radius: 8px;
    height: 80%; /* Chiều cao bằng với iframe */
}

/* Thiết lập biểu tượng spinner */
.spinner-icon {
    border: 4px solid #f3f3f3; /* Light grey */
    border-top: 4px solid #3b82f6; /* Blue */
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite; /* Tạo hiệu ứng xoay */
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Thêm tùy chỉnh cho chế độ tối (nếu cần) */
.dark .loading-overlay {
    background-color: var(--bg-color-dark, #1f2937);
    color: var(--text-color-dark, #f3f4f6);
}
/* Tùy chỉnh cho Nút Đóng Công cụ (#close-embed-btn) */
#close-embed-btn {
    /* Đảm bảo nút được hiển thị rõ ràng */
    padding: 8px 16px;
    border-radius: 9999px; /* Biến thành hình viên thuốc */
    font-weight: 600; /* Semi-bold */
    transition: all 0.2s ease-in-out;

    /* Thiết lập màu nền ban đầu (màu đỏ - danger) */
    background-color: #ef4444; /* red-500 */
    color: #ffffff;
    border: 1px solid #dc2626; /* red-600 */
}

/* Hiệu ứng khi di chuột qua (hover) */
#close-embed-btn:hover {
    background-color: #dc2626; /* red-600 */
    transform: translateY(-1px); /* Nâng nhẹ nút lên */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); /* Thêm bóng */
}

/* Tối ưu hóa cho chế độ tối (dark mode) */
html.dark #close-embed-btn {
    background-color: #b91c1c; /* red-700 tối */
    border-color: #991b1b; /* red-800 tối */
}

html.dark #close-embed-btn:hover {
    background-color: #7f1d1d; /* red-800 tối hơn */
    border-color: #7f1d1d;
}

/* Đảm bảo icon có khoảng cách với chữ */
#close-embed-btn i {
    margin-right: 8px;
}
/* 1. Ẩn thanh cuộn mặc định của các trình duyệt khác (Chủ yếu WebKit: Chrome, Safari) */
::-webkit-scrollbar {
    width: 12px; /* Độ rộng của thanh cuộn dọc */
    height: 12px; /* Độ cao của thanh cuộn ngang */
}

/* 2. Tạo rãnh (track) cho thanh cuộn */
::-webkit-scrollbar-track {
    background: #f1f1f1; /* Nền sáng */
    border-radius: 10px;
}

/* 3. Tạo thanh nắm (thumb) */
::-webkit-scrollbar-thumb {
    background: #888; /* Màu xám đậm */
    border-radius: 10px;
}

/* 4. Hiệu ứng khi di chuột qua thanh nắm */
::-webkit-scrollbar-thumb:hover {
    background: #555; /* Màu xám tối hơn */
}

/* 5. Tối ưu hóa cho Chế độ Tối (Dark Mode) */
html.dark ::-webkit-scrollbar-track {
    background: #1f2937; /* Màu nền tối (dark-gray-800) */
}

html.dark ::-webkit-scrollbar-thumb {
    background: #4b5563; /* Màu thanh nắm tối (dark-gray-600) */
}

html.dark ::-webkit-scrollbar-thumb:hover {
    background: #6b7280; /* Màu hover tối (dark-gray-500) */
}

/* TÙY CHỈNH CHO FIREFOX (Ít tùy biến hơn Webkit) */
/* Áp dụng cho body (toàn trang) */
body {
    scrollbar-color: #888 #f1f1f1; /* thumb color track color */
    scrollbar-width: thin; /* Kích thước thanh cuộn: auto, thin, none */
}

html.dark body {
    scrollbar-color: #4b5563 #1f2937;
}
/* ========================================================= */
/* 2. TÙY CHỈNH HỘP SELECT (SẮP XẾP THEO) */
/* ========================================================= */

/* Target the select element inside the sorting div */
.flex > span + label > select {
    /* Tắt mũi tên mặc định của trình duyệt */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;

    /* Thêm một chút padding để chừa chỗ cho mũi tên tùy chỉnh */
    padding-right: 25px;

    /* Đảm bảo nền màu trắng/tối theo chế độ */
    background-color: var(--bg-white, #FFFFFF);
    color: var(--text-color, #1a202c); /* Màu chữ */

    /* Thiết lập border cơ bản */
    border: 1px solid #E2E8F0;
    border-radius: 8px; /* Bo tròn góc */
}

/* Thêm mũi tên tùy chỉnh */
.flex > span + label {
    position: relative; /* Đảm bảo select box là vị trí tham chiếu */
}

.flex > span + label::after {
    content: '\f078'; /* Mã Unicode của icon Chevron Down (Font Awesome) */
    font-family: 'Font Awesome 6 Free'; /* Chỉ định Font Awesome */
    font-weight: 900;

    position: absolute;
    top: 50%;
    right: 8px; /* Vị trí mũi tên */
    transform: translateY(-50%);

    color: #4A5568; /* Màu icon */
    pointer-events: none; /* Đảm bảo có thể click qua icon để chọn */
    font-size: 10px;
}


/* --- Chế độ tối (Dark Mode cho Select) --- */
html.dark .flex > span + label > select {
    background-color: #2D3748; /* Dark Gray 800 */
    color: #EDF2F7; /* Light Gray 100 */
    border-color: #4A5568; /* Dark Gray 700 */
}

html.dark .flex > span + label::after {
    color: #A0AEC0; /* Light Gray 400 */
}
/* ========================================================= */
/* 2. TÙY CHỈNH THÔNG BÁO TÀI NGUYÊN (EMPTY MESSAGE) */
/* ĐÃ CHỈNH SỬA CHO KÍCH THƯỚC BÉ HƠN */
/* ========================================================= */

/* Áp dụng cho container chính */
.empty-message {
    display: flex;
    justify-content: center;
    align-items: center;

    /* 1. GIẢM CHIỀU CAO CONTAINER */
    min-height: 150px; /* Giảm từ 300px xuống 150px */

    width: 100%;

    /* 2. GIẢM KÍCH THƯỚC CHỮ */
    font-size: 1.2rem; /* Giảm từ 1.8rem xuống 1.2rem */

    font-weight: 700;
    flex-wrap: wrap;
    line-height: 1.2;
}

/* Các span (từng chữ cái) */
.empty-message span {
    display: inline-block;
    opacity: 1;
    margin: 0 1px;

    animation-name: colorChange, bounceEffect;
    animation-duration: 4s, 1s;
    animation-timing-function: linear, ease-in-out;
    animation-iteration-count: infinite, infinite;
    animation-direction: alternate, alternate;
}

/* -------------------------------------- */
/* @keyframes 2: Hiệu ứng Nhảy (Bounce) */
/* -------------------------------------- */
@keyframes bounceEffect {
    0%   { transform: translateY(0); }
    /* 3. GIẢM BIÊN ĐỘ NHẢY */
    50%  { transform: translateY(-2px); } /* Giảm từ -5px xuống -2px */
    100% { transform: translateY(0); }
}

/* @keyframes 1: Hiệu ứng Đổi Màu Cầu Vồng (GIỮ NGUYÊN) */
@keyframes colorChange {
    /* ... (Giữ nguyên) ... */
}
.page {
    display: none;
    animation: fade 0.4s ease;
}

.page.active {
    display: block;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 30px;
}

.pagination button {
    padding: 12px 28px;
    font-size: 18px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: #3498db;
    color: white;
    transition: 0.3s;
}

.pagination button:hover {
    background: #2980b9;
}

.pagination button:disabled {
    background: #777;
    cursor: not-allowed;
}

@keyframes fade {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}
