:root {
    --navy: #14477e;
    --navy-dark: #0d3560;
    --blue-bar: #1d6fbd;
    --blue-bar-dark: #175a99;
    --paper: #eef1f4;
    --ink: #26313a;
    --line: #dfe4ea;
    --gold: #f2a900;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Sarabun', 'Chulabhorn Likit Text', sans-serif;
    background: var(--paper);
    color: var(--ink);
    line-height: 1.65;
}

h1, h2, h3, h4, h5, h6 { font-family: 'Kanit', 'Sarabun', sans-serif; font-weight: 700; }

a { color: var(--navy); text-decoration: none; }
a:hover { color: var(--blue-bar); }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* ---------- Top identity bar ---------- */
.identity-bar {
    background: #fff;
    border-bottom: 3px solid var(--gold);
    padding: 14px 0;
}
.identity-bar .inner { display: flex; align-items: center; gap: 16px; }
.identity-bar img.logo { height: 56px; width: 56px; object-fit: contain; }
.identity-bar .org-name { font-size: 1.25rem; font-weight: 700; color: var(--navy-dark); margin: 0; }
.identity-bar .org-sub { font-size: .82rem; color: #6b7785; margin: 2px 0 0; }

/* ---------- Navbar ---------- */
.main-nav {
    background: linear-gradient(180deg, var(--navy) 0%, var(--navy-dark) 100%);
    position: relative;
    z-index: 40;
}
.main-nav-sticky { position: sticky; top: 0; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.main-nav .nav-wrap { display: flex; align-items: center; gap: 8px; }
.main-nav .nav-inner { display: flex; flex-wrap: wrap; flex: 1; }
.nav-hamburger {
    display: none; background: none; border: none; color: #fff; font-size: 1.5rem;
    padding: 10px 4px; cursor: pointer;
}
.main-nav a.nav-link {
    color: #fff; padding: 13px 18px; font-size: .92rem; font-weight: 600;
    display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.main-nav a.nav-link:hover, .main-nav .nav-item.open > a.nav-link { background: rgba(255,255,255,.12); color: #fff; }
.nav-item { position: relative; }
.nav-item .dropdown {
    display: none; position: absolute; left: 0; top: 100%; min-width: 230px;
    background: #fff; box-shadow: 0 10px 24px rgba(0,0,0,.18); border-radius: 0 0 8px 8px;
    padding: 6px 0; z-index: 50;
}
.nav-item.open .dropdown { display: block; }
.nav-item .dropdown a { display: block; padding: 9px 18px; color: var(--ink); font-size: .88rem; }
.nav-item .dropdown a:hover { background: var(--paper); color: var(--navy); }

/* ---------- Hero slider ---------- */
.hero { position: relative; background: #0b1b2b; overflow: hidden; }
.hero-track { display: flex; transition: transform .5s ease; }
.hero-slide { min-width: 100%; }
.hero-slide img { width: 100%; height: 380px; object-fit: contain; background: #0b1b2b; display: block; }
.hero-nav-btn {
    position: absolute; top: 50%; transform: translateY(-50%); z-index: 10;
    background: rgba(255,255,255,.15); border: none; color: #fff; width: 42px; height: 42px;
    border-radius: 50%; font-size: 1.2rem; cursor: pointer;
}
.hero-nav-btn:hover { background: rgba(255,255,255,.3); }
.hero-nav-btn.prev { left: 16px; } .hero-nav-btn.next { right: 16px; }
.hero-dots { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; z-index: 10; }
.hero-dots span { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.4); cursor: pointer; }
.hero-dots span.active { background: #fff; }

/* ---------- Content cards ---------- */
.content-area { padding: 28px 0 40px; }

/* ---------- 2-column layout: sidebar ซ้าย, เนื้อหาขวา (ตามภาพตัวอย่าง) ---------- */
.layout-2col { display: grid; grid-template-columns: 280px 1fr; gap: 24px; align-items: start; }
.layout-2col > div:first-child { order: 2; } /* เนื้อหาหลัก (มาก่อนใน DOM) แสดงฝั่งขวา */
.layout-2col > div:last-child { order: 1; }  /* sidebar (มาทีหลังใน DOM) แสดงฝั่งซ้าย */
@media (max-width: 900px) {
    .layout-2col { grid-template-columns: 1fr; }
    .layout-2col > div:first-child { order: 1; } /* มือถือ: เนื้อหาหลักขึ้นก่อนเสมอ */
    .layout-2col > div:last-child { order: 2; }
}
.card-block { background: #fff; border-radius: 6px; overflow: hidden; margin-bottom: 22px; box-shadow: 0 2px 8px rgba(20,71,126,.06); }
.card-block .bar {
    background: linear-gradient(120deg, var(--blue-bar) 0%, var(--blue-bar-dark) 100%);
    color: #fff; padding: 11px 16px; font-weight: 700; font-size: .96rem;
    display: flex; align-items: center; gap: 8px;
}
.card-block .body { padding: 14px 18px 6px; }
.card-block .item { padding: 10px 0; border-bottom: 1px solid var(--line); }
.card-block .item:last-child { border-bottom: none; }
.card-block .item a { font-size: .93rem; color: var(--ink); font-weight: 500; }
.card-block .item a:hover { color: var(--blue-bar-dark); }
.card-block .item .date { font-size: .76rem; color: #8a94a0; margin-top: 2px; }
.card-block .item .date i { margin-right: 4px; }
.card-block .more-btn-wrap { text-align: right; padding: 10px 18px 16px; }
.btn-pill {
    display: inline-block; border: 1.5px solid var(--blue-bar); color: var(--blue-bar-dark);
    border-radius: 50px; padding: 5px 18px; font-size: .84rem; font-weight: 600; background: #fff;
}
.btn-pill:hover { background: var(--blue-bar); color: #fff; }
.btn-pill-solid { background: var(--blue-bar); color: #fff; border-color: var(--blue-bar); }
.btn-pill-solid:hover { background: var(--blue-bar-dark); color: #fff; }

/* ---------- Sidebar quick links ---------- */
.sidebar-card { background: #fff; border-radius: 6px; box-shadow: 0 2px 8px rgba(20,71,126,.06); padding: 16px; margin-bottom: 20px; }
.sidebar-card h6 { color: var(--navy-dark); font-size: .95rem; margin: 0 0 10px; display: flex; align-items: center; gap: 6px; }
.sidebar-card a.quick-link { display: flex; align-items: center; gap: 8px; padding: 9px 4px; font-size: .9rem; border-bottom: 1px solid var(--line); }
.sidebar-card a.quick-link:last-child { border-bottom: none; }
.sidebar-card a.quick-link:hover { color: var(--blue-bar-dark); }

/* ---------- Footer ---------- */
.site-footer { background: linear-gradient(180deg, var(--navy) 0%, var(--navy-dark) 100%); color: rgba(255,255,255,.9); padding: 34px 0 18px; margin-top: 20px; }
.site-footer h6 { color: #fff; font-size: .92rem; margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }
.site-footer .col p, .site-footer .col div { font-size: .84rem; color: rgba(255,255,255,.78); margin: 0 0 6px; }
.site-footer .footer-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.footer-bottom { text-align: center; font-size: .78rem; color: rgba(255,255,255,.55); border-top: 1px solid rgba(255,255,255,.15); margin-top: 22px; padding-top: 14px; }

/* ---------- Detail page ---------- */
.detail-page { background: #fff; border-radius: 6px; padding: 26px 28px; box-shadow: 0 2px 8px rgba(20,71,126,.06); }
.detail-page h1 { font-size: 1.4rem; color: var(--navy-dark); margin-bottom: 6px; }
.detail-page .meta { font-size: .82rem; color: #8a94a0; margin-bottom: 18px; }
.detail-page .content { font-size: .95rem; line-height: 1.9; }
.detail-page img { max-width: 100%; border-radius: 6px; margin: 10px 0; }

/* ---------- File detail (แสดงไฟล์ภายในหน้าเว็บ) ---------- */
.detail-page .file-view-img { display: block; margin: 10px auto; border: 1px solid var(--line); }
.file-view-pdf { width: 100%; height: 80vh; min-height: 480px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); }
.file-view-other { text-align: center; padding: 36px 16px; background: var(--paper); border: 1px dashed var(--line); border-radius: 6px; color: #6b7480; }
.file-view-other i { font-size: 3rem; color: var(--blue-bar); }
.file-view-other p { margin: 10px 0 0; font-size: .9rem; }
.file-view-actions { margin-top: 18px; text-align: center; }

/* ---------- กิจกรรม (การ์ดภาพหลัก + Modal ดูภาพทั้งหมด) ---------- */
.activity-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; padding: 6px 0 12px; }
.activity-card {
    display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 0; border: 0;
    background: none; cursor: pointer; font: inherit; color: var(--ink);
}
.activity-cover { position: relative; display: block; aspect-ratio: 4 / 3; border-radius: 6px; overflow: hidden; background: var(--paper); }
.activity-cover img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s ease; }
.activity-card:hover .activity-cover img { transform: scale(1.05); }
.activity-count {
    position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.6); color: #fff;
    font-size: .75rem; padding: 2px 8px; border-radius: 999px;
}
.activity-title { font-size: .93rem; font-weight: 600; line-height: 1.4; margin-top: 4px; }
.activity-card:hover .activity-title { color: var(--blue-bar); }
.activity-card .date { font-size: .78rem; color: #8a94a0; }

.gallery-modal { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 16px; }
.gallery-modal[hidden], .gallery-modal [hidden] { display: none !important; }
.gallery-backdrop { position: absolute; inset: 0; background: rgba(10,10,15,.85); }
.gallery-box { position: relative; width: 100%; max-width: 1000px; max-height: 100%; display: flex; flex-direction: column; gap: 10px; }
.gallery-head { display: flex; align-items: center; gap: 12px; color: #fff; }
.gallery-head h5 { margin: 0; font-size: 1.05rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gallery-counter { font-size: .85rem; color: rgba(255,255,255,.75); }
.gallery-close { background: none; border: 0; color: #fff; font-size: 1.4rem; cursor: pointer; line-height: 1; padding: 4px; }
.gallery-stage { position: relative; display: flex; align-items: center; justify-content: center; min-height: 0; }
.gallery-stage img { max-width: 100%; max-height: 72vh; object-fit: contain; border-radius: 4px; user-select: none; }
.gallery-nav {
    position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%;
    border: 0; background: rgba(255,255,255,.18); color: #fff; font-size: 1.3rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.gallery-nav:hover { background: rgba(255,255,255,.35); }
.gallery-nav.prev { left: 6px; }
.gallery-nav.next { right: 6px; }
.gallery-thumbs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; justify-content: safe center; }
.gallery-thumbs button { flex: 0 0 auto; padding: 0; border: 2px solid transparent; border-radius: 4px; background: none; cursor: pointer; opacity: .55; }
.gallery-thumbs button.active { border-color: #fff; opacity: 1; }
.gallery-thumbs img { width: 64px; height: 48px; object-fit: cover; display: block; border-radius: 2px; }
@media (max-width: 600px) {
    .activity-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .gallery-stage img { max-height: 60vh; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .site-footer .footer-grid { grid-template-columns: 1fr; }
    .hero-slide img { height: 220px; }
    .nav-hamburger { display: block; }
    .main-nav .nav-inner {
        flex-direction: column; width: 100%; max-height: 0; overflow: hidden;
        transition: max-height .25s ease;
    }
    .main-nav .nav-inner.nav-open { max-height: 1000px; }
    .nav-item .dropdown { position: static; box-shadow: none; }
}

/* ---------- File thumbnails (แสดงภาพเต็มแบบ thumbnail ถ้าไฟล์เป็นรูปภาพ) ---------- */
.d-flex-item { display: flex; align-items: flex-start; gap: 12px; }
.file-thumb-link { flex-shrink: 0; }
.file-thumb {
    width: 72px; height: 72px; object-fit: contain; background: var(--paper);
    border: 1px solid var(--line); border-radius: 6px; display: block;
}

/* ---------- Pagination ---------- */
.pager { margin-top: 18px; display: flex; justify-content: center; }
.pager-list { list-style: none; display: flex; gap: 6px; padding: 0; margin: 0; flex-wrap: wrap; }
.pager-link {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 34px; height: 34px; padding: 0 8px; border-radius: 6px;
    border: 1px solid var(--line); color: var(--navy-dark); font-size: .85rem; font-weight: 600;
    background: #fff;
}
.pager-link:hover { background: var(--paper); color: var(--blue-bar-dark); }
.pager-link.active { background: var(--blue-bar); border-color: var(--blue-bar); color: #fff; }
.pager-link.disabled { opacity: .4; cursor: default; }

/* ---------- Leadership (sidebar mini box) ---------- */
.leader-mini {
    display: flex; flex-direction: column; align-items: center; text-align: center;
    padding: 14px 6px; border-bottom: 1px solid var(--line);
}
.leader-mini:last-of-type { border-bottom: none; }
.leader-mini img, .leader-mini-fallback {
    width: 160px; height: 190px; border-radius: 16px; object-fit: contain; background: var(--paper);
    flex-shrink: 0; margin-bottom: 10px; border: 1px solid var(--line);
}
.leader-mini-fallback { background: var(--paper); display: flex; align-items: center; justify-content: center; color: var(--navy); font-size: 3rem; }
.leader-mini-name { display: block; font-size: 1rem; font-weight: 700; color: var(--ink); line-height: 1.4; }
.leader-mini-position { display: block; font-size: .85rem; color: #8a94a0; margin-top: 2px; }

/* ---------- Leadership (full page grid) ---------- */
.leader-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 18px; }
.leader-card { text-align: center; }
.leader-card img, .leader-card-fallback {
    width: 100%; max-width: 160px; height: 190px; border-radius: 16px; object-fit: contain;
    background: var(--paper); border: 1px solid var(--line); margin: 0 auto 10px;
}
.leader-card-fallback { display: flex; align-items: center; justify-content: center; color: var(--navy); font-size: 2rem; }
.leader-card-name { font-weight: 600; font-size: .92rem; color: var(--ink); }
.leader-card-position { font-size: .8rem; color: #8a94a0; }

/* ---------- Back to top ---------- */
.back-to-top {
    position: fixed; right: 22px; bottom: 22px; width: 50px; height: 50px; border-radius: 50%;
    background: var(--blue-bar); color: #fff; border: 3px solid #fff; font-size: 1.25rem;
    box-shadow: 0 6px 16px rgba(0,0,0,.22);
    display: none; align-items: center; justify-content: center; z-index: 60; cursor: pointer;
    transition: transform .15s ease, background .15s ease;
}
.back-to-top.show { display: flex; }
.back-to-top:hover { background: var(--blue-bar-dark); transform: translateY(-2px); }

/* ---------- Logo Link grid (ลิงก์หน่วยงาน) ---------- */
.logo-link-grid { display: flex; flex-direction: column; gap: 12px; }
.logo-link-grid a { display: block; }
.logo-link-grid img { width: 100%; height: auto; display: block; border-radius: 8px; border: 1px solid var(--line); }

/* ---------- News/newsletter row with thumbnail + excerpt ---------- */
.news-row { display: flex; gap: 14px; align-items: flex-start; }
.news-thumb-link { flex-shrink: 0; }
.news-thumb {
    width: 120px; height: 88px; object-fit: contain; background: var(--paper);
    border: 1px solid var(--line); border-radius: 6px; display: block;
}
.news-row-body { flex: 1; min-width: 0; }
.news-row-title { display: block; font-weight: 600; font-size: .96rem; color: var(--ink); margin-bottom: 4px; }
.news-row-title:hover { color: var(--blue-bar-dark); }
.news-row-excerpt { font-size: .84rem; color: var(--ink-soft); margin: 0 0 6px; line-height: 1.6; }
@media (max-width: 600px) {
    .news-thumb { width: 84px; height: 64px; }
}

