/* LUMIÈRE Shop Filters — v1.9
   Layouts (body classes):
   - .lsf-layout-pc-modal / .lsf-layout-pc-sidebar
   - .lsf-layout-mobile-modal / .lsf-layout-mobile-drawer
   Breakpoint: 921px (max = mobile)
*/

.lsf-wrapper { position: relative; }

/* Toggle button — 全端显示，位于 woocommerce-result-count 位置。
   默认无背景无边框（纯文字），hover/focus/打开时才有背景色。 */
.lsf-toggle-btn {
    display: inline-flex; align-items: center; gap: 0.5em; cursor: pointer;
    width: auto;
    max-width: 100%;
    padding: 0.55em 1.2em; border: none; background: transparent; color: var(--ast-global-color-0, #111);
    font-size: 0.78rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em;
    border-radius: 0; transition: all 0.3s ease;
}
.lsf-toggle-btn:hover,
.lsf-toggle-btn:focus-visible { background: var(--lumiere-rose, #c9a087); color: #fff; }
.lsf-toggle-btn.lsf-btn-open { background: var(--lumiere-rose, #c9a087); color: #fff; }
.lsf-toggle-btn svg { flex-shrink: 0; }

.lsf-price-group { min-width: 0; }

/* ── Shared panel chrome ─────────────────────────────────────── */

.lsf-drawer-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1em 1.3em; border-bottom: 1px solid #e9e4dd;
    position: sticky; top: 0; background: #fff; z-index: 1;
}
.lsf-drawer-head strong { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: #111; }
.lsf-drawer-close {
    background: none !important; border: none !important;
    font-size: 1.5rem !important; line-height: 1 !important;
    font-weight: 400 !important; text-transform: none !important;
    letter-spacing: 0 !important;
    cursor: pointer; color: #111;
    padding: 0.2em 0.4em !important; min-width: auto !important;
    width: auto !important; height: auto !important;
    border-radius: 0 !important; box-shadow: none !important;
    text-decoration: none !important;
}
.lsf-drawer-close:hover { color: var(--lumiere-rose, #c9a087); }

.lsf-drawer-footer {
    display: flex; gap: 0.6em; align-items: center; justify-content: stretch;
    padding: 1em 1.4em; border-top: 1px solid #e9e4dd;
    position: sticky; bottom: 0; background: #fff; z-index: 1;
}
.lsf-apply-btn, .lsf-close-btn {
    flex: 1; padding: 0.7em 1em;
    font-size: 0.78rem !important; font-weight: 500 !important;
    text-transform: uppercase !important; letter-spacing: 0.08em !important;
    cursor: pointer; border-radius: 0 !important; transition: all 0.3s ease;
    width: auto !important; min-width: auto !important;
}
.lsf-apply-btn {
    background: var(--ast-global-color-0, #111) !important; color: #fff !important;
    border: 1px solid var(--ast-global-color-0, #111) !important;
}
.lsf-apply-btn:hover { background: var(--lumiere-rose, #c9a087) !important; border-color: var(--lumiere-rose, #c9a087) !important; }
.lsf-close-btn {
    background: transparent !important; color: #111 !important;
    border: 1px solid #e9e4dd !important;
}
.lsf-close-btn:hover { border-color: #111 !important; }

.lsf-group { margin: 0; min-width: 0; }
.lsf-group-title {
    font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
    color: #111; margin: 0 0 0.6em;
}
.lsf-group-list { list-style: none; margin: 0; padding: 0; }
.lsf-group-list li { margin-bottom: 0.4em; white-space: nowrap; }
.lsf-group-list li:last-child { margin-bottom: 0; }
.lsf-group-list li a {
    display: inline-flex; align-items: center; gap: 0.5em;
    font-size: 0.85rem; color: #4a4a4a; text-decoration: none; transition: color 0.15s;
}
.lsf-group-list li a::before {
    content: '';
    width: 14px; height: 14px; flex-shrink: 0;
    border: 1px solid #999;
    background: #fff;
    border-radius: 2px;
    transition: all 0.15s ease;
    display: inline-block;
}
.lsf-group-list li a:hover::before { border-color: var(--lumiere-rose, #c9a087); }
.lsf-group-list li.active a::before {
    content: '✓';
    font-size: 0.7rem; line-height: 1; text-align: center;
    color: #fff; background: var(--lumiere-rose, #c9a087);
    border-color: var(--lumiere-rose, #c9a087);
    display: inline-flex; align-items: center; justify-content: center;
}
.lsf-group-list li a:hover,
.lsf-group-list li.active a { color: #111; font-weight: 500; }

/* Tab nav：仅移动端 Drawer 显示；Modal / Sidebar 隐藏 */
.lsf-drawer-nav { display: none; }
.lsf-drawer-panels { display: contents; } /* Modal/Sidebar：面板直接参与父级 grid/flex */

.lsf-overlay {
    display: none; position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,0.35);
}
.lsf-overlay.visible { display: block; }

/* Layout shell — default block (modal modes); sidebar activates flex on PC */
.lsf-shop-layout { display: block; }
.lsf-shop-main { min-width: 0; }

/* ════════════════════════════════════════════════════════════════
   PC (≥922px) — Modal (default)
   ════════════════════════════════════════════════════════════════ */
@media (min-width: 922px) {
    .lsf-drawer {
        display: none; position: fixed; z-index: 1002;
        top: 50%; left: 50%; transform: translate(-50%, -50%);
        width: min(760px, calc(100vw - 2rem));
        max-height: 80vh; overflow-y: auto;
        background: #fff;
        border: 1px solid #e9e4dd;
        box-shadow: 0 12px 40px rgba(0,0,0,0.2);
        padding: 0;
        color: #111;
    }
    .lsf-drawer.open { display: block; }
    .lsf-drawer-body {
        padding: 1.4em 1.6em;
        display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.6em 2em;
        color: #4a4a4a;
    }

    /* PC Sidebar — left column always visible */
    body.lsf-layout-pc-sidebar .lsf-shop-layout {
        display: flex;
        align-items: flex-start;
        gap: 2rem;
    }
    body.lsf-layout-pc-sidebar .lsf-wrapper {
        flex: 0 0 260px;
        width: 260px;
        position: sticky;
        top: 1.25rem;
        z-index: 1;
    }
    body.lsf-layout-pc-sidebar .lsf-shop-main {
        flex: 1 1 auto;
        min-width: 0;
    }
    body.lsf-layout-pc-sidebar .lsf-drawer {
        display: block !important;
        position: static;
        transform: none;
        width: 100%;
        max-height: none;
        overflow: visible;
        border: none;
        box-shadow: none;
    }
    body.lsf-layout-pc-sidebar .lsf-drawer-head {
        position: static;
        padding: 0.9em 1em;
        border-bottom: none;
    }
    body.lsf-layout-pc-sidebar .lsf-drawer-close {
        display: none !important;
    }
    body.lsf-layout-pc-sidebar .lsf-drawer-body {
        display: flex;
        flex-direction: column;
        gap: 1.25em;
        padding: 1em;
        max-height: none;
    }
    body.lsf-layout-pc-sidebar .lsf-drawer-footer {
        position: static;
        flex-direction: column;
        padding: 0.9em 1em 1.1em;
        border-top: none;
    }
    body.lsf-layout-pc-sidebar .lsf-close-btn {
        display: none !important;
    }
    body.lsf-layout-pc-sidebar .lsf-overlay {
        display: none !important;
    }
    /* Filter 按钮在 PC 侧栏模式下隐藏（侧栏已常驻）；主题 CSS 也会补一层 */
    body.lsf-layout-pc-sidebar .lsf-toggle-btn {
        display: none !important;
    }
    body.lsf-layout-pc-sidebar .lsf-group-list li {
        white-space: normal;
    }

    /* PC Sidebar — 手风琴：默认全部闭合 */
    body.lsf-layout-pc-sidebar .lsf-drawer-body {
        gap: 0;
        padding: 0.4em 0.75em 0.75em;
    }
    body.lsf-layout-pc-sidebar .lsf-group {
        border-bottom: 1px solid #e9e4dd;
        padding: 0;
        margin: 0;
    }
    body.lsf-layout-pc-sidebar .lsf-group:last-child {
        border-bottom: none;
    }
    body.lsf-layout-pc-sidebar .lsf-group-title {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5em;
        margin: 0;
        padding: 0.85em 0.35em;
        cursor: pointer;
        user-select: none;
        font-size: 0.72rem;
    }
    body.lsf-layout-pc-sidebar .lsf-group-title::after {
        content: '+';
        flex-shrink: 0;
        font-size: 1rem;
        font-weight: 400;
        line-height: 1;
        color: #111;
        border: none;
        transform: none;
        margin: 0;
        width: auto;
        height: auto;
    }
    body.lsf-layout-pc-sidebar .lsf-group.is-open .lsf-group-title::after {
        content: '−';
        transform: none;
        margin: 0;
    }
    body.lsf-layout-pc-sidebar .lsf-group .lsf-group-list {
        display: none;
        padding: 0 0.35em 0.85em;
    }
    body.lsf-layout-pc-sidebar .lsf-group.is-open .lsf-group-list {
        display: block;
    }
}

/* ════════════════════════════════════════════════════════════════
   Mobile (≤921px) — Modal (default) + Drawer option
   ════════════════════════════════════════════════════════════════ */
@media (max-width: 921px) {
    .lsf-toggle-btn.lsf-btn-open { background: var(--lumiere-rose, #c9a087); }
    .lsf-toggle-btn {
        display: inline-flex;
        flex-shrink: 0;
        width: auto;
        padding: 0.5em 0.9em;
    }

    /* Mobile modal — centered (same as previous mobile) */
    body.lsf-layout-mobile-modal .lsf-drawer {
        display: none; position: fixed; z-index: 1002;
        top: 50%; left: 50%; transform: translate(-50%, -50%);
        width: min(94vw, 560px);
        max-height: 85vh; overflow-y: auto;
        padding: 0; border: 1px solid #e9e4dd;
        box-shadow: 0 12px 40px rgba(0,0,0,0.25);
        background: #fff; color: #111;
    }
    body.lsf-layout-mobile-modal .lsf-drawer.open { display: block; }
    body.lsf-layout-mobile-modal .lsf-drawer-body {
        padding: 1.2em 1.2em;
        display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.4em 1.5em;
    }

    /* Mobile drawer — slide in from the right; left tabs + right panel */
    body.lsf-layout-mobile-drawer .lsf-drawer {
        display: flex;
        flex-direction: column;
        position: fixed; z-index: 1002;
        top: 0; right: 0; bottom: 0; left: auto;
        width: min(92vw, 400px);
        max-height: 100vh;
        overflow: hidden;
        padding: 0;
        border: none;
        border-left: 1px solid #e9e4dd;
        box-shadow: -8px 0 28px rgba(0,0,0,0.18);
        background: #fff; color: #111;
        transform: translateX(105%);
        transition: transform 0.28s ease;
        visibility: hidden;
        pointer-events: none;
    }
    body.lsf-layout-mobile-drawer .lsf-drawer.open {
        transform: translateX(0);
        visibility: visible;
        pointer-events: auto;
    }
    body.lsf-layout-mobile-drawer .lsf-drawer-head,
    body.lsf-layout-mobile-drawer .lsf-drawer-footer {
        flex-shrink: 0;
    }
    body.lsf-layout-mobile-drawer .lsf-drawer-body {
        flex: 1 1 auto;
        min-height: 0;
        padding: 0;
        display: flex;
        flex-direction: row;
        align-items: stretch;
        gap: 0;
        overflow: hidden;
    }
    body.lsf-layout-mobile-drawer .lsf-drawer-nav {
        display: flex;
        flex-direction: column;
        flex: 0 0 108px;
        width: 108px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        background: #f6f5f3;
        border-right: 1px solid #e9e4dd;
        padding: 0.4em 0;
    }
    body.lsf-layout-mobile-drawer .lsf-drawer-tab {
        display: block;
        width: 100%;
        margin: 0;
        padding: 0.85em 0.7em;
        border: none;
        border-left: 3px solid transparent;
        background: transparent;
        color: #4a4a4a;
        font-size: 0.72rem;
        font-weight: 500;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        text-align: left;
        cursor: pointer;
        line-height: 1.3;
        border-radius: 0;
        box-shadow: none;
        white-space: normal;
        word-break: break-word;
    }
    body.lsf-layout-mobile-drawer .lsf-drawer-tab.is-active {
        background: #fff;
        color: #111;
        border-left-color: var(--lumiere-rose, #c9a087);
        font-weight: 600;
    }
    body.lsf-layout-mobile-drawer .lsf-drawer-panels {
        display: block;
        flex: 1 1 auto;
        min-width: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 1em 1.1em 1.2em;
    }
    body.lsf-layout-mobile-drawer .lsf-drawer-panels .lsf-group {
        display: none;
        margin: 0;
    }
    body.lsf-layout-mobile-drawer .lsf-drawer-panels .lsf-group.is-active {
        display: block;
    }
    body.lsf-layout-mobile-drawer .lsf-drawer-panels .lsf-group-title {
        display: none; /* 标题已在左侧 tab */
    }
    body.lsf-layout-mobile-drawer .lsf-group-list li {
        white-space: normal;
    }

    /* On mobile, PC sidebar layout must not force flex / sticky */
    body.lsf-layout-pc-sidebar .lsf-shop-layout {
        display: block;
    }
    body.lsf-layout-pc-sidebar .lsf-wrapper {
        flex: none;
        width: auto;
        position: relative;
        top: auto;
    }
    body.lsf-layout-pc-sidebar .lsf-toggle-btn {
        display: inline-flex !important;
    }

    body.lsf-open { overflow: hidden; }
}
