/**
 * Piston Tribe — Product Archive Layout
 *
 * Matches the marketplace-discover layout exactly:
 *  - Full-width #f0f2f5 wrapper
 *  - max-width 1850px container at 95vw
 *  - 280px sticky sidebar (card style)
 *  - flex feed area
 *
 * Breakpoint: 900px (sidebar → off-canvas popup)
 */

/* ================================================================
   VISIBILITY GUARDS
   Ensure desktop and popup filters are strictly separated.
   ================================================================ */

/* Popup filter hidden on desktop inside the archive template */
@media (min-width: 901px) {
    .pt-archive-page .custom-filter.popup-version,
    .pt-archive-page #custom-filter-popup,
    .pt-archive-page .custom-popup-overlay,
    .pt-archive-page .filter-buttons-fixed {
        display: none !important;
        visibility: hidden;
        pointer-events: none;
        height: 0;
        overflow: hidden;
    }
}

/* Desktop filter hidden on mobile — sidebar is hidden so this is belt-and-braces */
@media (max-width: 900px) {
    .pt-archive-page .custom-filter.desktop-version {
        display: none !important;
    }
}

/* Mobile filter button: only relevant inside our mobile bar — prevent the
   product-filter-menu-styles.css rule from triggering it outside that context */
.pt-archive-page .custom-mobile-filter-btn {
    display: flex; /* always flex inside our bar; the bar's own display controls it */
    width: auto;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 700;
    border: 1px solid #e4e6eb;
    border-radius: 8px;
    background: #fff;
    color: #050505;
    gap: 8px;
    align-items: center;
    cursor: pointer;
    transition: border-color 0.12s;
}

.pt-archive-page .custom-mobile-filter-btn:hover { border-color: #bcc0c4; }
.pt-archive-page .custom-mobile-filter-btn:active { background: #f0f2f5; }

.pt-archive-page .custom-mobile-filter-btn .filter-icon {
    width: 18px;
    height: 18px;
}

/* ================================================================
   PAGE WRAPPER — matches .pt-market-archive-wrapper
   ================================================================ */
.pt-archive-page {
    background-color: #f0f2f5;
    min-height: 100vh;
    padding: 40px 0 80px;

    /* Break out of GeneratePress container, same trick as marketplace */
    width: 100vw !important;
    max-width: 100vw !important;
    margin-left: calc(-50vw + 50%) !important;
    margin-right: calc(-50vw + 50%) !important;
    box-sizing: border-box;
}

/* ================================================================
   BREADCRUMBS — desktop only
   ================================================================ */
.pt-archive-breadcrumb {
    max-width: 1850px;
    width: 95%;
    margin: 0 auto;
    padding: 16px 0 0;
}

.pt-archive-breadcrumb .woocommerce-breadcrumb {
    font-size: 0.82rem;
    color: #65676b;
    margin: 0;
}

.pt-archive-breadcrumb .woocommerce-breadcrumb a {
    color: #65676b;
    text-decoration: none;
}

.pt-archive-breadcrumb .woocommerce-breadcrumb a:hover {
    color: #050505;
}

@media (max-width: 900px) {
    .pt-archive-breadcrumb {
        display: none;
    }
}

/* ================================================================
   MOBILE TOOLBAR
   Hidden on desktop, visible ≤900px.
   ================================================================ */
.pt-archive-mobile-bar {
    display: none;
    justify-content: space-between;
    align-items: center;
    padding: 12px 4%;
    background: #fff;
    border-bottom: 1px solid #e4e6eb;
    position: sticky;
    top: 0;
    z-index: 200;
}

/* ================================================================
   TWO-COLUMN LAYOUT — matches .pt-market-content-row
   ================================================================ */
.pt-archive-layout {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    max-width: 1850px;
    width: 95%;
    margin: 0 auto;
    padding: 24px 0 0;
}

/* ================================================================
   SIDEBAR — matches .pt-market-sidebar
   ================================================================ */
.pt-archive-sidebar {
    width: 280px;
    flex-shrink: 0;
    position: sticky;
    top: 30px;
    z-index: 10;
}

/* Wrap the desktop filter in a card matching .pt-nav-card */
.pt-archive-sidebar .custom-filter.desktop-version {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e4e6eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(100vh - 60px);
    scrollbar-width: thin;
}

.pt-archive-sidebar .custom-filter.desktop-version::-webkit-scrollbar { width: 6px; }
.pt-archive-sidebar .custom-filter.desktop-version::-webkit-scrollbar-track { background: transparent; }
.pt-archive-sidebar .custom-filter.desktop-version::-webkit-scrollbar-thumb { background: #bcc0c4; border-radius: 4px; }
.pt-archive-sidebar .custom-filter.desktop-version::-webkit-scrollbar-thumb:hover { background: #a0a3a7; }

/* Override the inner scroll area — let the card handle scrolling */
.pt-archive-sidebar .custom-filter-scroll {
    max-height: none;
    overflow: visible;
    padding-right: 0;
}

/* Remove the fade gradient (card handles overflow) */
.pt-archive-sidebar .custom-filter-wrapper::after { display: none; }

/* "Unselect all" link — style like a subtle pill */
.pt-archive-sidebar #unselect-all-global {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #65676b;
    padding: 12px 20px 0;
    cursor: pointer;
    margin: 0;
}
.pt-archive-sidebar #unselect-all-global:hover { color: #050505; }

/* ---- Filter groups — match marketplace accordion style ---- */

.pt-archive-sidebar .filter-group {
    border-bottom: 1px solid #e4e6eb;
    margin-bottom: 0;
    padding-bottom: 0;
}
.pt-archive-sidebar .filter-group:last-child { border-bottom: none; }

/* Toggle header */
.pt-archive-sidebar h4.filter-toggle {
    font-size: 0.95rem;
    font-weight: 700;
    color: #050505;
    padding: 15px 20px;
    margin: 0;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    transition: background 0.15s;
    gap: 0;
}
.pt-archive-sidebar h4.filter-toggle:hover { background: #fcfcfc; }

/* Selected count bubble — keep but tighten */
.pt-archive-sidebar .selected-count {
    font-size: 0.7rem;
    font-weight: 700;
    background: #e4e6eb;
    color: #050505;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: auto;
    margin-right: 8px;
}

/* Toggle icon (▾ / ▴) */
.pt-archive-sidebar .toggle-icon {
    font-size: 0.7rem;
    color: #8c939d;
    transition: transform 0.25s;
    flex-shrink: 0;
}

/* Filter content area */
.pt-archive-sidebar .filter-content {
    padding: 4px 20px 16px;
}

/* List items */
.pt-archive-sidebar .custom-filter ul li {
    margin-bottom: 6px;
    padding-left: 0;
}

/* Labels */
.pt-archive-sidebar .filter-content label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: #050505;
    cursor: pointer;
    font-weight: 500;
}

/* Checkboxes — match marketplace accent style */
.pt-archive-sidebar .filter-checkbox {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 1.5px solid #ced0d4;
    appearance: none;
    -webkit-appearance: none;
    background: #fff;
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
    transition: border-color 0.15s, background 0.15s;
    margin-right: 0;
}
.pt-archive-sidebar .filter-checkbox:checked {
    background: #050505;
    border-color: #050505;
}
.pt-archive-sidebar .filter-checkbox:checked::before {
    content: '';
    position: absolute;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: translate(-50%, -55%) rotate(45deg);
    top: 45%;
    left: 50%;
}

/* Price filter — always open, non-interactive header */
.pt-archive-sidebar .price-filter .filter-content {
    display: block !important;
    padding-top: 8px;
}
.pt-archive-sidebar .price-filter h4.filter-toggle {
    cursor: default;
    pointer-events: none;
}
.pt-archive-sidebar .price-filter .toggle-icon {
    display: none;
}
.pt-archive-sidebar .slider-wrapper-padding {
    padding: 0;
}

/* ================================================================
   MAIN FEED — matches .pt-market-feed
   ================================================================ */
.pt-archive-main {
    flex: 1;
    min-width: 0;
}

/* ================================================================
   TOPBAR — count (left) + sort select (right)
   ================================================================ */
.pt-archive-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid #e4e6eb;
    background: transparent;
}

/* ================================================================
   SORT SELECT
   ================================================================ */
.pt-archive-sort-select {
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid #e4e6eb;
    border-radius: 8px;
    padding: 7px 32px 7px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #050505;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2365676b'/%3E%3C/svg%3E") no-repeat right 10px center;
    cursor: pointer;
    transition: border-color 0.12s;
    min-width: 170px;
}

.pt-archive-sort-select:hover { border-color: #bcc0c4; }
.pt-archive-sort-select:focus { outline: none; border-color: #bcc0c4; }

/* ================================================================
   RESPONSIVE
   ================================================================ */

@media (max-width: 900px) {
    .pt-archive-page {
        padding-top: 0;
    }

    .pt-archive-layout {
        flex-direction: column;
        gap: 0;
        width: 100%;
        padding: 0;
    }

    .pt-archive-main {
        padding: 16px 4%;
    }

    .pt-archive-sidebar {
        display: none; /* popup filter replaces it */
    }

    .pt-archive-mobile-bar {
        display: flex;
    }

    /* Sort moves to mobile bar — hide from topbar */
    .pt-archive-topbar .pt-archive-sort-select {
        display: none;
    }

    .pt-archive-topbar {
        padding-bottom: 12px;
        margin-bottom: 16px;
    }
}

@media (max-width: 600px) {
    .pt-archive-mobile-bar {
        padding: 10px 16px;
    }

    .pt-archive-sort-select {
        min-width: 140px;
        font-size: 0.8rem;
    }
}

/* ================================================================
   CLEAR FILTER PILL
   Appears fixed at bottom-centre when attribute/price filters active.
   Matches seller dashboard #pt-global-clear-filter style exactly.
   ================================================================ */
#pt-archive-clear-filter {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(90px);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #111;
    color: #fff;
    border-radius: 30px;
    padding: 11px 20px 11px 18px;
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.28);
    font-size: 0.82rem;
    font-weight: 600;
    opacity: 0;
    transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.22s ease;
    pointer-events: none;
    white-space: nowrap;
}
#pt-archive-clear-filter.pt-gcf-visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: all;
}
#pt-archive-clear-filter .pt-gcf-label {
    color: rgba(255, 255, 255, 0.55);
    font-weight: 400;
    font-size: 0.78rem;
}
#pt-archive-gcf-btn {
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #fff;
    border-radius: 20px;
    padding: 4px 14px;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    transition: background 0.15s;
    line-height: 1.5;
}
#pt-archive-gcf-btn:hover {
    background: rgba(255, 255, 255, 0.26);
}
