/* Global Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Sarabun', 'Helvetica Neue', Arial, sans-serif;
}

:root {
    --primary-color: #1e3f20; /* เขียวทหารเข้ม */
    --secondary-color: #3b5e3d; /* เขียวมะกอก */
    --accent-color: #c9a054; /* สีทอง */
    --light-bg: #f4f6f4;
    --dark-text: #222222;
    --white: #ffffff;
}

body {
    background-color: var(--light-bg);
    color: var(--dark-text);
    line-height: 1.6;
}

/* Header & Navigation */
header {
    background-color: var(--primary-color);
    border-bottom: 3px solid var(--accent-color);
    padding: 20px;
    color: var(--white);
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.header-container h1 {
    font-size: 24px;
    color: var(--accent-color);
    margin-bottom: 5px;
}

.header-container h2 {
    font-size: 16px;
    font-weight: normal;
    opacity: 0.9;
}

nav {
    background-color: var(--secondary-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* ปุ่ม 3 ขีด (ซ่อนในคอมพิวเตอร์) */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 26px;
    height: 18px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
}

.menu-toggle span {
    width: 100%;
    height: 3px;
    background-color: var(--white);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.nav-menu {
    display: flex;
    justify-content: center;
    width: 100%;
}

.nav-menu a {
    color: var(--white);
    text-decoration: none;
    padding: 14px 20px;
    font-size: 15px;
    transition: all 0.3s ease;
    text-align: center;
}

.nav-menu a:hover, .nav-menu a.active {
    background-color: var(--accent-color);
    color: var(--primary-color);
    font-weight: bold;
}

/* Main Layout */
main {
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 15px;
    min-height: 60vh;
}

.page-title {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 30px;
    font-size: 26px;
    position: relative;
    padding-bottom: 10px;
}

.page-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 3px;
    background-color: var(--accent-color);
}

/* Landing Page (Mourning) */
.landing-body {
    background-color: #0c0c0c;
    color: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.mourning-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 600px;
}

.mourning-container {
    width: 100%;
    background: #141414;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 15px 40px rgba(0,0,0,0.8);
    margin-bottom: 25px;
}

.mourning-img {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #000;
}

.mourning-img img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
}

.mourning-content {
    padding: 35px 25px;
    text-align: center;
}

.mourning-title {
    color: #ffffff;
    font-size: 22px;
    line-height: 1.6;
    font-weight: 600;
    margin-bottom: 20px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.mourning-text {
    font-size: 16px;
    color: #e0e0e0;
    line-height: 1.8;
}

.enter-btn-wrapper {
    width: 100%;
    text-align: center;
}

.enter-btn {
    display: inline-block;
    background-color: transparent;
    color: #c9a054;
    padding: 12px 45px;
    text-decoration: none;
    font-weight: 600;
    font-size: 16px;
    border: 2px solid #c9a054;
    border-radius: 25px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.enter-btn:hover {
    background-color: #c9a054;
    color: #0c0c0c;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(201, 160, 84, 0.4);
}

/* Grid & Cards (สำหรับหน้าแรก / หน้ากิจกรรม) */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    margin-top: 20px;
}

.card {
    background: var(--white);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    border-top: 4px solid var(--secondary-color);
    transition: transform 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
}

.card-img {
    width: 100%;
    height: 220px;
    overflow: hidden;
    background: #e0e0e0;
}

.card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    cursor: pointer;
}

.card-content {
    padding: 20px;
}

.card-content h3 {
    color: var(--primary-color);
    margin-bottom: 12px;
    font-size: 19px;
}

/* ==========================================================================
   Commander Layout & Organization Chart Styles (ปรับปรุงใหม่เพื่อรองรับสายการบังคับบัญชา)
   ========================================================================== */
.commander-org-chart {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
}

/* แถวจัดกลุ่มการ์ดตำแหน่ง */
.chart-row {
    display: flex;
    width: 100%;
    gap: 20px;
}

/* จัดกึ่งกลางเดี่ยว (ผบ.พัน / รอง ผบ.พัน) */
.center-row {
    justify-content: center;
}

/* แบ่งโครงสร้างเป็นคู่ขนานซ้าย-ขวา (ฝอ.1 - ฝอ.3 และ ฝอ.4 - ฝอ.5) */
.split-row {
    justify-content: center;
    max-width: 760px; /* คุมระยะไม่ให้ห่างกันจนเกินไปบนจอใหญ่ */
}

.split-row .commander-card {
    flex: 1;
}

/* แถวแสดงผล 4 กองร้อยพร้อมกัน */
.companies-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    width: 100%;
}

/* สไตล์พื้นฐานของกล่องประจำตำแหน่ง (การ์ด) */
.commander-card {
    background: var(--white);
    padding: 20px;
    border-radius: 8px;
    border-top: 4px solid var(--secondary-color);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    text-align: center;
    transition: transform 0.3s ease;
}

.commander-card:hover {
    transform: translateY(-3px);
}

/* ขอบทองเน้นพิเศษสำหรับตำแหน่งสูงสุด (ผบ.พัน) */
.gold-border {
    border: 2px solid var(--accent-color);
    border-top: 5px solid var(--accent-color);
    max-width: 340px;
    width: 100%;
}

/* ขนาดกรอบสัดส่วนรูปภาพประจำตัวแนวตั้ง */
.commander-card .commander-img {
    width: 140px;
    height: 185px;
    background: #ccc;
    margin: 0 auto 15px auto;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.commander-card .commander-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* การจัดขนาดข้อความในการ์ดผู้บังคับบัญชา */
.commander-card h3 {
    font-size: 16px;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.commander-card .name {
    font-weight: bold;
    font-size: 15px;
    color: #333;
}

.commander-card .position {
    font-size: 13px;
    color: #666;
    margin-top: 2px;
}

/* สไตล์ลดขนาดความกว้างของการ์ดกลุ่มผู้บังคับกองร้อย (ผบ.ร้อย) */
.small-card {
    padding: 15px 10px;
}
.small-card .commander-img {
    width: 110px;
    height: 145px;
}
.small-card h3 {
    font-size: 14px;
}
.small-card .name {
    font-size: 13px;
}

/* หัวข้อหรือเส้นคั่นหมวดหมู่ย่อยในผัง */
.section-divider {
    width: 100%;
    text-align: center;
    color: var(--primary-color);
    margin: 25px 0 10px 0;
    font-size: 18px;
    position: relative;
}

/* โครงสร้างตารางทำเนียบรายนามอดีตผู้บังคับบัญชา */
.commander-list {
    width: 100%;
    max-width: 850px;
    background: var(--white);
    border-collapse: collapse;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.commander-list th, .commander-list td {
    padding: 14px 18px;
    text-align: left;
}

.commander-list th {
    background-color: var(--primary-color);
    color: var(--white);
}

.commander-list tr:nth-child(even) {
    background-color: #f9f9f9;
}

/* Contact Page & Maps */
.contact-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 30px;
    background: var(--white);
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.contact-info h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 20px;
}

.contact-info p {
    margin-bottom: 12px;
}

.map-container iframe {
    width: 100%;
    height: 350px;
    border: 0;
    border-radius: 8px;
}

/* Lightbox Modal (ขยายรูป) */
.modal {
    display: none;
    position: fixed;
    z-index: 200;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.85);
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.modal-content {
    max-width: 85%;
    max-height: 75vh;
    border: 3px solid var(--accent-color);
    border-radius: 4px;
    object-fit: contain;
}

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

/* Footer */
footer {
    background-color: var(--primary-color);
    color: var(--white);
    text-align: center;
    padding: 25px;
    margin-top: 50px;
    font-size: 14px;
    border-top: 3px solid var(--accent-color);
}

/* ==========================================================================
   Responsive Settings (สำหรับ Tablet และ Smartphone)
   ========================================================================== */
@media (max-width: 768px) {
    .nav-container {
        justify-content: flex-end;
        padding: 12px 20px;
    }

    .menu-toggle {
        display: flex;
    }

    .nav-menu {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background-color: var(--secondary-color);
        box-shadow: 0 4px 10px rgba(0,0,0,0.15);
        border-top: 1px solid rgba(255,255,255,0.1);
    }

    .nav-menu.show {
        display: flex;
    }

    .nav-menu a {
        padding: 14px 20px;
        width: 100%;
        text-align: left;
        border-bottom: 1px solid rgba(255,255,255,0.05);
    }

    .header-container h1 {
        font-size: 20px;
    }
    .page-title {
        font-size: 22px;
    }
    .contact-container {
        grid-template-columns: 1fr;
    }
    .mourning-title {
        font-size: 18px;
    }
    .mourning-text {
        font-size: 14px;
    }
    .enter-btn {
        padding: 10px 35px;
        font-size: 15px;
    }

    /* การปรับการจัดวางแผนผังองค์กรบนหน้าจอมือถือ/แท็บเล็ต */
    .split-row {
        flex-direction: column;
        align-items: center;
    }
    .split-row .commander-card {
        width: 100%;
        max-width: 320px;
    }
    .companies-row {
        grid-template-columns: repeat(2, 1fr); /* บนมือถือทั่วไปแบ่งกองร้อยออกเป็นแถวละ 2 กล่องคู่กัน */
    }
}

@media (max-width: 480px) {
    .companies-row {
        grid-template-columns: 1fr; /* บนสมาร์ตโฟนหน้าจอขนาดเล็ก ให้ทุกการ์ดเรียงต่อเป็นแนวดิ่งเดี่ยว */
    }
    .companies-row .commander-card {
        max-width: 280px;
        margin: 0 auto;
    }
}/* สไตล์สำหรับปุ่มอ่านต่อ */
.read-more-btn {
    display: inline-block;
    background-color: var(--secondary-color); /* เขียวมะกอก */
    color: var(--white);
    padding: 8px 20px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    border-radius: 4px;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.read-more-btn:hover {
    background-color: var(--accent-color); /* เปลี่ยนเป็นสีทองเวลาชี้ */
    color: var(--primary-color); /* ตัวหนังสือเข้มขึ้น */
    transform: translateY(-2px);
}

/* สไตล์สำหรับหน้าข่าวสารและแกลเลอรีรูปภาพ */
.news-detail-container {
    background: var(--white);
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    margin-bottom: 30px;
}

.news-full-text {
    font-size: 16px;
    line-height: 1.8;
    color: var(--dark-text);
    margin-bottom: 30px;
    text-indent: 2em; /* ย่อหน้าแรก */
}

.image-gallery-title {
    color: var(--primary-color);
    border-left: 4px solid var(--accent-color);
    padding-left: 10px;
    margin-bottom: 20px;
    font-size: 18px;
}

.news-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 15px;
}

.gallery-item {
    width: 100%;
    height: 180px;
    overflow: hidden;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border: 1px solid #ddd;
}

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

.gallery-item:hover img {
    transform: scale(1.05); /* ขยายรูปเล็กน้อยเวลาชี้ */
}

.back-home-btn {
    display: inline-block;
    margin-top: 25px;
    color: var(--secondary-color);
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
}
.back-home-btn:hover {
    color: var(--accent-color);
    text-decoration: underline;
}