/**
 * R/S Megamenu 樣式
 *
 * 100% Figma 設計還原，使用 Flexbox 布局
 * 依據: CLAUDE.md 領域 13 - 設計稿轉換規則（禁止使用 Table 模擬 Flexbox）
 *
 * @package RS_Megamenu
 * @since 1.0.0
 */

/* ========================================
   CSS 變數
   ======================================== */
:root {
    --rs-megamenu-bg-primary: #FEFDF9;
    --rs-megamenu-bg-secondary: #F9F5EF;
    --rs-megamenu-bg-sidebar: #A57865;
    --rs-megamenu-bg-button: #E3C6B4;
    --rs-megamenu-gap: 15px;
    --rs-megamenu-radius: 15px;
    --rs-megamenu-font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --rs-megamenu-transition: all 0.2s ease;
}

/* ========================================
   第一層選單容器
   ======================================== */
.rs-megamenu-nav {
    background: var(--rs-megamenu-bg-primary);
    padding: 16px 80px; /* ✅ 左右內縮 80px */
    position: sticky; /* ✅ 置頂功能 */
    top: 0; /* ✅ 固定在頂部 */
    z-index: 2147483647; /* ✅ 最高 z-index 層級（32-bit 最大值）*/
}

/* Elementor 環境：減少 padding 避免與容器衝突 */
.elementor-location-header .rs-megamenu-nav {
    padding: 16px 20px; /* ✅ Elementor 專用：減少到 20px */
}

.rs-megamenu-container {
    display: flex; /* ✅ Flexbox */
    align-items: center;
    justify-content: space-between; /* ✅ Logo 置左、選單置右 */
    max-width: 1440px;
    margin: 0 auto;
    position: relative; /* ✅ 修正：成為小版型的定位上下文，解決大螢幕（>1920px）定位偏移問題 */
}

/* Logo */
.rs-megamenu-logo {
    flex-shrink: 0;
    margin-right: 0; /* ✅ 移除右邊距，使用 space-between */
}

.rs-megamenu-logo img {
    height: 68px; /* ✅ 強制高度 68px */
    width: auto;
    display: block;
}

/* 漢堡選單（預設隱藏）*/
.rs-megamenu-hamburger {
    display: none;
    width: 30px;
    height: 30px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    position: relative;
    flex-direction: column;
    justify-content: space-between;
}

.rs-megamenu-hamburger span {
    display: block;
    width: 100%;
    height: 3px;
    background: #333;
    transition: var(--rs-megamenu-transition);
}

/* 收合狀態（展開後）：使用 X 圖示 */
.rs-megamenu-hamburger.active {
    background-image: url('data:image/svg+xml;charset=UTF-8,%3Csvg xmlns="http://www.w3.org/2000/svg" width="30" height="64" viewBox="0 0 30 64" fill="none"%3E%3Crect x="5" y="20.6274" width="30" height="2" transform="rotate(45 5 20.6274)" fill="%23E3C6B4"/%3E%3Crect x="4" y="41.6274" width="30" height="2" transform="rotate(-45 4 41.6274)" fill="%23E3C6B4"/%3E%3C/svg%3E');
    background-repeat: no-repeat;
    background-position: center;
    background-size: 30px auto; /* ✅ 控制 X 圖示寬度為 30px，高度自動 */
    justify-content: center; /* ✅ 確保內容居中 */
}

/* 收合狀態：隱藏三條橫線 */
.rs-megamenu-hamburger.active span {
    display: none;
}

/* 第一層選單 */
.rs-megamenu-menu {
    display: flex; /* ✅ Flexbox */
    gap: 41px; /* ✅ 選單之間距離 41px */
    list-style: none;
    margin: 0;
    padding: 0;
}

.rs-menu-item {
    font-family: var(--rs-megamenu-font-family);
    font-size: 16px;
    cursor: pointer;
    padding: 8px 0; /* ✅ 移除左右 padding */
    border-radius: 0; /* ✅ 移除圓角 */
    transition: none; /* ✅ 移除過渡效果 */
    position: static; /* ✅ 桌機版：讓 megamenu 向上找定位上下文 */
    color: #694B40; /* ✅ 選單顏色 */
}

/* ✅ 移除 hover 和 active 效果 */
.rs-menu-item:hover,
.rs-menu-item.active {
    background: transparent; /* ✅ 無背景色 */
}

.rs-menu-link {
    text-decoration: none !important; /* ✅ 不要底線 */
    color: #694B40; /* ✅ 選單顏色 */
}

.rs-menu-text {
    display: inline-block;
    color: #694B40; /* ✅ 選單顏色 */
    text-decoration: none !important; /* ✅ 不要底線 */
}

/* 手機版隱藏 */
.rs-hidden-mobile {
    display: flex;
}

/* ========================================
   Megamenu 區塊：大版型（桌面版）
   ======================================== */
.rs-megamenu-item.large {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--rs-megamenu-bg-primary);
    overflow: hidden;
    z-index: 1000;
    margin-top: 0; /* ✅ 大版型間距（可自訂）*/
    min-height: 400px;
    width: 100%; /* ✅ 大版型寬度 100% */
    border-radius: 0; /* ✅ 桌機版大版型：不要圓角 */
    box-shadow: none; /* ✅ 桌機版大版型：不用 box-shadow */
    filter: drop-shadow(2px 4px 8px rgba(0, 0, 0, 0.10)); /* ✅ 大版型外框陰影（可自訂）*/
}

.rs-megamenu-item.large.active {
    display: flex; /* ✅ Flexbox */
}

/* 左側分類 */
.rs-megamenu-left {
    display: flex; /* ✅ Flexbox */
    flex-direction: column;
    width: 200px;
    background: var(--rs-megamenu-bg-sidebar);
    padding: 24px;
    gap: 17px; /* ✅ 分類之間的距離 17px */
    flex-shrink: 0;
}

.category-tab {
    font-family: "Noto Sans CJK TC", var(--rs-megamenu-font-family);
    font-size: 16px;
    font-weight: 400;
    line-height: 160%; /* 25.6px */
    letter-spacing: 1.6px;
    color: rgba(255, 255, 255, 0.70);
    font-feature-settings: 'case' on;
    padding: 12px;
    cursor: pointer;
    border-radius: var(--rs-megamenu-radius);
    transition: var(--rs-megamenu-transition);
    text-align: right; /* ✅ 桌面版預設靠右對齊 */
}

.category-tab:hover,
.category-tab.active {
    /* ✅ 移除背景色 */
    background: none;
    color: #FFF;
    font-family: "Noto Sans TC", var(--rs-megamenu-font-family);
    font-size: 18px;
    font-weight: 500;
    line-height: 160%; /* 28.8px */
    letter-spacing: 1.8px;
    font-feature-settings: 'case' on;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

/* 手機版分類按鈕區（桌面版隱藏）*/
.category-buttons-mobile {
    display: none; /* ✅ 桌面版隱藏 */
}

/* 右側按鈕區 */
.rs-megamenu-right {
    display: flex; /* ✅ Flexbox */
    flex-wrap: wrap;
    gap: 41px; /* ✅ 按鈕之間的距離 41px */
    padding: 24px;
    flex: 1;
    align-content: flex-start;
}

.rs-megamenu-right.loading {
    position: relative;
    min-height: 200px;
}

.rs-megamenu-right.loading::before {
    content: '載入中...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--rs-megamenu-font-family);
    font-size: 16px;
    color: #666;
}

/* ========================================
   Megamenu 區塊：小版型（桌面版）
   ======================================== */
.rs-megamenu-item.small {
    display: none;
    position: absolute;
    top: 100%;
    background: var(--rs-megamenu-bg-primary);
    border-radius: var(--rs-megamenu-radius);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    z-index: 1000;
    margin-top: 0; /* ✅ 小版型間距（可自訂）*/
    padding: 24px; /* ✅ 小版型內距（可自訂）*/
    width: 267px; /* ✅ 桌機版：固定寬度 267px */
    left: auto; /* ✅ 由 JavaScript 動態設定 */
    right: auto; /* ✅ 不使用 right */
}

.rs-megamenu-item.small.active {
    display: flex; /* ✅ Flexbox */
}

.rs-megamenu-buttons {
    display: flex; /* ✅ Flexbox */
    flex-direction: column;
    gap: var(--rs-megamenu-gap);
    width: 100%;
}

/* 小版型內的按鈕：使用 100% 寬度適應容器 */
.rs-megamenu-item.small .button-card {
    width: 100%; /* ✅ 適應容器寬度（267px - 48px padding = 219px）*/
}

/* ========================================
   按鈕卡片（通用）
   桌機版：260×68px，圖片 hover 放大 1.2 倍
   ======================================== */
.button-card {
    display: inline-flex;
    flex-direction: row; /* 水平排列：左文字、右圖片 */
    width: 260px; /* ✅ 修正：260px */
    height: 68px; /* ✅ 固定高度 */
    padding: 0 16px; /* ✅ 左右內距 16px */
    background: var(--rs-megamenu-bg-primary);
    overflow: hidden;
    border-radius: var(--rs-megamenu-radius);
    outline: 1px var(--rs-megamenu-bg-button) solid;
    outline-offset: -1px;
    justify-content: flex-start;
    align-items: center; /* ✅ 文字垂直置中 */
    text-decoration: none !important;
    color: var(--COLOR-05, #683925);
    transition: background 0.2s ease, color 0.2s ease;
}

/* ✅ Hover 樣式：背景換色 + 文字換色 + 圖片放大 */
.button-card:hover {
    background: var(--rs-megamenu-bg-button); /* #E3C6B4 */
    color: #ffffff; /* 白色文字 */
    text-decoration: none !important;
}

.button-card:hover img {
    transform: scale(1.2); /* ✅ 圖片放大 1.2 倍 */
}

.button-card .title {
    font-family: var(--rs-megamenu-font-family);
    font-size: 14px;
    font-weight: 400;
    line-height: 22.4px;
    letter-spacing: 1.4px;
    color: inherit;
    word-wrap: break-word;
    text-decoration: none !important;
    flex: 1; /* 占據剩餘空間 */
}

/* 圖片包裝器 */
.button-card .image-wrapper {
    width: 132px; /* ✅ 圖片區域：132×68px */
    height: 68px;
    position: relative;
    flex-shrink: 0;
    overflow: hidden; /* ✅ 隱藏放大後溢出的部分 */
}

.button-card img {
    width: 132px; /* ✅ 圖片原始尺寸：132×68px */
    height: 68px;
    position: absolute;
    left: 0;
    bottom: 0; /* ✅ 改為置底對齊 */
    object-fit: cover;
    transition: transform 0.3s ease; /* ✅ 平滑放大動畫 */
}

/* ========================================
   RWD: 手機版/平板版 (< 1024px)
   ======================================== */
@media (max-width: 1023px) {
    /* Astra 主題導覽列調整 */
    .ast-article-single nav {
        padding-left: 0;
        padding-right: 0;
    }

    /* 導覽列調整 - 手機版預設 sticky */
    .rs-megamenu-nav {
        padding: 0; /* ✅ 移除 padding */
    }

    /* ✅ 手機版選單展開時：切換為 fixed 並啟用捲動 */
    .rs-megamenu-nav.menu-open {
        position: fixed; /* ✅ 展開時使用 fixed 定位 */
        top: 0;
        left: 0;
        right: 0;
        max-height: 100vh; /* ✅ 最大高度為視窗高度 */
        max-height: 100dvh; /* ✅ 使用動態視窗高度（較新瀏覽器支援）*/
        overflow-y: auto; /* ✅ 垂直方向可捲動 */
        overflow-x: hidden; /* ✅ 水平方向隱藏溢出 */
        -webkit-overflow-scrolling: touch; /* ✅ iOS 平滑捲動 */
    }

    /* Elementor 環境：完全移除 padding */
    .elementor-location-header .rs-megamenu-nav {
        padding: 0;
    }

    /* 容器調整 */
    .rs-megamenu-container {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
        padding: 6px 0 0 0; /* ✅ 統一間距：上 6px，其他 0 */
    }

    /* Elementor 容器：統一間距 */
    .elementor-location-header .rs-megamenu-container {
        padding-top: 6px;
        padding-bottom: 0;
    }

    /* Logo 調整 */
    .rs-megamenu-logo {
        display: block; /* ✅ 確保 LOGO 顯示 */
        margin-right: 0;
        margin-bottom: 16px;
        padding-left: 16px; /* ✅ Logo 統一左邊距 16px */
        padding-right: 16px;
    }

    /* Logo 圖片 */
    .rs-megamenu-logo img {
        height: 40px; /* ✅ 手機版統一 40px（原 43px 太大）*/
        width: auto;
        padding-top: 6px; /* ✅ 增加上方間距 */
        padding-left: 0;
        display: block; /* ✅ 確保圖片顯示 */
    }

    /* 顯示漢堡選單 */
    .rs-megamenu-hamburger {
        display: flex;
        width: 24px; /* ✅ 手機版改為 24px（原 30px 太大）*/
        height: 24px;
        position: absolute;
        top: 20px;
        right: 16px; /* ✅ 統一右邊距 16px */
        background: none;
        border: none;
        box-shadow: none;
    }

    /* 漢堡選單 - 移除所有交互效果 */
    .rs-megamenu-hamburger:hover,
    .rs-megamenu-hamburger:focus,
    .rs-megamenu-hamburger:active {
        background: none;
        box-shadow: none;
        outline: none;
    }

    /* 選單預設隱藏 */
    .rs-megamenu-menu {
        display: none;
        flex-direction: column;
        width: 100%;
        margin-top: 16px;
        gap: 8px;
        padding: 0; /* ✅ 移除 padding */
    }

    .rs-megamenu-menu.open {
        display: flex;
    }

    /* 選單項目調整 */
    .rs-menu-item {
        width: 100%;
        padding: 12px 0 12px 3px; /* ✅ 上下 12px，左側 3px 微調 */
        position: relative;
    }

    /* ========================================
       手機版母選單 active 樣式（分離版）
       ======================================== */

    /* 大版型選單項目展開時的樣式 */
    .rs-menu-item[data-type="large"].active {
        background: #F9F5EF; /* ✅ 大版型背景色（可自訂）*/
    }

    /* 小版型選單項目展開時的樣式 */
    .rs-menu-item[data-type="small"].active {
        background: #F9F5EF; /* ✅ 小版型背景色（可自訂）*/
    }

    /* 選單項目內的文字 - 左右內縮 16px */
    .rs-menu-text,
    .rs-menu-link {
        display: block;
        padding-left: 16px;
        padding-right: 16px;
    }

    /* 有子選單的項目：文字右側留空間給箭頭 */
    .rs-menu-item[data-type="large"] .rs-menu-text,
    .rs-menu-item[data-type="small"] .rs-menu-text {
        padding-right: 40px; /* ✅ 16px + 24px(箭頭) */
    }

    /* 有子選單的項目：展開箭頭（向下）- 只在未展開時顯示 */
    .rs-menu-item[data-type="large"]:not(.active)::after,
    .rs-menu-item[data-type="small"]:not(.active)::after {
        content: '';
        position: absolute;
        right: 16px;
        top: 50%;
        transform: translateY(-50%);
        width: 12px;
        height: 8px;
        background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMiIgaGVpZ2h0PSI4IiB2aWV3Qm94PSIwIDAgMTIgOCIgZmlsbD0ibm9uZSI+CiAgPHBhdGggZD0iTTYgNC42TDEwLjYgLTYuMTE5NTllLTA4TDEyIDEuNEw2IDcuNEwtNi4xMTk1OWUtMDggMS40TDEuNCAtNC42MzM0MWUtMDdMNiA0LjZaIiBmaWxsPSIjQTU3ODY1Ii8+Cjwvc3ZnPg==');
        background-repeat: no-repeat;
        background-position: center;
        background-size: contain;
    }

    /* 手機版隱藏項目 */
    .rs-hidden-mobile {
        display: none !important;
    }

    /* ========================================
       Megamenu 區塊調整（手機版：static 定位）
       ======================================== */

    /* ========================================
       大版型 (Large) 手機版樣式（獨立調整區）
       ======================================== */

    .rs-megamenu-item.large {
        position: static !important; /* ✅ 強制覆蓋桌面版的 absolute */
        box-shadow: none !important; /* ✅ 移除桌面版陰影 */
        filter: none !important; /* ✅ 移除桌面版 drop-shadow */
        margin-top: 0;
        border-radius: 0;
        left: auto;
        right: auto;
        width: 100%;
        padding: 0; /* ✅ 移除 padding，由內部元素控制 */
        background-color: #f9f5ef; /* ✅ 大版型背景色（可自訂）*/
        flex-direction: column;
        min-height: auto;
    }

    /* 大版型展開時顯示 */
    .rs-megamenu-item.large.active {
        display: flex;
    }

    /* 大版型：左側分類區 */
    .rs-megamenu-item.large .rs-megamenu-left {
        width: 100%;
        padding: 16px; /* ✅ 大版型左側區 padding（可自訂）*/
    }

    /* 大版型：右側按鈕區（桌面版顯示，手機版隱藏）*/
    .rs-megamenu-item.large .rs-megamenu-right {
        width: 100%;
        min-width: auto;
        padding: 16px;
        display: none !important; /* ✅ 手機版隱藏桌面版的右側按鈕區 */
    }

    /* ========================================
       小版型 (Small) 手機版樣式（獨立調整區）
       ======================================== */

    .rs-megamenu-item.small {
        position: static !important; /* ✅ 強制覆蓋桌面版的 absolute */
        box-shadow: none !important; /* ✅ 移除桌面版陰影 */
        filter: none !important; /* ✅ 移除桌面版 drop-shadow（如果有）*/
        margin-top: 0;
        border-radius: 0;
        left: auto;
        right: auto;
        background-color: #f9f5ef; /* ✅ 小版型背景色（可自訂）*/
        width: 100%;
        padding: 0; /* ✅ 小版型外層 padding（可自訂）*/
    }

    /* 小版型展開時顯示 */
    .rs-megamenu-item.small.active {
        display: flex;
    }

    /* 小版型：按鈕容器 */
    .rs-megamenu-item.small .rs-megamenu-buttons {
        padding: 16px 0; /* ✅ 小版型按鈕容器 padding（可自訂）*/
        display: flex;
        flex-direction: column;
        gap: 16px; /* ✅ 小版型按鈕之間距離（可自訂）*/
    }

    /* ========================================
       按鈕卡片（手機版通用樣式）
       ======================================== */

    .button-card {
        width: 100%; /* ✅ 手機版：100% 寬度 */
        height: auto; /* ✅ 手機版：自動高度 */
        padding: 0; /* ✅ 移除 padding，讓按鈕邊框對齊分類文字和箭頭 */
    }

    /* 大版型按鈕卡片樣式（可在此自訂大版型的按鈕）*/
    .rs-megamenu-item.large .button-card {
        /* 繼承上方通用樣式，可在此覆寫 */
    }

    /* 小版型按鈕卡片樣式（可在此自訂小版型的按鈕）*/
    .rs-megamenu-item.small .button-card {
        /* 繼承上方通用樣式，可在此覆寫 */
    }

    /* 按鈕圖片區域 */
    .button-card .image-wrapper {
        width: 158px; /* ✅ 手機版圖片區域：158×82px */
        height: 82px;
    }

    .button-card img {
        width: 158px; /* ✅ 手機版圖片：158×82px */
        height: 82px;
        left: 0;
        bottom: 0; /* ✅ 置底對齊 */
    }

    /* 按鈕標題 */
    .button-card .title {
        font-size: 13px; /* 手機版字體稍微縮小 */
        line-height: 20px;
        letter-spacing: 1.2px;
        padding-left: 16px; /* ✅ 文字左邊距，與分類文字對齊 */
    }

    /* ========================================
       Accordion 展開樣式（分離版，避免聯動）
       ======================================== */

    /* 大版型選單展開時，只顯示大版型 Megamenu */
    .rs-menu-item[data-type="large"].active .rs-megamenu-item.large {
        display: flex;
    }

    /* 小版型選單展開時，只顯示小版型 Megamenu */
    .rs-menu-item[data-type="small"].active .rs-megamenu-item.small {
        display: flex;
    }

    .category-tab {
        width: 100%;
        position: relative;
        padding: 12px 16px; /* ✅ 與第一層對齊：上下 12px，左右 16px */
    }

    /* ✅ 手機版：覆蓋桌面版的 hover 和 active 樣式，字體不放大 */
    .category-tab:hover,
    .category-tab.active {
        font-size: 16px; /* ✅ 保持原大小，不放大 */
        font-weight: 400; /* ✅ 保持原字重 */
        text-shadow: none; /* ✅ 移除陰影 */
        background: #A57865; /* ✅ 子選單 active 底色 */
        color: #FEFDF9; /* ✅ 子選單 active 文字顏色 */
        text-align: left; /* ✅ 手機版靠左對齊，覆蓋桌面版靠右 */
    }

    /* 第一個分類 tab（代表第一層）：為箭頭留空間 */
    .category-tab:first-child.active {
        padding-right: 44px; /* ✅ 16px + 28px(箭頭+間距) */
    }

    /* 第一個分類 tab（代表第一層）：收合箭頭 - 深色背景用淺色箭頭 */
    .category-tab:first-child.active::after {
        content: '';
        position: absolute;
        right: 16px; /* ✅ 與第一層箭頭對齊 */
        top: 12px; /* ✅ 置頂對齊，與 padding-top 相同 */
        width: 24px;
        height: 24px;
        background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIj4KICA8cGF0aCBkPSJNMTIgMTEuNEw3LjQgMTZMNiAxNC42TDEyIDguNkwxOCAxNC42TDE2LjYgMTZMMTIgMTEuNFoiIGZpbGw9IiNGRUZERjkiLz4KPC9zdmc+');
        background-repeat: no-repeat;
        background-position: center;
        background-size: contain;
    }

    /* 第二層（非第一個分類 tab）有子選單時：為箭頭留空間 */
    .category-tab:not(:first-child).active.has-submenu {
        padding-right: 44px; /* ✅ 為箭頭留空間 */
    }

    /* 第二層（非第一個分類 tab）有子選單時：收合箭頭 */
    .category-tab:not(:first-child).active.has-submenu::after {
        content: '';
        position: absolute;
        right: 16px;
        top: 12px; /* ✅ 置頂對齊，與 padding-top 相同 */
        width: 24px;
        height: 24px;
        background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIj4KICA8cGF0aCBkPSJNMTIgMTEuNEw3LjQgMTZMNiAxNC42TDEyIDguNkwxOCAxNC42TDE2LjYgMTZMMTIgMTEuNFoiIGZpbGw9IiNGRUZERjkiLz4KPC9zdmc+');
        background-repeat: no-repeat;
        background-position: center;
        background-size: contain;
    }

    /* ========================================
       大版型：分類按鈕區（手機版）
       ======================================== */

    /* 分類按鈕區預設隱藏 */
    .category-buttons-mobile {
        display: none;
        padding: 16px 0; /* ✅ 只保留上下 padding，左右對齊分類和箭頭 */
        flex-direction: column;
        gap: 16px; /* ✅ 按鈕之間距離 16px */
    }

    /* ✅ 手機版：分類 active 時顯示按鈕區 */
    .category-tab.active .category-buttons-mobile {
        display: flex;
    }

    /* 小版型：選單項目為箭頭留空間 */
    .rs-menu-item.rs-menu-type-small.active {
        padding-right: 40px; /* ✅ 為箭頭留空間 */
    }

    /* 小版型：選單項目收合箭頭（向上）*/
    .rs-menu-item.rs-menu-type-small.active::after {
        content: '';
        position: absolute;
        right: 16px; /* ✅ 距離右邊 16px，與第一層選單對齊 */
        top: 12px; /* ✅ 置頂對齊，與 padding-top 相同 */
        width: 24px;
        height: 24px;
        background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIj4KICA8cGF0aCBkPSJNMTIgMTEuNEw3LjQgMTZMNiAxNC42TDEyIDguNkwxOCAxNC42TDE2LjYgMTZMMTIgMTEuNFoiIGZpbGw9IiNGRUZERjkiLz4KPC9zdmc+');
        background-repeat: no-repeat;
        background-position: center;
        background-size: contain;
    }
}

/* ========================================
   桌面版 (>= 1024px)
   ======================================== */
@media (min-width: 1024px) {
    .rs-megamenu-left {
        padding: 24px 40px 24px 0; /* ✅ 桌面版：右側 40px 分隔空間 */
    }
}

/* ========================================
   中等桌面 (<= 1439px)
   ======================================== */
@media (max-width: 1439px) {
    .rs-megamenu-logo img {
        height: 40px; /* ✅ 中等桌面維持 40px */
    }
}

/* ========================================
   小桌面 (<= 991px)
   ======================================== */
@media (max-width: 991px) {
    .rs-megamenu-logo img {
        height: 38px; /* ✅ 小桌面略縮至 38px */
    }
}

/* ========================================
   大手機 (<= 575px)
   ======================================== */
@media (max-width: 575px) {
    .rs-megamenu-logo img {
        height: 36px; /* ✅ 大手機縮至 36px */
        padding-top: 4px; /* ✅ 調整垂直位置 */
    }
}

/* ========================================
   小手機 (<= 479px)
   ======================================== */
@media (max-width: 479px) {
    .rs-megamenu-logo img {
        height: 34px; /* ✅ 小手機縮至 34px */
        padding-top: 3px; /* ✅ 調整垂直位置 */
    }
}

/* ========================================
   平板版 (768px - 1024px)
   已移除：1024px 以下統一使用漢堡選單模式
   ======================================== */

/* ========================================
   大螢幕 (> 1440px)
   ======================================== */
@media (min-width: 1441px) {
    .rs-megamenu-container {
        max-width: 1600px;
    }

    .button-card {
        width: 260px; /* ✅ 大螢幕也維持 260px */
    }
}

/* ========================================
   列印樣式
   ======================================== */
@media print {
    .rs-megamenu-nav {
        display: none;
    }
}

/* ========================================
   無障礙輔助
   ======================================== */
.rs-menu-item:focus,
.button-card:focus,
.category-tab:focus {
    outline: 2px solid #4A90E2;
    outline-offset: 2px;
}

/* 高對比模式 */
@media (prefers-contrast: high) {
    .rs-megamenu-nav {
        border: 2px solid #000;
    }

    .button-card {
        border: 1px solid #000;
    }
}

/* 減少動畫模式 */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}
