/* ใช้สำหรับ reset ค่าพื้นฐานเล็กน้อย */
body {
    font-family: Arial, sans-serif;
    margin: 0;
}

/* ==============================================
  == ส่วนที่สำคัญที่สุดสำหรับการ ซ่อน/แสดง ==
  ==============================================
*/

/* 1. ส่วนพื้นหลังสีดำ (Overlay) - สถานะปกติ (ซ่อน) */
.modal-overlay {
    display: none;
    /* <-- ซ่อนไว้ก่อน */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);

    /* ใช้ Flexbox เพื่อจัดกล่อง Popup ให้อยู่ตรงกลางจอ */
    justify-content: center;
    align-items: center;
}

/* 2. คลาส .active (JS จะใช้ตัวนี้สั่งโชว์) - สถานะทำงาน (แสดง) */
.modal-overlay.active {
    display: flex;
    /* <-- สั่งให้แสดงเป็น flex (เพราะเราใช้จัดกลาง) */
}

/* ==============================================
  == จบส่วนสำคัญ ==
  ==============================================
*/


/* 3. กล่องเนื้อหา Popup (กล่องสีขาว) */
.modal-content {
    position: relative;
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    max-width: 90%;
    max-height: 90%;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

/* 4. สไตล์รูปภาพ */
.slide img {
    width: 100%;
    max-width: 600px;
    height: auto;
    display: block;
}

/* 5. ซ่อนสไลด์ทั้งหมดไว้ก่อน */
.slide {
    display: none;
}

/* 6. แสดงเฉพาะสไลด์ที่มีคลาส .active */
.slide.active {
    display: block;
    animation: fadeIn 0.5s;
}

@keyframes fadeIn {
    from {
        opacity: 0.4;
    }

    to {
        opacity: 1;
    }
}

/* 7. ปุ่มปิด (X) */
.close-btn {
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 30px;
    font-weight: bold;
    color: #555;
    cursor: pointer;
}

.close-btn:hover {
    color: #000;
}

/* 8. ปุ่มเลื่อน (Prev/Next) */
.prev,
.next {
    cursor: pointer;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    padding: 16px;
    color: #333;
    font-weight: bold;
    font-size: 24px;
    user-select: none;
    background-color: rgba(255, 255, 255, 0.5);
    transition: background-color 0.3s ease;
}

.prev {
    left: 20px;
}

.next {
    right: 20px;
}

.prev:hover,
.next:hover {
    background-color: rgba(255, 255, 255, 0.9);
}