/* Header CSS - Thai Style with Theme Support - Fixed z-index */

/* ========================================== */
/* CRITICAL FIX: Header z-index Management */
/* ========================================== */
.header-wrapper {
    position: sticky;
    top: 0;
    z-index: 1000 !important;
    /* สูงกว่า hero slider */
    transition: all 0.3s ease-in-out;
}

.header-wrapper.scrolled .top-bar,
.header-wrapper.scrolled .logo-section {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    transition: all 0.3s ease-in-out;
}

.header-wrapper.scrolled {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* ========================================== */
/* Dropdown Menu - Ensure Proper z-index */
/* ========================================== */
.dropdown {
    position: relative;
    z-index: 100;
}

.dropdown:hover .dropdown-menu {
    display: block;
}

.dropdown-menu {
    display: none;
    position: absolute;
    z-index: 999 !important;
    /* ให้แน่ใจว่าสูงกว่าองค์ประกอบอื่น */
    animation: fadeIn 0.3s ease-in-out;
}

#mobile-menu {
    position: relative;
    z-index: 999 !important;
}

#mobile-menu .dropdown-menu {
    display: none;
}

#mobile-menu .dropdown-menu.open {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Thai Pattern Background - ใช้สีจากธีม */
.thai-pattern-bg {
    background: var(--theme-primary);
    position: relative;
    overflow: hidden;
}

.thai-pattern-bg::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: repeating-linear-gradient(45deg, transparent, transparent 35px, rgba(255, 255, 255, .05) 35px, rgba(255, 255, 255, .05) 70px),
        repeating-linear-gradient(-45deg, transparent, transparent 35px, rgba(255, 255, 255, .05) 35px, rgba(255, 255, 255, .05) 70px);
    opacity: 0.3;
}

.thai-pattern-bg::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    border-radius: 50%;
}

/* Thai Ornament Decorations */
.thai-ornament {
    position: relative;
}

.thai-ornament::before,
.thai-ornament::after {
    content: '◈';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    color: var(--theme-secondary);
    opacity: 0.6;
    animation: pulse 2s ease-in-out infinite;
}

.thai-ornament::before {
    left: -30px;
}

.thai-ornament::after {
    right: -30px;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.6;
        transform: translateY(-50%) scale(1);
    }

    50% {
        opacity: 1;
        transform: translateY(-50%) scale(1.1);
    }
}

/* ========================================== */
/* ENHANCED: Logo Section with Thai Pattern */
/* ========================================== */
.header-logo-section {
    background: linear-gradient(135deg,
            rgba(251, 191, 36, 0.05) 0%,
            rgba(251, 191, 36, 0.15) 50%,
            rgba(251, 191, 36, 0.05) 100%);
    border-bottom: 3px solid var(--theme-secondary);
    position: relative;
}

/* ลวดลายไทยสำหรับ Logo Section */
.header-logo-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: repeating-linear-gradient(45deg,
            transparent,
            transparent 25px,
            rgba(75, 0, 130, 0.03) 25px,
            rgba(75, 0, 130, 0.03) 50px),
        repeating-linear-gradient(-45deg,
            transparent,
            transparent 25px,
            rgba(138, 43, 226, 0.03) 25px,
            rgba(138, 43, 226, 0.03) 50px);
    opacity: 0.5;
    pointer-events: none;
}

/* ลวดลายวงกลมประดับ Logo Section */
.header-logo-section::after {
    content: '';
    position: absolute;
    top: -30%;
    right: -5%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle,
            rgba(251, 191, 36, 0.15) 0%,
            rgba(251, 191, 36, 0.05) 40%,
            transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

/* ========================================== */
/* ENHANCED: Menu Bar with Thai Pattern */
/* ========================================== */
.menu-bar-enhanced {
    background: linear-gradient(to bottom,
            rgba(255, 255, 255, 1) 0%,
            rgba(248, 250, 252, 1) 50%,
            rgba(241, 245, 249, 1) 100%);
    border-top: 3px solid var(--theme-secondary);
    border-bottom: 3px solid var(--theme-secondary);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 100;
}

/* ลวดลายไทยสำหรับ Menu Bar */
.menu-bar-enhanced::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: repeating-linear-gradient(90deg,
            transparent,
            transparent 30px,
            rgba(75, 0, 130, 0.02) 30px,
            rgba(75, 0, 130, 0.02) 60px),
        repeating-linear-gradient(0deg,
            transparent,
            transparent 3px,
            rgba(251, 191, 36, 0.03) 3px,
            rgba(251, 191, 36, 0.03) 6px);
    opacity: 0.6;
    pointer-events: none;
}

/* เส้นประดับด้านบน Menu Bar */
.menu-bar-enhanced::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg,
            transparent 0%,
            var(--theme-secondary) 20%,
            var(--theme-primary-solid) 50%,
            var(--theme-secondary) 80%,
            transparent 100%);
    opacity: 0.5;
    pointer-events: none;
}

/* Menu Items with Thai Style */
.menu-item-thai {
    position: relative;
    transition: all 0.3s ease;
    z-index: 10;
}

.menu-item-thai::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 80%;
    height: 3px;
    background: var(--theme-secondary);
    transition: transform 0.3s ease;
    border-radius: 2px;
}

.menu-item-thai:hover::after {
    transform: translateX(-50%) scaleX(1);
}

.menu-item-thai:hover {
    color: var(--theme-primary-solid) !important;
}

/* Icon Enhancement */
.icon-enhanced {
    transition: all 0.3s ease;
}

.icon-enhanced:hover {
    transform: scale(1.2) rotate(5deg);
    color: var(--theme-secondary) !important;
}

/* Mobile Menu Enhancement */
.mobile-menu-enhanced {
    background: linear-gradient(to bottom, #ffffff 0%, #f8fafc 100%);
    border-top: 2px solid var(--theme-secondary);
    position: relative;
    z-index: 999;
}

/* Notification Bar Enhancement */
.notification-bar-enhanced {
    background: var(--theme-secondary);
    position: relative;
    overflow: hidden;
}

.notification-bar-enhanced::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 3s linear infinite;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }

    100% {
        left: 100%;
    }
}

/* Thai Border Pattern */
.thai-border-top {
    border-top: 4px solid var(--theme-secondary);
}

.thai-border-bottom {
    border-bottom: 4px solid var(--theme-secondary);
}

/* Font Size Buttons Enhancement */
.font-size-btn-enhanced {
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.font-size-btn-enhanced:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
    background-color: var(--theme-secondary) !important;
}

.font-size-btn-enhanced:active {
    transform: translateY(0);
}

.font-size-btn-enhanced.active {
    background-color: var(--theme-secondary) !important;
    ring-color: var(--theme-primary-solid) !important;
}

/* Search and Sitemap Icons */
.utility-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.3s ease;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

.utility-icon:hover {
    background: var(--theme-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.utility-icon:hover i {
    color: white !important;
}

/* Logo Container Enhancement */
.logo-glow {
    position: relative;
}

.logo-glow::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--theme-primary);
    border-radius: 50%;
    filter: blur(20px);
    opacity: 0.3;
    z-index: -1;
}

/* Title Gradient using Theme Colors */
.title-gradient {
    background: var(--theme-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Login Button Enhancement */
.login-btn-enhanced {
    background: var(--theme-secondary);
    transition: all 0.3s ease;
}

.login-btn-enhanced:hover {
    background: var(--theme-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

/* Dropdown Menu Enhancement */
.dropdown-menu-enhanced {
    border-top: 4px solid var(--theme-secondary) !important;
}

.dropdown-item-enhanced:hover {
    color: var(--theme-primary-solid) !important;
    background-color: rgba(251, 191, 36, 0.1) !important;
}

/* Theme Button Ring */
.theme-btn.active {
    ring-width: 3px;
    ring-color: var(--theme-secondary);
}

/* Mobile Dropdown */
.mobile-dropdown-item:hover {
    background-color: rgba(251, 191, 36, 0.1) !important;
    color: var(--theme-primary-solid) !important;
}

/* Icon Colors using Theme */
.icon-theme-primary {
    color: var(--theme-primary-solid);
}

.icon-theme-secondary {
    color: var(--theme-secondary);
}

/* Submenu Background */
.submenu-bg-hover:hover {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.05), rgba(251, 191, 36, 0.1));
}

/* News Divider using Theme */
.news-divider {
    color: var(--theme-primary-solid);
    opacity: 0.6;
}

/* ========================================== */
/* Mobile Menu Button - Ensure Clickability */
/* ========================================== */
#mobile-menu-button {
    position: relative;
    z-index: 1001 !important;
    touch-action: manipulation;
}

/* ========================================== */
/* Fix for Touch Devices */
/* ========================================== */
@media (max-width: 768px) {
    .header-wrapper {
        z-index: 1000 !important;
    }

    .menu-bar-enhanced {
        z-index: 100;
    }

    #mobile-menu {
        z-index: 999 !important;
        position: relative;
    }

    .dropdown-menu {
        z-index: 998 !important;
    }
}

/* ========================================== */
/* [EDIT] Google Translate Stying */
/* ========================================== */

/* Hide the Google Translate top bar */
body {
    top: 0 !important;
}
.goog-te-banner-frame {
    display: none !important;
}

/* Hide the original Google Translate dropdown (now in a hidden div) */
#google_translate_element.hidden {
    display: none !important;
}

/* Style for the flag icons (base) */
.lang-flag {
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    border-radius: 9999px; /* rounded-full */
}

/* Style for the text buttons (TH/EN) */
.lang-text {
    font-size: 13px; /* Match font-size buttons */
    font-weight: 700; /* bold */
    color: white;
    background-color: rgba(255, 255, 255, 0.1); /* same as font-size bg */
    backdrop-filter: blur(2px);
    width: 28px;  /* 1.75rem (w-7) */
    height: 28px; /* 1.75rem (h-7) */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease-in-out;
    border: 2px solid transparent; /* placeholder for active state */
    text-decoration: none !important;
}

/* Style for the inactive text button */
.lang-flag.inactive-lang.lang-text {
    opacity: 0.7;
}

.lang-flag.inactive-lang.lang-text:hover {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.3);
}

/* Style for the active text button */
.lang-flag.active-lang.lang-text {
    opacity: 1;
    background-color: var(--theme-secondary, #FFD700); /* Use theme color */
    color: #000000; /* Black text on yellow */
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-color: rgba(255, 255, 255, 0.5);
}


/* Style the container (old styles, now unused but kept just in case) */
#google_translate_element {
    display: flex;
    align-items: center;
    height: 38px; /* Match font-size button height */
}

/* Style the dropdown (old styles, now hidden but kept just in case) */
.goog-te-combo {
    font-family: 'Sarabun', sans-serif !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #000000 !important;
    background-color: #ffffff !important;
    border: 1px solid #d1d5db !important;
    border-radius: 9999px !important; /* rounded-full */
    padding: 6px 10px !important;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
    cursor: pointer;
}

.goog-te-combo:hover {
    border-color: var(--theme-secondary, #FFD700) !important;
    box-shadow: 0 0 0 2px rgba(255, 215, 0, 0.3);
}

/* Hide the "Powered by" text */
.goog-logo-link,
.goog-te-gadget span {
    display: none !important;
}

.goog-te-gadget {
    color: transparent !important;
    line-height: 0 !important;
    font-size: 0 !important;
}

/* Ensure it fits on mobile (old styles) */
@media (max-width: 380px) {
    #google_translate_element {
        margin-right: 8px; /* mr-2 */
    }
    .goog-te-combo {
        font-size: 12px !important;
        padding: 6px 8px !important;
    }
}

