@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600&display=swap');

body {
    font-family: 'Kanit', sans-serif;
    background-color: #fcfcfc;
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.page-wrapper {
    flex: 1;
    padding: 30px 20px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.layout-container {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

/* --- ส่วนแสดงรายการ (ซ้าย) --- */
.file-list-section {
    flex: 1;
    background: #fff;
    padding: 25px;
    border-radius: 16px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.05);
}

.file-list-section h3 {
    margin-top: 0;
    margin-bottom: 25px;
    font-size: 1.4rem;
    color: #444;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 15px;
}

/* Grid ปกติ */
.file-list-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
    align-items: start;
}

/* --- ส่วนรูปใหญ่ (ตอนไม่ล็อกอิน) --- */
.file-list-section.full-width-list {
    background: transparent;
    box-shadow: none;
    padding: 0;
}

.file-list-section.full-width-list .file-list-container {
    grid-template-columns: 1fr !important; 
    gap: 50px;
    max-width: 1200px;
    margin: 0 auto;
}

.file-list-section.full-width-list .file-card {
    border: none;
    background: transparent;
    box-shadow: none;
    padding: 0;
    text-align: center;
}

.file-list-section.full-width-list .file-thumb-img {
    width: 100%;
    height: auto;
    max-height: none;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    border-radius: 12px;
    margin-bottom: 15px;
    transition: transform 0.3s;
}

.file-list-section.full-width-list .file-thumb-img:hover {
    transform: scale(1.01);
}

.file-list-section.full-width-list .file-info {
    border-top: none;
}

.file-list-section.full-width-list .file-date {
    background: rgba(255,255,255,0.8);
    padding: 5px 15px;
    border-radius: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

/* --- การ์ดไฟล์ทั่วไป --- */
.file-card {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 12px;
    padding: 15px;
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 10px rgba(0,0,0,0.03);
}

.file-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    border-color: #ffcea8;
}

.file-thumb-img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 10px;
    border: 1px solid #f0f0f0;
    object-fit: cover;
    object-position: top center;
}

.file-info {
    text-align: center;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed #eee;
}

.file-date {
    font-size: 0.85rem;
    color: #888;
}

/* --- ปุ่มลบ --- */
.btn-delete {
    position: absolute;
    top: -10px;
    right: -10px;
    background-color: #ff4d4d;
    color: white;
    border: 2px solid #fff;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0,0,0,0.2);
    transition: all 0.2s;
    z-index: 5;
    opacity: 0;
    transform: scale(0.8);
}

.file-card:hover .btn-delete {
    opacity: 1;
    transform: scale(1);
    top: 10px;
    right: 10px;
}

.btn-delete:hover {
    background-color: #d63030;
    transform: scale(1.1) !important;
}

/* --- ส่วนอัปโหลด (ขวา) --- */
.upload-wrapper {
    flex: 0 0 320px;
    position: sticky;
    top: 20px;
}

.upload-card {
    background: #fff;
    padding: 25px;
    border-radius: 16px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.05);
    text-align: center;
    border-top: 5px solid #ff8c61;
}

.upload-card h2 {
    font-size: 1.2rem;
    color: #333;
    margin-bottom: 5px;
}

.custom-file {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border: 2px dashed #ddd;
    border-radius: 12px;
    padding: 40px 20px;
    cursor: pointer;
    background: #fafafa;
    transition: all 0.3s;
    margin: 20px 0;
    min-height: 150px;
}

.custom-file:hover {
    border-color: #ff8c61;
    background: #fffdfa;
}

.upload-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #ff8c61, #ff6b6b);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    font-family: 'Sarabun', sans-serif;
    box-shadow: 0 4px 10px rgba(255, 107, 107, 0.3);
}

.upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(255, 107, 107, 0.4);
}

/* =========================================
   🔥🔥 เพิ่มส่วน PDF Icon เข้ามาใน CSS 🔥🔥 
   ========================================= */
.pdf-preview-box {
    width: 100%;
    height: 100%;
    min-height: 300px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #fff0f0;
    border-radius: 8px;
    margin-bottom: 10px;
    border: 1px solid #ffcccc;
    color: #d32f2f;
    flex-direction: column;
    cursor: pointer;
    transition: all 0.3s;
}

.pdf-preview-box:hover {
    background-color: #ffe0e0;
    transform: scale(1.02);
}

.pdf-preview-box i {
    font-size: 80px;
    margin-bottom: 15px;
}

.pdf-text {
    font-size: 1.2rem;
    font-weight: bold;
}

/* Lightbox */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.lightbox.active { opacity: 1; visibility: visible; }
.lightbox img { max-width: 95%; max-height: 95%; border-radius: 4px; }
.lightbox-close { position: absolute; top: 20px; right: 30px; font-size: 30px; color: #fff; cursor: pointer; }

/* Responsive */
@media (max-width: 900px) {
    .layout-container { flex-direction: column; }
    .upload-wrapper { width: 100%; position: static; order: -1; }
    .file-list-container { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
    
    .file-list-section.full-width-list .file-list-container {
        grid-template-columns: 1fr !important;
    }
}