/* ============================================================
   ird-theme.css — ชั้นธีมกลางของเว็บ IRD SUT
   โหลดต่อจาก style.css ใน header_TH.php จึงมีผลกับทุกหน้าที่ include header
   หลักการ: ไม่แตะโครงสร้าง HTML ของหน้าเดิม แค่ปรับหน้าตาให้เป็นชุดเดียวกัน
   สีหลักยังเป็นส้มตามธีมเดิม (#fd7e14 / #ffbf4e)
   ============================================================ */

:root {
    --ird-orange: #fd7e14;
    --ird-orange-dark: #e8690b;
    --ird-amber: #ffbf4e;
    --ird-ink: #2f3542;
    --ird-muted: #7a8290;
    --ird-line: #e8ecf1;
    --ird-bg: #f4f6f8;
    --ird-radius: 14px;
    --ird-shadow: 0 6px 20px rgba(31, 41, 55, .08);
    --ird-shadow-lg: 0 16px 36px rgba(31, 41, 55, .16);
}

/* ---------- พื้นฐาน ---------- */
html,
body {
    overflow-x: hidden;
}

body {
    background-color: var(--ird-bg);
    color: #4a5160;
}

img {
    max-width: 100%;
    height: auto;
}

a {
    transition: color .2s ease;
}

a:hover,
a:focus {
    color: var(--ird-orange);
    text-decoration: none;
}

/* ---------- แถบใต้เมนู (header bar) ----------
   คงโทนฟ้าเดิม #CAE1FF ไว้ตามที่ใช้กันอยู่ทุกหน้า
   ทำแค่ไล่เฉดอ่อน ๆ ในโทนฟ้าเดียวกัน ไม่เปลี่ยนสี */
section[style*="CAE1FF"],
div[style*="CAE1FF"] {
    background: linear-gradient(160deg, #d9eaff 0%, #CAE1FF 100%) !important;
    border-bottom: 3px solid #9cc4ec;
}

/* ---------- หัวข้อหน้า ----------
   ทุกหน้าใช้แถบเดียวกัน: .row + inline background (#ffbf4e / cornsilk / ครีมอื่น ๆ)
   รวบให้เป็นป้ายไล่เฉดส้มหน้าตาเดียวกันทั้งเว็บ */
.row[style*="#ffbf4e"],
.row[style*="cornsilk"],
.row[style*="FFFFF0"],
.row[style*="FFFFCC"],
.row[style*="FFFAF0"] {
    background: linear-gradient(100deg, var(--ird-amber) 0%, var(--ird-orange) 100%) !important;
    color: #fff !important;
    /* เต็มความกว้างจอเสมอ แม้แถบจะอยู่ใน .container (full-bleed)
       body มี overflow-x:hidden อยู่แล้ว จึงไม่เกิดสกรอลล์แนวนอนจากความกว้าง scrollbar */
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    padding: 1.15rem 1.5rem;
    border: 0 !important;
    border-radius: 0;
    box-shadow: 0 6px 20px rgba(253, 126, 20, .25);
}

.row[style*="#ffbf4e"] h1,
.row[style*="#ffbf4e"] h2,
.row[style*="#ffbf4e"] h3,
.row[style*="#ffbf4e"] h4,
.row[style*="cornsilk"] h1,
.row[style*="cornsilk"] h2,
.row[style*="cornsilk"] h3,
.row[style*="cornsilk"] h4,
.row[style*="FFFFF0"] h3,
.row[style*="FFFFCC"] h3,
.row[style*="FFFAF0"] h3 {
    margin: 0 !important;
    padding-left: 0 !important;
    color: #fff !important;
    font-size: 26px;
    font-weight: 500;
    line-height: 1.5;
    text-align: center;
}

/* บางหน้าใส่ .container ซ้อนไว้ในหัวข้อ — อย่าให้ดัน padding เพิ่ม */
.row[style*="#ffbf4e"] h3 .container,
.row[style*="cornsilk"] h3 .container {
    padding: 0;
}

.row[style*="#ffbf4e"] h3::before,
.row[style*="cornsilk"] h3::before {
    display: none !important;
}

/* ลิงก์ในแถบหัวข้อ — ต้องไม่เป็นส้มบนส้ม (อ่านไม่ออก) */
.row[style*="#ffbf4e"] a,
.row[style*="cornsilk"] a,
.row[style*="FFFFF0"] a,
.row[style*="FFFFCC"] a,
.row[style*="FFFAF0"] a {
    color: #fff !important;
    text-decoration: underline;
}

@media (max-width: 767.98px) {
    .row[style*="#ffbf4e"],
    .row[style*="cornsilk"] {
        padding: .85rem 1rem;
    }

    .row[style*="#ffbf4e"] h1,
    .row[style*="#ffbf4e"] h2,
    .row[style*="#ffbf4e"] h3,
    .row[style*="#ffbf4e"] h4,
    .row[style*="cornsilk"] h3 {
        font-size: 20px;
    }
}

/* ---------- ตัวเลือกปีงบประมาณ (fund_TH.php) ---------- */
.year-picker {
    background: #fff;
    border: 1px solid var(--ird-line);
    border-radius: var(--ird-radius);
    box-shadow: var(--ird-shadow);
    padding: 1.5rem 1.6rem;
}

.year-picker-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
    padding-bottom: .85rem;
    margin-bottom: 1.15rem;
    border-bottom: 1px solid var(--ird-line);
}

.year-picker-title {
    position: relative;
    margin: 0;
    padding-left: .85rem;
    font-size: 21px;
    font-weight: 500;
    color: var(--ird-ink);
}

.year-picker-title::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 5px;
    height: 24px;
    border-radius: 3px;
    background: linear-gradient(180deg, var(--ird-amber), var(--ird-orange));
}

.year-picker-current {
    font-size: 14px;
    color: var(--ird-muted);
}

.year-picker-current strong {
    color: var(--ird-orange);
    font-weight: 600;
}

.year-picker-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: .85rem;
}

.year-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .15rem;
    padding: 1rem .75rem .85rem;
    border: 1px solid var(--ird-line);
    border-radius: 12px;
    background: #fff;
    color: var(--ird-ink);
    text-align: center;
    text-decoration: none;
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease, background .2s ease;
}

.year-card:hover,
.year-card:focus {
    border-color: var(--ird-orange);
    background: #fff8ef;
    color: var(--ird-ink);
    text-decoration: none;
    transform: translateY(-4px);
    box-shadow: 0 10px 24px rgba(253, 126, 20, .18);
}

.year-card-label {
    font-size: 12.5px;
    letter-spacing: .5px;
    color: var(--ird-muted);
}

.year-card-year {
    font-size: 30px;
    font-weight: 700;
    line-height: 1.15;
    color: var(--ird-ink);
}

.year-card-cta {
    margin-top: .35rem;
    font-size: 12.5px;
    color: var(--ird-orange);
}

/* ปีที่กำลังดูอยู่ */
.year-card.is-active {
    background: linear-gradient(150deg, var(--ird-amber) 0%, var(--ird-orange) 100%);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 10px 26px rgba(253, 126, 20, .35);
}

.year-card.is-active:hover {
    background: linear-gradient(150deg, var(--ird-amber) 0%, var(--ird-orange) 100%);
    color: #fff;
    transform: none;
}

.year-card.is-active .year-card-label,
.year-card.is-active .year-card-year,
.year-card.is-active .year-card-cta {
    color: #fff;
}

@media (max-width: 575.98px) {
    .year-picker {
        padding: 1.15rem 1rem;
    }

    .year-picker-list {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: .6rem;
    }

    .year-card-year {
        font-size: 25px;
    }
}

/* ตัวอักษรสีน้ำตาลเดิม → สีหมึกของธีม (ยกเว้นในป้ายหัวข้อด้านบน) */
[style*="color:brown"]:not([style*="cornsilk"]) {
    color: var(--ird-ink) !important;
}

/* ---------- กล่องเนื้อหาหลักของหน้าใน ---------- */
.ftco-section-content {
    padding: 2.5em 0 3.5em;
}

.ftco-section-content>.container,
.ftco-section-content>.container-fluid {
    background: #fff;
    border-radius: var(--ird-radius);
    box-shadow: var(--ird-shadow);
    padding: 2rem 1.75rem;
}

.ftco-section-content>.container+.container {
    margin-top: 1.5rem;
}

/* บางหน้ามี .container เปล่าคั่นไว้ — อย่าวาดเป็นการ์ดขาวลอย ๆ
   (เบราว์เซอร์ที่ไม่รู้จัก :has จะข้ามกฎนี้ไปเฉย ๆ ไม่กระทบอย่างอื่น) */
.ftco-section-content>.container:not(:has(*)) {
    display: none;
}

@media (max-width: 767.98px) {
    .ftco-section-content>.container,
    .ftco-section-content>.container-fluid {
        padding: 1.35rem 1.1rem;
        border-radius: 10px;
    }
}

/* หัวข้อในเนื้อหา — ขีดส้มนำหน้าให้ไล่ระดับชัด */
.ftco-section-content h2,
.ftco-section-content h3,
.ftco-section-content h4 {
    position: relative;
    padding-left: .9rem;
    margin-top: 1.75rem;
    margin-bottom: .9rem;
    color: var(--ird-ink);
    font-weight: 500;
    line-height: 1.55;
}

.ftco-section-content h2 {
    font-size: 26px;
}

.ftco-section-content h3 {
    font-size: 22px;
}

.ftco-section-content h4 {
    font-size: 19px;
}

.ftco-section-content h2::before,
.ftco-section-content h3::before,
.ftco-section-content h4::before {
    content: "";
    position: absolute;
    left: 0;
    top: .18em;
    bottom: .18em;
    width: 5px;
    border-radius: 3px;
    background: linear-gradient(180deg, var(--ird-amber), var(--ird-orange));
}

/* หัวข้อที่จัดกึ่งกลาง / อยู่ในตาราง-การ์ด-modal ไม่ต้องมีขีดนำหน้า */
.ftco-section-content center h2,
.ftco-section-content center h3,
.ftco-section-content center h4,
.ftco-section-content .text-center h2,
.ftco-section-content .text-center h3,
.ftco-section-content .text-center h4,
.ftco-section-content td h4,
.ftco-section-content th h4,
.ftco-section-content .modal h2,
.ftco-section-content .modal h3,
.ftco-section-content .modal h4,
.ftco-section-content .card-header h4 {
    padding-left: 0;
}

.ftco-section-content center h2::before,
.ftco-section-content center h3::before,
.ftco-section-content center h4::before,
.ftco-section-content .text-center h2::before,
.ftco-section-content .text-center h3::before,
.ftco-section-content .text-center h4::before,
.ftco-section-content td h4::before,
.ftco-section-content th h4::before,
.ftco-section-content .modal h2::before,
.ftco-section-content .modal h3::before,
.ftco-section-content .modal h4::before,
.ftco-section-content .card-header h4::before {
    display: none;
}

.ftco-section-content td h4,
.ftco-section-content th h4 {
    margin-top: 0;
}

/* เนื้อความภาษาไทยอ่านง่ายขึ้น */
.ftco-section-content .container {
    line-height: 1.85;
    color: #4a5160;
}

/* รูปในเนื้อหา — มุมมน เงาอ่อน */
.ftco-section-content .container img:not(.no-frame) {
    border-radius: 8px;
}

/* ---------- ปุ่ม ---------- */
/* ไม่แตะ padding ของ .btn — ไม่งั้นจะทับ .btn-lg/.btn-sm ของ bootstrap ที่โหลดมาก่อน */
.btn {
    border-radius: 999px;
    letter-spacing: .3px;
    transition: all .2s ease;
}

.btn-primary,
.btn-primary:not(:disabled):not(.disabled):active {
    background: var(--ird-orange);
    border-color: var(--ird-orange);
    color: #fff;
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--ird-orange-dark);
    border-color: var(--ird-orange-dark);
    box-shadow: 0 6px 16px rgba(253, 126, 20, .3);
}

.btn-outline-secondary,
.btn-outline-info,
.btn-outline-warning,
.btn-outline-light {
    border-color: var(--ird-line);
    background: #fff;
    color: var(--ird-ink);
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus,
.btn-outline-info:hover,
.btn-outline-info:focus,
.btn-outline-warning:hover,
.btn-outline-warning:focus,
.btn-outline-light:hover,
.btn-outline-light:focus {
    background: var(--ird-orange);
    border-color: var(--ird-orange);
    color: #fff;
    box-shadow: 0 6px 16px rgba(253, 126, 20, .28);
}

/* ปุ่มที่ฝังสีเหลือง #EFD35E / ส้มอ่อน ไว้ใน inline style → ปรับเป็นส้มธีม */
.btn[style*="EFD35E"],
.btn[style*="EFD36E"],
.btn[style*="ffbf4e"],
.btn[style*="FFBF4E"] {
    background: linear-gradient(100deg, var(--ird-amber) 0%, var(--ird-orange) 100%) !important;
    border: 0 !important;
    color: #fff !important;
    box-shadow: 0 4px 14px rgba(253, 126, 20, .28);
}

.btn[style*="EFD35E"]:hover,
.btn[style*="EFD36E"]:hover,
.btn[style*="ffbf4e"]:hover,
.btn[style*="FFBF4E"]:hover {
    filter: brightness(.94);
    color: #fff !important;
}

/* ---------- รายการลิงก์ (list-group) ---------- */
.list-group {
    gap: .6rem;
    display: flex;
    flex-direction: column;
}

.list-group>a {
    color: inherit;
}

.list-group-item {
    border: 1px solid var(--ird-line);
    border-radius: 10px !important;
    padding: 1rem 1.15rem;
    color: #4a5160;
    line-height: 1.75;
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.list-group>a:hover .list-group-item,
.list-group-item:hover {
    border-color: var(--ird-orange);
    box-shadow: 0 6px 18px rgba(253, 126, 20, .16);
    transform: translateX(3px);
}

.list-group-item .fa-file,
.list-group-item .fa-file-pdf,
.list-group-item .fa-download,
.list-group-item .fa-location-arrow {
    color: var(--ird-orange);
}

.list-group-item-warning {
    background: #fff6e8 !important;
    border-color: var(--ird-amber) !important;
}

/* ---------- ตาราง ---------- */
/* หมายเหตุ: ไม่เปลี่ยน border-collapse — .table-bordered ของ bootstrap จะเส้นซ้อน */
.table {
    background: #fff;
    font-size: 15px;
    color: #4a5160;
}

.table thead th {
    background: linear-gradient(100deg, var(--ird-amber) 0%, var(--ird-orange) 100%);
    border-color: rgba(255, 255, 255, .35);
    color: #fff;
    font-weight: 500;
    letter-spacing: .3px;
    vertical-align: middle;
}

.table td {
    vertical-align: middle;
    border-top: 0;
    border-bottom: 1px solid var(--ird-line);
    line-height: 1.75;
}

/* ตารางแบบมีเส้นกรอบ — คืนเส้นบนที่กฎด้านบนตัดออกไป ไม่งั้นตารางจะขาดเส้น */
.table.table-bordered td {
    border: 1px solid var(--ird-line);
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: #fbfcfd;
}

.table-hover tbody tr:hover,
.table tbody tr:hover {
    background-color: #fff6e8;
}

/* ตารางกว้างเกินจอ → เลื่อนแนวนอนในกรอบตัวเอง ไม่ดันหน้าเว็บ */
@media (max-width: 767.98px) {
    .ftco-section-content .table,
    .dataTables_wrapper .table {
        display: block;
        width: 100% !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }
}

/* ---------- DataTables ---------- */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info {
    font-size: 14px;
    color: var(--ird-muted);
    padding-bottom: .5rem;
}

.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid var(--ird-line);
    border-radius: 999px;
    padding: .3rem .9rem;
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.dataTables_wrapper .dataTables_filter input:focus,
.dataTables_wrapper .dataTables_length select:focus {
    border-color: var(--ird-orange);
    box-shadow: 0 0 0 3px rgba(253, 126, 20, .15);
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 8px !important;
    border: 1px solid var(--ird-line) !important;
    background: #fff !important;
    color: var(--ird-ink) !important;
    margin-left: 3px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover,
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--ird-orange) !important;
    border-color: var(--ird-orange) !important;
    color: #fff !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
    opacity: .45;
}

/* ---------- ฟอร์ม ---------- */
.form-control {
    border-radius: 10px;
    border-color: var(--ird-line);
    transition: border-color .2s ease, box-shadow .2s ease;
}

.form-control:focus {
    border-color: var(--ird-orange);
    box-shadow: 0 0 0 3px rgba(253, 126, 20, .15);
}

/* ---------- การ์ด / modal ---------- */
.card {
    border: 1px solid var(--ird-line);
    border-radius: var(--ird-radius);
    box-shadow: var(--ird-shadow);
}

.card-header {
    background: #fff8ef;
    border-bottom: 1px solid var(--ird-line);
    font-weight: 500;
}

.modal-content {
    border: 0;
    border-radius: var(--ird-radius);
    overflow: hidden;
    box-shadow: var(--ird-shadow-lg);
}

.modal-header {
    background: linear-gradient(100deg, var(--ird-amber) 0%, var(--ird-orange) 100%);
    border-bottom: 0;
    color: #fff;
}

.modal-header .close {
    color: #fff;
    text-shadow: none;
    opacity: .9;
}

/* ---------- กล่อง "สอบถามรายละเอียดเพิ่มเติม" (.contact-box มีอยู่ ~37 หน้า) ----------
   แต่ละหน้านิยาม .contact-box ไว้ใน <style> ของตัวเอง (กรอบน้ำเงิน #007BFF)
   ซึ่งถูกพิมพ์ก่อน header_TH.php ไฟล์นี้จึงทับได้ด้วย specificity เท่ากัน */
.contact-box {
    max-width: 640px;
    border: 1px solid var(--ird-line);
    border-left: 5px solid var(--ird-orange);
    border-radius: var(--ird-radius);
    background: #fff;
    box-shadow: var(--ird-shadow);
    padding: 1.5rem;
}

.ftco-section-content .contact-box h4,
.contact-box h4 {
    margin: 0 0 .75rem;
    padding-left: 0;
    color: var(--ird-orange);
    font-size: 19px;
    font-weight: 500;
}

.ftco-section-content .contact-box h4::before {
    display: none;
}

.contact-box p {
    margin: .25rem 0;
    color: #4a5160;
    line-height: 1.85;
}

/* ---------- แท็บหมวดข่าวในหน้า new_TH.php ----------
   หน้านี้ใช้คลาส w3-* แต่ w3.css ถูกคอมเมนต์ไว้ไม่ได้โหลด
   แท็บที่เลือกอยู่ (JS ใส่คลาส w3-orange) จึงไม่มีสถานะให้เห็น */
.tablink {
    border-radius: 999px !important;
    margin: 0 .3rem .6rem 0;
}

.tablink.w3-orange {
    background: linear-gradient(100deg, var(--ird-amber) 0%, var(--ird-orange) 100%) !important;
    border-color: transparent !important;
    color: #fff !important;
    box-shadow: 0 6px 16px rgba(253, 126, 20, .3);
}

.w3-container.city {
    background: #fff;
    border: 1px solid var(--ird-line);
    border-radius: var(--ird-radius);
    padding: 1.5rem;
    box-shadow: var(--ird-shadow);
}

@media (max-width: 767.98px) {
    .w3-container.city {
        padding: 1rem;
    }
}

/* ---------- ปุ่มกลับขึ้นด้านบน (ใส่ไว้ใน footer_TH.php ใช้ได้ทุกหน้า) ---------- */
.go-top {
    position: fixed;
    right: 22px;
    bottom: 26px;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border: 0;
    border-radius: 50%;
    background: var(--ird-orange);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s ease, visibility .25s ease, background .2s ease, transform .2s ease;
}

.go-top.is-visible {
    opacity: 1;
    visibility: visible;
}

.go-top:hover,
.go-top:focus {
    background: var(--ird-orange-dark);
    transform: translateY(-3px);
    color: #fff;
}

@media (max-width: 767.98px) {
    .go-top {
        right: 14px;
        bottom: 90px;
        width: 42px;
        height: 42px;
    }
}

/* ---------- footer ---------- */
.ftco-footer .ftco-heading-2 {
    color: var(--ird-amber);
}

.ftco-footer a:hover {
    color: var(--ird-amber) !important;
}
