@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: "Inter", sans-serif;
}

body {
    margin: 0;
    background-color: #fff;
    min-height: 100dvh;
}

.logo {
    display: block;
    width: 100px;
    height: 100px;
    user-select: none;
    cursor: pointer;
}

@media (max-width: 400px) {
    .logo {
        margin: 0 auto;
    }
}

.container {
    width: 100%;
    margin: auto;
    background-color: transparent;
    padding: 10px;
    height: 100%;
}

/* Popup */

.popup {
    display: block;
    position: fixed;
    width: 100vw;
    height: 100vh;
    top: 0;
    left: 0;
    background-color: rgba(0,0,0,0.5);
    z-index: 999999;
}

.popup-content {
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #fff;
    width: calc(100% - 10px);
    max-width: 600px;
    height: auto;
    max-height: calc(100% - 10px);
    display: flex;
    flex-direction: column;
    padding: 20px;
    border-radius: 12px;
}

#popup-close {
    background-color: transparent;
    width: 20px;
    height: 20px;
    border: none;
    cursor: pointer;
    position: absolute;
    top: 20px;
    right: 20px;
    transition: .2s ease-in-out;
}

#popup-close img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#popup-close:hover {
    transform: scale(1.1);
}

#popup-logo {
    width: 80px;
    margin: 0 auto 15px auto;
}

.popup-text {
    font-size: 16px;
    color: #333;
}

.logo-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 30px;
    justify-content: space-around;
}

.logo-item {
    flex: 0 0 calc(33.333% - 20px);
    box-sizing: border-box;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.logo-image {
    height: 60px;
    width: 100%;
    object-fit: contain;
    margin: 0 auto;
    flex-shrink: 0;
}

.logo-text {
    font-size: 14px;
    color: #333;
    font-weight: 500;
    font-style: italic;
}

@media (max-width: 768px) {
    .popup-content {
        padding: 10px;
    }
    .popup-text {
        font-size: 14px;
    }
    .logo-image {
        height: 40px; 
    }
    .logo-text {
        font-size: 12px;
    }
    #popup-logo {
        width: 55px;
        margin: 0 auto 8px auto;
    }
    .logo-container {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        margin-top: 15px;
        justify-content: space-around;
    }
}

/* Popup */

h1 {
    text-align: center;
    color: #333;
}

.item-year-slider {
    font-size: 18px;
    display: block;
    margin-top: 5px;
    font-weight: 500;
    color: #333;
}

.search-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.search-controls > div {
    flex: 1 1 200px;
    display: flex;
    flex-direction: column;
}

.search-controls label {
    margin-bottom: 5px;
    font-weight: bold;
    font-size: 0.9em;
    color: #555;
}

.search-controls input[type="text"],
.search-controls input[type="number"],
.search-controls select {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 1em;
    outline: none;
}

.date-range-inputs {
    display: flex;
    gap: 10px;
}
.date-range-inputs input {
    width: 100%;
}


#loading-spinner {
    display: none;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3498db;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

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

#search-result-count {
    text-align: center;
    font-weight: bold;
    margin-bottom: 15px;
    font-size: 1.1em;
    color: #333;
}

#results-container {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    min-height: 50px;
}

#results-container p.initial-message {
    width: 100%;
    text-align: center;
    color: #777;
    font-style: italic;
    margin-top: 20px;
}

.result-item {
    width: 300px;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    transition: box-shadow 0.3s ease, transform 0.2s ease;
    background-color: #fff;
    position: relative;
    display: flex;
    flex-direction: column;
}

.result-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-3px);
}

.result-item img, .result-item .image-placeholder {
    width: 100%;
    height: 500px;
    object-fit: cover;
    border-radius: 3px;
    margin-bottom: 5px;
}
.result-item .image-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #ddd;
    color: #888;
    font-size: 0.9em;
    background-color: #f9f9f9;
}
.result-item .title-tooltip {
    visibility: hidden;
    width: max-content;
    max-width: 250px;
    background-color: #555;
    color: #fff;
    text-align: left;
    border-radius: 6px;
    padding: 8px;
    position: absolute;
    z-index: 1;
    bottom: 105%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.85em;
    white-space: normal;
}
    .result-item .title-tooltip p {
    margin: 2px 0;
    }


.result-item:hover .title-tooltip {
    visibility: visible;
    opacity: 1;
}

/* ----- Modal Item Details Styles - Fullscreen ----- */
.modal { /* For item details modal */
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100vw; /* Chiếm toàn bộ chiều rộng viewport */
    height: 100vh; /* Chiếm toàn bộ chiều cao viewport */
    overflow: hidden; /* Ngăn body cuộn khi modal mở */
    background-color: rgba(0,0,0,0.7); /* Tăng độ mờ nền */
}

.modal-outer-wrapper {
    width: 100%; /* Chiếm toàn bộ không gian của modal */
    height: 100%;
    margin: 0; /* Bỏ margin mặc định */
    max-width: none; /* Bỏ max-width mặc định */
    padding: 20px; /* Khoảng đệm nhỏ xung quanh modal-content */
    display: flex; /* Để căn giữa modal-content (nếu cần, nhưng ở đây content chiếm full) */
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: #fefefe;
    padding: 20px; /* Padding bên trong modal content */
    border: 1px solid #888;
    border-radius: 8px; /* Giữ lại bo góc cho đẹp */
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    position: relative;
    width: 100%; /* Chiếm toàn bộ .modal-outer-wrapper (sau padding) */
    height: 100%; /* Chiếm toàn bộ .modal-outer-wrapper (sau padding) */
    display: flex;
    flex-direction: column; /* Để title ở trên, body ở dưới và co giãn */
    overflow: hidden; /* Ngăn modal-content tự cuộn */
}

.modal-close {
    color: #aaa;
    position: absolute;
    top: 15px; /* Điều chỉnh vị trí nút đóng */
    right: 20px;
    font-size: 32px; /* Tăng kích thước nút đóng */
    font-weight: bold;
    cursor: pointer;
    z-index: 1005; /* Đảm bảo nằm trên cùng */
}
.modal-close:hover,
.modal-close:focus {
    color: black;
    text-decoration: none;
}

.modal-nav-item { /* Nút điều hướng item (trước/sau) */
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(0,0,0,0.4);
    color: white;
    border: none;
    font-size: 22px;
    cursor: pointer;
    border-radius: 50%;
    user-select: none;
    z-index: 1002;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    transition: background-color 0.2s;
}
.modal-nav-item:hover { background-color: rgba(0,0,0,0.7); }
.modal-nav-item.prev-item { left: 15px; }
.modal-nav-item.next-item { right: 15px; }
.modal-nav-item:disabled { opacity: 0.3; cursor: not-allowed; }

#modalItemTitle {
        margin-top: 0;
        margin-bottom: 15px;
        font-size: 1.8em; /* Tăng kích thước title */
        color: #333;
        padding-right: 40px; /* Khoảng trống cho nút close */
}

.modal-body-container {
    flex-grow: 1; /* Chiếm hết không gian dọc còn lại */
    display: flex;
    flex-direction: row;
    gap: 20px; /* Khoảng cách giữa image pane và info pane */
    /* margin-top: 0;  Bỏ margin-top vì #modalItemTitle đã có margin-bottom */
    overflow: hidden; /* Ngăn body-container tự cuộn, các pane con sẽ cuộn */
}

.modal-image-pane {
    flex: 0 0 70%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    user-select: none;
    background-color: #f0f0f0; /* Màu nền nhẹ cho image pane */
    border-radius: 4px;
}

#modalMainImage {
    max-width: 100%;
    max-height: calc(100% - 40px); /* Trừ không gian cho image-nav-buttons nếu có */
    object-fit: contain;
    border: none; /* Bỏ border vì đã có nền cho pane */
    border-radius: 4px;
    display: block;
    transform-origin: center center;
}

.image-nav-buttons {
    display: none;
    justify-content: space-between;
    align-items: center;
    width: 80%;
    margin-top: 10px;
    position: absolute; /* Để nằm trên ảnh nếu cần */
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
}
.image-nav-btn {
    background-color: rgba(0,0,0,0.4);
    color: white; border: none; padding: 8px 12px;
    font-size: 18px; cursor: pointer; border-radius: 4px;
    user-select: none; transition: background-color 0.2s;
}
.image-nav-btn:hover { background-color: rgba(0,0,0,0.7); }
.image-nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }

#modalImageCounter { font-size: 0.9em; color: #fff; background-color: rgba(0,0,0,0.4); padding: 2px 8px; border-radius:3px; margin: 0 10px; }
#modalImageError, #modalNoImage { text-align:center; color:#555; margin-top:10px; width: 100%; font-size: 1.1em; }

.modal-info-pane {
    flex: 1 1 30%; /* Thông tin chiếm 30% chiều rộng */
    overflow-y: auto; /* Cho phép cuộn nếu nội dung dài */
    padding-left: 20px;
    padding-right: 10px; /* Thêm padding phải */
    border-left: 1px solid #ccc; /* Đường phân cách rõ hơn */
    max-height: 100%; /* Đảm bảo không vượt quá chiều cao body container */
}
#modal-details-content p { margin: 10px 0; line-height: 1.7; font-size:0.95em; }
#modal-details-content strong { color: #333; }

@media (max-width: 768px) {
    .modal-body-container {
        flex-direction: column;
        gap: 5px;
    }
    .modal-image-pane {
        flex: 0 0 60%;
    }
    #modalItemTitle {
        margin-bottom: 10px;
        font-size: 1.2em;
    }
    .modal-outer-wrapper {
        padding: 5px;
    }
    .modal-content {
        padding: 10px;
    }
    .modal-info-pane {
        flex: 1 1 40%;
        overflow-y: auto;
        padding-left: 0px;
        padding-right: 0px;
        border-left: none;
        max-height: 100%;
    }
    .modal-close {
        top: 10px;
        right: 15px;
    }
}

/* ----- Styles for Image Zoom Modal (modal zoom chi tiết) ----- */
.modal-zoom {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.85);
    justify-content: center;
    align-items: center;
}

.modal-zoom-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 2010;
}
.modal-zoom-close:hover,
.modal-zoom-close:focus {
    color: #bbb;
    text-decoration: none;
}

.modal-zoom-content-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#zoomedImage {
    max-width: 95vw;
    max-height: 95vh;
    object-fit: contain;
    cursor: grab;
    transition: transform 0.05s linear;
    transform-origin: center center;
    will-change: transform;
}

.zoom-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(40,40,40,0.7);
    padding: 10px;
    border-radius: 5px;
    display: flex;
    gap: 10px;
    z-index: 2010;
    user-select: none;
}

.zoom-controls button {
    background-color: #555;
    color: white;
    border: none;
    padding: 8px 12px;
    font-size: 16px;
    border-radius: 3px;
    cursor: pointer;
}
.zoom-controls button:hover {
    background-color: #777;
}
.zoom-controls button:disabled {
    background-color: #333;
    color: #888;
    cursor: not-allowed;
}

.modal-image-pane {
    flex: 0 0 70%; /* Ảnh chiếm 70% chiều rộng */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative; /* Quan trọng cho spinner và nút mở tab mới */
    overflow: hidden;
    user-select: none;
    background-color: #f0f0f0; /* Màu nền nhẹ cho image pane */
    border-radius: 4px;
}

/* Spinner cho ảnh trong modal */
.modal-image-loader {
    display: none; /* Ẩn mặc định */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* Căn giữa spinner */
    border: 4px solid #f3f3f3; /* Light grey */
    border-top: 4px solid #3498db; /* Blue */
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite; /* Sử dụng animation spin đã có */
    z-index: 5; /* Nằm trên ảnh nhưng dưới các nút điều khiển khác nếu có chồng chéo */
}
/* Nút mở ảnh trong tab mới */
.open-new-tab-btn {
    display: none; /* Ẩn mặc định */
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: rgba(0,0,0,0.5);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 16px;
    cursor: pointer;
    z-index: 6; /* Đảm bảo nút có thể click được */
    transition: background-color 0.2s;
}
.open-new-tab-btn:hover {
    background-color: rgba(0,0,0,0.8);
}


#modalMainImage {
    max-width: 100%;
    max-height: calc(100% - 40px); /* Trừ không gian cho image-nav-buttons nếu có */
    object-fit: contain;
    border: none;
    border-radius: 4px;
    display: block;
    transform-origin: center center;
}

/* Thêm CSS cho pagination */
#pagination-controls-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 0;
    flex-wrap: wrap; /* Cho phép xuống dòng nếu không đủ chỗ */
    user-select: none; /* Tránh chọn text khi click nhanh */
}

#pagination-controls-container button,
#pagination-controls-container span.page-number-btn { /* Đổi span thành button hoặc style giống button */
    margin: 0 5px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    background-color: #f9f9f9;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.9em;
    min-width: 38px; /* Đảm bảo các nút số có chiều rộng tương đối đồng đều */
    text-align: center;
}

#pagination-controls-container button:hover,
#pagination-controls-container span.page-number-btn:hover {
    background-color: #e9e9e9;
}

#pagination-controls-container button:disabled,
#pagination-controls-container span.page-number-btn.current-page { /* Style cho trang hiện tại */
    background-color: #3498db;
    color: white;
    border-color: #3498db;
    cursor: default;
}
#pagination-controls-container button:disabled:not(.current-page){ /* Style cho nút prev/next bị disable */
    background-color: #f5f5f5;
    color: #ccc;
    cursor: not-allowed;
    border-color: #eee;
}


#pagination-controls-container span.ellipsis {
    border: none;
    background-color: transparent;
    padding: 8px 2px; /* Giảm padding cho ellipsis */
    cursor: default;
}
.search-controls select#itemsPerPageSelect {
    /* Đảm bảo select này có style giống các input khác nếu cần */
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 1em;
    width: 100%; /* Chiếm toàn bộ không gian của div cha */
}

/* ----- Random Items Slider Styles ----- */
#random-items-slider-container {
    margin-bottom: 30px;
    padding: 20px 15px 15px 15px; /* Thêm padding trên */
    border-radius: 8px;
    overflow: hidden; /* Quan trọng để các nút điều hướng không làm vỡ layout */
}

#random-items-slider-container h2 {
    text-align: center;
    margin-bottom: 20px;
    color: #333;
    font-size: 1.6em; /* Tăng kích thước tiêu đề */
    font-weight: 500;
}

.slider-navigation {
    display: flex;
    align-items: center; /* Căn giữa các nút và wrapper theo chiều dọc */
    justify-content: space-between; /* Đẩy các nút ra hai bên */
}

.slider-navigation button {
    background-color: rgba(52, 152, 219, 0.8); /* Màu xanh dịu hơn, có độ trong */
    color: white;
    border: none;
    padding: 10px; /* Padding đều cho nút tròn hơn */
    font-size: 1.8em; /* Tăng kích thước icon mũi tên */
    border-radius: 50%; /* Nút tròn */
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    width: 45px; /* Kích thước cố định cho nút */
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1; /* Căn icon mũi tên vào giữa */
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    flex-shrink: 0
}

.slider-navigation button:hover {
    background-color: #3498db; /* Đậm hơn khi hover */
    transform: scale(1.05); /* Hiệu ứng phóng to nhẹ */
}
.slider-navigation button:active {
    transform: scale(0.98);
}

.slider-wrapper {
    flex-grow: 1; /* Cho phép wrapper chiếm hết không gian còn lại */
    overflow-x: hidden; /* Quan trọng: Ẩn scrollbar ngang của wrapper */
    margin: 0 5px; /* Khoảng cách giữa nút và slider content */
}

.slider-content {
    display: flex; /* Các item nằm trên một hàng */
    gap: 15px;
    padding: 5px 0; /* Chỉ padding trên dưới cho content */
    /* transition: transform 0.5s ease-in-out; */ /* Bỏ transition này vì ta sẽ render lại */
}

.slider-item {
    flex: 0 0 220px; /* Chiều rộng cố định cho mỗi item, không co giãn, tăng nhẹ */
    border: 1px solid #e0e0e0; /* Border nhạt hơn */
    border-radius: 6px; /* Bo góc nhẹ hơn */
    padding: 10px;
    text-align: center;
    cursor: pointer;
    transition: box-shadow 0.3s ease, transform 0.2s ease;
    background-color: #fff;
    position: relative;
    display: flex;
    flex-direction: column;
    height: auto;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.slider-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-3px);
}

.slider-item img, .slider-item .image-placeholder {
    width: 250px;
    height: 300px; /* Chiều cao cố định cho ảnh trong slider item, tăng nhẹ */
    object-fit: cover;
    border-radius: 4px; /* Bo góc ảnh */
    margin: 0 auto 8px auto;
}
.slider-item .image-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e0e0e0;
    color: #888;
    font-size: 0.9em;
    background-color: #f5f5f5;
}

/* Tooltip cho slider item, có thể kế thừa từ .result-item .title-tooltip nếu muốn */
.slider-item .title-tooltip {
    visibility: hidden;
    width: max-content;
    max-width: 200px;
    background-color: #333; /* Nền tối hơn */
    color: #fff;
    text-align: left;
    border-radius: 5px;
    padding: 8px 10px;
    position: absolute;
    z-index: 10;
    bottom: 103%; /* Điều chỉnh vị trí tooltip */
    left: 50%;
    transform: translateX(-50%) translateY(5px); /* Hiệu ứng xuất hiện từ dưới lên */
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
    font-size: 0.85em;
    white-space: normal;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.slider-item .title-tooltip p {
    margin: 3px 0;
}
.slider-item:hover .title-tooltip {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.slider-item .item-title-slider {
    font-size: 0.95em;
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
    max-width: 100%;
}
.slider-item .item-ref-slider {
    font-size: 0.8em;
    color: #777;
}

/* Responsive cho slider (tùy chọn) */
@media (max-width: 768px) {
    #random-items-slider-container h2 {
        font-size: 1.3em;
        margin-top: 15px;
        margin-bottom: 10px;
    }
    .slider-item {
        flex: 0 0 180px;
        height: 320px;
    }
    .slider-item img, .slider-item .image-placeholder {
        height: 220px;
    }
    .slider-navigation button {
        padding: 8px;
        font-size: 1.5em;
        width: 40px;
        height: 40px;
    }
}
@media (max-width: 480px) {
    .slider-item {
        flex: 0 0 150px;
        height: 280px;
    }
    .slider-item img, .slider-item .image-placeholder {
        height: 180px;
    }
    #random-items-slider-container {
        padding: 0;
    }
    .slider-wrapper {
        overflow-x: auto;
         -webkit-overflow-scrolling: touch;
    }
    .slider-wrapper::-webkit-scrollbar {
        height: 5px;
    }
    .slider-wrapper::-webkit-scrollbar-thumb {
        background: #ccc;
        border-radius: 10px;
    }
}