/* ============================================================
   ShipItAll - Refine Filters
   v1.0.62  - initial release
   v1.0.68.2 - mobile restyled from slide-up bottom sheet to right-side
               slide-in drawer at <=768px. Desktop sticky sidebar is
               unchanged. Backdrop is always in the DOM; opacity +
               pointer-events toggle via .is-open.
   ============================================================ */

/* ---- Buyer side: archive layout adjustments ---- */

.sia-archive-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 28px;
    align-items: start;
}
@media (max-width: 768px) {
    .sia-archive-layout {
        grid-template-columns: 1fr;
        gap: 14px;
    }
    /* On mobile the sidebar wrapper only houses subcats + the hidden drawer
       panel; collapse its spacing so stacked layout is tight. */
    .sia-archive-sidebar {
        margin-bottom: 0;
    }
}

/* ---- Panel base ---- */

.sia-refine-panel {
    background: #fff;
    border: 1px solid var(--sia-border, #e5e5e5);
    border-radius: 12px;
    padding: 14px 14px 10px;
    font-size: 14px;
    position: sticky;
    top: 16px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    box-sizing: border-box;
}

.sia-refine-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--sia-border, #eee);
    margin-bottom: 10px;
}
.sia-refine-title {
    font-size: 15px;
    font-weight: 800;
    margin: 0;
    flex: 1;
    letter-spacing: 0.3px;
}
.sia-refine-clear {
    font-size: 12px;
    color: var(--sia-primary, #E8380D);
    text-decoration: none;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
}
.sia-refine-clear:hover {
    background: rgba(232, 56, 13, 0.08);
    text-decoration: none;
}
.sia-refine-close {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    color: var(--sia-text-muted, #666);
}

/* ---- Sections (one per facet) ---- */

.sia-refine-section {
    border-bottom: 1px solid var(--sia-surface, #f5f5f0);
    padding: 6px 0;
}
.sia-refine-section:last-of-type {
    border-bottom: none;
}
.sia-refine-section-head {
    width: 100%;
    background: none;
    border: none;
    padding: 10px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    color: var(--sia-dark, #1a1a2e);
    text-align: left;
}
.sia-refine-chev {
    color: var(--sia-text-muted, #777);
    font-size: 12px;
    transition: transform 0.15s;
}
.sia-refine-section[data-open="false"] .sia-refine-chev {
    transform: rotate(-90deg);
}
.sia-refine-section[data-open="false"] .sia-refine-section-body {
    display: none;
}
.sia-refine-section-body {
    padding: 2px 0 8px;
}
.sia-refine-scrollable {
    max-height: 220px;
    overflow-y: auto;
}

/* ---- Options (radio/checkbox rows) ---- */

.sia-refine-opt {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 2px;
    cursor: pointer;
    font-size: 13px;
    color: var(--sia-text, #222);
    line-height: 1.3;
}
.sia-refine-opt:hover {
    background: var(--sia-surface, #fafafa);
    border-radius: 4px;
}
.sia-refine-opt input[type="checkbox"],
.sia-refine-opt input[type="radio"] {
    margin: 0;
    flex-shrink: 0;
    accent-color: var(--sia-primary, #E8380D);
}
.sia-refine-label-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sia-refine-count {
    color: var(--sia-text-muted, #888);
    font-size: 12px;
    flex-shrink: 0;
}
.sia-refine-stars {
    color: #f39c12;
    letter-spacing: 1px;
    font-size: 13px;
}
.sia-refine-and-up {
    color: var(--sia-text-muted, #777);
    font-size: 12px;
}

/* ---- Actions ---- */

.sia-refine-actions {
    display: none;       /* hidden on desktop, shown on mobile */
    padding-top: 12px;
    border-top: 1px solid var(--sia-border, #eee);
}
.sia-refine-apply {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    background: var(--sia-primary, #E8380D);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

/* ---- Mobile: side drawer (v1.0.68.2) ----
   Slides in from the right on <=768px. Desktop >768px keeps the inline
   sticky sidebar untouched. Backdrop is always in the DOM but opacity 0 /
   pointer-events none until .is-open is set. Transform-based slide so
   the browser can composite it on the GPU; prefers-reduced-motion
   handled below. */

.sia-refine-mobile-trigger {
    /* Hidden on desktop, shown inside the mobile @media block. The second
       display declaration below re-asserts flex when visible. */
    display: none;
    width: 100%;
    padding: 12px;
    border: 1.5px solid var(--sia-border, #e5e5e5);
    border-radius: 10px;
    background: #fff;
    font-size: 14px;
    font-weight: 700;
    color: var(--sia-dark, #222);
    cursor: pointer;
    margin-bottom: 14px;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.sia-refine-mobile-trigger svg {
    width: 18px;
    height: 18px;
}
.sia-refine-mobile-count {
    background: var(--sia-primary, #E8380D);
    color: #fff;
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 11px;
    margin-left: 6px;
}

/* Backdrop lives at the body root; transitions apply in all viewport sizes
   but it is only made interactive when the drawer is open (guarded by the
   .is-open modifier, which is only added by JS on mobile). */
.sia-refine-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}
.sia-refine-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 768px) {
    .sia-refine-mobile-trigger {
        display: inline-flex;
    }

    /* Panel becomes a right-side drawer. Always rendered in the DOM,
       kept off-screen via translateX(100%) and visibility:hidden until
       JS adds .is-open. visibility coordinates with the transform so
       the drawer cannot steal focus or pointer events while closed. */
    .sia-refine-panel {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: auto;
        width: min(360px, 88vw);
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
        border: none;
        border-left: 1px solid var(--sia-border, #e5e5e5);
        z-index: 10000;
        box-shadow: -10px 0 40px rgba(0, 0, 0, 0.25);
        padding: 14px 16px;
        margin: 0;
        transform: translateX(100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                    visibility 0s linear 0.28s;
        visibility: hidden;
        display: flex;
        flex-direction: column;
        overflow: hidden; /* the .sia-refine-form is the scroll container */
    }
    .sia-refine-panel.is-open {
        transform: translateX(0);
        visibility: visible;
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                    visibility 0s linear 0s;
    }

    /* Close button visible in drawer mode, pill-shaped tap target. */
    .sia-refine-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        border-radius: 999px;
        background: var(--sia-surface, #f5f5f0);
        font-size: 22px;
    }
    .sia-refine-head {
        flex-shrink: 0;
    }

    /* Form takes the remaining height and scrolls internally. min-height:0
       is required inside a flex column to let overflow-y work. The sticky
       Apply bar sits at the bottom of the scroll container; margin-top:auto
       keeps it pinned to the bottom even when content is short. */
    .sia-refine-form {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        margin: 0 -16px;
        padding: 0 16px;
    }
    .sia-refine-actions {
        display: block;
        position: sticky;
        bottom: 0;
        background: #fff;
        margin: auto -16px 0;
        padding: 12px 16px;
        border-top: 1px solid var(--sia-border, #eee);
    }
}

@media (prefers-reduced-motion: reduce) {
    .sia-refine-panel,
    .sia-refine-backdrop {
        transition: none;
    }
}

/* ============================================================
   VENDOR DASHBOARD - Refine tab chip input
   ============================================================ */

.sia-refine-field {
    margin-bottom: 20px;
}

.sia-refine-chip-box {
    position: relative;
    border: 1.5px solid var(--sia-border, #e5e5e5);
    border-radius: 8px;
    padding: 6px;
    background: #fff;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    min-height: 44px;
    box-sizing: border-box;
}
.sia-refine-chip-box:focus-within {
    border-color: var(--sia-primary, #E8380D);
}

.sia-refine-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.sia-refine-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--sia-surface, #f5f5f0);
    color: var(--sia-dark, #1a1a2e);
    padding: 4px 4px 4px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
}
.sia-refine-chip-x {
    background: rgba(0, 0, 0, 0.08);
    border: none;
    border-radius: 999px;
    width: 18px;
    height: 18px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    color: #222;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.sia-refine-chip-x:hover {
    background: rgba(232, 56, 13, 0.2);
}

.sia-refine-chip-input {
    border: none;
    outline: none;
    padding: 6px 8px;
    font-size: 13px;
    background: transparent;
    flex: 1;
    min-width: 120px;
}

.sia-refine-suggest {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--sia-border, #e5e5e5);
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 180px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}
.sia-refine-suggest.is-open {
    display: block;
}
.sia-refine-suggest-item {
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
}
.sia-refine-suggest-item:hover,
.sia-refine-suggest-item.is-active {
    background: var(--sia-surface, #f5f5f0);
}

/* ============================================================
   v1.3.2.3 - ARCHIVE REFINE MODAL
   Shown when [data-sia-refine-open] is clicked on redesigned archive.
   The wrapper #sia-archive-refine-slot has inline style="display:none"
   so only .is-open flips it to a fixed side-drawer on ALL viewports.
   ============================================================ */

.sia-rd-refine-hidden.is-open {
    display: block !important;       /* override inline style="display:none" */
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 92vw;
    max-width: 440px;
    background: #fff;
    z-index: 10000;
    overflow-y: auto;
    box-shadow: -6px 0 24px rgba(0, 0, 0, 0.18);
    animation: sia-refine-slide-in 0.22s ease-out;
    -webkit-overflow-scrolling: touch;
}

.sia-rd-refine-hidden.is-open .sia-refine-panel {
    /* Neutralise any sticky/sidebar positioning the panel picks up at
       desktop widths; inside the modal it should just scroll. */
    position: static !important;
    width: 100% !important;
    max-width: none !important;
    padding: 44px 18px 24px !important; /* top padding leaves room for close btn */
    box-shadow: none;
    border: none;
    margin: 0;
}

.sia-refine-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    z-index: 9999;
    transition: opacity 0.2s ease;
}
.sia-refine-modal-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}

.sia-refine-modal-close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 50%;
    background: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: #555;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.sia-refine-modal-close:hover {
    background: #f5f5f0;
    border-color: rgba(0, 0, 0, 0.15);
}

@keyframes sia-refine-slide-in {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}

/* Small screens: full-width drawer. */
@media (max-width: 520px) {
    .sia-rd-refine-hidden.is-open {
        width: 100vw;
        max-width: none;
    }
}
