/* 固定選單在最上方 */
header {
    background: #0056b3;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 50px;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* 避免內容被固定選單遮住 */
body {
    padding-top: 80px;
}

/* 限制選單區域的最大寬度 */
nav {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

/* Logo 樣式 */
.logo {
    font-size: 24px;
    font-weight: bold;
    white-space: nowrap;
    /* 防止換行 */
}

/* 確保 Logo 連結不變色 */
.logo a {
    text-decoration: none;
    color: white;
    transition: 0.3s;
}

.logo a:hover {
    color: #ffcc00;
}

/* 讓選單靠右對齊 */
nav ul {
    list-style: none;
    padding: 0;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    flex-grow: 1;
    /* 讓選單可以調整大小，不會擠壓 logo */
}

/* 避免選單太靠近螢幕邊緣 */
nav ul li {
    margin-right: 20px;
}

/* 讓最右邊的登入按鈕不會超出畫面 */
nav ul li:last-child {
    margin-right: 70px;
}

/* 選單連結樣式 */
nav ul li a {
    color: white;
    text-decoration: none;
    font-size: 18px;
    transition: 0.3s;
    padding: 10px 15px;
}

/* 選單連結懸停效果 */
nav ul li a:hover {
    color: #ffcc00;
}

/* 登入/註冊按鈕 */
.loginbtn {
    background: white;
    color: #0056b3;
    padding: 10px 20px;
    border-radius: 5px;
    text-decoration: none;
    font-weight: bold;
    border: 2px solid #0056b3;
    transition: 0.3s;
}

.loginbtn:hover {
    background: #ffcc00;
    color: black;
    border-color: #ffcc00;
}


/* === 漢堡選單 (手機版) === */
/* 漢堡選單按鈕 */
.menu-icon {
    display: none;
    /* 預設隱藏 */
    font-size: 24px;
    color: white;
    cursor: pointer;
    margin-left: auto;
    /* 讓 `☰` 按鈕靠右 */
}

/* 預設所有 mobile-only 都隱藏 */
.mobile-only {
    display: none !important;
}

/* 桌面專用下拉（desktop-only）預設顯示 */
.desktop-only {
    display: inline-block !important;
}

@media (max-width: 768px) {
    header {
        padding: 15px 20px;
    }

    /* 漢堡按鈕顯示 */
    .menu-icon {
        display: block !important;
        position: absolute;
        right: 20px;
    }

    /* 漢堡按鈕開啟後的選單 */
    nav ul {
        display: none;
        flex-direction: column;
        position: fixed;
        top: 60px;
        left: 0;
        width: 100%;
        background: #0056b3;
        padding: 10px 0;
        gap: 8px;
        /* ← 加一點 gap，讓 li 之間不會擠在一起 */
        z-index: 1100;
    }

    /* 漢堡選單開啟後，整個 ul 置中所有 li */
    .menu-open nav ul {
        display: flex;
        align-items: center;
    }

    /* 桌面隱藏、手機顯示 */
    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: block !important;
    }

    /* 各 li 恢復自動寬度，不要撐滿 100% */
    nav ul li.mobile-only {
        width: auto;
        /* ← 刪掉 100%，讓 li shrink-wrap */
        margin: 4px 0;
        /* 上下間距 */
        display: block;
        /* 恢復 block，也可省略 */
    }

    /* 按鈕統一固定寬度，防止文字換行 */
    nav ul li.mobile-only a.loginbtn {
        display: block;
        width: 200px;
        /* 固定寬度（可自行微調） */
        white-space: nowrap;
        /* 不自動換行 */
        padding: 10px 0;
        background-color: #f8f9fa;
        color: #0056b3;
        font-size: 16px;
        font-weight: 600;
        text-align: center;
        border: 1px solid #0056b3;
        border-radius: 4px;
        transition: background 0.2s, color 0.2s;
    }

    /* 懸停微調色 */
    nav ul li.mobile-only a.loginbtn:hover {
        background-color: #e2e6ea;
        color: #0056b3;
    }

    /* 移除桌面的右邊距 */
    nav ul li {
        margin-right: 0 !important;
        /* 改成上下間距 */
        margin: 8px 0 !important;
    }

    /* 也把最後一個 margin-right 取消 */
    nav ul li:last-child {
        margin-right: 0 !important;
    }
}


/* 下拉選單樣式 */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    background: white;
    min-width: 150px;
    box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
    border-radius: 5px;
    overflow: hidden;
    z-index: 1000;
}

.dropdown-content a {
    color: #0056b3;
    padding: 10px 15px;
    display: block;
    text-decoration: none;
    transition: background 0.3s;
}

.dropdown-content a:hover {
    background: #ffcc00;
    color: black;
}

/* 當滑鼠懸停在 .dropdown 時顯示選單 */
.dropdown:hover .dropdown-content {
    display: block;
}