/* Modern 模版專屬樣式
 * 極簡現代風 — 大留白、圓形按鈕、底部 floating tab bar
 */

:root {
    --tpl-modern-radius: 16px;
}

body {
    padding-bottom: 0;
}

/* Announce bar */
.tpl-modern-announce {
    font-size: 12px;
    letter-spacing: .5px;
    padding: 8px 16px;
    text-align: center;
}

/* Header */
.tpl-modern-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--header-bg, #fff);
    border-bottom: 1px solid rgba(0,0,0,.06);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.tpl-modern-header .container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
}
.tpl-modern-bar {
    display: flex;
    align-items: center;
    height: 64px;
    gap: 8px;
}
.tpl-modern-bar .tpl-modern-burger { flex: 0 0 40px; }
.tpl-modern-bar .tpl-modern-logo { flex: 1; }
.tpl-modern-bar .tpl-modern-actions { flex: 0 0 auto; }

/* 漢堡選單位置:right 時放最後 */
.tpl-modern-header[data-burger="right"] .tpl-modern-burger { order: 99; }
.tpl-modern-burger {
    background: transparent;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    color: inherit;
    transition: background .15s;
}
.tpl-modern-burger:hover { background: rgba(0,0,0,.05); }
.tpl-modern-burger span {
    display: block;
    width: 18px;
    height: 1.5px;
    background: currentColor;
    border-radius: 2px;
}
.tpl-modern-logo {
    text-align: center;
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -.3px;
}
.tpl-modern-logo a { color: inherit; text-decoration: none; }
.tpl-modern-logo img { max-height: 32px; width: auto; vertical-align: middle; }

.tpl-modern-actions { display: flex; align-items: center; gap: 4px; }
.tpl-modern-iconbtn {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    position: relative;
    transition: background .15s;
}
.tpl-modern-iconbtn:hover { background: rgba(0,0,0,.06); }
.tpl-modern-iconbtn svg { width: 20px; height: 20px; }
.tpl-modern-iconbtn .count {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--primary, #0d9488);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    text-align: center;
}

/* Search bar (inline) */
.tpl-modern-searchbar {
    padding: 12px 0 16px;
    border-top: 1px solid rgba(0,0,0,.06);
}
.tpl-modern-searchbar input {
    width: 100%;
    padding: 14px 20px;
    border-radius: var(--tpl-modern-radius);
    border: 1px solid rgba(0,0,0,.1);
    background: rgba(0,0,0,.03);
    font-size: 15px;
    color: inherit;
}
.tpl-modern-searchbar input:focus { outline: 2px solid var(--primary, #0d9488); outline-offset: 0; background: #fff; }

/* Drawer override (use existing #mobileDrawer ID; full-screen on mobile, side on desktop) */
.tpl-modern-overlay {
    background: rgba(0,0,0,.5);
    backdrop-filter: blur(6px);
}
.tpl-modern-drawer {
    background: #fff;
    color: #1e293b;
    padding: 0;
}
.tpl-modern-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(0,0,0,.06);
}
.tpl-modern-drawer-head .drawer-brand { font-weight: 700; font-size: 18px; }
.tpl-modern-drawer-head .mobile-close {
    background: rgba(0,0,0,.05);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 999px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: inherit;
}
.tpl-modern-locale {
    display: flex;
    gap: 6px;
    padding: 12px 24px;
    border-bottom: 1px solid rgba(0,0,0,.06);
}
.tpl-modern-locale a {
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 13px;
    text-decoration: none;
    color: #6b7280;
}
.tpl-modern-locale a.is-active { background: #111827; color: #fff; }
.tpl-modern-drawer-nav { padding: 12px 0; display: flex; flex-direction: column; }
.tpl-modern-drawer-link {
    display: block;
    padding: 14px 24px;
    color: #1e293b !important;
    font-size: 16px;
    font-weight: 500;
    text-decoration: none;
    border: none !important;
    transition: background .12s;
}
.tpl-modern-drawer-link:hover { background: rgba(0,0,0,.04); }
.tpl-modern-drawer-divider {
    margin: 12px 24px;
    border-top: 1px solid rgba(0,0,0,.08);
}
.tpl-modern-drawer-footer {
    padding: 16px 24px;
    font-size: 12px;
    color: #94a3b8;
    border-top: 1px solid rgba(0,0,0,.06);
}

/* Mobile bottom tab bar — only show on mobile */
.tpl-modern-mobilebar { display: none; }
@media (max-width: 768px) {
    .tpl-modern-mobilebar {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 99;
        background: rgba(255,255,255,.95);
        backdrop-filter: blur(20px);
        border-top: 1px solid rgba(0,0,0,.08);
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0));
    }
    .tpl-modern-mobilebar a {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        padding: 6px 4px;
        color: #6b7280;
        text-decoration: none;
        font-size: 10px;
        position: relative;
    }
    .tpl-modern-mobilebar a svg { width: 22px; height: 22px; }
    .tpl-modern-mobilebar a:hover, .tpl-modern-mobilebar a.is-active { color: var(--primary, #0d9488); }
    .tpl-modern-mobilebar-cart .dot {
        position: absolute;
        top: 4px;
        right: calc(50% - 18px);
        width: 8px;
        height: 8px;
        border-radius: 999px;
        background: var(--primary, #0d9488);
    }
    body { padding-bottom: 64px; }

    /* 底部導航列高約 64px，右下角的浮動元素全部要讓開。
       --ec-float-base 是全站浮動元素的基準位置（見
       includes/helpers/float-stack.php），聊天浮動掣一併跟隨，
       不會再壓住導航列。 */
    body[data-template="modern"] { --ec-float-base: calc(80px + env(safe-area-inset-bottom, 0)); }

    .tpl-modern-wa { bottom: 80px !important; }
    /* 回到頂部掣要排在 WhatsApp 掣（80px + 56px 高）之上，
       原本兩者同樣是 80px，會完全疊住。 */
    .back-to-top { bottom: 148px !important; }
}

/* Hide default mega-menu styles that don't apply here */
.tpl-modern-header .header-nav,
.tpl-modern-header .header-top,
.tpl-modern-header .mega-menu { display: none !important; }

/* Back-to-top（極簡圓形按鈕）
   桌面版排在 WhatsApp 浮動掣（24px + 56px 高）之上，
   原本兩者同樣是 24px，會完全疊住。 */
.tpl-modern-backtop {
    position: fixed;
    right: 24px;
    bottom: 88px;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    background: rgba(255,255,255,.9);
    color: #1e293b;
    border: 1px solid rgba(0,0,0,.08);
    box-shadow: 0 4px 14px rgba(0,0,0,.12);
    cursor: pointer;
    z-index: 90;
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity .2s, transform .2s, background .15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}
.tpl-modern-backtop.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.tpl-modern-backtop:hover {
    background: var(--primary, #0d9488);
    color: #fff;
    border-color: var(--primary, #0d9488);
}
@media (max-width: 768px) {
    .tpl-modern-backtop { bottom: 80px; right: 16px; }
}

/* ── 內頁 (list / category / brand / search / flash-sales) 樣式微調 ──
 * 透過 body[data-template="modern"] 加高特異性,蓋過 view 內嵌嘅 inline <style>
 */
body[data-template="modern"] .product-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}
body[data-template="modern"] .product-card {
    border: 1px solid #f1f5f9 !important;
    border-radius: 18px !important;
    box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
body[data-template="modern"] .product-card:hover {
    border-color: transparent !important;
    box-shadow: 0 16px 40px rgba(0,0,0,.08) !important;
    transform: translateY(-4px);
}
body[data-template="modern"] .section-header h2 {
    font-size: 28px !important;
    font-weight: 800 !important;
    letter-spacing: -.5px !important;
    padding-left: 0 !important;
}
body[data-template="modern"] .section-header h2::before { display: none !important; }
body[data-template="modern"] .breadcrumb { font-size: 13px; opacity: .8; }
body[data-template="modern"] .cat-sidebar,
body[data-template="modern"] .brands-grid,
body[data-template="modern"] .empty-hint {
    border-radius: 18px !important;
}

@media (max-width: 900px) {
    body[data-template="modern"] .product-grid { grid-template-columns: repeat(2, 1fr); }
}
