/* Custom Variables & Bootstrap Overrides */
:root {
    --bs-primary: #1e3b89;
    /* Main Blue */
    --bs-primary-rgb: 2, 132, 199;
    --primary-dark: #1e3b89;
    --primary-light: #fee4e5;
    --bs-body-font-family: 'Figtree', 'IBM Plex Sans Thai', sans-serif;
    --bs-body-bg: #f8f9fa;
}

body {
    font-family: var(--bs-body-font-family);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.text-primary-dark {
    color: var(--primary-dark);
}

.bg-primary-dark {
    background-color: var(--primary-dark);
}

.bg-primary-light {
    background-color: #F8F9FA;
}

/* Modern Glass Navbar */
.glass-navbar {
    background-color: rgba(255, 255, 255, 0.92) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.04);
    transition: all 0.3s ease;
}

.navbar-brand .logo-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    transition: all 0.3s;
}

.navbar-brand:hover .logo-icon {
    background-color: var(--primary-dark) !important;
    transform: rotate(-5deg) scale(1.05);
}

.nav-link {
    font-weight: 700;
    color: #4b5563;
    border-bottom: 2px solid transparent;
    padding-bottom: 0.25rem !important;
    transition: all 0.3s;
}

.nav-link:hover,
.nav-link.active {
    color: var(--bs-primary) !important;
}

/* Modern Dropdown */
.modern-dropdown {
    border: 1px solid rgba(0, 0, 0, 0.04);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.08);
    border-radius: 1rem;
    padding: 0.75rem;
    min-width: 280px;
    background-color: white;
    animation: dropFade 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

@keyframes dropFade {
    0% {
        opacity: 0;
        transform: translateY(15px) scale(0.98);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modern-dropdown .dropdown-item {
    border-radius: 0.6rem;
    padding: 0.65rem 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    font-weight: 500;
    color: #4b5563;
    transition: all 0.25s ease;
    margin-bottom: 0.2rem;
}

.modern-dropdown .dropdown-item:last-child {
    margin-bottom: 0;
}

.modern-dropdown .dropdown-item i {
    font-size: 1.1rem;
    color: #6b7280;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background-color: #f3f4f6;
    border-radius: 0.5rem;
    flex-shrink: 0;
}

.modern-dropdown .dropdown-item:hover,
.modern-dropdown .dropdown-item.active {
    background-color: var(--primary-light);
    color: var(--bs-primary);
    transform: translateX(4px);
}

.modern-dropdown .dropdown-item:hover i,
.modern-dropdown .dropdown-item.active i {
    color: var(--bs-primary);
    background-color: white;
    box-shadow: 0 4px 10px rgba(2, 132, 199, 0.15);
}

@media (min-width: 992px) {

    .nav-link:hover,
    .nav-link.active {
        border-bottom: 2px solid var(--bs-primary);
    }

    .navbar .nav-item.dropdown:hover .dropdown-menu {
        display: block;
        margin-top: 0 !important;
        /* ลบ margin ที่ทำให้เกิดช่องว่าง */
    }

    /* สร้างสะพานโปร่งใส (Invisible Bridge) ป้องกันเมาส์หลุดออกจาก Hover */
    .navbar .nav-item.dropdown .dropdown-menu::before {
        content: '';
        position: absolute;
        top: -15px;
        left: 0;
        right: 0;
        height: 15px;
        background-color: transparent;
    }
}

/* Hero Slider (Owl Carousel) Customization */
.hero-slide-item {
    position: relative;
    height: 65vh;
    min-height: 500px;
}

.hero-slide-item img.slide-bg {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:linear-gradient(to right, rgb(14 14 14 / 90%), rgba(12, 74, 110, 0.4));
    display: flex;
    align-items: center;
}

/* Owl Nav Customization */
.hero-slider .owl-nav button.owl-prev,
.hero-slider .owl-nav button.owl-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.2) !important;
    color: white !important;
    border-radius: 50% !important;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.3s;
}

.hero-slider .owl-nav button.owl-prev:hover,
.hero-slider .owl-nav button.owl-next:hover {
    background: rgba(255, 255, 255, 0.5) !important;
}

.hero-slider .owl-nav button.owl-prev {
    left: 20px;
}

.hero-slider .owl-nav button.owl-next {
    right: 20px;
}

.hero-slider .owl-dots {
    position: absolute;
    bottom: 20px;
    width: 100%;
}

.hero-slider .owl-theme .owl-dots .owl-dot span {
    background: rgba(255, 255, 255, 0.4);
}

.hero-slider .owl-theme .owl-dots .owl-dot.active span {
    background: #fff;
}

/* News Cards */
.news-card {
    border: 1px solid #f3f4f6;
    transition: transform 0.3s, box-shadow 0.3s;
}

.news-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
}

.news-card .card-img-wrapper {
    overflow: hidden;
    height: 220px;
}

.news-card .card-img-top {
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s;
}

.news-card:hover .card-img-top {
    transform: scale(1.05);
}

.news-date-badge {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(4px);
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Partner Slider */
.partner-item {
    opacity: none;
    width: 160px;
    height: 90px;
}

.partner-item img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Some partner logos are pure white and disappear on the light section
   background — give those items a dark chip (existing brand navy) instead
   of changing the whole section, which would hurt the other logos that
   are dark-on-transparent and need the light background to read. */
.partner-item-on-dark {
    padding: 0.75rem 1rem;
}

.partner-item:hover {
    transition: transform 0.2s ease;
}

@media (prefers-reduced-motion: no-preference) {

    .partner-item:hover,
    .partner-item:focus-visible {
        transform: scale(1.1);
    }
}

/* Footer Maps */
.footer-map-container {
    border-radius: 1rem;
    overflow: hidden;
    height: 250px;
}

/* Footer Maps & Decorations */
.footer-map-container {
    border-radius: 1rem;
    overflow: hidden;
    height: 250px;
}

.footer-decor {
    position: absolute;
    color: #ffffff;
    opacity: 0.04;
    pointer-events: none;
    z-index: 0;
}

.footer-circle-1 {
    width: 400px;
    height: 400px;
    border-radius: 50%;
    border: 60px solid #ffffff;
    top: -150px;
    right: -100px;
}

.footer-circle-2 {
    width: 250px;
    height: 250px;
    border-radius: 50%;
    border: 60px solid #ffffff;
    bottom: -80px;
    left: -80px;
}

.footer-icon-1 {
    top: 10%;
    left: 15%;
    font-size: 12rem;
    transform: rotate(-20deg);
}

.footer-icon-2 {
    bottom: 15%;
    right: 28%;
    font-size: 8rem;
    transform: rotate(15deg);
}

.footer-icon-3 {
    top: 40%;
    left: 45%;
    font-size: 14rem;
    transform: rotate(10deg);
}

/* Page Header Banner */
.page-header {
    position: relative;
    background-image: linear-gradient(to right, rgba(45, 35, 134), rgba(12, 74, 110, 0.6)), url('https://images.unsplash.com/photo-1576091160550-2173ff9e5eb2?ixlib=rb-4.0.3&auto=format&fit=crop&w=1920&q=80');
    background-size: cover;
    background-position: center;
    padding: 2.5rem 0;
    border-bottom: 5px solid var(--bs-primary);
}

/* เพิ่มลายจุด (Dot Pattern Overlay) ให้ดูมีมิติและทันสมัย */
.page-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: radial-gradient(rgba(255, 255, 255, 0.15) 1px, transparent 1px);
    background-size: 24px 24px;
    z-index: 0;
}

/* เพิ่มเงาให้ข้อความเพื่อให้ตัวหนังสือชัดเจนขึ้น (Text Shadow) */
.page-header .display-6 {
    text-shadow: 2px 2px 10px rgba(0, 0, 0, 0.5);
}

.breadcrumb-item+.breadcrumb-item::before {
    color: rgba(255, 255, 255, 0.5);
}

/* Sidebar Nav Customization (Redesigned) */
.sidebar-wrapper {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.03);
    padding: 1.5rem;
    border: 1px solid #f3f4f6;
}

.sidebar-title {
    color: var(--primary-dark);
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1.25rem;
    border-bottom: 2px dashed #e5e7eb;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.85rem 1.2rem;
    color: #4b5563;
    font-weight: 500;
    text-decoration: none;
    border-radius: 0.75rem;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.sidebar-link i {
    font-size: 1.25rem;
    margin-right: 0.75rem;
    color: #9ca3af;
    transition: all 0.3s;
}

.sidebar-link:hover {
    background-color: var(--primary-light);
    color: var(--bs-primary);
    transform: translateX(4px);
}

.sidebar-link:hover i {
    color: var(--bs-primary);
}

.sidebar-link.active {
    background-color: var(--bs-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);
}

.sidebar-link.active i {
    color: white;
}

/* Sidebar Submenu */
.sidebar-submenu {
    padding-left: 0;
    margin-top: 0.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    border-left: 2px solid #e5e7eb;
    margin-left: 1.75rem;
    /* Align with icon */
}

.submenu-link {
    padding: 0.5rem 1rem 0.5rem 1.5rem;
    color: #6b7280;
    font-size: 0.95rem;
    text-decoration: none;
    border-radius: 0 0.5rem 0.5rem 0;
    transition: all 0.2s;
    position: relative;
}

.submenu-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 0.75rem;
    height: 2px;
    background-color: #e5e7eb;
    transition: all 0.2s;
}

.submenu-link:hover {
    color: var(--bs-primary);
    background-color: #f9fafb;
    padding-left: 1.75rem;
}

.submenu-link:hover::before {
    background-color: var(--bs-primary);
    width: 1rem;
}

.submenu-link.active {
    color: var(--bs-primary);
    font-weight: 600;
}

/* Content Area Customization */
.content-card {
    background: white;
    border-radius: 1rem;
    padding: 2.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    border: 1px solid #f3f4f6;
}

.content-card h2 {
    color: var(--primary-dark);
    border-bottom: 2px solid var(--primary-light);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
    font-weight: 700;
}

.content-card p {
    color: #4b5563;
    line-height: 1.8;
    margin-bottom: 1.5rem;
}

/* New File Download Card Customization */
.file-download-card {
    transition: all 0.3s ease;
    border: 1px solid #f3f4f6;
    position: relative;
    overflow: hidden;
    background-color: white;
    text-decoration: none;
}

.file-download-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(2, 132, 199, 0.08) !important;
    border-color: #e0f2fe !important;
}

.file-download-card .file-icon {
    transition: transform 0.3s ease;
}

.file-download-card:hover .file-icon {
    transform: scale(1.1);
}

.file-download-card .download-btn {
    background-color: var(--primary-light);
    color: #dc3545;
    transition: all 0.3s;
    border: none;
}

.file-download-card:hover .download-btn {
    background-color: #c0113c;
    color: white;
    box-shadow: 0 4px 10px rgba(2, 132, 199, 0.3);
}

/* Gallery Customization */
.gallery-item {
    position: relative;
    cursor: pointer;
    overflow: hidden;
    border-radius: 0.75rem;
}

.gallery-item img {
    transition: transform 0.5s ease;
}

.gallery-item:hover img {
    transform: scale(1.1);
}

.gallery-overlay {
    position: absolute;
    inset: 0;
    background: rgba(2, 132, 199, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-item:hover .gallery-overlay {
    opacity: 1;
}

.text-primary {
    --bs-text-opacity: 1;
    color: #c0113c !important;
}

.text-icon-footer {
    color: #e1e7ff !important;
}

.bg-lorem {
    background-color: #eaf8ff !important;
}

a.linkft {
    color: #F8F9FA;
    text-decoration: none;
}

a.linkft:hover {
    color: #EDEDED;
    text-decoration: none;
}

/* --- ส่วน Top Bar (โลโก้ และ เบอร์ติดต่อ) --- */
 .new-navbar .top-bar {
            background-color: #ffffff;
            padding: 1.5rem 0;
        }

        .new-navbar .logo-img {
            max-height: 140px; /* ปรับขนาดความสูงโลโก้ตามต้องการ */
            width: auto;
            max-width: 100%;
        }


/* ไอคอนติดต่อ */
.new-navbar .contact-icon {
    background-color: #1e3b89;
    /* เปลี่ยนสีหลักเป็น #1e3b89 */
    color: white;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    transition: all 0.3s;
}

.new-navbar .contact-text {
    font-size: 1.05rem;
    font-weight: 600;
    color: #1e3b89;
    /* เปลี่ยนสีข้อความเป็น #1e3b89 */
}

/* --- ส่วนเมนู Navigation --- */
.new-navbar .nav-main {
    background-color: #1e3b89;
    /* เปลี่ยนสีพื้นหลังเมนูเป็น #1e3b89 */
}

.new-navbar .navbar-nav {
    align-items: stretch;
}

.new-navbar .nav-item {
    display: flex;
}

.new-navbar .nav-link {
    color: #ffffff !important;
    padding: 16px 35px !important;
    font-weight: 400;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    transition: background-color 0.2s;
}

/* Hover Effect สำหรับเมนูทั่วไป */
.new-navbar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* เมนูที่กำลังใช้งาน (เช่น Home) */
.new-navbar .nav-item.active .nav-link {
    background-color: #d82332;
    /* สีแดง */
    font-weight: 500;
}

/* --- สไตล์ของ Dropdown (Hover สำหรับ Desktop) --- */
@media (min-width: 992px) {
    .new-navbar .dropdown:hover>.dropdown-menu {
        display: block;
        opacity: 1;
        transform: translateY(0);
        visibility: visible;
    }

    .new-navbar .dropdown>.dropdown-menu {
        display: block;
        opacity: 0;
        transform: translateY(-15px);
        /* เปลี่ยนค่าเป็นติดลบ เพื่อให้ตอนเปิดมีลูกเล่นเฟดสไลด์ลงมาด้านล่าง */
        visibility: hidden;
        transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
        margin-top: 0;
        border: none;
        border-radius: 0 0 8px 8px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
        padding: 10px 0;
    }
}

/* สไตล์ไอเทมใน Dropdown */
.new-navbar .dropdown-menu {
    background-color: #ffffff;
}

.new-navbar .dropdown-item {
    padding: 12px 25px;
    font-weight: 500;
    color: #1e3b89;
    /* เปลี่ยนสีข้อความ Dropdown เป็น #1e3b89 */
    transition: background-color 0.2s, color 0.2s, padding-left 0.2s;
}

.new-navbar .dropdown-item:hover {
    background-color: #f8f9fa;
    color: #d82332;
    /* เปลี่ยนเป็นสีแดงเมื่อชี้ */
    padding-left: 30px;
    /* เลื่อนข้อความไปทางขวานิดนึงเพิ่มความสมูท */
}

/* --- Hamburger Icon ปรับแต่งให้ดูสมูท ไม่มีปุ่มกรอบ --- */
.new-navbar .navbar-toggler {
    border: none;
    padding: 0;
    margin: 15px 20px;
}

.new-navbar .navbar-toggler:focus {
    box-shadow: none;
    /* เอาขอบสีน้ำเงินเวลาคลิกออก */
    outline: none;
}

.new-navbar .navbar-toggler-icon {
    /* เปลี่ยนสีเส้น Hamburger เป็นสีขาว */
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 1%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2.5' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
    width: 1.8em;
    height: 1.8em;
    transition: transform 0.3s ease;
}

/* เพิ่มลูกเล่นเวลา Hamburger โดนเปิด */
.new-navbar .navbar-toggler[aria-expanded="true"] .navbar-toggler-icon {
    transform: scale(0.9);
    opacity: 0.8;
}

/* Member Application Form — compact spacing (reduce padding / no excess whitespace) */
.member-application-form .form-label {
    margin-bottom: 0.25rem;
    font-weight: 600;
    color: var(--primary-dark);
}

.member-application-form .form-text {
    margin-top: 0.15rem;
    font-size: 0.8rem;
}

.member-application-form .form-check {
    margin-bottom: 0.25rem;
}

.member-application-form textarea.form-control {
    resize: vertical;
}

@media (max-width: 991.98px) {
    .member-application-form.content-card {
        padding: 1.25rem;
    }

    .member-application-form h2 {
        font-size: 1.35rem;
        margin-bottom: 1rem;
    }

    .member-application-form .row.g-3 {
        --bs-gutter-y: 0.6rem;
    }
}

/* --- Mobile adjustments --- */
@media (max-width: 991.98px) {

    /* จัดโลโก้ให้อยู่ตรงกลางบนมือถือ (หรือถ้าอยากให้ชิดซ้ายก็ลบ text-center ได้ครับ) */
    .new-navbar .top-bar {
        padding: 1rem 0;
        text-align: center;
    }

    .new-navbar .nav-link {
        padding: 15px 20px !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .new-navbar .dropdown-menu {
        background-color: #152960;
        /* ปรับพื้นหลัง Dropdown มือถือให้เข้มขึ้นจาก #1e3b89 เล็กน้อย */
        border: none;
        padding: 0;
    }

    .new-navbar .dropdown-item {
        color: #ffffff;
        padding: 12px 35px;
    }

    .new-navbar .dropdown-item:hover {
        background-color: transparent;
        color: #d82332;
    }
}

/* Content body (CMS rich-text output) — images pasted/embedded via the CMS
   editor have no class of their own, so make every image inside responsive
   by default instead of relying on each upload being sized correctly. */
.content-body img {
    display: block;
    max-width: 100%;
    height: auto;
    margin-left: auto;
    margin-right: auto;
    border-radius: 1rem;
    margin-bottom: 1rem;
}

/* Inner pages (about/member/news/knowledge) share this main+container padding
   pattern. On mobile it stacks up to ~4.5rem of empty space before any real
   content — tighten it there; desktop is untouched. */
@media (max-width: 991.98px) {
    main.py-5 {
        padding-top: 1.5rem;
        padding-bottom: 1.5rem;
    }

    main.py-5 > .container.py-4 {
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
}

/* News page — search box (top-right) */
.news-search-box {
    width: 100%;
}

@media (min-width: 768px) {
    .news-search-box {
        max-width: 280px;
    }
}