header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    box-shadow: 0 0 16px 0 #0002;
    border-bottom: 1px solid #0001;
    background-color: #fff;
    z-index: 100;
    position: sticky;
    top: 0;

    nav {
        display: flex;
        align-items: center;
        gap: 12px;

        a,
        summary {
            text-wrap: nowrap;

            &:hover {
                font-weight: bold;
            }

            &.line {
                background-color: #06C755;
                color: #fff;
                display: flex;
                align-items: center;
                padding: 8px 10px;
                border-radius: 8px;
                gap: 4px;
            }
        }

        details {
            position: relative;

            summary {
                display: flex;
                align-items: center;
                gap: 2px;
                list-style: none;

                &::-webkit-details-marker {
                    display: none;
                }
            }

            div {
                position: absolute;
                top: calc(100% + 20px);
                left: 0;
                background-color: #fff;
                display: flex;
                align-items: start;
                flex-direction: column;
                border-radius: 12px;
                box-shadow: 0 0 8px 0 #0002;
                overflow: hidden;

                a {
                    border-top: 1px solid #0002;
                    width: 100%;
                    padding: 8px 16px;

                    &:hover {
                        background-color: #0002;
                    }
                }
            }
        }

        details[open] img {
            rotate: 180deg;
        }
    }

    .mobile-menu {
        display: none;
    }

    /* Language Switcher with Flags */
    .lang-switcher {
        position: relative;
        margin-left: 8px;
    }

    .lang-current {
        display: flex;
        align-items: center;
        gap: 6px;
        padding: 8px 12px;
        border: 1px solid #e0e0e0;
        border-radius: 10px;
        background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
        cursor: pointer;
        font-family: inherit;
        font-weight: 500;
        font-size: 14px;
        color: #333;
        transition: all 0.3s ease;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
        white-space: nowrap;
    }

    .lang-current:hover {
        border-color: #c8a96b;
        box-shadow: 0 4px 12px rgba(200, 169, 107, 0.2);
        transform: translateY(-1px);
    }

    .lang-switcher.open .lang-current {
        border-color: #c8a96b;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
    }

    .flag {
        width: 22px;
        height: 16px;
        border-radius: 2px;
        object-fit: cover;
        flex-shrink: 0;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    }

    .lang-code {
        font-weight: 600;
        color: #555;
    }

    .dropdown-arrow {
        transition: transform 0.3s ease;
        color: #888;
        flex-shrink: 0;
    }

    .lang-switcher.open .dropdown-arrow {
        transform: rotate(180deg);
    }

    .lang-dropdown {
        position: absolute;
        top: 100%;
        left: 0;
        min-width: 120px;
        background: #fff;
        border: 1px solid #c8a96b;
        border-top: none;
        border-radius: 0 0 10px 10px;
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
        overflow: hidden;
        opacity: 0;
        visibility: hidden;
        transform: translateY(-10px);
        transition: all 0.3s ease;
        z-index: 100;
    }

    .lang-switcher.open .lang-dropdown {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    .lang-option {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px 12px;
        text-decoration: none;
        color: #444;
        font-weight: 500;
        font-size: 13px;
        transition: all 0.2s ease;
        border-top: 1px solid #f0f0f0;
        white-space: nowrap;
    }

    .lang-option:first-child {
        border-top: none;
    }

    .lang-option:hover {
        background: linear-gradient(135deg, #fdf9f3 0%, #f5f0e6 100%);
        color: #c8a96b;
    }

    .lang-option.active {
        background: linear-gradient(135deg, #f9f5ed 0%, #f0e8d9 100%);
        color: #b89a5c;
        font-weight: 600;
    }

    .lang-option.active::after {
        content: '✓';
        margin-left: auto;
        color: #c8a96b;
        font-weight: bold;
    }

    .lang-name {
        font-size: 13px;
    }
}


@media only screen and (max-width:1000px) {
    header {
        z-index: 100;

        nav {
            display: none;
        }

        /* ฉากหลังทึบตอนเปิดเมนูมือถือ กันเนื้อหาด้านหลังโปร่งแสง/ทับกัน */
        &:has(.mobile-menu[open])::before {
            content: '';
            position: fixed;
            inset: 70px 0 0 0;
            background: rgba(0, 0, 0, .45);
            z-index: 5;
        }

        .mobile-menu {
            display: unset;

            summary {
                display: flex;
                align-items: center;
                gap: 2px;
                list-style: none;

                &::-webkit-details-marker {
                    display: none;
                }
            }

            aside {
                display: flex;
                align-items: start;
                flex-direction: column;
                position: fixed;
                top: 70px;
                right: 0;
                background-color: #fff;
                height: calc(100dvh - 70px);
                min-width: 60vw;
                border-left: 1px solid #0002;
                box-shadow: -8px 0 24px 0 #0003;
                z-index: 10;
                overflow-y: auto;

                a,
                details {
                    border-top: 1px solid #0001;
                    width: 100%;
                    padding: 8px 16px;

                    &:not(details):hover {
                        background-color: #0002;
                    }

                    div {
                        display: flex;
                        align-items: start;
                        flex-direction: column;
                    }

                    &.line {
                        display: flex;
                        align-items: center;
                        gap: 4px;
                    }
                }

                /* Mobile Language Switcher */
                .lang-switcher.mobile {
                    margin: 12px 16px;
                    width: calc(100% - 32px);
                }

                .lang-switcher.mobile .lang-current {
                    width: 100%;
                    justify-content: flex-start;
                    padding: 12px 16px;
                }

                .lang-switcher.mobile .lang-code {
                    flex: 1;
                }

                .lang-switcher.mobile .dropdown-arrow {
                    margin-left: auto;
                }

                .lang-switcher.mobile .lang-dropdown {
                    position: relative;
                    border-radius: 10px;
                    border: 1px solid #c8a96b;
                    margin-top: 8px;
                }

                .lang-switcher.mobile.open .lang-current {
                    border-radius: 10px;
                }
            }
        }
    }
}

/* โลโก้หัวเว็บ: ใหญ่ขึ้นบน desktop, คงขนาดเดิม 54px บนมือถือ */
/* (header สูง ~70px บนมือถือ เพื่อให้เมนู aside top:70px ยังตรง) */
header .header-logo {
    width: 76px;
    height: 76px;
}

@media only screen and (max-width: 1000px) {
    header .header-logo {
        width: 54px;
        height: 54px;
    }
}
