/* คอนเทนเนอร์หลัก */
.img-it-upload-container {
    max-width: 100%;
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Dropzone */
.img-it-upload-dropzone {
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background-color: #f9f9f9;
}

.img-it-upload-dropzone:hover,
.img-it-upload-dropzone.highlight {
    border-color: #3498db;
    background-color: #f0f8ff;
}

.img-it-upload-icon {
    margin-bottom: 15px;
}

.img-it-upload-icon svg {
    fill: #666;
    transition: fill 0.3s ease;
}

.img-it-upload-dropzone:hover .img-it-upload-icon svg,
.img-it-upload-dropzone.highlight .img-it-upload-icon svg {
    fill: #3498db;
}

.img-it-upload-text {
    color: #666;
    font-size: 16px;
    transition: color 0.3s ease;
}

.img-it-upload-dropzone:hover .img-it-upload-text,
.img-it-upload-dropzone.highlight .img-it-upload-text {
    color: #3498db;
}

/* คอนเทนเนอร์สำหรับพรีวิว */
.img-it-upload-preview-container {
    margin-top: 30px;
}

/* ส่วนหัวของพรีวิว */
.img-it-upload-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.img-it-upload-header h3 {
    margin: 0 0 10px 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.img-it-image-count {
    color: #666;
    font-weight: normal;
}

/* ช่องค้นหา */
.img-it-search-container {
    position: relative;
    margin-bottom: 10px;
}

#img-it-search {
    padding: 8px 32px 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    width: 250px;
    max-width: 100%;
}

#img-it-search:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

#img-it-search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #999;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    width: 16px;
    height: 16px;
    line-height: 16px;
}

#img-it-search-clear:hover {
    color: #e74c3c;
}

/* กริดแสดงรูปภาพ */
.img-it-upload-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    min-height: 200px;
}

/* Skeleton Loading */
.img-it-skeleton-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    min-height: 200px;
}

.img-it-skeleton-item {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    background-color: #fff;
}

.img-it-skeleton-image {
    width: 100%;
    height: 180px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

.img-it-skeleton-filename {
    height: 16px;
    margin: 12px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 4px;
}

.img-it-skeleton-actions {
    display: flex;
    padding: 10px;
    gap: 10px;
}

.img-it-skeleton-button {
    flex: 1;
    height: 34px;
    border-radius: 4px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* รายการพรีวิว */
.img-it-preview-item {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background-color: #fff;
}

.img-it-preview-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
}

.img-it-preview-image {
    width: 100%;
    height: 420px; /* ปรับความสูงให้เท่ากัน */
    overflow: hidden;
    background-color: #f7f7f7;
    position: relative;
}

.img-it-preview-image img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* ให้รูปภาพเต็มกรอบโดยไม่บิดเบี้ยว */
    display: block;
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}

.img-it-preview-image img.loaded {
    opacity: 1;
}

/* แก้ไขตรงนี้: Loader ที่แสดงระหว่างโหลดรูปภาพ */
.img-it-preview-image::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    border: 3px solid #f0f0f0;
    border-top-color: #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* แก้ไขตรงนี้: ซ่อน loader เมื่อภาพโหลดเสร็จ */
.img-it-preview-image img.loaded ~ ::before,
.img-it-preview-image.loaded::before {
    display: none !important;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

.img-it-image-error {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f8d7da;
    color: #721c24;
    padding: 10px;
    text-align: center;
    font-size: 14px;
}

.img-it-preview-item:hover .img-it-preview-image img {
    transform: scale(1.05);
}

/* ชื่อไฟล์ */
.img-it-preview-filename {
    padding: 10px 12px;
    font-size: 14px;
    color: #333;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background-color: #f8f9fa;
}

.img-it-preview-actions {
    display: flex;
    flex-wrap: wrap;
    padding: 10px;
    background-color: #fff;
}

.img-it-preview-actions button {
    flex: 1;
    min-width: 75px;
    margin: 5px;
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.img-it-copy-url {
    background-color: #3498db;
    color: white;
}

.img-it-copy-url:hover {
    background-color: #2980b9;
}

.img-it-view-image {
    background-color: #2ecc71;
    color: white;
}

.img-it-view-image:hover {
    background-color: #27ae60;
}

.img-it-delete-image {
    background-color: #e74c3c;
    color: white;
}

.img-it-delete-image:hover {
    background-color: #c0392b;
}

/* ระบบหน้า (Pagination) */
.img-it-pagination {
    margin-top: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.img-it-pagination.hidden {
    display: none;
}

.img-it-pagination-info {
    margin-bottom: 10px;
    color: #666;
    font-size: 14px;
}

.img-it-pagination-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.img-it-pagination-button,
.img-it-page-number {
    padding: 8px 12px;
    margin: 0 5px;
    border: 1px solid #ddd;
    background-color: #fff;
    color: #333;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.img-it-pagination-button:hover:not(:disabled),
.img-it-page-number:hover:not(:disabled) {
    background-color: #f0f8ff;
    border-color: #3498db;
    color: #3498db;
}

.img-it-pagination-button:disabled,
.img-it-page-number:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.img-it-page-number.active {
    background-color: #3498db;
    border-color: #3498db;
    color: white;
}

.img-it-pagination-pages {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    margin: 5px 0;
}

.img-it-pagination-ellipsis {
    margin: 0 5px;
    color: #999;
}

/* ป๊อปอัพ */
.img-it-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.img-it-popup.show {
    opacity: 1;
    visibility: visible;
}

.img-it-popup-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    overflow: auto;
}

.img-it-popup-close {
    position: absolute;
    top: -40px;
    right: 0;
    font-size: 30px;
    color: white;
    cursor: pointer;
    z-index: 1;
}

#img-it-popup-image {
    display: block;
    max-width: 100%;
    max-height: 80vh;
    margin: 0 auto;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.5);
}

#img-it-popup-filename {
    display: block;
    text-align: center;
    color: white;
    padding: 10px;
    font-size: 14px;
    margin-top: 10px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 4px;
}

/* ตัวแสดงความคืบหน้า */
.img-it-progress-item {
    background-color: #f9f9f9;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.img-it-progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.img-it-filename {
    font-size: 14px;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 70%;
}

.img-it-progress-text {
    font-size: 14px;
    color: #666;
}

.img-it-progress-bar {
    width: 100%;
    height: 8px;
    background-color: #eee;
    border-radius: 4px;
    overflow: hidden;
}

.img-it-progress-fill {
    height: 100%;
    background-color: #3498db;
    width: 0;
    transition: width 0.3s ease;
}

/* ข้อความแจ้งเตือน */
.img-it-message {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 10px 20px;
    border-radius: 4px;
    color: white;
    font-size: 14px;
    max-width: 300px;
    z-index: 10000;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.img-it-message.show {
    opacity: 1;
    transform: translateY(0);
}

.img-it-message-success {
    background-color: #2ecc71;
}

.img-it-message-error {
    background-color: #e74c3c;
}

/* สถานะของ body */
body.img-it-popup-open {
    overflow: hidden;
}

/* ข้อความเมื่อไม่มีรูปภาพ */
.img-it-no-images {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 16px;
    background-color: #f9f9f9;
    border-radius: 8px;
    border: 1px dashed #ddd;
    grid-column: 1 / -1;
}

/* การปรับให้รองรับขนาดหน้าจอต่างๆ */
@media (max-width: 767px) {
    .img-it-upload-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .img-it-search-container {
        width: 100%;
    }
    
    #img-it-search {
        width: 100%;
    }
    
    .img-it-upload-preview-grid,
    .img-it-skeleton-container {
        grid-template-columns: 1fr;
    }
    
    .img-it-preview-actions {
        flex-direction: column;
    }
    
    .img-it-preview-actions button {
        margin: 5px 0;
    }
    
    .img-it-pagination-controls {
        flex-direction: column;
    }
    
    .img-it-pagination-button {
        margin: 5px;
    }
}

@media (max-width: 480px) {
    .img-it-pagination-pages {
        margin: 10px 0;
    }
}