/* 導航欄CSS生成器 */

/* ===== 統一手機版和小螢幕導航欄字體大小系統 ===== */
:root {
    /* 導航欄字體大小變數 */
    --nav-font-size: 1rem;
    --nav-small-font-size: 0.9rem;
    --nav-large-font-size: 1.1rem;
    --logo-font-size: 1.5rem;
}

/* 手機版和小螢幕統一字體大小 */
@media (max-width: 768px) {
    :root {
        /* 手機版導航欄字體大小 - 統一為 1rem (16px) */
        --nav-font-size: 1rem;
        --nav-small-font-size: 0.9rem;
        --nav-large-font-size: 1rem;
        --logo-font-size: 1.25rem;
    }
    
    /* 強制統一導航欄字體大小 */
    .nav-menu a, .nav-menu .login-btn, .logo {
        font-size: var(--nav-font-size) !important;
    }
}

/* 小螢幕進一步優化 */
@media (max-width: 480px) {
    :root {
        /* 小螢幕導航欄字體大小 - 統一為 1rem (16px) */
        --nav-font-size: 1rem;
        --nav-small-font-size: 0.9rem;
        --nav-large-font-size: 1rem;
        --logo-font-size: 1.125rem;
    }
}

/* 超小螢幕優化 */
@media (max-width: 360px) {
    :root {
        /* 超小螢幕導航欄字體大小 - 統一為 0.95rem (15.2px) */
        --nav-font-size: 0.95rem;
        --nav-small-font-size: 0.85rem;
        --nav-large-font-size: 0.95rem;
        --logo-font-size: 1rem;
    }
}

/* ===== 原有導航欄樣式開始 ===== */
.navbar {
    background: linear-gradient(135deg, #ff6b35, #ff8c42);
    padding: 15px 0;
    box-shadow: 0 2px 10px rgba(255, 107, 53, 0.3);
    position: sticky;
    top: 0;
    z-index: 9999;
}

@media (max-width: 768px) {
    .navbar {
        padding: 10px 0;
    }
}

/* 當螢幕寬度足夠時，導航菜單可以向上放置到第一行 */
@media (min-width: 1200px) {
    .nav-container {
        grid-template-areas: 
            "logo nav right-buttons";
        grid-template-columns: auto 1fr auto;
        align-items: start;
    }
    
    .nav-menu {
        justify-content: center;
        flex-wrap: nowrap;
        gap: 15px;
    }
}

/* 當螢幕寬度較小時，導航菜單自動換行到第二行 */
@media (max-width: 1199px) and (min-width: 769px) {
    .nav-container {
        gap: 10px;
        align-items: start;
    }
    
    .nav-menu {
        justify-content: center;
        flex-wrap: wrap;
        gap: 12px;
    }
}

/* Logo區域 */
.logo {
    font-size: 24px;
}

.logo img {
    height: 50px;
    margin-right: 10px;
}

/* 英文版導航欄優化 - 按鈕完整顯示並自動換行 */
.nav-menu[lang="en"] {
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    max-height: none;
    overflow: visible;
}

.nav-menu[lang="en"] a {
    padding: 8px 14px;
    min-width: auto;
    width: auto;
    text-align: center;
    overflow: visible !important;
    text-overflow: clip !important;
    white-space: normal !important;
    word-wrap: break-word !important;
    word-break: keep-all !important;
    flex: 0 0 auto;
    max-width: none;
}

.nav-menu li {
    flex: 0 0 auto;
    margin: 0;
    padding: 0;
    min-width: 0;
}



/* 響應式設計 */
@media (max-width: 1024px) and (min-width: 769px) {
    .nav-container {
        gap: 8px;
        align-items: start;
    }
    
    .nav-menu {
        gap: 15px;
        justify-content: center;
    }
    

    
    /* 英文版響應式優化 - 按鈕完整顯示並自動換行 */
    .nav-menu[lang="en"] {
        gap: 12px;
        flex-wrap: wrap;
        justify-content: center;
        align-items: flex-start;
        max-height: none;
        overflow: visible;
    }
    
    .nav-menu[lang="en"] a {
        padding: 6px 12px;
        min-width: auto;
        width: auto;
        overflow: visible !important;
        text-overflow: clip !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        word-break: keep-all !important;
        text-align: center;
        flex: 0 0 auto;
        max-width: none;
        font-size: var(--nav-small-font-size) !important;
    }
    
    .logo {
        grid-area: logo;
        justify-self: start;
    }
}

/* 769px-1134px 樣式已移至 nav-variables.css 中統一管理 */



/* 針對 1135px 以上的大螢幕優化 */
@media (min-width: 1135px) and (max-width: 1199px) {
    .nav-container {
        max-width: 1800px;
        padding: 0 30px;
        gap: 15px;
    }
    
    .nav-menu {
        gap: 25px;
        justify-content: center;
        flex-wrap: wrap;
        row-gap: 10px;
    }
    

    
    .nav-menu a:hover {
        background: rgba(255, 255, 255, 0.25);
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
    
    /* 英文版大螢幕優化 - 按鈕完整顯示並自動換行 */
    .nav-menu[lang="en"] {
        gap: 20px;
        row-gap: 8px;
        flex-wrap: wrap;
        justify-content: center;
        align-items: flex-start;
        max-height: none;
        overflow: visible;
    }
    
    .nav-menu[lang="en"] a {
        padding: 10px 18px;
        min-width: auto;
        width: auto;
        overflow: visible !important;
        text-overflow: clip !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        word-break: keep-all !important;
        text-align: center;
        flex: 0 0 auto;
        max-width: none;
        font-size: var(--nav-font-size) !important;
        /* 維持手機版配色 */
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 25px;
    }
    
    .nav-menu[lang="en"] a:hover {
        background: rgba(255, 255, 255, 0.25);
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
    
    .logo {
        grid-area: logo;
        justify-self: start;
        font-size: var(--logo-font-size);
        flex-shrink: 0;
    }
    
    .logo img {
        height: 55px;
    }
}

/* 針對 1200px 以上的超大螢幕，導航菜單可以向上放置到第一行 */
@media (min-width: 1200px) {
    .nav-container {
        max-width: 1800px;
        padding: 0 30px;
        gap: 25px;
    }
    
    .nav-menu {
        gap: 25px;
        justify-content: center;
        flex-wrap: nowrap;
        row-gap: 0;
    }
    
    /* 英文版超大螢幕優化 */
    .nav-menu[lang="en"] {
        gap: 20px;
        flex-wrap: nowrap;
        justify-content: center;
        align-items: flex-start;
        max-height: none;
        overflow: visible;
    }
    
    .nav-menu[lang="en"] a {
        padding: 10px 18px;
        min-width: auto;
        width: auto;
        overflow: visible !important;
        text-overflow: clip !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        word-break: keep-all !important;
        text-align: center;
        flex: 0 0 auto;
        max-width: none;
        font-size: var(--nav-font-size) !important;
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 25px;
    }
    
    .nav-menu[lang="en"] a:hover {
        background: rgba(255, 255, 255, 0.25);
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
    
    .logo {
        grid-area: logo;
        justify-self: start;
        font-size: var(--logo-font-size);
        flex-shrink: 0;
    }
    
    .logo img {
        height: 55px;
    }
}

/* === 導航：字體與高度全面一致化（置於檔尾提高優先級）=== */
:root {
    --nav-item-font-size-unified: 13px;
    --nav-item-height-unified: 40px;
    --nav-item-padding-x-unified: 12px;
    --nav-item-min-width-unified: 100px;
    --nav-item-width-unified: 100px;
    --nav-item-border-radius: 20px;
}

/* 強制統一所有導航按鈕的樣式 */
.nav-menu a,
.nav-menu .login-btn,
.nav-menu .lang-switcher .lang-btn {
    font-size: var(--body-text-size) !important;
    height: var(--nav-item-height-unified) !important;
    line-height: var(--nav-item-height-unified) !important;
    padding: 0 var(--nav-item-padding-x-unified) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    min-width: auto !important;
    width: auto !important;
    border-radius: var(--nav-item-border-radius) !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    transition: all 0.3s ease !important;
    white-space: nowrap !important;
    overflow: visible !important;
    text-overflow: clip !important;
}

/* 讓語言切換器容器本身也與其他項目垂直置中且同高 */
.nav-menu li { 
    display: flex; 
    align-items: flex-start; 
    height: var(--nav-item-height-unified) !important;
}
.nav-menu .lang-switcher {
    display: inline-flex !important;
    align-items: flex-start !important;
    height: var(--nav-item-height-unified) !important;
    margin-top: 0 !important;
}

/* 手機與小螢幕：維持一致但可視需要微調高度 */
@media (max-width: 768px) {
    :root {
        --nav-item-font-size-unified: 12.5px;
        --nav-item-height-unified: 36px;
        --nav-item-padding-x-unified: 10px;
        --nav-item-min-width-unified: 80px;
        --nav-item-width-unified: 80px;
        --nav-item-border-radius: 18px;
    }

    /* 手機版：導覽選單清除浮動，避免第一列（Logo/右側按鈕）旁出現任何選單項目 */
    .navbar .nav-menu {
        clear: both !important;
    }

    /* 手機版：右側語言/登入按鈕垂直置中對齊，並統一高度與內距 */
    .navbar .nav-right-buttons {
        align-items: center !important;
    }
    .navbar .nav-right-buttons .lang-switcher,
    .navbar .nav-right-buttons .lang-btn,
    .navbar .nav-right-buttons .login-btn {
        height: var(--nav-item-height-unified) !important;
        line-height: var(--nav-item-height-unified) !important;
    }
    .navbar .nav-right-buttons .lang-btn,
    .navbar .nav-right-buttons .login-btn {
        padding: 0 var(--nav-item-padding-x-unified) !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        box-sizing: border-box !important;
        border-radius: var(--nav-item-border-radius) !important;
        border-width: 2px !important;
    }
    /* 確保語言按鈕視覺上與登入鍵完全等高，不受內文或箭頭影響 */
    .navbar .nav-right-buttons .lang-btn::after {
        margin-top: 0 !important;
        margin-bottom: 0 !important;
    }
}

/* 超小螢幕：保持一致性 */
@media (max-width: 360px) {
    :root {
        --nav-item-font-size-unified: 12px;
        --nav-item-height-unified: 32px;
        --nav-item-padding-x-unified: 8px;
        --nav-item-min-width-unified: 70px;
        --nav-item-width-unified: 70px;
        --nav-item-border-radius: 16px;
    }
}

/* 英文版導覽列：確保按鈕群靠右且緊貼容器邊緣（避免右側留過多空白） */
.nav-menu[lang="en"] { 
    margin-left: auto !important; 
    justify-content: flex-end !important; 
}

/* 手機與平板：英文版與中文版使用相同置中規則 */
@media (max-width: 768px) {
  .nav-menu[lang="en"] {
    margin-left: 0 !important;
    justify-content: center !important;
  }
}

/* 針對超大螢幕的額外優化 */
@media (min-width: 1600px) {
    .nav-container {
        max-width: 2000px;
        padding: 0 40px;
        gap: 12px;
    }
    
    .nav-menu {
        gap: 18px;
        flex-wrap: wrap;
        row-gap: 8px;
        justify-content: center;
    }
    
    .nav-menu[lang="en"] a {
        min-width: auto;
        width: auto;
        overflow: visible !important;
        text-overflow: clip !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        word-break: keep-all !important;
        text-align: center;
        flex: 0 0 auto;
        max-width: none;
        /* 維持手機版配色 */
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 25px;
    }
    
    .nav-menu[lang="en"] a:hover {
        background: rgba(255, 255, 255, 0.25);
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
    
    .nav-menu[lang="en"] {
        row-gap: 10px;
        flex-wrap: wrap;
        justify-content: center;
        align-items: flex-start;
        max-height: none;
        overflow: visible;
    }
    
    .logo {
        grid-area: logo;
        justify-self: start;
        font-size: var(--logo-font-size);
    }
    
    .logo img {
        height: 60px;
    }
}

@media (max-width: 768px) {
    .nav-container {
        display: grid;
        grid-template-areas: 
            "logo right-buttons"
            "nav nav";
        grid-template-columns: 1fr auto;
        gap: 12px;
        row-gap: 16px;
        padding: 8px 12px;
        align-items: start;
    }
    
    /* 右側按鈕區域移到頂部右側 */
    .nav-right-buttons {
        grid-area: right-buttons;
        justify-self: end;
        margin-top: 0;
        gap: 6px;
        display: flex;
        align-items: flex-start;
    }
    
    /* Logo 保持在頂部左側 */
    .logo {
        grid-area: logo;
        justify-self: start;
    }
    
    /* 導航選單移到第二行 */
    .nav-menu {
        grid-area: nav;
        justify-self: center;
    }

    .nav-menu {
        display: flex;
        position: static;
        transform: none;
        width: 100%;
        max-width: none;
        background: none;
        box-shadow: none;
        border-radius: 0;
        margin-top: 8px;
        padding: 0;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
        justify-content: center;
        align-items: flex-start;
        max-height: none;
        overflow: visible;
        flex: none;
    }
    
    /* 英文版手機優化 - 按鈕完整顯示並自動換行 */
    .nav-menu[lang="en"] {
        gap: 3px;
        flex-wrap: wrap;
        justify-content: center;
        align-items: flex-start;
        max-height: none;
        overflow: visible;
    }
    
    .nav-menu[lang="en"] a {
        min-width: auto;
        width: auto;
        padding: 6px 10px;
        font-size: var(--nav-font-size) !important;
        overflow: visible !important;
        text-overflow: clip !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        word-break: keep-all !important;
        text-align: center;
        flex: 0 0 auto;
        max-width: none;
    }
    
    .nav-menu[lang="en"] .login-btn {
        min-width: auto;
        width: auto;
        padding: 6px 10px;
        font-size: var(--nav-font-size) !important;
        overflow: visible !important;
        text-overflow: clip !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        word-break: keep-all !important;
        text-align: center;
        flex: 0 0 auto;
        max-width: none;
    }

    .nav-menu li {
        margin: 0;
        flex: 0 0 auto;
        min-width: 0;
    }

    .nav-menu a {
        padding: 0 var(--nav-item-padding-x-unified) !important;
        font-size: var(--body-text-size) !important;
        white-space: nowrap !important;
        border-radius: var(--nav-item-border-radius) !important;
        text-align: center !important;
        font-weight: 600 !important;
        transition: all 0.3s ease !important;
        background: rgba(255, 255, 255, 0.1) !important;
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        min-width: auto !important;
        width: auto !important;
        height: var(--nav-item-height-unified) !important;
        box-sizing: border-box !important;
        text-decoration: none !important;
        color: white !important;
        overflow: visible !important;
        text-overflow: clip !important;
    }

    .nav-menu a:hover {
        background: rgba(255, 255, 255, 0.25);
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    .nav-menu .login-btn {
        margin: 0 !important;
        align-self: auto !important;
        padding: 0 var(--nav-item-padding-x-unified) !important;
        font-size: var(--body-text-size) !important;
        white-space: nowrap !important;
        border-radius: var(--nav-item-border-radius) !important;
        text-align: center !important;
        font-weight: 600 !important;
        transition: all 0.3s ease !important;
        background: rgba(255, 255, 255, 0.9) !important;
        border: 1px solid rgba(255, 255, 255, 0.8) !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        min-width: auto !important;
        width: auto !important;
        height: var(--nav-item-height-unified) !important;
        box-sizing: border-box !important;
        color: #ff8c42 !important;
        text-decoration: none !important;
    }

    .nav-menu .login-btn:hover {
        background: rgba(255, 255, 255, 1);
        color: #ff8c42;
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(255, 255, 255, 0.3);
    }
}

/* 針對360px以上到480px以下的設備，加大字體 */
@media (min-width: 361px) and (max-width: 480px) {
    .nav-container {
        display: grid;
        grid-template-areas: 
            "logo right-buttons"
            "nav nav";
        grid-template-columns: 1fr auto;
        gap: 10px;
        row-gap: 12px;
        padding: 6px 12px;
        align-items: start;
    }
    
    /* 右側按鈕區域移到頂部右側 */
    .nav-right-buttons {
        grid-area: right-buttons;
        justify-self: end;
        margin-top: 0;
        gap: 5px;
        display: flex;
        align-items: flex-start;
    }
    
    /* Logo 保持在頂部左側 */
    .logo {
        grid-area: logo;
        justify-self: start;
    }
    
    /* 導航選單移到第二行 */
    .nav-menu {
        grid-area: nav;
        justify-self: center;
        gap: 4px;
        max-height: none;
        overflow: visible;
        flex-wrap: wrap;
        justify-content: center;
        align-items: flex-start;
        margin-top: 6px;
    }

    .nav-menu a {
        padding: 0 var(--nav-item-padding-x-unified) !important;
        font-size: var(--body-text-size) !important;
        min-width: auto !important;
        width: auto !important;
        height: var(--nav-item-height-unified) !important;
        font-weight: 600 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        text-decoration: none !important;
        color: white !important;
        border-radius: var(--nav-item-border-radius) !important;
        box-sizing: border-box !important;
    }
    
    /* 英文版小螢幕優化 - 按鈕完整顯示並自動換行 */
    .nav-menu[lang="en"] {
        gap: 4px;
        flex-wrap: wrap;
        justify-content: center;
        align-items: flex-start;
        max-height: none;
        overflow: visible;
        margin-top: 10px;
    }
    
    .nav-menu[lang="en"] a {
        min-width: auto;
        width: auto;
        padding: 8px 12px;
        font-size: var(--nav-font-size) !important;
        overflow: visible;
        text-overflow: clip;
        white-space: normal;
        word-wrap: break-word;
        word-break: keep-all;
        text-align: center;
        flex: 0 0 auto;
        max-width: none;
    }
    
    .nav-menu[lang="en"] .login-btn {
        min-width: auto;
        width: auto;
        padding: 8px 12px;
        font-size: var(--nav-font-size) !important;
        overflow: visible;
        text-overflow: clip;
        white-space: normal;
        word-wrap: break-word;
        word-break: keep-all;
        text-align: center;
        flex: 0 0 auto;
        max-width: none;
    }

    .nav-menu .login-btn {
        padding: 8px 16px;
        font-size: var(--nav-font-size);
        min-width: 60px;
        background: rgba(255, 255, 255, 0.9);
        border: 1px solid rgba(255, 255, 255, 0.8);
        color: #ff8c42;
        text-decoration: none;
        font-weight: 600;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
    }

    .logo {
        font-size: var(--logo-font-size);
    }

    .logo img {
        height: 40px;
    }
}

@media (max-width: 480px) {
    .nav-container {
        display: grid;
        grid-template-areas: 
            "logo right-buttons"
            "nav nav";
        grid-template-columns: 1fr auto;
        gap: 12px;
        padding: 5px 8px;
        align-items: start;
    }
    
    /* 右側按鈕區域移到頂部右側 */
    .nav-right-buttons {
        grid-area: right-buttons;
        justify-self: end;
        margin-top: 0;
        gap: 4px;
        display: flex;
        align-items: flex-start;
    }
    
    /* Logo 保持在頂部左側 */
    .logo {
        grid-area: logo;
        justify-self: start;
    }
    
    /* 導航選單移到第二行 */
    .nav-menu {
        grid-area: nav;
        justify-self: center;
    }

    .nav-menu {
        gap: 4px;
        max-height: none;
        overflow: visible;
        flex-wrap: wrap;
        justify-content: center;
        align-items: flex-start;
    }

    .nav-menu a {
        padding: 3px 6px;
        font-size: var(--nav-font-size);
        min-width: 60px;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        text-decoration: none;
        color: white;
    }
    
    .nav-menu {
        margin-top: 8px;
    }
    
    /* 英文版超小螢幕優化 - 按鈕完整顯示並自動換行 */
    .nav-menu[lang="en"] {
        gap: 2px;
        flex-wrap: wrap;
        justify-content: center;
        align-items: flex-start;
        max-height: none;
        overflow: visible;
    }
    
    .nav-menu[lang="en"] a {
        min-width: auto;
        width: auto;
        padding: 4px 8px;
        font-size: var(--nav-font-size) !important;
        overflow: visible !important;
        text-overflow: clip !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        word-break: keep-all !important;
        text-align: center;
        flex: 0 0 auto;
        max-width: none;
    }
    
    .nav-menu[lang="en"] .login-btn {
        min-width: auto;
        width: auto;
        padding: 4px 8px;
        font-size: var(--nav-font-size) !important;
        overflow: visible !important;
        text-overflow: clip !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        word-break: keep-all !important;
        text-align: center;
        flex: 0 0 auto;
        max-width: none;
    }

    .nav-menu .login-btn {
        padding: 3px 6px;
        font-size: var(--nav-font-size);
        min-width: 60px;
        background: rgba(255, 255, 255, 0.9);
        border: 1px solid rgba(255, 255, 255, 0.8);
        color: #ff8c42;
        text-decoration: none;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
    }

    .logo {
        font-size: var(--logo-font-size);
    }

    .logo img {
        height: 35px;
    }
}

/* ===== 全新語言選單樣式系統 ===== */

/* 語言切換器容器 */
.lang-switcher {
    position: relative;
    display: inline-block;
    z-index: 9999;
    pointer-events: auto !important;
}

/* 確保語言切換器在所有情況下都能正常工作 */
.lang-switcher * {
    pointer-events: auto !important;
}

/* 語言選單按鈕 - 整合三個語言的下拉選單 */
.lang-btn {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px;
    background: #fff !important;
    background-color: #fff !important;
    color: #ff8c42 !important;
    border: 2px solid #ff8c42 !important;
    padding: 0 var(--nav-item-padding-x-unified) !important;
    border-radius: var(--nav-item-border-radius) !important;
    cursor: pointer !important;
    font-size: var(--body-text-size) !important;
    font-weight: 600 !important;
    transition: all 0.3s ease !important;
    min-width: auto !important;
    width: auto !important;
    height: var(--nav-item-height-unified) !important;
    line-height: var(--nav-item-height-unified) !important;
    text-decoration: none !important;
    white-space: nowrap !important;
    user-select: none !important;
    font-family: "Microsoft JhengHei", "PingFang TC", "Helvetica Neue", Arial, sans-serif !important;
    font-synthesis: none !important;
    box-sizing: border-box !important;
    position: relative !important;
    z-index: 9999 !important;
    pointer-events: auto !important;
}

/* 移除地球圖示，改為顯示當前語言 */
.lang-btn::before {
    content: none;
}

/* 下拉箭頭 */
.lang-btn::after {
    content: "";
    width: 6px;
    height: 6px;
    border-right: 1.5px solid #ff8c42;
    border-bottom: 1.5px solid #ff8c42;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
    margin-left: 4px;
}

/* 展開狀態箭頭旋轉 */
.lang-switcher.active .lang-btn::after {
    transform: rotate(-135deg);
}

/* 懸停效果 */
.lang-btn:hover {
    background: #fff !important;
    background-color: #fff !important;
    color: #ff8c42 !important;
    box-shadow: 0 4px 12px rgba(255, 140, 66, 0.35);
    transform: translateY(-1px);
    z-index: 9999 !important;
}

/* 點擊效果 */
.lang-btn:active {
    transform: translateY(0);
}

/* 下拉選單 */
.lang-dropdown {
    position: absolute !important;
    top: calc(100% + 8px);
    right: 0;
    background: rgba(255, 255, 255, 0.95) !important;
    background-color: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    min-width: 140px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
    z-index: 9999;
    overflow: visible;
    display: flex !important;
    flex-direction: column;
    pointer-events: auto !important;
}

/* 展開狀態 */
.lang-switcher.active .lang-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* 語言選項 */
.lang-option {
    position: relative;
    display: block;
    padding: 10px 16px;
    background: #fff !important;
    color: #ff8c42 !important;
    text-decoration: none;
    font-size: var(--nav-font-size);
    font-weight: 500;
    transition: all 0.15s ease;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    text-align: left;
    font-family: "Microsoft JhengHei", "PingFang TC", "Helvetica Neue", Arial, sans-serif !important;
    font-synthesis: none;
    cursor: pointer !important;
    pointer-events: auto !important;
    z-index: 9999 !important;
}

.lang-option:last-child {
    border-bottom: none;
}

/* 懸停效果 */
.lang-option:hover {
    background-color: rgba(255, 140, 66, 0.1) !important;
    color: #ff8c42 !important;
}

/* 當前語言高亮 */
.lang-option.active {
    background: #fff !important;
    color: #ff8c42 !important;
    font-weight: 600;
}

/* ===== 響應式語言選單樣式 ===== */

/* 1024px以下 */
@media (max-width: 1024px) {
    .lang-btn {
        padding: 0 var(--nav-item-padding-x-unified) !important;
        font-size: var(--body-text-size) !important;
        min-width: auto !important;
        width: auto !important;
        height: var(--nav-item-height-unified) !important;
        border-radius: var(--nav-item-border-radius) !important;
    }
    
    .lang-btn::after {
        width: 5px;
        height: 5px;
        border-right: 1px solid #ff8c42;
        border-bottom: 1px solid #ff8c42;
    }
    
    .lang-dropdown {
        min-width: 130px;
    }
    
    .lang-option {
        padding: 8px 14px;
        font-size: var(--body-text-size) !important;
    }
    
    /* 英文版平板優化 - 按鈕完整顯示並自動換行 */
    .nav-menu[lang="en"] {
        gap: 8px;
        flex-wrap: wrap;
        justify-content: flex-end;
        align-items: flex-start;
        max-height: none;
        overflow: visible;
    }
    
    .nav-menu[lang="en"] a {
        min-width: auto;
        width: auto;
        padding: 8px 12px;
        font-size: var(--nav-small-font-size) !important;
        overflow: visible !important;
        text-overflow: clip !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        word-break: keep-all !important;
        text-align: center;
        flex: 0 0 auto;
        max-width: none;
    }
    
    .nav-menu[lang="en"] .login-btn {
        min-width: auto;
        width: auto;
        padding: 8px 12px;
        font-size: var(--nav-small-font-size) !important;
        overflow: visible !important;
        text-overflow: clip !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        word-break: keep-all !important;
        text-align: center;
        flex: 0 0 auto;
        max-width: none;
    }
}

/* 768px到1134px之間 - 樣式已移至 nav-variables.css 中統一管理 */

/* 768px以下 */
@media (max-width: 768px) {
    .lang-btn {
        padding: 0 var(--nav-item-padding-x-unified) !important;
        font-size: var(--body-text-size) !important;
        min-width: auto !important;
        width: auto !important;
        height: var(--nav-item-height-unified) !important;
        border-radius: var(--nav-item-border-radius) !important;
    }
    
    .lang-btn::after {
        width: 5px;
        height: 5px;
        border-right: 1px solid #ff8c42;
        border-bottom: 1px solid #ff8c42;
    }
    
    .lang-dropdown {
        right: 0;
        transform: translateY(-8px);
        min-width: 120px;
    }
    
    .lang-switcher.active .lang-dropdown {
        transform: translateY(0);
    }
    
    .lang-option {
        padding: 8px 12px;
        font-size: var(--nav-font-size);
        text-align: center;
    }
}

/* 480px以下 */
@media (max-width: 480px) {
    .lang-btn {
        padding: 0 var(--nav-item-padding-x-unified) !important;
        font-size: var(--body-text-size) !important;
        min-width: auto !important;
        width: auto !important;
        height: var(--nav-item-height-unified) !important;
        border-radius: var(--nav-item-border-radius) !important;
    }
    
    .lang-btn::after {
        width: 4px;
        height: 4px;
        border-right: 1px solid #ff8c42;
        border-bottom: 1px solid #ff8c42;
    }
    
    .lang-dropdown {
        min-width: 110px;
    }
    
    .lang-option {
        padding: 6px 10px;
        font-size: var(--body-text-size) !important;
    }
}

/* 360px以下 */
@media (max-width: 360px) {
    .nav-container {
        display: grid;
        grid-template-areas: 
            "logo right-buttons"
            "nav nav";
        grid-template-columns: 1fr auto;
        gap: 10px;
        padding: 4px 6px;
        align-items: start;
    }
    
    /* 右側按鈕區域移到頂部右側 */
    .nav-right-buttons {
        grid-area: right-buttons;
        justify-self: end;
        margin-top: 0;
        gap: 3px;
        display: flex;
        align-items: flex-start;
    }
    
    /* Logo 保持在頂部左側 */
    .logo {
        grid-area: logo;
        justify-self: start;
    }
    
    /* 導航選單移到第二行 */
    .nav-menu {
        grid-area: nav;
        justify-self: center;
        flex-wrap: wrap;
        justify-content: center;
        align-items: flex-start;
        max-height: none;
        overflow: visible;
        margin-top: 8px;
    }
    
    .lang-btn {
        padding: 0 var(--nav-item-padding-x-unified) !important;
        font-size: var(--body-text-size) !important;
        min-width: auto !important;
        width: auto !important;
        height: var(--nav-item-height-unified) !important;
        border-radius: var(--nav-item-border-radius) !important;
    }
    
    .lang-dropdown {
        min-width: 100px;
    }
    
    .lang-option {
        padding: 5px 8px;
        font-size: var(--nav-font-size);
    }
    
    /* 英文版超小螢幕優化 - 按鈕完整顯示並自動換行 */
    .nav-menu[lang="en"] {
        gap: 1px;
        flex-wrap: wrap;
        justify-content: flex-end;
        align-items: flex-start;
        max-height: none;
        overflow: visible;
    }
    
    .nav-menu[lang="en"] a {
        min-width: auto;
        width: auto;
        padding: 4px 8px;
        font-size: var(--nav-font-size) !important;
        overflow: visible !important;
        text-overflow: clip !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        word-break: keep-all !important;
        text-align: center;
        flex: 0 0 auto;
        max-width: none;
    }
    
    .nav-menu[lang="en"] .login-btn {
        min-width: auto;
        width: auto;
        padding: 4px 8px;
        font-size: var(--nav-font-size) !important;
        overflow: visible !important;
        text-overflow: clip !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        word-break: keep-all !important;
        text-align: center;
        flex: 0 0 auto;
        max-width: none;
    }
}

/* ===== 檔尾最終覆蓋：確保第一列有按鈕、第二列優先填滿（必要時才到第三列）===== */
.navbar .nav-container {
    display: block !important;
    position: relative !important;
}
.navbar .nav-container::after {
    content: "" !important;
    display: block !important;
    clear: both !important;
}
.navbar .logo {
    float: left !important;
    height: var(--nav-item-height-unified) !important;
    display: flex !important;
    align-items: center !important;
}
.navbar .nav-right-buttons {
    float: right !important;
    height: var(--nav-item-height-unified) !important;
    display: flex !important;
    align-items: center !important;
}
.navbar .nav-menu {
    display: block !important;
    margin: 2px 0 0 0 !important; /* 與第一列（Logo/語言/登入）拉開最小垂直距離 */
    padding: 0 !important;
    font-size: 0 !important; /* 消除 inline-block 之間空白 */
    overflow: visible !important;
    text-align: center !important; /* 讓第二列起置中對齊 */
}

/* 確保768px以下有最小的垂直間距 */
@media (max-width: 768px) {
    .navbar .nav-menu {
        margin: 4px 0 0 0 !important; /* 最小的768px以下的垂直間距 */
    }
    
    /* 確保第一行和第二行之間有最小間距 */
    .navbar .nav-container {
        row-gap: 4px !important; /* 設置最小的grid row gap */
    }
    
    /* 確保右側按鈕區域與導航選單有最小分離 */
    .navbar .nav-right-buttons {
        margin-bottom: 2px !important;
    }
    
    /* 確保Logo與導航選單有最小分離 */
    .navbar .logo {
        margin-bottom: 2px !important;
    }
}

/* 手機版最小間距優化 */
@media (max-width: 768px) {
    .navbar .nav-menu {
        margin: 4px 0 0 0 !important; /* 手機版最小的垂直間距 */
    }
    
    .navbar .nav-container {
        padding: 8px 12px !important; /* 手機版最小的容器內距 */
    }
    
    /* 確保grid佈局有最小的垂直間距 */
    .navbar .nav-container {
        gap: 4px !important; /* 設置最小的grid gap */
    }
}

@media (max-width: 480px) {
    .navbar .nav-menu {
        margin: 2px 0 0 0 !important; /* 小螢幕最小垂直間距 */
    }
    
    .navbar .nav-container {
        padding: 4px 8px !important; /* 小螢幕最小容器內距 */
    }
}

@media (max-width: 360px) {
    .navbar .nav-menu {
        margin: 1px 0 0 0 !important; /* 超小螢幕最小垂直間距 */
    }
    
    .navbar .nav-container {
        padding: 3px 6px !important; /* 超小螢幕最小容器內距 */
    }
}
/* 不再使用清浮動，inline-block 會自然換行 */
.navbar .nav-menu li {
    display: inline-block !important;
    vertical-align: top !important;
    margin: 0 4px 8px 4px !important; /* 左右等距，利於置中 */
    padding: 0 !important;
}

/* 手機版適中垂直間距 */
@media (max-width: 768px) {
    .navbar .nav-menu li {
        margin: 0 4px 8px 4px !important; /* 手機版減少底部間距 */
    }
}

@media (max-width: 480px) {
    .navbar .nav-menu li {
        margin: 0 3px 6px 3px !important; /* 小螢幕減少垂直間距 */
    }
}

@media (max-width: 360px) {
    .navbar .nav-menu li {
        margin: 0 2px 4px 2px !important; /* 超小螢幕減少垂直間距 */
    }
}
.navbar .nav-menu li + li {
    margin-left: 4px !important;
}
.navbar .nav-menu li:last-child {
    margin-right: 0 !important;
}

/* 進一步確保鏈結本身不強制固定寬度，避免撐出不必要空間 */
.navbar .nav-menu a,
.navbar .nav-menu .login-btn,
.navbar .nav-menu .lang-switcher .lang-btn {
    min-width: 0 !important;
    width: auto !important;
    white-space: nowrap !important;
}

/* 保障電腦版點擊：確保右側按鈕層級高於導覽選單，避免被覆蓋導致無法點擊 */
.navbar .nav-right-buttons {
    position: relative !important;
    z-index: 10001 !important;
}

/* 同時將導覽選單層級稍降，避免透明區塊壓住右側按鈕 */
.navbar .nav-menu {
    position: relative !important;
    z-index: 9998 !important;
}

/* === 最終一致化：右上語言與登入按鈕完全等高（消除原生按鈕差異） === */
.navbar .nav-right-buttons .login-btn,
.navbar .nav-right-buttons .lang-btn {
    height: var(--nav-item-height-unified) !important;
    min-height: var(--nav-item-height-unified) !important;
    line-height: 1 !important;
    block-size: var(--nav-item-height-unified) !important;
    padding-block: 0 !important;
    margin-block: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    border-width: 2px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    align-self: center !important;
    box-sizing: border-box !important;
    -webkit-appearance: none !important;
    appearance: none !important;
}

.navbar .nav-right-buttons .lang-switcher {
    height: var(--nav-item-height-unified) !important;
    display: inline-flex !important;
    align-items: center !important;
}

.navbar .nav-right-buttons .lang-btn::after {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    line-height: 0 !important;
}

/* 右上兩顆按鈕 hover 時不位移，避免看起來高度不同 */
.navbar .nav-right-buttons .login-btn:hover,
.navbar .nav-right-buttons .lang-btn:hover {
    transform: none !important;
    box-shadow: none !important;
}

/* 視覺一致：語言鍵使用白色邊框，與登入鍵一致，避免白色區域看起來較小 */
.navbar .nav-right-buttons .lang-btn {
    border-color: #ffffff !important;
}
.navbar .nav-right-buttons .lang-btn:hover {
    border-color: #ffffff !important;
}

/* 手機版最小間距保障 */
@media (max-width: 768px) {
    /* 確保登入按鈕與下方按鈕有最小間距 */
    .navbar .nav-right-buttons {
        padding-bottom: 2px !important;
        margin-bottom: 2px !important;
    }
    
    /* 確保導航選單與上方元素有最小分離 */
    .navbar .nav-menu {
        padding-top: 2px !important;
        margin-top: 2px !important;
    }
    
    /* 設置最小的grid行間距 */
    .navbar .nav-container {
        grid-row-gap: 4px !important;
        row-gap: 4px !important;
    }
}