/*
 * ss-plp-mobile — Mobile PLP polish
 *
 * 1. Sticky bottom action bar (Filter | Sort) — pinned above the site
 *    bottom nav. Ships as a portal element on <body>.
 * 2. Bottom sheet component — reusable for both Filter and Sort. Slide-up
 *    animation, backdrop, tap-to-dismiss.
 * 3. Hides the desktop filter sidebar + toolbar on mobile.
 *
 * All ≤767px scoped so desktop is untouched.
 */

@media (max-width: 767px) {
    /* Reserve room at bottom for site nav (60px) + action bar (56px) */
    body.page-products {
        padding-bottom: calc(116px + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* Hide the desktop filter sidebar + toolbar — moved into sheets */
    .page-products .sidebar.sidebar-main,
    .page-products .sidebar.sidebar-additional {
        display: none !important;
    }
    .page-products .toolbar-products {
        display: none !important;
    }
    /* Bottom pager still hidden (v2 uses infinite scroll / load more later);
       keep only the count summary. */
    .page-products .ss-plp-pager .pages { display: none !important; }

    /* Column.main full width */
    .page-products .column.main {
        width: 100% !important;
    }
}

/* ── Sticky action bar (Filter | Sort) ─────────────────────────── */
.ss-plp-actionbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    height: 56px;
    display: none; /* revealed on mobile below */
    align-items: stretch;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
    z-index: 9997;
}
@media (max-width: 767px) {
    .ss-plp-actionbar { display: flex; }
}
.ss-plp-actionbar__btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: transparent;
    border: 0;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #1a2543;
    cursor: pointer;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}
.ss-plp-actionbar__btn:active {
    background: #f3f4f6;
}
.ss-plp-actionbar__btn + .ss-plp-actionbar__btn {
    border-left: 1px solid #e5e7eb;
}
.ss-plp-actionbar__btn svg {
    width: 16px;
    height: 16px;
    color: #6b7280;
}
.ss-plp-actionbar__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: #1abc9c;
    color: #ffffff;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    font-weight: 800;
    border-radius: 999px;
    line-height: 1;
    margin-left: 4px;
}
.ss-plp-actionbar__labels {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    line-height: 1.15;
    min-width: 0;
}
.ss-plp-actionbar__label {
    font-size: 13px;
    font-weight: 700;
    color: #1a2543;
    letter-spacing: 0.02em;
}
.ss-plp-actionbar__value {
    font-size: 11px;
    font-weight: 500;
    color: #6b7280;
    text-transform: none;
    letter-spacing: normal;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Price range slider (inside filter sheet) ─────────────────── */
.ss-price-range { padding: 4px 6px 12px; }
.ss-price-range__values {
    display: flex;
    justify-content: space-between;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 14px;
    font-weight: 700;
    color: #1a2543;
    margin-bottom: 12px;
}
.ss-price-range__slider {
    position: relative;
    height: 32px;
    margin: 0 8px;
}
.ss-price-range__track {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 4px;
    background: #e5e7eb;
    border-radius: 999px;
    transform: translateY(-50%);
}
.ss-price-range__fill {
    position: absolute;
    top: 0;
    height: 100%;
    background: #1abc9c;
    border-radius: 999px;
}
.ss-price-range input[type="range"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 32px;
    background: transparent;
    -webkit-appearance: none;
    appearance: none;
    pointer-events: none;
    margin: 0;
    padding: 0;
}
.ss-price-range input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #ffffff;
    border: 2px solid #1a2543;
    cursor: grab;
    pointer-events: auto;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.2);
    margin-top: 0;
}
.ss-price-range input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #ffffff;
    border: 2px solid #1a2543;
    cursor: grab;
    pointer-events: auto;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.2);
}
.ss-price-range input[type="range"]::-webkit-slider-runnable-track,
.ss-price-range input[type="range"]::-moz-range-track {
    background: transparent;
    height: 32px;
    border: 0;
}
.ss-price-range__apply {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    margin-top: 12px;
    background: #1a2543;
    color: #ffffff;
    border: 0;
    border-radius: 6px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* ── Grid/List mode selector inside Sort sheet ────────────────── */
.ss-view-modes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 12px 0 0;
    margin-top: 12px;
    border-top: 1px solid #e5e7eb;
}
.ss-view-modes__label {
    grid-column: 1 / -1;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #6b7280;
    margin: 0 0 4px;
}
.ss-view-modes__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px;
    background: #ffffff;
    border: 1.5px solid #e5e7eb;
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    color: #1a2543;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.ss-view-modes__btn.is-active {
    border-color: #1a2543;
    background: #eef2ff;
}
.ss-view-modes__btn svg { width: 18px; height: 18px; }

/* ── Bottom sheet ─────────────────────────────────────────────── */
.ss-sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms ease;
    z-index: 10000;
}
.ss-sheet-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}
.ss-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 85vh;
    background: #ffffff;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.2);
    transform: translateY(100%);
    transition: transform 260ms cubic-bezier(.2,.7,.3,1);
    z-index: 10001;
    display: flex;
    flex-direction: column;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
.ss-sheet.is-open {
    transform: translateY(0);
}
.ss-sheet__handle {
    display: block;
    width: 44px;
    height: 4px;
    margin: 8px auto 4px;
    background: #d1d5db;
    border-radius: 999px;
    flex-shrink: 0;
}
.ss-sheet__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px 12px;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}
.ss-sheet__title {
    margin: 0;
    font-size: 16px;
    font-weight: 800;
    color: #1a2543;
    letter-spacing: -0.005em;
}
.ss-sheet__close {
    background: transparent;
    border: 0;
    padding: 6px;
    cursor: pointer;
    color: #6b7280;
    -webkit-tap-highlight-color: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.ss-sheet__close svg { width: 20px; height: 20px; }
.ss-sheet__body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 16px 24px;
    flex: 1 1 auto;
}
.ss-sheet__foot {
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}
.ss-sheet__foot .ss-sheet__btn {
    flex: 1;
    padding: 14px 16px;
    border: 0;
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.ss-sheet__btn--ghost {
    background: #ffffff;
    color: #1a2543;
    border: 1px solid #d1d5db;
}
.ss-sheet__btn--primary {
    background: #1a2543;
    color: #ffffff;
}
.ss-sheet__btn--primary:active { background: #0f172a; }

/* ── Filter sheet content — Magento uses <dl> with <dt> title + <dd> content pairs ── */
.ss-sheet__body .filter-content { margin: 0; padding: 0; }
.ss-sheet__body .filter-options { margin: 0; padding: 0; }
.ss-sheet__body .filter-options-title,
.ss-sheet__body .filter-options-content,
.ss-sheet__body .filter-current .filter-current-subtitle {
    display: block;
}
.ss-sheet__body .filter-options-title {
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6b7280;
    padding: 14px 24px 10px 0;
    margin: 0;
    border-top: 1px solid #f3f4f6;
    cursor: pointer;
    position: relative;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.ss-sheet__body .filter-options-title:first-child { border-top: 0; }
.ss-sheet__body .filter-options-title::after {
    content: '';
    position: absolute;
    right: 4px;
    top: 50%;
    width: 8px;
    height: 8px;
    border-right: 2px solid #6b7280;
    border-bottom: 2px solid #6b7280;
    transform: translateY(-70%) rotate(-135deg); /* chevron up (expanded) */
    transition: transform 180ms ease;
}
.ss-sheet__body .filter-options-title.is-collapsed::after {
    transform: translateY(-30%) rotate(45deg); /* chevron down */
}
.ss-sheet__body .filter-options-content {
    padding: 0 0 12px;
}
.ss-sheet__body .filter-options-content { padding: 4px 0 8px; }
.ss-sheet__body .filter-options-content .items { margin: 0; padding: 0; list-style: none; }
.ss-sheet__body .filter-options-content .item {
    padding: 8px 0;
    font-size: 13px;
}
.ss-sheet__body .filter-options-content .item a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #1a2543;
    text-decoration: none;
    padding: 6px 0;
    -webkit-tap-highlight-color: transparent;
}
.ss-sheet__body .filter-options-content .item a:active { color: #0f172a; }
.ss-sheet__body .filter-options-content .count {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    color: #6b7280;
}
.ss-sheet__body .filter-current {
    padding: 0 0 12px;
    margin: 0 0 12px;
    border-bottom: 1px solid #e5e7eb;
}
.ss-sheet__body .filter-current .filter-current-subtitle {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6b7280;
    margin-bottom: 8px;
}
.ss-sheet__body .filter-current .items { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.ss-sheet__body .filter-current .item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #eef2ff;
    color: #1a2543;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.ss-sheet__body .filter-actions { display: none; } /* footer sheet handles this */

/* ── Sort sheet — radio list ─────────────────────────────────── */
.ss-sort-list { list-style: none; margin: 0; padding: 0; }
.ss-sort-list li { border-bottom: 1px solid #f3f4f6; }
.ss-sort-list li:last-child { border-bottom: 0; }
.ss-sort-list button {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 4px;
    background: transparent;
    border: 0;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: #1a2543;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.ss-sort-list button.is-active {
    font-weight: 800;
    color: #1a2543;
}
.ss-sort-list button.is-active::after {
    content: '';
    width: 20px;
    height: 20px;
    background: #1abc9c;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center/contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center/contain no-repeat;
}
