/* --- การตั้งค่าทั่วไปและ Font --- */
body {
    font-family: 'Noto Serif Thai', serif;
    background-color: #f4f7f6;
    margin: 0;
    color: #333;
}

/* ================================================= */
/* =========  หน้า Log in (MODERN DESIGN)  ========= */
/* ================================================= */

/* --- ตั้งค่า Background เต็มจอสำหรับหน้า Login --- */
body.login-body-bg {
    background-image: url('../images/login-bg.jpg');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    height: 100vh;
    overflow: hidden; /* ป้องกันการเลื่อน */
}

.login-page-modern {
    height: 100vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- กล่อง Glassmorphism Effect --- */
.login-box {
    width: 400px;
    max-width: 90%;
    padding: 40px 30px;
    background: rgba(255, 255, 255, 0.1); /* ความโปร่งแสงของพื้นหลัง */
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37); /* เงามืด */
    backdrop-filter: blur(10px); /* เอฟเฟกต์กระจกฝ้า */
    -webkit-backdrop-filter: blur(10px); /* สำหรับ Safari */
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.logo-in-box {
    width: 80px;
    margin-bottom: 15px;
}

.event-name-in-box {
    font-size: 1.8rem;
    color: #ffffff;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.3);
    margin: 0;
    text-align: center;
}

.event-name-login {
    font-size: 1.8rem;
    color: #ffffff;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.3);
    margin: 0;
    text-align: center;
}

.login-box h2 {
    font-size: 1.2rem;
    color: #ffffff;
    margin-top: 10px;
    margin-bottom: 30px;
    font-weight: 400;
}

.login-form {
    width: 100%;
}

.form-group-modern {
    position: relative;
    margin-bottom: 25px;
}

.form-group-modern input {
    width: 100%;
    padding: 10px 0;
    font-size: 1rem;
    font-family: 'Noto Serif Thai', serif; /* หรือใช้ Kanit, Prompt เพื่อความ Modern */
    color: #fff;
    background-color: transparent;
    border: none;
    border-bottom: 2px solid rgba(255, 255, 255, 0.5);
    outline: none;
}
.form-group-modern input::placeholder { /* ทำให้ placeholder โปร่งแสง */
    color: rgba(255, 255, 255, 0.7);
}
.form-group-modern input:focus {
    border-bottom-color: #ffffff;
}

.btn-login-modern {
    width: 100%;
    padding: 12px;
    background: #0056b3;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    margin-top: 20px;
    transition: all 0.3s ease;
}
.btn-login-modern:hover {
    background: #0069d9;
    box-shadow: 0 4px 15px rgba(0, 86, 179, 0.4);
}

.flash-message.error {
    color: #721c24; /* สีตัวอักษรเข้มขึ้น */
    background-color: #f8d7da; /* พื้นหลังสีแดงอ่อน */
    border: 1px solid #f5c6cb; /* เพิ่มเส้นขอบ */
    padding: 15px;
    border-radius: 8px;
    text-align: left; /* จัดชิดซ้าย */
    width: 100%;
    box-sizing: border-box;
    display: flex; /* ใช้ Flexbox เพื่อจัดวางไอคอน */
    align-items: center;
    gap: 10px; /* ระยะห่างระหว่างไอคอนกับข้อความ */
}

/* เพิ่มไอคอนรูปสามเหลี่ยมตกใจ ⚠ */
.flash-message.error::before {
    content: "⚠";
    font-size: 1.5rem;
    color: #721c24;
}



/* ================================================= */
/* ===============  หน้า Watch VDO  ================ */
/* ================================================= */

/* --- ตั้งค่า Background สำหรับหน้า Watch --- */
body.watch-body-bg {
    background: linear-gradient(to bottom right, #eef2f7, #d8e1ec);
    background-repeat: no-repeat;
    min-height: 100vh;
}

.watch-page-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}
.page-header {
    background-color: #ffffff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 10px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    z-index: 10;
}
.header-left {
    display: flex;
    align-items: center; /* จัดให้โลโก้กับตัวหนังสืออยู่กึ่งกลางแนวตั้ง */
    gap: 15px; /* ระยะห่างระหว่างโลโก้กับตัวหนังสือ */
}

.header-logo {
    height: 40px; /* กำหนดความสูงของโลโก้ */
}
.event-title {
    font-size: 1.5rem;
    margin: 0;
    color: #004a7c;
}
.user-info {
    display: flex;
    align-items: center;
    gap: 20px;
}
.welcome-message {
    font-size: 0.9rem;
    color: #555;
}
.logout-button {
    background-color: #e74c3c;
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}
.logout-button:hover {
    background-color: #c0392b;
}

.watch-page-grid {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 30px;
    padding: 30px 40px;
    flex-grow: 1;
    overflow: hidden;
}

.main-content {
    background-color: white;
    padding: 25px;
    border-radius: 8px;
    overflow-y: auto;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.video-player {
    width: 100%;
    aspect-ratio: 16 / 9;
    background-color: #000;
    margin-top: 1rem;
    border-radius: 8px;
    overflow: hidden;
}
.video-player iframe {
    width: 100%;
    height: 100%;
}
.video-info {
    margin-top: 1.5rem;
    border-top: 1px solid #eee;
    padding-top: 1.5rem;
}
.download-button {
    display: inline-block;
    margin-top: 1.5rem;
    padding: 12px 24px;
    background-color: #27ae60;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    font-weight: bold;
    transition: background-color 0.2s;
}
.download-button:hover {
    background-color: #229954;
}

.sidebar {
    background-color: white;
    padding: 25px;
    border-radius: 8px;
    overflow-y: auto;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.sidebar h4 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.4rem;
    color: #333;
}

.accordion-header {
    background-color: #f9f9f9;
    color: #444;
    cursor: pointer;
    padding: 18px;
    width: 100%;
    border: none;
    text-align: left;
    outline: none;
    font-size: 1.1rem;
    font-weight: bold;
    font-family: 'Noto Serif Thai', serif;
    transition: background-color 0.3s;
    border-radius: 5px;
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.accordion-header:hover, .accordion-header.active {
    background-color: #e3e8f0;
}
.accordion-header::after {
    content: '\25B6'; /* สามเหลี่ยมชี้ขวา ► */
    font-size: 0.9rem; /* ปรับขนาดให้พอดี */
    color: #0056b3;
    transition: transform 0.3s ease-out;
}
.accordion-header.active::after {
    transform: rotate(90deg); /* หมุนสามเหลี่ยม 90 องศาเมื่อ active */
}

.accordion-panel {
    padding: 0;
    background-color: white;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}
.accordion-panel ul {
    list-style: none;
    padding: 0;
    margin: 10px 0;
}
.accordion-panel li a {
    display: block;
    padding: 15px 20px;
    text-decoration: none;
    color: #333;
    border-radius: 5px;
    margin: 0 5px 5px 5px;
    border: 1px solid #e9ecef; /* เพิ่มเส้นขอบบางๆ */
    transition: background-color 0.2s, border-color 0.2s;
    background-color: #f8f9fa; /* เพิ่มสีพื้นหลังสีเทาอ่อนๆ */
}
.accordion-panel li a:hover {
    background-color: #e9ecef; /* ทำให้สี hover เข้มขึ้น */
    border-color: #dee2e6;
}
.accordion-panel li.active-video a {
    background-color: #dbeafe; /* สไตล์ของวิดีโอที่เลือกยังคงโดดเด่นเหมือนเดิม */
    color: #1e40af;
    border-left: 4px solid #1e40af;
    font-weight: bold;
}
.topic-title {
    display: block;
}
.topic-time {
    font-size: 0.9rem;
    color: #666;
}
.accordion-panel li.active-video a .topic-time {
    color: #1e40af;
}

/* ================================================= */
/* ============ Animation Styles =================== */
/* ================================================= */

.hidden {
    display: none !important;
}

#animation-container {
    height: 200px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* --- Loading Spinner --- */
#loading-spinner {
    width: 60px;
    height: 60px;
    border: 8px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- Success Checkmark --- */
#success-checkmark {
    width: 80px;
    height: 80px;
}
.checkmark-circle {
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    stroke-width: 3;
    stroke: #4CAF50;
    fill: none;
    animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}
.checkmark-check {
    transform-origin: 50% 50%;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    stroke-width: 4;
    stroke: #4CAF50;
    animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}

@keyframes stroke {
    100% { stroke-dashoffset: 0; }
}


/* ================================================= */
/* === Responsive Design for Tablets & Mobiles === */
/* ================================================= */

/* ใช้กฎเหล่านี้เมื่อความกว้างหน้าจอน้อยกว่า 820px */
@media (max-width: 820px) {

    /* --- ปรับ Header ด้านบน --- */
    .page-header {
        padding: 10px 20px; /* ลดระยะขอบซ้ายขวา */
        flex-direction: column; /* จัดเรียงบนลงล่าง */
        align-items: flex-start; /* จัดชิดซ้าย */
        gap: 10px;
    }

    .event-title {
        font-size: 1.1rem; /* ลดขนาด Title ลง */
    }

    .user-info {
        width: 100%;
        justify-content: space-between; /* จัดให้ "สวัสดี" และ "ออกจากระบบ" อยู่คนละฝั่ง */
    }


    /* --- ปรับ Layout หลักให้เป็น 1 คอลัมน์ --- */
    .watch-page-grid {
        grid-template-columns: 1fr; /* เปลี่ยนจาก 2 คอลัมน์เป็น 1 คอลัมน์ */
        padding: 20px; /* ลดระยะขอบ */
        gap: 20px; /* ลดระยะห่างระหว่างกล่อง */
        overflow-y: auto; /* อนุญาตให้เลื่อนหน้าจอได้ */
    }

    /* --- ปรับขนาดตัวอักษรใน Main Content --- */
    .main-content h3 {
        font-size: 1.2rem;
    }

    .video-info p {
        font-size: 0.9rem;
    }

    /* --- ปรับ Sidebar (ที่ตอนนี้อยู่ด้านล่าง) --- */
    .sidebar {
        padding: 20px;
    }

}

/* สำหรับหน้าจอที่แคบมากๆ เช่น มือถือ */
@media (max-width: 480px) {
    .page-header, .watch-page-grid {
        padding: 15px; /* ลดระยะขอบอีก */
    }

    .event-title {
        font-size: 1rem; /* ลดขนาด Title อีก */
    }

    .welcome-message {
        font-size: 0.8rem; /* ลดขนาดตัวอักษร "สวัสดี" */
    }
}