/* ===== FAME SLIDER SECTION ===== */
.fame-slider-section {
    padding: 50px 20px 0 20px;
    /* background: linear-gradient(135deg, #f8f9fa 0%, #fff 100%); */
}

.slider-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
    padding: 0 60px; /* เพิ่มบรรทัดนี้: เพื่อเว้นที่ว่างด้านซ้ายและขวาให้ปุ่ม */
}

/* --- SLIDER TRACK (Main Container) --- */
.slider-track {
    display: flex;
    gap: 20px;
    padding: 20px 0;
    /* Critical: No hardcoded width, let it flex */
    will-change: transform;
    /* Smooth cubic-bezier animation */
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- SLIDER CARD (Individual Item) --- */
.slider-card {
    flex: 0 0 calc(25% - 15px); /* 4 cards on desktop, accounting for gap */
    min-width: 0;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 12px;
    overflow: hidden;
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid #eee;
    height: 100%;
}

.slider-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.card-container {
    display: flex;
    flex-direction: column;
    height: 350px;
}

.card-img-wrapper {
    width: 100%;
    height: 200px;
    overflow: hidden;
    background: #f0f0f0;
    flex-shrink: 0;
}

.card-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.slider-card:hover .card-img-wrapper img {
    transform: scale(1.08);
}

.card-text {
    padding: 16px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.card-text h3 {
    margin: 0 0 8px 0;
    font-size: 1rem;
    font-weight: 600;
    color: #e67e22;
    line-height: 1.3;
    flex-grow: 1;
}

.card-text p {
    margin: 0;
    font-size: 0.85rem;
    color: #666;
    text-align: right;
}

/* --- NAVIGATION BUTTONS --- */
.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    background: var(--accent-orange); /* เปลี่ยนตรงนี้เป็นสีเทา */
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    z-index: 10;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.nav-btn:hover {
    /* background: #666666;  */
    transform: translateY(-50%) scale(1.1);
}

.prev-btn {
    left: 10px; /* เปลี่ยนจาก -24px เป็น 10px เพื่อให้ปุ่มเข้ามาอยู่ในระยะ padding */
}

.next-btn {
    right: 10px; /* เปลี่ยนจาก -24px เป็น 10px */
}

/* ===== SLIDER MODAL ===== */
.slider-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 20px;
    overflow-y: auto;
}

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

.modal-inner {
    background: white;
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    border-radius: 16px;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideInModal 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideInModal {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-close {
    position: sticky;
    top: 15px;
    right: 20px;
    font-size: 32px;
    color: #999;
    cursor: pointer;
    background: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    float: right;
    margin-bottom: -40px;
    z-index: 10001;
}

.modal-close:hover {
    color: #e67e22;
    background: #f5f5f5;
}

#fameModalBody {
    padding: 0;
    margin: 0;
    line-height: 1.8;
    color: #333;
}

#fameModalBody img {
    width: 100%;
    border-radius: 12px;
    margin-bottom: 24px;
    max-height: 400px;
    object-fit: contain;
}

#fameModalBody h2 {
    font-size: 1.6rem;
    font-weight: 700;
    color: black;
    margin: 20px 0 15px 0;
}

#fameModalBody div {
    white-space: pre-line;
    font-size: 0.95rem;
    color: #555;
}

/* ===== RESPONSIVE DESIGN ===== */

/* Tablet: 2 cards */
@media (max-width: 1024px) {
    .slider-card {
        flex: 0 0 calc(50% - 10px); /* 2 cards on tablet */
    }

    .prev-btn {
        left: 10px;
    }

    .next-btn {
        right: 10px;
    }
}

/* Mobile: 1 card */
@media (max-width: 768px) {
    .fame-slider-section {
        padding: 50px 20px 0 20px;
    }

    .slider-wrapper {
        /* padding: 0; */
    }

    .slider-card {
        flex: 0 0 100%; /* 1 card on mobile */
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    .nav-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .prev-btn {
        left: 5px;
    }

    .next-btn {
        right: 5px;
    }

    .card-text h3 {
        font-size: 0.9rem;
    }

    .card-text p {
        font-size: 0.75rem;
    }

    .modal-inner {
        width: 95%;
        max-height: 90vh;
        border-radius: 12px;
    }

    #fameModalBody {
        padding: 20px;
    }

    #fameModalBody h2 {
        font-size: 1.3rem;
    }

    .modal-close {
        width: 36px;
        height: 36px;
        font-size: 28px;
        top: 10px;
        right: 10px;
    }
}

/* Extra small mobile */
@media (max-width: 480px) {
    .slider-track {
        gap: 12px;
        padding: 10px 0;
    }

    .card-img-wrapper {
        height: 150px;
    }

    .card-text {
        padding: 12px;
    }

    .card-text h3 {
        font-size: 0.85rem;
    }

    #fameModalBody {
        padding: 16px;
    }

    .nav-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
}


/* ===== SLIDER MODAL (อัปเดตใหม่) ===== */
.slider-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

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

.modal-inner {
    background: white;
    width: 95%;
    max-width: 900px;
    max-height: 90vh;
    border-radius: 12px;
    overflow: hidden; /* บังคับให้รูปไม่ล้นขอบโค้ง */
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

/* ปุ่ม X ปิด Modal (ลอยบนรูป) */
.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 28px;
    color: white;
    background: rgba(0, 0, 0, 0.4);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100;
    transition: all 0.3s ease;
    border: none;
    line-height: 1;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

/* คอนเทนเนอร์ครอบรูปภาพใน Modal */
.modal-image-wrapper {
    position: relative;
    width: 100%;
    height: 450px; /* ปรับความสูงตามความเหมาะสม */
    background: #000;
    flex-shrink: 0;
}

.modal-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* รักษาอัตราส่วนรูปภาพ */
    display: block;
}

/* ปุ่มเลื่อนซ้าย-ขวา ภายใน Modal */
.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    width: 45px;
    height: 70px;
    font-size: 24px;
    cursor: pointer;
    z-index: 50;
    transition: 0.3s;
}

.modal-nav:hover {
    background: rgba(0, 0, 0, 0.8);
}

.modal-prev { left: 0; border-radius: 0 4px 4px 0; }
.modal-next { right: 0; border-radius: 4px 0 0 4px; }

/* พื้นที่ข้อความด้านล่าง */
#fameModalBody {
    padding: 30px 40px;
    overflow-y: auto;
    background: white;
}

#fameModalBody h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: black; /* สีน้ำเงินเข้มตามธีม */
    margin-bottom: 15px;
}

#fameModalBody div {
    white-space: pre-line;
    line-height: 1.7;
    color: #444;
}

/* คอนเทนเนอร์จัดตำแหน่งปุ่ม */
/* จัดการตำแหน่งคอนเทนเนอร์ให้ชิดขวา */
.view-all-container {
    max-width: 1400px; /* ให้กว้างเท่ากับ slider-wrapper */
    margin: 20px auto 40px auto; 
    padding: 0 60px;   /* ให้ Padding เท่ากับ slider-wrapper เพื่อให้ขอบตรงกัน */
    display: flex;
    justify-content: flex-end; /* สั่งให้เนื้อหาข้างในชิดขวา */
}

/* ปรับหน้าตาปุ่มให้เหมือนคำว่า "เพิ่มเติม" */
.view-all-btn {
    display: inline-block;
    color: #999; /* สีเทาเริ่มต้น */
    text-decoration: none;
    font-size: 1rem; /* ขนาดเล็กลงหน่อยให้เท่ากับการ์ด */
    font-weight: 500;
    transition: all 0.3s ease;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px 0;
}

/* เมื่อ Hover แล้วเป็นสีส้ม */
.view-all-btn:hover {
    color: #f7941e; /* สีส้มหลักของ KMITL IoTE */
    transform: translateX(3px); /* ขยับขวาเล็กน้อย */
}

/* เมื่อคลิกแล้วเป็นสีส้มเข้ม */
.view-all-btn:active {
    color: #e67e22;
    transform: scale(0.98);
}