/* ============================================
   手機版手風琴導覽選單（所有頁面共用）
   ============================================ */

/* lg 以上隱藏手風琴，顯示桌機版 */
@media (min-width: 992px) {
    .mobile-accordion-menu { display: none !important; }
}

/* lg 以下：手風琴選單樣式 */
@media (max-width: 991px) {
    /* 讓展開的 navbar 可以捲動，避免子選單被遮住 */
    #navbarContent {
        max-height: calc(100vh - 130px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* 隱藏桌機版原生 dropdown，改用手風琴 */
    .mobile-accordion-menu { display: block; }
    .desktop-dropdown-menu { display: none !important; }

    .mob-acc-item { border-bottom: 1px solid #f0f0f0; }

    .mob-acc-btn {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        background: none;
        border: none;
        padding: 12px 16px;
        font-size: 1rem;
        font-weight: 600;
        color: #444;
        text-align: left;
        cursor: pointer;
        text-decoration: none;
    }
    .mob-acc-btn:hover { color: #C0392B; background: #fafafa; }

    .mob-acc-btn .mob-acc-arrow {
        font-size: 0.75rem;
        color: #aaa;
        transition: transform 0.25s ease;
        flex-shrink: 0;
        margin-left: 8px;
    }
    .mob-acc-btn[aria-expanded="true"] .mob-acc-arrow {
        transform: rotate(180deg);
        color: #C0392B;
    }
    .mob-acc-btn[aria-expanded="true"] { color: #C0392B; }

    .mob-acc-body { background: #f8f9fa; }

    .mob-acc-group-label {
        font-size: 0.75rem;
        font-weight: 700;
        color: #0F2C47;
        padding: 8px 20px 4px;
        letter-spacing: 1px;
        text-transform: uppercase;
        background: #eef4ff;
        display: block;
    }

    .mob-acc-link {
        display: flex;
        align-items: center;
        padding: 10px 20px;
        font-size: 0.93rem;
        color: #555;
        text-decoration: none;
        border-left: 3px solid transparent;
        transition: 0.2s;
    }
    .mob-acc-link:hover {
        color: #C0392B;
        border-left-color: #C0392B;
        background: #fff;
    }

    .mob-acc-divider { height: 1px; background: #e8e8e8; margin: 4px 16px; }

    /* 手機版：讓展開內容區塊也能捲動
       避免看起來像「只顯示前面 3~4 個連結」但其實是被視窗高度限制。 */
    #mobPort,
    #mobProd {
        max-height: 68vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* 避免捲動時出現橫向抖動 */
    #mobPort { overscroll-behavior: contain; }
    #mobProd { overscroll-behavior: contain; }

    /* 實績案例：依品牌瀏覽改為折疊式，避免選單過長點不到 */
    .mob-acc-nested { margin: 0; }
    .mob-acc-nested-btn {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        background: #eef4ff;
        border: none;
        padding: 8px 20px 8px;
        font-size: 0.75rem;
        font-weight: 700;
        color: #0F2C47;
        text-align: left;
        cursor: pointer;
        letter-spacing: 1px;
        text-transform: uppercase;
    }
    .mob-acc-nested-btn:hover { background: #e0ebff; color: #C0392B; }
    .mob-acc-nested-btn .mob-acc-group-label { padding: 0; background: none; display: inline; }
    .mob-acc-nested-arrow {
        font-size: 0.65rem;
        color: #888;
        transition: transform 0.25s ease;
        flex-shrink: 0;
        margin-left: 8px;
    }
    .mob-acc-nested-btn[aria-expanded="true"] .mob-acc-nested-arrow {
        transform: rotate(180deg);
        color: #C0392B;
    }
    .mob-acc-nested-body { padding: 0 0 8px; background: #f0f4fa; }

    /* 一般 nav-link 在手機版 */
    .mob-plain-link {
        display: block;
        padding: 12px 16px;
        font-size: 1rem;
        font-weight: 600;
        color: #444;
        text-decoration: none;
        border-bottom: 1px solid #f0f0f0;
    }
    .mob-plain-link:hover { color: #C0392B; background: #fafafa; }
    .mob-plain-link.active { color: #C0392B; }

    /* 手機版 CTA 按鈕 */
    .mob-cta-wrap { padding: 14px 16px; }
}

/* ============================================
   手機版底部固定導覽列（所有頁面共用）
   ============================================ */
.mobile-bottom-nav { display: none; }

@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 65px;
        background: #fff;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
        z-index: 9999;
        justify-content: space-around;
        align-items: center;
        padding-bottom: 5px;
    }
    .mobile-nav-item {
        flex: 1;
        text-align: center;
        text-decoration: none;
        color: #555;
        font-size: 0.75rem;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        height: 100%;
    }
    .mobile-nav-item i { font-size: 1.4rem; margin-bottom: 2px; }
    .mobile-nav-item.call { color: #C0392B; }
    .mobile-nav-item.line { color: #06c755; }
    .mobile-nav-item.fb { color: #1877F2; }
}

/* ============================================
   無障礙：跳到主要內容連結（鍵盤 Tab 聚焦時顯示）
   ============================================ */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 10000;
    padding: 12px 20px;
    background: var(--primary-color, #0F2C47);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    border-radius: 0 0 8px 0;
    transition: left 0.2s;
}
.skip-link:focus {
    left: 0;
    outline: 2px solid #ffc107;
    outline-offset: 2px;
}

/* ============================================
   浮動聯絡按鈕（桌機版顯示，手機版由 mobile-bottom-nav 取代）
   ============================================ */
@media (min-width: 769px) {
    .floating-contact {
        position: fixed;
        bottom: 30px;
        right: 30px;
        z-index: 9999;
        display: flex;
        flex-direction: column-reverse;
        gap: 15px;
        align-items: flex-end;
    }
    .float-btn {
        width: 50px;
        height: 50px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        color: white !important;
        font-size: 20px;
        box-shadow: 0 4px 15px rgba(0,0,0,0.3);
        text-decoration: none;
        transition: 0.3s;
    }
    .float-btn:hover { transform: scale(1.1); color: white !important; }
    .float-btn.btn-line { background: #06c755; }
    .float-btn.btn-phone { background: var(--accent-color, #C0392B); }
    .float-btn.btn-fb { background: #1877f2; }
    .float-btn.btn-ig { background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888); }
}

/* ============================================
   手機版修復：恢復左側圖示、統一頂部尺寸
   ============================================ */

@media (max-width: 768px) {
    /* 1. 手機版 top-bar：左右均分排版，強制各佔 50% */
    .top-bar {
        display: block !important;
        padding: 12px 0;
        font-size: 0.8rem;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .top-bar .container {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 0;
        padding: 0 15px !important;
        max-width: 100% !important;
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    /* 隱藏桌面版左側，讓 grid 只顯示兩欄 */
    .top-bar .d-none.d-md-block {
        display: none !important;
    }
    
    /* 左欄：地址 + 營業時間（各佔 50% 寬度） */
    .top-bar-mobile-left {
        display: flex !important;
        flex-direction: column;
        justify-content: center;
        gap: 6px;
        padding-right: 10px;
        border-right: 1px solid rgba(255,255,255,0.35);
        min-width: 0;
        overflow: hidden;
    }
    
    .top-bar-mobile-left span {
        white-space: nowrap;
        line-height: 1.4;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .top-bar-mobile-left i {
        margin-right: 6px;
        opacity: 0.95;
        width: 14px;
        text-align: center;
    }
    
    /* 右欄：電話 + LINE（各佔 50% 寬度） */
    .top-bar .container > div:last-child {
        display: flex !important;
        flex-direction: column;
        justify-content: center;
        align-items: flex-start;
        gap: 8px;
        padding-left: 12px;
        min-width: 0;
        overflow: hidden;
    }
    
    .top-bar a {
        margin-right: 0;
        font-size: 0.85rem;
        padding: 2px 0;
        white-space: nowrap;
        line-height: 1.4;
    }
}

/* 極窄螢幕（約 400px 以下）改為上下堆疊，避免過度壓縮 */
@media (max-width: 400px) {
    .top-bar .container {
        grid-template-columns: 1fr !important;
    }
    
    .top-bar-mobile-left {
        border-right: none !important;
        border-bottom: 1px solid rgba(255,255,255,0.35);
        padding-right: 0 !important;
        padding-bottom: 10px;
    }
    
    .top-bar .container > div:last-child {
        padding-left: 0 !important;
        padding-top: 8px;
    }
}

@media (max-width: 768px) {
    /* 2. 恢復左側懸浮按鈕（緊貼左緣，不影響瀏覽寬度） */
    .side-sticky-btn-group {
        display: flex !important;
        padding: 8px 4px;
    }
    
    .side-sticky-btn {
        padding: 8px 4px;
        font-size: 0.75rem;
        writing-mode: vertical-rl;
    }
    
    /* 3. 統一頂部導覽列尺寸 */
    .navbar {
        padding: 8px 0 !important;
        min-height: 56px;
    }
    
    .navbar-brand img {
        height: 45px !important;
        width: auto !important;
    }
    
    /* 4. 統一各類頁面標題橫幅區塊高度（page-header/about-header/news-header） */
    .page-header,
    .about-header,
    .news-header {
        padding: 50px 15px 40px !important;
        min-height: 120px !important;
    }
    
    .page-header h1,
    .about-header h1,
    .news-header h1 {
        font-size: 1.5rem !important;
    }
    
    /* floating-contact 手機版仍隱藏（已有 mobile-bottom-nav） */
    .floating-contact {
        display: none !important;
    }

    /* 5. 觸控目標優化：最小 44×44px 符合無障礙建議 */
    .navbar-nav .nav-link,
    .navbar-nav .dropdown-toggle,
    .btn,
    .side-sticky-btn {
        min-height: 44px !important;
        min-width: 44px;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        padding: 10px 16px !important;
    }
    .navbar-toggler {
        min-width: 44px !important;
        min-height: 44px !important;
        padding: 12px !important;
    }
}
