/* ============ Logo ติ่งลงมา ============ */
.navbar .container>a:first-child {
    position: relative;
    display: inline-block;
    margin-left: -15px;
    margin-top: -20px;
    z-index: 1060;
}

.logo-hesder {
    background-color: #000;
    padding: 8px;
    border-radius: 0 0 32px 32px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.25);
    display: block;
    width: 120px;
    height: 126px;
    object-fit: contain;
    margin-bottom: -65px !important;
    position: relative;
}

/* ============ Navbar Hover Effect ============ */
.navbar {
    transition: background-color 0.3s ease;
}

.navbar:hover {
    background-color: #121212 !important;
}

.navbar .nav-link {
    transition: color 0.3s ease;
}

.navbar:hover .nav-link {
    color: #ffffff !important;
}

/* ซ่อน submenu เริ่มต้น */
.dropdown-submenu>.submenu {
    display: none;
    padding-left: 0;
    list-style: none;
    position: relative;
    /* ป้องกันถูกบัง */
    z-index: 1000;
}

.dropdown-menu.show {
    padding: 20px 16px 30px;
    display: block;
    border-radius: 20px;
    background-color: #121212 !important;
}

.dropdown-submenu>.submenu li a.dropdown-item {
    padding-left: 32px !important;
}

/* แสดง submenu เมื่อมี class show */
.dropdown-submenu>.submenu.show {
    display: block;
}

/* หมุน chevron ของ submenu เมื่อเปิด */
.dropdown-submenu>a.dropdown-toggle::after {
    transition: transform 0.3s ease;
}

.dropdown-submenu.show>a.dropdown-toggle::after {
    transform: rotate(-135deg);
}

/* ============ Dropdown Menu Styling ============ */
.dropdown-menu {
    background-color: rgb(83, 86, 90) !important;
}

.dropdown-item {
    color: #ffffff !important;
}

.dropdown-item:hover {
    background-color: #121212 !important;
    color: #facc15 !important;
}

.dropdown-item.active,
.dropdown-item:active {
    color: var(--bs-dropdown-link-active-color);
    text-decoration: none;
    background-color: #5f5f5f;
}

.menu-desktop {
    display: block;
}

.menu-mobile {
    display: none;
}

@media (max-width: 991.98px) {
    .menu-desktop {
        display: none;
    }

    .menu-mobile {
        display: block;
    }
}

/* ///////////////////////////////////////////////////////////////////////////// */
/* ============ ปุ่ม toggle icon ============ */
.navbar-toggler {
    position: relative;
    width: 40px;
    height: 40px;
    border: none;
}

.bi-x-lg::before {
    content: "\f659";
}

.bi::before,
[class^="bi-"]::before,
[class*=" bi-"]::before {
    display: inline-block;
    font-family: bootstrap-icons !important;
    font-style: normal;
    font-weight: normal !important;
    font-variant: normal;
    text-transform: none;
    line-height: 1;
    vertical-align: -.125em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

*,
::after,
::before {
    box-sizing: border-box;
}

.navbar-toggler .toggler-icon {
    background-color: #000c;
    font-size: 27px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    /* border: 0.5px solid #ddd; */
    padding: 9px;
    border-radius: 8px;
    color: #ffffff;
}

/* hamburger ตอนเมนูปิด */
.navbar-toggler.collapsed .hamburger {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* close ตอนเมนูเปิด */
.navbar-toggler:not(.collapsed) .close {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(90deg);
}

button:hover {
    color: rgba(255, 255, 255, 0) !important;
    text-decoration: none !important;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: var(--bs-dropdown-item-padding-y) var(--bs-dropdown-item-padding-x);
    clear: both;
    font-weight: 400;
    color: var(--bs-dropdown-link-color);
    text-align: inherit;
    text-decoration: none;
    white-space: nowrap;
    background-color: #28252500;
    border-bottom: 1px solid #3e3e3eb0;
    border-radius: var(--bs-dropdown-item-border-radius, 0);
}

/* จัด dropdown ให้ใช้ flex */
.dropdown-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 8px;
}

/* caret - chevron icon */
.dropdown-toggle::after {
    margin-left: auto;
    content: "";
    display: inline-block;
    width: 0.5em;
    height: 0.5em;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.3s ease;
    border-top: 0;
    border-left: 0;
}

/* หมุน chevron เมื่อเปิด dropdown */
.dropdown-toggle[aria-expanded="true"]::after {
    transform: rotate(-135deg);
}

.dropdown-item:focus {
    background-color: #000 !important;
}

/* ///////////////////////////////////////////////////////////////////////////// */
/* ล็อกให้ชิดขวาของปุ่มแม่ และไม่เลื่อน/ล้นขอบจอ */
.no-popper-fix {
    right: 0 !important;
    left: auto !important;
    transform: none !important;
    max-width: min(92vw, 420px);
    white-space: normal;
    word-break: break-word;
    max-height: calc(100vh - 96px);
    overflow: auto;
}

/* Desktop: กันล้นจอ */
@media (min-width: 992px) {
    .navbar .dropdown-menu {
        max-height: calc(100vh - 96px);
        overflow: auto;
    }
}

/* Mobile: ให้ยืดตามเนื้อหา แล้วเลื่อนทั้งหน้า */
@media (max-width: 991.98px) {
    .navbar .dropdown-menu {
        max-height: none;
        overflow: visible;
        width: 100%;
    }
}

/* Mobile & Tablet: ธงภาษาเรียงข้างกัน */
@media (max-width: 991.98px) {
    .lang-switcher {
        display: flex;
        gap: 12px;
        align-items: center;
        margin-left: 16px;
    }

    .lang-switcher .nav-link {
        padding: 0;
    }

    .lang-switcher img {
        width: 34px;
        height: 34px;
    }

    /* ลดความสูงของ logo ใน mobile */
    .menu-mobile .logo-hesder {
        height: 110px;
        width: 104px;
        margin-bottom: -56px !important
    }

    /* ขยับเมนูลงมา */
    .menu-mobile .navbar-collapse {
        margin-top: 72px;
    }

    /* Mobile navbar - พื้นขาวตอนปิดเมนู */
    nav.navbar.menu-mobile {
        background-color: #ffffff !important;
        min-height: auto;
        transition: background-color 0s, min-height 0.2s ease !important;
    }

    /* ปิด hover effect ใน mobile */
    nav.navbar.menu-mobile:hover {
        background-color: #ffffff !important;
    }

    nav.navbar.menu-mobile:hover .nav-link {
        color: inherit !important;
    }

    /* เมื่อเปิดเมนู ให้พื้นเป็นสีดำทันที และค่อยๆขยายเต็มจอ */
    nav.navbar.menu-mobile.menu-open,
    nav.navbar.menu-mobile.menu-open:hover {
        background-color: #121212 !important;
        min-height: 100vh !important;
    }

    /* ตัวอักษรเป็นสีขาวเมื่อเมนูเปิด */
    nav.navbar.menu-mobile.menu-open .nav-link,
    nav.navbar.menu-mobile.menu-open:hover .nav-link {
        color: #ffffff !important;
    }

    /* เมนูเนื้อหาค่อยๆขยาง - ปิดเร็วกว่าเปิด */
    .menu-mobile .navbar-collapse {
        transition: height 0.25s ease !important;
    }

    .menu-mobile .navbar-collapse.collapsing {
        transition: height 0.25s ease !important;
    }
}

/* หน้าจอเล็ก 576px ลงไป - เพิ่ม padding ซ้ายให้ logo */
@media (max-width: 576px) {
    .menu-mobile .container>a:first-child {
        margin-left: 0;
        padding-left: 0;
    }
}