/**
 * file: assets/css/style.css
 * Description: Final complete stylesheet for the KUSDGs Evidence project.
 * (Merged, enhanced, and organized version)
 */

/* =================================================================
   1. Global Styles & Theme Overrides
   ================================================================= */

/* --- Import Google Font: Noto Sans Thai --- */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@400;500;600;700&display=swap');

/* --- Define Theme Colors --- */
:root {
    --bs-primary: #006664;
    --bs-primary-rgb: 0, 102, 100;
    --bs-secondary: #6c757d;
    --bs-success: #198754;
    --bs-info: #0dcaf0;
    --bs-warning: #ffc107;
    --bs-danger: #dc3545;
    --bs-light: #f8f9fa;
    --bs-dark: #212529;
    --bs-font-sans-serif: 'Noto Sans Thai', sans-serif;
}

body {
    font-family: var(--bs-font-sans-serif);
    background-color: #f4f7f6;
    color: #343a40;
    border-top: 4px solid var(--bs-primary);
}

/* --- Custom Text Selection Color --- */
::selection { background-color: var(--bs-primary); color: #ffffff; }
::-moz-selection { background-color: var(--bs-primary); color: #ffffff; }

/* --- Headings --- */
h1, h2, h3, h4, h5, h6 {
    color: var(--bs-primary);
    font-weight: 600;
}

/* --- Bootstrap Component Overrides --- */
.btn-primary {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
}
.btn-primary:hover, .btn-primary:focus {
    background-color: #004d4b;
    border-color: #004d4b;
}

.card {
    border: 1px solid #e9ecef;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.04);
    border-radius: 0.5rem;
}

.card-header {
  background-color: #ffffff;
  border-bottom: 1px solid #e9ecef;
  font-weight: 600;
  color: #004d4b;
}

.breadcrumb-item a {
    color: var(--bs-primary);
    text-decoration: none;
}

/* --- Form Control Focus State --- */
.form-control:focus, .form-select:focus, .tom-select-focus .ts-control {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.25rem rgba(0, 102, 100, 0.25);
}

.form-label {
    font-weight: 500;
    color: #006664;
}

/* =================================================================
   2. Layout & Navigation Styles
   ================================================================= */

/* --- Main Layout --- */
.main-content {
    min-height: calc(100vh - 200px);
}

/* --- Top Header (Public) --- */
.top-header .navbar-brand img { height: 60px; }

/* --- Main Navigation Bar --- */
.main-navbar {
    z-index: 1030; /* ทำให้ Nav bar อยู่ทับทุกอย่างเสมอ */
}
.main-navbar .navbar-brand img { height: 40px; }
.lang-switcher a { color: #6c757d; text-decoration: none; font-weight: 500; }
.lang-switcher a.active { color: var(--bs-primary); font-weight: bold; }

.main-navbar .navbar-nav .nav-link {
    border-bottom: 4px solid transparent;
    padding-bottom: 0.75rem;
    transition: border-color 0.2s ease-in-out, color 0.2s ease-in-out;
}
.main-navbar .navbar-nav .nav-link.active {
    color: var(--bs-primary) !important;
    border-bottom-color: var(--bs-primary);
    font-weight: bold;
}
.main-navbar .navbar-nav .nav-link:not(.active):hover {
    color: #004d4b;
    border-bottom-color: #e9ecef; 
}

.dropdown-header {
    font-weight: 700;
    color: var(--bs-primary);
    font-size: 0.9rem;
}

/* --- Horizontal Sticky SDG Navigation --- */
.sdg-nav-sticky {
    position: sticky;
    top: 62px; /* ความสูงโดยประมาณของ .main-navbar */
    z-index: 1020;
    background-color: rgba(248, 249, 250, 0.95);
    backdrop-filter: blur(5px);
}

.sdg-nav-scroll-container {
    margin-top: 500;
    overflow-x: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.sdg-nav-scroll-container::-webkit-scrollbar {
    display: none;
}

.sdg-nav-item {
    display: block;
    padding: 4px;
    border: 2px solid transparent;
    border-radius: 8px;
    transition: all 0.2s ease-in-out;
    opacity: 0.7;
}
.sdg-nav-item:hover {
    opacity: 1;
    transform: scale(1.05);
}
.sdg-nav-item.active {
    border-color: var(--bs-primary);
    opacity: 1;
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* =================================================================
   3. Page Specific Styles
   ================================================================= */

/* --- Homepage (index.php) SDG Cards --- */
.goal-card {
    transition: transform .2s, box-shadow .2s;
    border: none;
    border-radius: 0.5rem;
    display: block;
    color: inherit;
    text-decoration: none;
}
.goal-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 .5rem 1rem rgba(0,0,0,.15)!important;
    color: inherit;
}
.goal-card .card-body {
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}
.goal-card img {
    width: 50px;
    height: 50px;
    margin-bottom: 0.75rem;
}
.goal-card h6 {
    font-weight: 600;
}

/* --- manage_goals.php --- */
.card[id^="goal-card-"] {
    scroll-margin-top: 155px; /* (Navbar Height + Sticky Nav Height + Padding) */
}

/* --- Project Form (add_project.php) --- */
.indicator-list { max-height: 250px; overflow-y: auto; }
.attachment-thumbnail img { width: 100%; height: 100px; object-fit: cover; }
.accordion-button:not(.collapsed) { background-color: rgba(0, 102, 100, 0.1); color: #004c4a; }

/* --- Project View (view_public.php) --- */
.summary-table td { padding: 0.5rem 0.25rem; vertical-align: middle; }
.content-body img { max-width: 100%; height: auto; border-radius: 0.25rem; }

/* --- Department Management Page --- */
.department-node { display: flex; align-items: center; gap: 0.75rem; padding-top: 0.25rem; padding-bottom: 0.25rem; border-bottom: 1px solid #f0f0f0; }
.department-node:last-child { border-bottom: none; }
.tree-actions { flex-shrink: 0; display: inline-flex; gap: 0.25rem; }
.department-name { font-weight: 500; }


/* =================================================================
   4. Table & Pagination Styles
   ================================================================= */
.table a { color: #006664; text-decoration: none; font-weight: 500; transition: color 0.2s ease-in-out; }
.table a:hover { color: #004d4b; text-decoration: underline; }
.table thead th { background-color: #f8f9fa; color: #006664; font-weight: 400; border-bottom-width: 1px; }
.table thead a { color: inherit; }

.pagination .page-item .page-link { color: var(--bs-primary); }
.pagination .page-item.active .page-link { background-color: var(--bs-primary); border-color: var(--bs-primary); color: #fff; }
.pagination .page-item.disabled .page-link { color: #6c757d; }
.pagination .page-item:not(.active) .page-link:hover { background-color: #e9ecef; }
.pagination .page-item.active .page-link:hover { background-color: #004d4b; border-color: #004d4b; }


/* =================================================================
   5. Profile & Tab Styles
   ================================================================= */
.profile-card .card-header { background-color: var(--bs-primary); color: #ffffff; text-align: center; padding: 1.5rem 1rem; }
.profile-card .card-header h4 { color: #ffffff; margin: 0; }
.profile-avatar-preview { width: 120px; height: 120px; object-fit: cover; border: 4px solid #ffffff; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1); }

.nav-tabs .nav-link { color: #6c757d; border-color: transparent; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.nav-tabs .nav-link.active, .nav-tabs .nav-item.show .nav-link { color: #004D40; background-color: #fff; border-color: #dee2e6 #dee2e6 #fff; font-weight: 600; }
.nav-tabs .nav-link:hover:not(.active) { color: #006664; border-color: transparent; }

/* Styling for evidence subtitles in view.php */
.evidence-subtitle {
    font-weight: 600;
    color: var(--bs-primary);
    margin-top: 0.75rem; /* เพิ่มระยะห่างด้านบน */
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #dee2e6; /* เพิ่มเส้นขีดบางๆ */
    display: flex; /* ใช้ Flexbox เพื่อจัดไอคอนกับข้อความ */
    align-items: center;
}

/* ทำให้หัวข้อแรกสุดไม่มีระยะห่างด้านบนที่มากเกินไป */
.evidence-card-body > .project-section:first-child .evidence-subtitle,
.evidence-card-body > div:first-child .evidence-subtitle {
    margin-top: 0;
}

/* ปรับขนาดไอคอนในหัวข้อย่อยให้สวยงาม */
.evidence-subtitle .fas {
    font-size: 1.2em;
    margin-right: 0.6rem;
    color: #6c757d; /* ทำให้ไอคอนเป็นสีเทา */
}

/* =================================================================
   PROJECTS PUBLIC LISTING - LIST VIEW (Image on Left)
   ================================================================= */
.project-list-item {
    display: flex;
    padding: 1.25rem;
    border-left-width: 5px;
    border-left-style: solid;
    transition: background-color 0.2s ease-in-out, transform 0.2s ease-in-out;
    text-decoration: none;
    color: inherit;
    border-radius: 0.5rem;
    background-color: #fff;
    position: relative; /* เพิ่ม position relative */
}
.project-list-item:hover {
    background-color: #f8f9fa;
    transform: translateY(-2px);
}
.project-list-image-wrapper {
    width: 150px;
    height: 100px;
    flex-shrink: 0;
    margin-right: 1.5rem; /* **[แก้ไข]** เปลี่ยนจาก margin-left เป็น margin-right */
    /* **[แก้ไข]** ไม่ต้องใช้ order แล้ว */
}
.project-list-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0.375rem;
}
.project-list-content {
    flex-grow: 1;
    display: flex; /* << เพิ่ม */
    flex-direction: column; /* << เพิ่ม */
    /* **[แก้ไข]** ไม่ต้องใช้ order แล้ว */
}
.project-list-year-wrapper {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-weight: bold;
    color: #6c757d;
}


.project-sdg-icon {
    width: 42px;  /* << ปรับขนาดความกว้างตามต้องการ */
    height: 42px; /* << ปรับขนาดความสูงตามต้องการ */
    border-radius: 0.375rem; /* << ปรับความโค้งของมุม */
    margin-right: 0.25rem; /* << ระยะห่างระหว่างไอคอน */
    object-fit: cover; /* ป้องกันภาพบิดเบี้ยว */
}

/* =================================================================
   PROJECTS PUBLIC LISTING - CARD/GRID VIEW (Final Curved Border)
   ================================================================= */
.project-card-public {
    transition: transform .2s, box-shadow .2s;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    position: relative;
    
    /* --- ส่วนที่แก้ไข --- */
    /* กำหนดเส้นขอบด้านอื่นๆ ให้เป็นสีเทาบางๆ เหมือนเดิม */
    border-right: px solid #dee2e6;
    border-bottom: 1px solid #dee2e6;
    border-left: 1px solid #dee2e6;

    /* กำหนดเฉพาะความหนาและรูปแบบของเส้นขอบบน (สีจะมาจาก PHP) */
    border-top-width: 10px;
    border-top-style: solid;
    border-radius: 0.5rem;
     overflow: hidden; 
}
.project-card-public:hover {
    transform: translateY(-5px);
    box-shadow: 0 .5rem 1rem rgba(0,0,0,.15)!important;
}
/* **[นี่คือพระเอกของเรา]** สร้างเส้นขอบโค้งขึ้นมาเอง */
.project-card-public::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px; /* ความหนาของเส้นขอบ */
    border-bottom-left-radius: 0.5rem; /* ทำให้มุมซ้ายล่างของ "แถบ" โค้ง */
    border-bottom-right-radius: 0.5rem; /* ทำให้มุมขวาล่างของ "แถบ" โค้ง */
}
.project-card-public .card-img-container {
    height: 200px;
    overflow: hidden;
    border-top-left-radius: 0.5rem;  /* ทำให้มุมบนซ้ายโค้ง */
    border-top-right-radius: 0.5rem; /* ทำให้มุมบนขวาโค้ง */
    margin: -5px -1px 0 -1px;
}
.project-card-public .card-img-top {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease-in-out;
}
.project-card-public:hover .card-img-top {
    transform: scale(1.05);
}
.project-card-public .card-body {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding-top: 1.25rem;
}
.project-card-public .department-path {
    font-size: 0.8rem;
    color: #6c757d;
    margin-bottom: 0.5rem;
}
.project-card-public .card-footer {
    margin-top: auto;
}
.project-card-public .card-footer .d-flex {
    min-height: 24px;
}

/* --- [เพิ่มของใหม่] CSS สำหรับแสดงปีใต้รูปภาพใน List View --- */
.project-list-image-wrapper {
    position: relative; /* << **สำคัญมาก:** ทำให้เป็นจุดอ้างอิงสำหรับ badge ปี */
    width: 170px;
    height: 120px;
    flex-shrink: 0;
    margin-right: 1.5rem;
}

.project-list-year-badge {
    position: absolute;
    bottom: 1.5rem;
    right: 1.5rem;
    background-color: rgba(0, 0, 0, 0.6); /* พื้นหลังสีดำโปร่งแสง */
    color: #ffffff; /* ตัวอักษรสีขาว */
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    font-weight: bold;
    border-radius: 0.25rem;
}

/* --- [เพิ่มใหม่] CSS สำหรับบังคับ Grid View บนจอมือถือแนวตั้ง --- */
@media (max-width: 767.98px) and (orientation: portrait) {

    /* 1. ซ่อน List View Container เสมอ */
    #list-view-container {
        display: none !important; 
    }

    /* 2. แสดง Grid View Container เสมอ */
    #grid-view-container {
        display: flex !important; 
    }
    
    /* 3. ซ่อนปุ่มสลับ View ไปเลย เพราะไม่จำเป็นต้องให้ผู้ใช้เลือก */
    .d-flex .btn-group[role="group"] {
        display: none;
    }
}

.col-lg-4 {
    min-width: 0;
}

/* =================================================================
   8. Homepage Specific Styles
   ================================================================= */

/* --- SDG Icon Scroller --- */
.sdg-icon-scroller {
    border-top: 1px solid #dee2e6;
    border-bottom: 1px solid #dee2e6;
    padding: 1.5rem 0;
}
.scrolling-wrapper {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
}
.scrolling-wrapper::-webkit-scrollbar {
    display: none; /* Safari and Chrome */
}
.sdg-card {
    flex: 0 0 auto;
    margin-right: 1rem;
    text-align: center;
}
.sdg-card img {
    width: 100px;
    height: 100px;
    border-radius: 0.5rem;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}
.sdg-card img:hover {
    transform: scale(1.05);
    box-shadow: 0 .5rem 1rem rgba(0,0,0,.15)!important;
}

/* --- Widget Card (Right Sidebar) --- */
.widget-title {
    font-size: 1.25rem;
    border-bottom: 3px solid var(--bs-primary);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}
.widget-card .list-item:hover p {
    color: var(--bs-primary);
}

/* --- Featured Card Hover Effect --- */
.featured-card {
    overflow: hidden; /* Important for image zoom effect */
}
.featured-card:hover .card-img-top {
    transform: scale(1.05);
}
.featured-card .card-img-top {
    transition: transform 0.3s ease;
}

/* --- SDG Content Block Header --- */
.sdg-content-block .sdg-block-header {
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 0.75rem;
    display: flex;       /* <-- เพิ่ม flex เพื่อจัดวางในแถว */
    align-items: center; /* <-- จัดให้อยู่กึ่งกลางแนวตั้ง */
}

/* [แก้ไข] กำหนดขนาดที่ img โดยตรง แต่ยังคงใช้ class me-3 จาก HTML */
.sdg-content-block .sdg-block-header img {
    width: 50px;
    height: 50px;
    border-radius: 0.375rem !important; /* 6px, ทำให้ขอบมนสวยงาม */
    flex-shrink: 0; /* <-- คำสั่งสำคัญ: ป้องกันไม่ให้ไอคอนถูกบีบ */
}

.sdg-content-block .sdg-block-header h4 {
    margin-bottom: 0;
    font-size: 1.5rem;
    font-weight: bold;
}

/* =================================================================
   9. Homepage Sidebar Project List Styles
   ================================================================= */
.campus-project-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem; /* ระยะห่างระหว่างรายการ */
}
.campus-project-item {
    position: relative;
    display: block;
    height: 100px;
    border-radius: 0.5rem;
    overflow: hidden;
    text-decoration: none;
    color: white;
    background-color: #343a40; /* สีพื้นหลังสำรอง */
}
.campus-project-item .background-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}
.campus-project-item:hover .background-image {
    transform: scale(1.05);
}
.campus-project-item .overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.1) 100%);
    z-index: 1;
}
.campus-project-item .project-title {
    position: absolute;
    bottom: 10px;
    left: 15px;
    right: 15px;
    margin: 0;
    font-weight: bold;
    z-index: 2;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.7);
}

/* =================================================================
   8. Homepage Specific Styles (Magazine Layout)
   ================================================================= */
.sdg-block-header .sdg-icon-container {
    width: 50px;  /* ปรับขนาดกรอบตามต้องการ */
    height: 50px; /* ปรับขนาดกรอบตามต้องการ */
    padding: 0.5rem;
    border-radius: 0.375rem; /* ความโค้งมนของกรอบ */
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0; /* ป้องกันการหดตัว */
}

/* [แก้ไข] ทำให้ img ที่อยู่ข้างในยืดหยุ่นตามขนาดกรอบ */
.sdg-block-header .sdg-icon-container img {
    max-width: 100%;
    height: auto;
}

.sdg-block-header h4 {
    margin-bottom: 0;
    font-size: 1.5rem;
    font-weight: bold;
}
.featured-main-post img {
    height: 400px;
    object-fit: cover;
}
.featured-sub-post img {
    height: 120px;
    object-fit: cover;
}
.sdg-main-post-card img {
    height: 300px;
    object-fit: cover;
}
.widget-title {
    font-size: 1.1rem;
    font-weight: bold;
    border-bottom: 2px solid var(--bs-primary);
    padding-bottom: 0.5rem;
    margin-bottom: 1.25rem;
    color: var(--bs-primary);
}
.widget-card .list-item:hover .fw-bold {
    color: var(--bs-primary);
}
.featured-card {
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}
.featured-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 .5rem 1rem rgba(0,0,0,.15)!important;
}

/* =================================================================
   10. Homepage Sidebar Faculty Showcase Widget
   ================================================================= */

.faculty-showcase-block .faculty-title {
    font-size: 1rem;
    font-weight: 700;
    color: #343a40; /* สีเข้มขึ้นเล็กน้อย */
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
}

.faculty-showcase-block .faculty-title .fas {
    color: var(--bs-primary); /* ใช้สีหลักของเว็บ */
}

/* ปรับปรุงเส้นแบ่งให้สวยงามขึ้น */
.faculty-showcase-block.border-top {
    border-top: 1px solid #e9ecef !important; /* เส้นบางๆ สีเทาอ่อน */
}

/* โค้ดที่แก้ไขแล้ว */
.faculty-showcase-block .list-item {
    padding: 0.25rem 0.5rem; /* เพิ่ม padding บน-ล่าง */
    margin-bottom: 0.5rem !important; /* เพิ่มระยะห่างด้านล่าง */
    border-bottom: 1px solid #f0f0f0; /* เพิ่มเส้นคั่นบางๆ */
    border-radius: 0.375rem;
    transition: background-color 0.2s ease-in-out;
}

/* ทำให้รายการสุดท้ายไม่มีเส้นคั่นและระยะห่างด้านล่าง */
.faculty-showcase-block .list-item:last-child {
    margin-bottom: 0 !important;
    border-bottom: none;
    padding-bottom: 0.0rem; /* ลด padding ล่างของอันสุดท้ายเล็กน้อย */
}

.faculty-showcase-block .list-item:hover {
    background-color: #f8f9fa; /* เปลี่ยนสีพื้นหลังเมื่อ hover */
}

/* กำหนดสไตล์พื้นฐานของลิงก์และข้อความ */
.sdg-content-block .list-item .fw-bold {
    color: #212529; /* สีข้อความปกติ (สีดำเกือบสนิท) */
    transition: color 0.2s ease-in-out; /* เพิ่ม transition ให้การเปลี่ยนสีนุ่มนวล */
}

/* --- นี่คือส่วนสำคัญ: กำหนดสไตล์เมื่อนำเมาส์ไปชี้ที่ "ชื่อโครงการ" เท่านั้น --- */
.sdg-content-block .list-item:hover .fw-bold {
    color: #006664; /* เปลี่ยนสีเฉพาะตัวอักษรของชื่อโครงการเป็นสีเขียว */
}

/* =================================================================
   12. SDG Icon Overlay on Main Project Image
   ================================================================= */

.card-img-overlay-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.75rem 1rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0)); /* ไล่สีดำโปร่งแสงจากล่างขึ้นบน */
    display: flex;
    gap: 0.5rem; /* ระยะห่างระหว่างไอคอน */
}

.overlay-sdg-icon {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.1); /* พื้นหลังโปร่งแสงเล็กน้อย */
    padding: 2px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* =================================================================
   13. Image Zoom Hover Effect Fix
   ================================================================= */

/* สร้างกรอบที่มองไม่เห็นสำหรับรูปภาพ */
.card-img-container {
    position: relative;
    overflow: hidden;
    /* --- [จุดแก้ไข] --- */
    aspect-ratio: 16 / 9; /* กำหนดสัดส่วนภาพเป็น 16:9 (ปรับแก้ได้) */
    /* ลบ height: 400px; ออกไป */
    border-top-left-radius: var(--bs-card-inner-border-radius);
    border-top-right-radius: var(--bs-card-inner-border-radius);
    background-color: #f0f0f0; /* เพิ่มสีพื้นหลังเผื่อรูปโหลดไม่ขึ้น */
}

/* กำหนดความสูงสำหรับรูปในบล็อก SDG */
.sdg-main-post-card .card-img-container {
    height: 300px;
}

/* กำหนดให้รูปภาพขยายเต็มกรอบเสมอ */
.card-img-container .card-img-top {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

/* เอฟเฟกต์: เมื่อชี้ที่การ์ด ให้ซูมเฉพาะรูปภาพที่อยู่ข้างในกรอบ */
.featured-card:hover .card-img-top {
    transform: scale(1.05);
}

/* ทำให้ Overlay ยึดตำแหน่งกับกรอบ ไม่ใช่รูปภาพ */
.card-img-container .card-img-overlay-bottom {
    /* สไตล์เดิมของ overlay ยังคงทำงานได้ดีกับโครงสร้างใหม่นี้ */
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 2;
}

/* =================================================================
   14. SDG Icon Bar (Fully Responsive & Interactive - FINAL)
   ================================================================= */

/* --- Container หลักของ Icon Bar --- */
.sdg-icon-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem; /* << แก้ไขตรงนี้! 2.5rem คือประมาณ 40px */
}

/* --- สไตล์ของลิงก์ที่ครอบไอคอน --- */
.sdg-icon-bar a {
    flex: 1 1 0; /* *** ทำให้ไอคอนขยายเต็มพื้นที่ในตอนแรก *** */
    min-width: 0; /* อนุญาตให้หดได้ */
    display: block;
    text-decoration: none;
    border-radius: 0.5rem;
    overflow: hidden;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

/* --- เอฟเฟกต์เมื่อนำเมาส์ไปชี้ --- */
.sdg-icon-bar a:hover {
    transform: scale(1.05) translateY(-5px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    z-index: 10;
    position: relative;
}

/* --- สไตล์ของรูปภาพไอคอนข้างใน --- */
.sdg-icon-bar img {
    width: 100%;
    height: auto;
    display: block;
}


/* =================================================================
   Media Query สำหรับทำให้ Scroll ได้เมื่อจอแคบ
   ================================================================= */
@media (max-width: 1399.98px) { /* เริ่มทำงานเมื่อจอแคบกว่า 1400px */
    .sdg-icon-bar {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 1rem;
    }
    .sdg-icon-bar::-webkit-scrollbar { display: none; }
    .sdg-icon-bar { -ms-overflow-style: none; scrollbar-width: none; }

    /* กำหนดขนาดคงที่ให้ไอคอนในโหมด scroll */
    .sdg-icon-bar a {
        flex: 0 0 90px; /* ไม่ต้องยืด-หดแล้ว และมีความกว้าง 90px */
    }
}

/* Media Query สำหรับหน้าจอมือถือ (ปรับขนาดให้เล็กลง) */
@media (max-width: 767.98px) {
    .sdg-icon-bar a {
        flex-basis: 50px; /* ลดขนาดลง 20% */
    }
}

/* =================================================================
   15. Hover Effect for Homepage List Items
   ================================================================= */

/* กำหนด Transition ให้กับรูปภาพ Thumbnail */
.list-item img {
    transition: transform 0.2s ease-in-out;
}

/* เอฟเฟกต์: เมื่อนำเมาส์ไปชี้ที่รายการ ให้ซูมรูปภาพเล็กน้อย */
.list-item:hover img {
    transform: scale(1.08); /* ซูมขึ้น 8% */
}

/* กำหนด Transition ให้กับชื่อโครงการ/บทความ */
.list-item .fw-bold {
    transition: color 0.2s ease-in-out;
}

/* เอฟเฟกต์: เมื่อนำเมาส์ไปชี้ที่รายการ ให้เปลี่ยนสีของชื่อเรื่อง */
.list-item:hover .fw-bold {
    color: var(--bs-primary); /* ใช้สีหลัก (#006664) */
}

/* =================================================================
   16. Homepage Featured Projects Grid Styles
   ================================================================= */
.featured-projects-grid .card-img-container {
    height: auto; /* ยกเลิก height คงที่ */
    aspect-ratio: 4 / 3; /* กำหนดสัดส่วน 4:3 */
}

/* =================================================================
   17. Full-width Hero Banner (Magazine Style) - FINAL
   ================================================================= */

.hero-banner-full-width {
}
.hero-banner-full-width .carousel-item,
.hero-banner-full-width .carousel-image-container,
.hero-banner-full-width .carousel-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.hero-banner-full-width .carousel-caption {
    top: 50%;
    transform: translateY(-50%);
    bottom: auto;
    background: none;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.7); /* เพิ่มเงาให้ข้อความ */
}

/* --- สไตล์สำหรับไอคอน SDG บนแบนเนอร์ --- */
.banner-sdg-icons {
    display: flex;
    gap: 0.75rem; /* ระยะห่างระหว่างไอคอน */
}

.banner-sdg-icons img {
    width: 48px;
    height: 48px;
    border-radius: 0.375rem; /* ขอบมน */
    background-color: rgba(255, 255, 255, 0.15);
    padding: 4px;
    transition: transform 0.2s ease;
}

.banner-sdg-icons img:hover {
    transform: scale(1.1);
}

/* =================================================================
   18. Homepage Dashboard Component Styles (FIXED)
   ================================================================= */

/* [แก้ไข] สร้าง Wrapper ที่มีขนาดชัดเจนสำหรับ Canvas */
.chart-container {
    position: relative; /* << สำคัญมาก: ทำให้เป็นจุดอ้างอิง */
    height: 450px;      /* << กำหนดความสูงคงที่ */
    width: 100%;        /* << กำหนดความกว้างให้เต็ม Card */
    overflow-y: auto;   /* ทำให้ scroll ได้ถ้าเนื้อหา (Legend) เกิน */
}

/* ... โค้ด CSS ส่วน .loading เหมือนเดิม ... */
.tom-select-focus .ts-control {
    border-color: var(--bs-primary);
    box-shadow: none;
}
#dashboard-chart-grid.loading {
    position: relative;
    min-height: 200px;
}
#dashboard-chart-grid.loading .card-body {
    opacity: 0.4;
    transition: opacity 0.3s ease-in-out;
    pointer-events: none;
}
#dashboard-chart-grid.loading::after {
    content: '<?php echo _l('ai_processing'); ?>';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--bs-primary);
    z-index: 10;
    padding: 1rem 2rem;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 0.5rem;
}
.chart-no-data-message {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    color: #6c757d; /* text-muted color */
    font-style: italic;
    text-align: center;
    padding: 1rem;
}

/* =================================================================
   19. Homepage Hero Card with Animated Background (Final Version)
   ================================================================= */
.hero-card .card-body {
    position: relative;
    overflow: hidden;
    z-index: 1;
}
.animated-background {
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: linear-gradient(-45deg, #e8f5e9, #c8e6c9, #a5d6a7, #e0f2f1);
    background-size: 400% 400%;
    animation: gradient-flow 16s ease infinite;
    z-index: -1;
}
@keyframes gradient-flow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ทำให้ chart canvas โปร่งใสและมีสไตล์ */
.hero-card .tab-pane { background-color: transparent; }
.hero-card canvas {
    background-color: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(4px); /* เพิ่มเอฟเฟกต์กระจกฝ้า */
    border-radius: 0.75rem;
    padding: 1rem;
}

/* [แก้ไข] ทำให้ Dropdown ที่อยู่ในตารางแบบ responsive แสดงผลได้เต็มที่ */
.table-responsive {
    overflow: visible;
}
/* =================================================================
   20. Mobile Off-canvas Menu Style Overrides (Corrected Selector)
   ================================================================= */

/* กำหนดสไตล์โดยตรงไปที่ Tag <a> ที่อยู่ใน ul.nav ภายใน Off-canvas */
.offcanvas-body .nav > .nav-item > a.nav-link {
    color: #343a40; /* สีเทาเข้มเกือบดำ */
    font-size: 1.1rem;
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid #f0f0f0;
    transition: color 0.2s ease, background-color 0.2s ease;
    border-radius: 0.375rem;
}

/* เอฟเฟกต์เมื่อ hover หรือ focus */
.offcanvas-body .nav > .nav-item > a.nav-link:hover,
.offcanvas-body .nav > .nav-item > a.nav-link:focus {
    color: var(--bs-primary); /* สีเขียวหลัก */
    background-color: #f8f9fa;
}

/* สไตล์สำหรับลิงก์ที่ Active */
.offcanvas-body .nav > .nav-item > a.nav-link.active {
    color: var(--bs-primary);
    font-weight: bold;
    background-color: transparent;
}

/* สไตล์สำหรับเมนูย่อย (Sub-menu) ที่อยู่ใน Accordion */
.offcanvas-body .collapse .nav-link {
    color: #6c757d; /* สีเทา */
    font-size: 1rem;
    padding-left: 1.5rem;
    border-bottom: none;
}

.offcanvas-body .collapse .nav-link:hover {
    color: var(--bs-primary);
}

/* [สำคัญ] จัดการปุ่ม Profile และ Logout ที่อยู่นอก ul.nav หลัก */
.offcanvas-body > a.nav-link {
    color: #343a40;
    font-size: 1.1rem;
    padding: 0.75rem 0.5rem;
}
.offcanvas-body > a.nav-link:hover {
    color: var(--bs-primary);
}

/* Admin Dashboard Cards */
.card .border-left-primary { border-left: .25rem solid var(--bs-primary) !important; }
.card .border-left-success { border-left: .25rem solid var(--bs-success) !important; }
.card .border-left-info { border-left: .25rem solid var(--bs-info) !important; }
.card .border-left-warning { border-left: .25rem solid var(--bs-warning) !important; }

.text-xs { font-size: .7rem; }
.text-gray-300 { color: #dddfeb !important; }
.text-gray-800 { color: #5a5c69 !important; }

body {
    font-family: 'Noto Sans Thai', sans-serif;
}
.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  padding: 48px 0 0;
  box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
}
@media (max-width: 767.98px) {
  .sidebar {
    top: 5rem;
  }
}
.sidebar-sticky {
  height: calc(100vh - 48px);
  overflow-x: hidden;
  overflow-y: auto;
}
.sidebar .nav-link {
  font-weight: 500;
  color: #333;
}
.sidebar .nav-link.active {
  color: #006664;
}
main {
  padding-top: 1rem;
}