/* ========================================= */
/* สร้างตัวแปร CSS สำหรับทำระบบ Dark Mode / Light Mode */
/* ========================================= */
:root {
    --primary-red: #b91c1c;
    --dark-blue: #1e1b4b;
    --footer-bg: #1b193d; 
    
    /* โหมดสว่าง (Light Mode) */
    --light-bg: #f9f9f9;
    --text-color: #333333;
    --card-bg: #ffffff;
    --topbar-bg: #f8f9fa;
    --border-color: #e0e0e0;
    --muted-text: #666666;
    --heading-color: #1e1b4b;
    --detail-bg: rgba(255, 255, 255, 0.9);
}

body.dark-mode {
    /* โหมดมืด (Dark Mode) */
    --light-bg: #121212;
    --text-color: #e0e0e0;
    --card-bg: #1e1e1e;
    --topbar-bg: #1a1a1a;
    --border-color: #333333;
    --muted-text: #aaaaaa;
    --heading-color: #facc15;
    --detail-bg: rgba(30, 30, 30, 0.9);
}

* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
    font-family: 'Prompt', sans-serif; 
}

html { 
    scroll-behavior: smooth; 
} 

body { 
    background-color: var(--light-bg); 
    color: var(--text-color); 
    overflow-x: hidden; 
    transition: background-color 0.3s, color 0.3s;
}

.container { 
    max-width: 1200px; 
    margin: 0 auto; 
    padding: 0 15px; 
}

/* ========================================= */
/* Top Bar */
/* ========================================= */
.top-bar { 
    background-color: var(--topbar-bg); 
    padding: 10px 0; 
    font-size: 0.85rem; 
    border-top: none !important; /* บังคับลบเส้นขอบดำด้านบนที่หลุดมา */
    border-left: none !important; /* บังคับลบเส้นขอบซ้าย */
    border-right: none !important; /* บังคับลบเส้นขอบขวา */
    border-bottom: 1px solid var(--border-color); 
    overflow-x: auto; 
    white-space: nowrap; 
    transition: background-color 0.3s;
}

.top-bar::-webkit-scrollbar {
    display: none;
}

.top-bar-content { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    min-width: max-content; 
    gap: 15px; 
}

.top-bar-left, .top-bar-right { 
    display: flex; 
    align-items: center; 
    gap: 12px;
}

.top-bar-right { 
    color: var(--muted-text); 
}

/* ปุ่ม Toggles สำหรับโหมดมืดและภาษา */
.theme-lang-toggles {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 15px;
    padding-left: 15px;
    border-left: 1px solid var(--border-color);
}

.toggle-btn {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: 0.3s;
    font-size: 0.75rem;
    font-weight: 600;
}

.toggle-btn:hover {
    background-color: var(--primary-red);
    color: white;
    border-color: var(--primary-red);
}

/* จัดไอคอนโซเชียล */
.social-icons { 
    display: flex; 
    gap: 8px; 
}

.social-icons a { 
    display: inline-flex; 
    justify-content: center; 
    align-items: center;
    width: 28px; 
    height: 28px; 
    background-color: #ffc107; 
    color: white; 
    border-radius: 50%; 
    text-decoration: none; 
    transition: 0.3s;
    font-size: 14px; 
}

.social-icons a:hover { 
    transform: scale(1.1); 
    background-color: #e0a800; 
}

.top-bar-text-container {
    overflow: hidden; 
}

.top-bar-text { 
    display: flex; 
    align-items: center; 
    gap: 10px; 
}

.animated-text > span {
    opacity: 0; 
    animation: fadeSlideIn 0.6s forwards;
}

.animated-text > span:nth-child(1) { animation-delay: 0.2s; } 
.animated-text > span:nth-child(3) { animation-delay: 0.4s; } 
.animated-text > span:nth-child(5) { animation-delay: 0.6s; } 

@keyframes fadeSlideIn {
    0% { opacity: 0; transform: translateX(-20px); }
    100% { opacity: 1; transform: translateX(0); }
}

.motto-item { 
    color: var(--primary-red); 
    font-weight: 500; 
}

.red-divider { 
    color: var(--primary-red); 
    font-weight: bold; 
    display: inline-block;
    transform: translateY(-2px); 
}

.contact-item i { 
    margin-right: 5px; 
    color: var(--text-color); 
}

.contact-divider { 
    color: var(--border-color); 
    margin: 0 5px; 
}

/* ========================================= */
/* Header & Navbar */
/* ========================================= */
.main-header { 
    background-color: var(--primary-red); 
    color: white; 
    padding: 25px 0 0 0; 
}

.header-container { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
}

.logo-center { 
    display: flex; 
    flex-direction: column; 
    align-items: center;    
    gap: 15px; 
    margin-bottom: 15px; 
}

.logo-img { 
    height: 80px; 
    transition: 0.3s; 
}

.logo-img:hover { 
    transform: scale(1.05); 
}

.college-name { 
    font-size: 1.6rem; 
    font-weight: 600; 
    text-align: center; 
}

.college-name span { 
    font-size: 1.1rem; 
    font-weight: 300; 
}

.navbar { 
    width: 100%; 
    border-top: 1px solid rgba(255,255,255,0.2); 
    margin-top: 15px;
}

.navbar ul { 
    display: flex; 
    justify-content: center; 
    list-style: none; 
    padding: 12px 0; 
    gap: 20px;
}

.navbar a { 
    color: white; 
    text-decoration: none; 
    font-size: 0.9rem; 
    transition: 0.3s;
}

.navbar a:hover, .navbar a.active { 
    font-weight: 600; 
    color: #facc15; 
}

@media (max-width: 768px) {
    .navbar ul {
        justify-content: flex-start;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 10px 15px;
        gap: 10px;
    }
    .navbar ul::-webkit-scrollbar { display: none; }
    .navbar li { flex: 0 0 auto; }
    .navbar a {
        display: inline-block;
        padding: 8px 18px;
        background-color: rgba(255, 255, 255, 0.1); 
        border-radius: 20px;        
        border: 1px solid rgba(255, 255, 255, 0.2); 
    }
    .navbar a.active {
        background-color: #facc15;  
        color: var(--primary-red);
    }
}

/* ========================================= */
/* Page Title */
/* ========================================= */
.page-title-section { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 50px 30px; 
    margin-top: 20px; 
    border-radius: 10px;
    background-image: linear-gradient(var(--detail-bg), var(--detail-bg)), url('images/hero-bg.jpg');
    background-size: cover; 
    background-position: center; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    flex-wrap: wrap; 
    gap: 20px;
}

.title-left h2 { 
    color: var(--heading-color); 
    font-size: 2rem; 
    border-left: 5px solid var(--primary-red); 
    padding-left: 15px; 
}

.title-left p { 
    color: var(--muted-text); 
    margin-left: 20px; 
    margin-top: 5px; 
    font-weight: 500;
}

.breadcrumb { 
    background-color: var(--primary-red); 
    color: white; 
    padding: 8px 20px; 
    border-radius: 20px; 
    font-size: 0.9rem; 
}

/* ========================================= */
/* 3D Carousel */
/* ========================================= */
.gallery-container { 
    position: relative; 
    width: 100%; 
    height: 650px;
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    margin-bottom: 50px; 
}

.scene { 
    width: 340px; 
    height: 460px; 
    perspective: 1200px; 
}

.carousel { 
    width: 100%; 
    height: 100%; 
    position: absolute; 
    transform-style: preserve-3d; 
    transition: 0.8s; 
}

.carousel-cell {
    position: absolute; 
    width: 320px; 
    height: 440px; 
    background: var(--card-bg); 
    border-radius: 12px; 
    overflow: hidden; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.2); 
    border: 1px solid var(--border-color);
    display: flex; 
    flex-direction: column;
    transition: background-color 0.3s;
}

.carousel-cell img { 
    width: 100%; 
    height: 240px; 
    object-fit: cover; 
    border-bottom: 4px solid var(--primary-red); 
}

.cell-content { 
    padding: 20px; 
    text-align: center; 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    justify-content: space-between; 
}

.cell-content h3 { 
    color: var(--heading-color); 
    font-weight: 600;
} 

.btn-view { 
    padding: 8px 25px; 
    border: 1px solid var(--primary-red); 
    background: transparent; 
    color: var(--primary-red); 
    border-radius: 20px; 
    cursor: pointer; 
    transition: 0.3s; 
}

.btn-view:hover { 
    background-color: var(--primary-red); 
    color: white; 
}

.carousel-cell.active-glow { 
    transform: scale(1.05); 
    z-index: 5; 
    box-shadow: 0 0 20px var(--primary-red); 
}

.controls { 
    margin-top: 40px; 
    display: flex; 
    gap: 20px; 
}

.controls button {
    background: var(--heading-color); 
    color: var(--card-bg); 
    border: none;
    width: 50px; 
    height: 50px; 
    font-size: 1.2rem; 
    border-radius: 50%; 
    cursor: pointer; 
    transition: 0.3s; 
    display: flex; 
    justify-content: center; 
    align-items: center;
}

.controls button:hover { 
    background: var(--primary-red); 
    color: white;
}

/* ========================================= */
/* Detail Section (SPA) */
/* ========================================= */
#detail-section { 
    padding-bottom: 50px; 
}

.detail-header-bg { 
    background: linear-gradient(var(--detail-bg), var(--detail-bg)), url('images/hero-bg.jpg') center/cover;
    padding: 40px 0; 
    border-top: 1px solid var(--border-color);
}

.detail-nav-wrapper { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    flex-wrap: wrap; 
    gap: 20px;
}

.header-left-group { 
    display: flex; 
    align-items: center; 
    gap: 20px; 
}

.red-vertical-bar { 
    width: 8px; 
    height: 70px; 
    background: var(--primary-red); 
    border-radius: 4px; 
}

.header-text-group h1 { 
    color: var(--primary-red); 
    font-size: 2.5rem; 
    margin-bottom: 5px; 
}

.header-text-group p { 
    color: var(--muted-text); 
    font-size: 1.2rem; 
}

.close-badge { 
    background: var(--heading-color); 
    color: var(--card-bg); 
    padding: 12px 25px; 
    border: none; 
    cursor: pointer;
    border-radius: 30px; 
    font-size: 1.1rem; 
    transition: 0.3s; 
}

.close-badge:hover { 
    background: var(--primary-red); 
    color: white;
}

.content-area { 
    background: var(--card-bg); 
    padding: 40px; 
    border-radius: 12px; 
    margin-top: 20px; 
    border: 1px solid var(--border-color);
}

.feature-img { 
    width: 100%; 
    max-height: 450px; 
    object-fit: cover; 
    border-radius: 8px; 
    margin-bottom: 25px; 
    border-bottom: 5px solid var(--primary-red);
}

.detail-text-box { 
    color: var(--text-color); 
    line-height: 1.8; 
}

.detail-text-box h4 {
    color: var(--primary-red); 
    margin: 20px 0 10px 0; 
}

.detail-text-box p { 
    margin-bottom: 20px; 
    text-indent: 2rem; 
}

.detail-text-box ol, .detail-text-box ul {
    margin-left: 25px; 
    margin-bottom: 20px; 
    background-color: var(--topbar-bg);
    padding: 20px 20px 20px 40px; 
    border-radius: 8px; 
    border: 1px solid var(--border-color);
}

/* ========================================= */
/* อาคารสถานที่และแกลเลอรีห้อง */
/* ========================================= */
.building-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-top: 25px;
}

.building-item {
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease;
}

.building-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

.building-item img.main-building-img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    border-bottom: 3px solid var(--primary-red);
}

.building-caption {
    padding: 15px;
}

.building-caption strong {
    display: block;
    font-size: 1.1rem;
    color: var(--heading-color);
    margin-bottom: 8px;
}

.building-caption p {
    font-size: 0.95rem;
    color: var(--muted-text);
    text-indent: 0 !important;
}

.divider {
    border: 0;
    height: 1px;
    background: var(--border-color);
    margin: 15px 0;
}

.room-gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.room-item {
    text-align: center;
}

.room-item img {
    width: 100%;
    height: 70px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border-color) !important;
    transition: 0.3s;
    cursor: pointer;
}

.room-item img:hover {
    transform: scale(1.05);
}

.room-item span {
    display: block;
    font-size: 0.8rem;
    color: var(--muted-text);
    margin-top: 6px;
}

/* ========================================= */
/* CSS ระบบ Popup ขยายรูปภาพ (Lightbox) */
/* ========================================= */
.img-modal { 
    display: none; 
    position: fixed; 
    z-index: 999; 
    left: 0; 
    top: 0; 
    width: 100%; 
    height: 100%; 
    background-color: rgba(0,0,0,0.9); 
    justify-content: center; 
    align-items: center; 
}

.img-modal-content { 
    max-width: 90%; 
    max-height: 80vh; 
    border-radius: 8px; 
}

.img-modal-close { 
    position: absolute; 
    top: 20px; 
    right: 35px; 
    color: #fff; 
    font-size: 40px; 
    font-weight: bold; 
    cursor: pointer; 
}

/* ========================================= */
/* Contact Us (หน้า 4 การ์ด) */
/* ========================================= */
.contact-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 30px 0;
}

.contact-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.contact-header {
    background: var(--topbar-bg);
    padding: 15px;
    font-weight: 600;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
}

.contact-body {
    padding: 20px;
    color: var(--text-color);
}

.contact-body p {
    margin-bottom: 10px;
}

.btn-outline-yellow {
    display: inline-block;
    border: 1px solid #facc15;
    color: #d97706;
    padding: 6px 15px;
    border-radius: 4px;
    text-decoration: none;
    margin-top: 10px;
    font-size: 0.9rem;
    transition: 0.3s;
}

.btn-outline-yellow:hover {
    background: #facc15;
    color: white;
}

body.dark-mode .btn-outline-yellow {
    color: #facc15;
}

body.dark-mode .btn-outline-yellow:hover {
    background: #facc15;
    color: #121212;
}

/* ส่วนที่แก้ไขสำหรับ Q&A Flex */
/* ส่วนที่แก้ไขสำหรับ Q&A Flex */
.qa-flex {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center; /* เพิ่มคำสั่งนี้ให้เนื้อหาและรูปอยู่กึ่งกลาง */
}

.qa-image {
    width: 100%;
    text-align: center;
}

.qa-image img {
    width: 100%;
    max-width: 350px; /* <--- ปรับลดขนาดตรงนี้ครับ (เปลี่ยนเป็น 300px หรือ 400px ได้ตามชอบเลย) */
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.3s ease;
    border: 1px solid var(--border-color);
    margin: 0 auto; /* บังคับให้รูปภาพอยู่กึ่งกลางกล่อง */
    display: block;
}

.qa-image img:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}
.map-container iframe {
    width: 100%;
    height: 300px;
    border: none;
    border-radius: 8px;
}

/* ========================================= */
/* หน้ากำลังพัฒนา (Under Construction) */
/* ========================================= */
.construction-container {
    text-align: center;
    padding: 80px 20px;
    min-height: 55vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: var(--card-bg);
    margin: 40px auto;
    border-radius: 15px;
    border: 1px solid var(--border-color);
}

.construction-icon {
    font-size: 6rem;
    color: #ffc107;
    margin-bottom: 25px;
    animation: spin 4s linear infinite; 
}

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

.construction-title {
    font-size: 2.2rem;
    color: var(--heading-color);
    margin-bottom: 10px;
}

.construction-desc {
    font-size: 1.2rem;
    color: var(--muted-text);
}

.btn-back-home {
    margin-top: 25px;
    display: inline-block;
    padding: 12px 30px;
    background: var(--primary-red);
    color: white;
    text-decoration: none;
    border-radius: 30px;
    font-size: 1.1rem;
    transition: 0.3s;
}

.btn-back-home:hover {
    background: var(--heading-color);
}

/* ========================================= */
/* Footer โฉมใหม่ (แก้ปัญหาการแสดงผล) */
/* ========================================= */
.complex-footer { 
    width: 100%;
    margin-top: 50px; 
    font-family: 'Prompt', sans-serif;
}

/* แถบ CTA ด้านบน (สีแดง-น้ำเงิน) */
.footer-cta { 
    display: flex; 
    background-color: var(--footer-bg); 
    color: white; 
    position: relative;
}

/* ฝั่งซ้าย (สีแดง) จัดระเบียบไอคอนและข้อความ */
.cta-left { 
    flex: 1; 
    background: linear-gradient(105deg, var(--primary-red) 90%, transparent 90.5%); 
    padding: 35px 5%; 
    display: flex; 
    align-items: center;
    gap: 40px; 
}

.cta-info {
    display: flex;
    align-items: flex-start;
    gap: 15px;
}

.cta-info i {
    font-size: 1.8rem;
    margin-top: 5px;
    color: #facc15; 
}

.cta-info div {
    display: flex;
    flex-direction: column;
}

.cta-info strong {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 5px;
}

.cta-info span {
    font-size: 0.9rem;
    font-weight: 300;
    color: rgba(255, 255, 255, 0.9);
}

/* ไอคอนวงกลมตรงกลาง (โทรโข่ง) */
.cta-center-icon { 
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 65px;
    height: 65px;
    background-color: var(--footer-bg);
    border: 4px solid var(--primary-red);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    z-index: 5;
    color: white;
    box-shadow: 0 0 0 6px var(--footer-bg); 
}

/* ฝั่งขวา (สมัครเรียน) */
.cta-right { 
    flex: 1; 
    padding: 30px 5%; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
}

.cta-action {
    display: flex;
    flex-direction: column; 
    align-items: center;
    gap: 15px;
    text-align: center;
}

.cta-action-text .highlight {
    font-size: 1.2rem;
    color: #facc15; 
    font-weight: 600;
    display: block;
    margin-bottom: 5px;
}

.cta-action-text span {
    font-size: 0.95rem;
    font-weight: 300;
}

.btn-apply { 
    background-color: var(--primary-red); 
    color: white; 
    padding: 12px 30px; 
    border-radius: 30px; 
    text-decoration: none; 
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: 0.3s;
    box-shadow: 0 4px 15px rgba(185, 28, 28, 0.4);
}

.btn-apply:hover {
    background-color: #facc15;
    color: var(--primary-red);
    transform: translateY(-3px);
}

/* พื้นที่หลัก Footer */
.footer-main { 
    background-color: var(--footer-bg); 
    color: #e5e7eb; 
    padding: 60px 0; 
    position: relative; 
    overflow: hidden;
}

/* ลายน้ำด้านหลัง */
.footer-main::before { 
    content: 'PHETCHABUN'; 
    position: absolute; 
    top: 50%; 
    left: 50%; 
    transform: translate(-50%, -50%); 
    font-size: 10vw; 
    color: rgba(255, 255, 255, 0.02); 
    font-weight: 800; 
    pointer-events: none; 
    z-index: 0;
}

.footer-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); 
    gap: 40px; 
    position: relative; 
    z-index: 1; 
}

.footer-col h4 {
    color: white;
    font-size: 1.1rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
}

.footer-col p {
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 10px;
    font-weight: 300;
}

/* จัดระเบียบโซเชียลมีเดีย */
.footer-socials { 
    display: flex; 
    gap: 12px; 
    margin-top: 20px; 
}

.footer-socials a { 
    width: 38px; 
    height: 38px; 
    background-color: rgba(255, 255, 255, 0.1); 
    color: white; 
    border-radius: 50%; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    text-decoration: none; 
    transition: 0.3s;
    font-size: 1.1rem;
}

.footer-socials a:hover { 
    background-color: var(--primary-red); 
    transform: translateY(-3px);
}

/* จัดระเบียบลิงก์ที่เกี่ยวข้อง */
.footer-links { 
    list-style: none; 
    padding-left: 0;
}

.footer-links li { 
    margin-bottom: 12px; 
    display: flex;
    align-items: center;
}

.footer-links li::before {
    content: "\f105"; 
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    color: var(--primary-red);
    margin-right: 10px;
}

.footer-links a { 
    color: #e5e7eb !important; 
    text-decoration: none; 
    font-size: 0.95rem;
    font-weight: 300;
    transition: 0.3s; 
}

.footer-links a:hover { 
    color: #facc15 !important; 
    padding-left: 5px; 
}

.footer-logo {
    width: 80px;
    margin-top: 15px;
    border-radius: 50%; 
}

.footer-bottom { 
    background-color: #0f0d26; 
    padding: 15px 0; 
    text-align: center; 
    color: rgba(255, 255, 255, 0.4); 
    font-size: 0.85rem; 
    font-weight: 300;
}

/* ========================================= */
/* Back to Top Button */
/* ========================================= */
#backToTopBtn {
    position: fixed; 
    bottom: 25px; 
    right: 25px; 
    z-index: 99; 
    font-size: 1.5rem;
    border: none; 
    background-color: var(--primary-red); 
    color: white;
    cursor: pointer; 
    width: 45px; 
    height: 45px; 
    border-radius: 50%; 
    display: none;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

#backToTopBtn:hover { 
    background-color: var(--heading-color); 
}

/* ========================================= */
/* Responsive ย่อย */
/* ========================================= */
@media (max-width: 992px) {
    .footer-cta { flex-direction: column; }
    .cta-left { 
        background: var(--primary-red); 
        flex-direction: column; 
        text-align: center; 
        clip-path: none;
        padding: 30px;
    }
    .cta-info {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .cta-center-icon { display: none; }
}

@media (max-width: 768px) {
    .contact-grid { grid-template-columns: 1fr; }
    .qa-flex { flex-direction: column; }
    .scene { transform: scale(0.85); }
    .gallery-container { height: 550px; }
    .title-left h2 { font-size: 1.6rem; }
}

//* ========================================= */
/* หน้าโครงสร้างบริหาร (Organization Chart) */
/* ========================================= */
.org-tree-container {
    width: 100%;
    overflow-x: auto;
    padding: 20px 0 60px 0;
}

.org-tree {
    display: flex;
    justify-content: center;
    min-width: max-content;
}

.org-tree ul {
    padding-top: 30px;
    position: relative;
    display: flex;
    justify-content: center;
    list-style-type: none;
    padding-left: 0;
    margin: 0;
}

.org-tree li {
    text-align: center;
    list-style-type: none;
    position: relative; /* <-- จุดนี้แหละครับที่หายไป ทำให้เส้นบินไปด้านบน */
    padding: 30px 15px 0 15px;
}

/* เส้นโครงสร้างบริหาร */
.org-tree li::before, .org-tree li::after {
    content: '';
    position: absolute;
    top: 0;
    right: 50%;
    border-top: 3px solid #000;
    width: 50%;
    height: 30px;
}

.org-tree li::after {
    right: auto;
    left: 50%;
    border-left: 3px solid #000;
}

.org-tree li:only-child::after, .org-tree li:only-child::before {
    display: none;
}

.org-tree li:only-child {
    padding-top: 0;
}

.org-tree li:first-child::before, .org-tree li:last-child::after {
    border: 0 none;
}

.org-tree li:first-child::after {
    border-radius: 5px 0 0 0;
}

.org-tree li:last-child::before {
    border-right: 3px solid #000;
    border-radius: 0 5px 0 0;
}

/* เส้นแนวตั้งที่ลากลงมาจาก Node แม่ */
.org-tree ul ul::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    border-left: 3px solid #000;
    width: 0;
    height: 30px;
    transform: translateX(-50%);
}

/* สไตล์ของกล่องข้อมูล (บัตร) */
.org-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    margin-top: 15px;
}

/* ========================================= */
/* เส้นและลูกศรโครงสร้างบริหาร (อัปเกรด UI & Animation) */
/* ========================================= */

/* 1. เปลี่ยนสีเส้นโครงสร้างให้ดูนุ่มนวลและทันสมัยขึ้น (ใช้สีแดงของวิทยาลัย) */
.org-tree li::before, .org-tree li::after {
    content: '';
    position: absolute;
    top: 0;
    right: 50%;
    border-top: 3px solid var(--primary-red);
    width: 50%;
    height: 30px;
}

.org-tree li::after {
    right: auto;
    left: 50%;
    border-left: 3px solid var(--primary-red);
}

.org-tree li:only-child::after, .org-tree li:only-child::before {
    display: none;
}

.org-tree li:only-child {
    padding-top: 0;
}

.org-tree li:first-child::before, .org-tree li:last-child::after {
    border: 0 none;
}

/* ทำให้มุมเส้นมีความโค้งมนเล็กน้อย ไม่ดูแข็งกระด้าง */
.org-tree li:first-child::after {
    border-radius: 8px 0 0 0;
}

.org-tree li:last-child::before {
    border-right: 3px solid var(--primary-red);
    border-radius: 0 8px 0 0;
}

/* เส้นแนวตั้งที่ลากลงมาจาก Node แม่ */
.org-tree ul ul::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    border-left: 3px solid var(--primary-red);
    width: 0;
    height: 30px;
    transform: translateX(-50%);
}

.org-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    margin-top: 25px; /* เพิ่มระยะให้ลูกศรมีพื้นที่ขยับกระดิกได้ */
}

/* 2. สร้างลูกศรด้วยไอคอน FontAwesome และใส่เอฟเฟกต์เด้งขึ้นลง */
.org-tree ul ul li .org-node::before {
    content: '\f107'; /* รหัสไอคอน Angle-Down ของ FontAwesome */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: -36px;
    left: 50%;
    font-size: 1.8rem; /* ขยายขนาดลูกศรให้ชัดขึ้น */
    color: var(--primary-red);
    background-color: var(--light-bg); /* ใช้สีพื้นหลังบังเส้นทับตรงกลางให้ดูมีมิติ */
    padding: 0 10px;
    border: none;
    
    /* เรียกใช้แอนิเมชัน */
    animation: arrowBounce 2s infinite ease-in-out;
}

/* คำสั่งแอนิเมชันให้ลูกศรขยับขึ้น-ลงอย่างนุ่มนวล */
@keyframes arrowBounce {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(6px); text-shadow: 0 4px 8px rgba(185, 28, 28, 0.4); }
}

/* สไตล์ของกล่องรูปภาพและข้อมูล (คงเดิม) */
.org-card {
    width: 140px;
    height: 160px;
    background-color: #4472c4;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-weight: 500;
    margin-bottom: 15px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: transform 0.3s, box-shadow 0.3s;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.org-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
    border-color: #facc15;
}

.org-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.org-info {
    max-width: 220px;
}

.org-info h4 {
    font-size: 1.05rem;
    color: var(--heading-color);
    margin-bottom: 5px;
    font-weight: 600;
}

.org-info p {
    font-size: 0.85rem;
    color: var(--muted-text);
    line-height: 1.4;
}

/* 3. โหมดมืด (ปรับเส้นและลูกศรเป็นสีเหลืองทองให้ตัดกับพื้นหลังมืด) */
body.dark-mode .org-card {
    background-color: #2b4982;
}
body.dark-mode .org-tree li::before,
body.dark-mode .org-tree li::after,
body.dark-mode .org-tree ul ul::before,
body.dark-mode .org-tree li:last-child::before {
    border-color: #facc15; 
}
body.dark-mode .org-tree ul ul li .org-node::before {
    color: #facc15;
    background-color: var(--light-bg);
}

/* ปรับสีเส้นตอนใช้ Dark Mode */
body.dark-mode .org-card {
    background-color: #2b4982;
}
body.dark-mode .org-tree li::before,
body.dark-mode .org-tree li::after,
body.dark-mode .org-tree ul ul::before,
body.dark-mode .org-tree li:last-child::before {
    border-color: var(--text-color); 
}
body.dark-mode .org-tree ul ul li .org-node::before {
    border-top-color: var(--text-color);
    border-left-color: transparent;
    border-right-color: transparent;
}

/* ========================================= */
/* แกลเลอรีรูปภาพ (สำหรับข้อมูลด้านสังคม) */
/* ========================================= */
.content-gallery {
    display: grid;
    /* สำหรับ PC และ iPad: จะปรับจำนวนคอลัมน์อัตโนมัติ ถ้าที่พอจะแสดง 2-3 รูป */
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
    margin-top: 20px;
    margin-bottom: 20px;
}

.content-gallery img {
    width: 100%;
    height: 220px; /* ล็อกความสูงให้เท่ากันทุกรูป */
    object-fit: cover; /* ตัดรูปภาพส่วนเกินออกโดยไม่ทำให้สัดส่วนรูปเบี้ยว */
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.content-gallery img:hover {
    transform: scale(1.03); /* เอฟเฟกต์ซูมเล็กน้อยเมื่อเอาเมาส์ชี้ */
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
    border-color: var(--primary-red);
}

/* ========================================= */
/* ปรับแต่งสำหรับหน้าจอมือถือ (สมาร์ทโฟน) */
/* ========================================= */
@media (max-width: 576px) {
    .content-gallery {
        grid-template-columns: 1fr; /* บังคับให้แสดงแถวละ 1 รูป เรียงต่อกันลงมา */
        gap: 12px;
    }
    
    .content-gallery img {
        height: 200px; /* ปรับความสูงลงเล็กน้อยให้พอดีกับแนวนอนของมือถือ */
    }
}

/* ========================================= */
/* หน้าข่าวประชาสัมพันธ์และจัดซื้อจัดจ้าง (News List) */
/* ========================================= */
.news-list-wrapper {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
}

.list-heading {
    color: var(--heading-color);
    font-size: 1.4rem;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

.text-link-list {
    list-style: none;
    padding: 0;
    margin: 0 0 30px 0;
}

.text-link-list li {
    margin-bottom: 15px;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 12px;
}

.text-link-list li:last-child {
    border-bottom: none;
}

.text-link-list a {
    color: var(--text-color);
    text-decoration: none;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: 0.3s;
}

.text-link-list a i {
    font-size: 1.2rem;
    color: #4b5563;
}

/* สีไอคอนเฉพาะสำหรับ PDF */
.pdf-list a i {
    color: var(--primary-red);
}

.text-link-list a:hover {
    color: var(--primary-red);
    transform: translateX(5px);
}

.text-link-list a:hover i {
    color: var(--primary-red);
}

/* ========================================= */
/* ระบบแบ่งหน้า (Pagination) */
/* ========================================= */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
}

.pagination a {
    color: var(--text-color);
    text-decoration: none;
    padding: 8px 14px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: 0.3s;
    font-size: 0.95rem;
}

.pagination a:hover {
    background-color: var(--topbar-bg);
    color: var(--primary-red);
    border-color: var(--primary-red);
}

.pagination a.active {
    background-color: var(--primary-red);
    color: white;
    border-color: var(--primary-red);
}

/* ========================================= */
/* ลูกเล่น 3D Flip Card สำหรับหน้าข่าวประชาสัมพันธ์ */
/* ========================================= */

/* ล้างพื้นหลังเดิมของตัวเซลล์ เพื่อให้โปร่งใส */
.carousel-cell.news-flip-card {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    perspective: 1000px;
}

/* กล่องย่อยด้านในที่เป็นตัวรับคำสั่งพลิกหน้า-หลัง */
.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1);
    transform-style: preserve-3d;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

/* คำสั่งพลิกการ์ด 180 องศาเมื่อนำเมาส์ไปชี้ */
.carousel-cell.news-flip-card:hover .flip-card-inner {
    transform: rotateY(180deg);
}

/* ตั้งค่าพื้นฐานให้หน้าและหลังทับกัน และซ่อนด้านที่หันหลังอยู่ */
.flip-card-front, .flip-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden; 
    backface-visibility: hidden;
    border-radius: 12px;
    overflow: hidden;
}

/* ---------- ตกแต่งด้านหน้า (รูปภาพเต็มแผ่น) ---------- */
.flip-card-front {
    background: var(--card-bg);
    display: flex;
    flex-direction: column;
    border: none; /* เอาเส้นขอบออกให้รูปเต็มพื้นที่ */
}

/* บังคับให้รูปภาพขยายเต็ม 100% ของพื้นที่การ์ด */
.flip-card-front img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border: none;
}

/* จัดกล่องข้อความให้ลอยอยู่ทับรูปภาพด้านล่าง */
.flip-card-front .cell-content {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end; /* ดันเนื้อหาไปด้านล่างสุด */
    align-items: center;
    padding-bottom: 25px;
    /* ไล่สีดำโปร่งแสงจากขอบล่างขึ้นมา เพื่อให้ปุ่มอ่านง่ายขึ้นเมื่อภาพสว่าง */
    background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 40%);
}

/* ซ่อนหัวข้อ h3 ด้านหน้า ให้เหลือแค่ปุ่มตามที่คุณต้องการ */
.flip-card-front .cell-content h3 {
    display: none;
}

/* ตกแต่งปุ่มชี้เพื่อดูรายละเอียดให้โดดเด่นเมื่ออยู่บนรูปภาพ */
.flip-hint {
    color: #ffffff;
    background: rgba(185, 28, 28, 0.9); /* สีแดงวิทยาลัยแบบโปร่งแสง */
    border: 1px solid rgba(255, 255, 255, 0.5);
    font-size: 0.85rem;
    padding: 8px 25px;
    border-radius: 25px;
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    backdrop-filter: blur(4px); /* เพิ่มลูกเล่นเบลอพื้นหลังปุ่ม */
}

/* ---------- ตกแต่งด้านหลัง (ข้อความอธิบาย) ---------- */
.flip-card-back {
    background: var(--dark-blue); /* ใช้สีน้ำเงินเข้ม */
    color: white;
    transform: rotateY(180deg); /* หมุนกลับหลังเตรียมรอไว้ */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 25px;
    border: 2px solid var(--primary-red);
}

.flip-card-back h3 {
    color: #facc15; /* สีเหลืองทอง */
    font-size: 1.4rem;
    margin-bottom: 15px;
}

.flip-card-back p {
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 25px;
    color: #e5e7eb;
}

.btn-view-back {
    background: var(--primary-red);
    color: white;
    border: none;
    padding: 10px 25px;
    border-radius: 25px;
    cursor: pointer;
    transition: 0.3s;
    font-weight: 500;
    box-shadow: 0 4px 10px rgba(185, 28, 28, 0.4);
}

.btn-view-back:hover {
    background: #facc15;
    color: var(--dark-blue);
    transform: translateY(-2px);
}

/* แก้ไขเอฟเฟกต์ Glow เรืองแสงให้แสดงผลที่กล่องด้านใน ไม่ใช่ขอบใส */
.carousel-cell.news-flip-card.active-glow {
    box-shadow: none !important;
}
.carousel-cell.news-flip-card.active-glow .flip-card-inner {
    box-shadow: 0 0 25px rgba(185, 28, 28, 0.5);
}

