/* =========================================
   1. ตั้งค่าพื้นฐาน (Base Styles)
   ========================================= */
:root {
    --primary-color: #1a56db; /* สีน้ำเงินหลัก */
    --secondary-color: #f3f4f6; /* สีเทาพื้นหลัง */
    --accent-color: #fbbf24; /* สีเหลืองทอง (Badge) */
    --text-dark: #1f2937;
    --text-light: #6b7280;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Sarabun', sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background-color: #fff;
    scroll-behavior: smooth; /* เลื่อนหน้าเว็บแบบนุ่มนวล */
}

/* Container (กล่องจัดกึ่งกลาง) */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

/* =========================================
   2. เมนูนำทาง (Navbar)
   ========================================= */
.navbar {
    position: sticky; /* ติดอยู่ด้านบน */
    top: 0;
    background-color: #ffffff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
    padding: 15px 0;
}

.nav-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 20px;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-dark);
    font-weight: 600;
    font-size: 0.95rem;
    transition: color 0.3s;
}

.nav-links a:hover {
    color: var(--primary-color);
}

/* =========================================
   3. ส่วนหัว (Header)
   ========================================= */
header {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    color: white;
    padding: 80px 0;
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

header h2 {
    font-size: 1.5rem;
    font-weight: 400;
    opacity: 0.9;
}

header .badge {
    background-color: var(--accent-color);
    color: #000;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    display: inline-block;
    margin-bottom: 20px;
}

/* ลิงก์กลับหน้าหลัก */
.back-link {
    text-decoration: none;
    color: white;
    display: inline-block;
    margin-top: 15px;
    transition: opacity 0.3s;
}

.back-link:hover {
    opacity: 0.7;
}

/* =========================================
   4. ส่วนเนื้อหาทั่วไป (Sections & Info)
   ========================================= */
section {
    padding: 60px 0;
}

.section-title {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 40px;
    font-weight: 700;
    position: relative;
}

.section-title::after {
    content: '';
    display: block;
    width: 60px;
    height: 4px;
    background-color: var(--primary-color);
    margin: 10px auto;
}

/* ตารางข้อมูลผู้จัดทำ */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    background-color: var(--secondary-color);
    padding: 40px;
    border-radius: 10px;
}

.info-item h3 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

.info-list {
    list-style: none;
}

.info-list li {
    margin-bottom: 8px;
    padding-left: 20px;
    position: relative;
}

.info-list li::before {
    content: '•';
    color: var(--primary-color);
    position: absolute;
    left: 0;
    font-weight: bold;
}

/* =========================================
   5. การ์ดข้อตกลง (PA Part 1)
   ========================================= */
.pa-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.card {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 30px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background: white;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

.card-icon {
    font-size: 2rem;
    margin-bottom: 20px;
    color: var(--primary-color);
}

/* =========================================
   6. ประเด็นท้าทาย (PA Part 2)
   ========================================= */
#challenge, #certificates {
    background-color: #f9fafb;
}

.challenge-box {
    background: white;
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    border-left: 5px solid var(--primary-color);
}

.challenge-topic {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 20px;
}

.tag {
    display: inline-block;
    background: #e0e7ff;
    color: #3730a3;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    margin-right: 5px;
    margin-bottom: 5px;
}

.outcome-grid {
    display: grid;
    grid-template-columns: 1fr; /* ค่าเริ่มต้น 1 คอลัมน์ */
    gap: 20px;
    margin-top: 30px;
}
@media (min-width: 768px) {
    .outcome-grid { grid-template-columns: 1fr 1fr; } /* จอใหญ่แบ่ง 2 คอลัมน์ */
}

/* =========================================
   7. แกลเลอรี่รูปภาพ (Gallery Grid)
   ========================================= */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.gallery-item {
    position: relative;
    height: 200px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    border: 1px solid #e5e7eb;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.gallery-item:hover img {
    transform: scale(1.1);
}

/* แถบคำอธิบาย (Overlay) */
.gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 0.9rem;
    transform: translateY(100%);
    transition: transform 0.3s ease-in-out;
    text-align: center;
}

.gallery-item:hover .gallery-overlay {
    transform: translateY(0);
}

/* =========================================
   8. Lightbox (หน้าต่างแสดงภาพใหญ่)
   ========================================= */
.lightbox {
    display: none;
    position: fixed;
    z-index: 2000;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.lightbox.active {
    display: flex;
}

.lightbox img {
    max-width: 90%;
    max-height: 80vh;
    border: 2px solid white;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    font-weight: bold;
}

.lightbox-caption-text {
    margin-top: 15px;
    color: #f3f4f6;
    font-size: 1.1rem;
    text-align: center;
    max-width: 80%;
    background: rgba(0,0,0,0.5);
    padding: 5px 15px;
    border-radius: 20px;
}

/* =========================================
   9. ปุ่มดาวน์โหลด & แสดง PDF
   ========================================= */
.btn-download {
    display: inline-block;
    background-color: var(--primary-color);
    color: white;
    padding: 10px 25px;
    border-radius: 30px;
    text-decoration: none;
    font-weight: bold;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: transform 0.2s, background 0.2s;
}

.btn-download:hover {
    background-color: #1e40af;
    transform: translateY(-2px);
}

.pdf-container {
    width: 100%;
    height: 800px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    background-color: #f9fafb;
}

/* =========================================
   10. ปุ่มกลับสู่ด้านบน (Back to Top)
   ========================================= */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background-color: var(--primary-color);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    text-decoration: none;
    font-size: 1.5rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    background-color: #1e40af;
    transform: translateY(-3px);
}

/* =========================================
   11. ส่วนท้าย (Footer) & Responsive
   ========================================= */
footer {
    background-color: #1f2937;
    color: #d1d5db;
    text-align: center;
    padding: 40px 0;
    font-size: 0.9rem;
}

/* ปรับแต่งสำหรับมือถือ */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8rem;
    }
    
    .nav-links {
        display: none; /* ซ่อนเมนูบนมือถือเพื่อความเรียบง่าย */
    }
    
    .logo {
        margin: 0 auto;
    }

    .pdf-container {
        height: 500px; /* ลดความสูง PDF ในมือถือ */
    }

}

.pdf-container {
    width: 100%;
    height: 800px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden; /* สำคัญมาก */
    background-color: #f9fafb;
    position: relative; /* เพื่อให้จัดตำแหน่งภายในได้ง่าย */
}

/* ปรับความสูงสำหรับมือถือ */
@media (max-width: 768px) {
    .pdf-container {
        height: 400px; /* ลดความสูงลงไม่ให้กินพื้นที่เกินไป */
    }
}

/* =========================================
   UI พิเศษสำหรับ iOS (ปุ่มใหญ่ + อนิเมชั่น)
   ========================================= */

/* กล่องจัดกึ่งกลาง */
.ios-pdf-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    background-color: #f3f4f6;
}

/* ดีไซน์ปุ่มให้เด่นสะดุดตา */
.btn-ios-large {
    display: inline-block;
    background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%); /* สีแดงไล่เฉดให้ดูสำคัญ */
    color: white;
    font-size: 1.3rem;
    font-weight: bold;
    padding: 20px 40px;
    border-radius: 50px;
    text-decoration: none;
    box-shadow: 0 10px 25px rgba(220, 38, 38, 0.4); /* เงาสีแดงฟุ้งๆ */
    transition: transform 0.2s;
    
    /* เพิ่มอนิเมชั่นให้ปุ่มขยับได้ */
    animation: pulse-red 2s infinite;
}

.btn-ios-large:active {
    transform: scale(0.95); /* กดยุบลงนิดนึง */
}

/* สร้างอนิเมชั่นวิบวับ (Pulse Effect) */
@keyframes pulse-red {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
        transform: scale(1);
    }
    70% {
        box-shadow: 0 0 0 20px rgba(239, 68, 68, 0);
        transform: scale(1.05); /* ขยายใหญ่ขึ้นนิดนึง */
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
        transform: scale(1);
    }
}
