/**
 * plp-toolbar.css
 * Above-the-grid toolbar with active filter pills, reset, item count and sort.
 *
 * The toolbar is rendered inside <main> by PHP, then promoted to a sibling of
 * <main> by plp-toolbar.js so it spans both the sidebar and the product grid.
 * Both grid-column and flex-basis are set so it behaves as a full-row child
 * regardless of whether the Kadence container is using grid or flex.
 */

/*
 * Two-level structure:
 *   .plp-toolbar          — full-page-width band (background + bottom border)
 *   .plp-toolbar__inner   — Kadence container, max-width like the rest of the
 *                           site, holds the actual flex layout of pills + sort.
 *
 * The outer is rendered inside <main> by PHP and moved by plp-toolbar.js to
 * be a sibling immediately BEFORE .content-container so the band can span
 * the whole viewport width above the sidebar+grid layout.
 */
.plp-toolbar {
    width: 100%;
    margin: 0 0 24px;
    background: var(--rv-surface);
    border-bottom: 1px solid var(--rv-border);
    font-family: var(--rv-controls-font);
    font-size: 13px;
    color: var(--rv-text);
}

.plp-toolbar__inner {
    box-sizing: border-box;
    display: flex !important;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 14px;
    padding-bottom: 14px;
}

.plp-toolbar__left,
.plp-toolbar__right {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.plp-toolbar__right {
    margin-left: auto;
    gap: 10px;
}

/* -----------------------------------------------
   Active filter pills
   ----------------------------------------------- */
.plp-toolbar__pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    color: var(--rv-text);
    text-decoration: none;
    transition: background-color .15s ease;
    border-radius: 4px;
    background: var(--rv-surface-soft);
    font-family: var(--rv-toolbar-pill-font);
    font-size: var(--rv-toolbar-pill-size);
    font-weight: var(--rv-toolbar-pill-weight);
    line-height: 16px;
}
.plp-toolbar__sort-label {
    color: var(--rv-text-muted);
    font-family: var(--rv-toolbar-sort-font);
    font-size: var(--rv-toolbar-sort-size);
    font-weight: var(--rv-toolbar-sort-weight);
    line-height: 17px;
}
.plp-toolbar__pill:hover,
.plp-toolbar__pill:focus {
    background: #f5f5f5;
    text-decoration: none;
    color: var(--rv-text);
}

.plp-toolbar__pill-x {
    font-size: 16px;
    line-height: 1;
    color: #6b6b6b;
}

.plp-toolbar__reset {
    margin-left: 6px;
    color: var(--rv-text);
    text-decoration: none;
    font-family: var(--rv-toolbar-reset-font);
    font-size: var(--rv-toolbar-reset-size);
    font-weight: var(--rv-toolbar-reset-weight);
    line-height: 16px;
}

.plp-toolbar__reset:hover,
.plp-toolbar__reset:focus {
    text-decoration: underline;
    color: var(--rv-text);
}

/* -----------------------------------------------
   Right side: item count + sort
   ----------------------------------------------- */
.plp-toolbar__count {
    color: var(--rv-text-muted);
    font-family: var(--rv-toolbar-count-font);
    font-size: var(--rv-toolbar-count-size);
    font-weight: var(--rv-toolbar-count-weight);
    line-height: 17px;
}

.plp-toolbar__sort {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding-left: 10px;
    border-left: 1px solid var(--rv-border);
}

.plp-toolbar__sort .woocommerce-ordering,
.plp-toolbar__sort form {
    margin: 0;
    padding: 0;
}

.plp-toolbar__sort label {
    color: #6b6b6b;
    font-family: var(--rv-toolbar-sort-font);
    font-size: var(--rv-toolbar-sort-size);
    font-weight: var(--rv-toolbar-sort-weight);
}

.plp-toolbar__sort select {
    border: 0;
    background: transparent;
    font-family: var(--rv-toolbar-sort-font);
    color: var(--rv-text);
    cursor: pointer;
    padding: 4px 24px 4px 4px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%231a1a1a' stroke-width='1.5' fill='none' stroke-linecap='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 4px center;
    font-size: var(--rv-toolbar-sort-size);
    font-weight: var(--rv-toolbar-sort-weight);
    line-height: 17px;
}

.plp-toolbar__sort select:focus {
    outline: 2px solid rgba(0, 0, 0, .12);
    outline-offset: 2px;
}

/* -----------------------------------------------
   Empty state — no active filters yet
   ----------------------------------------------- */
.plp-toolbar.is-empty .plp-toolbar__left:empty {
    display: none;
}

/* -----------------------------------------------
   Sort preloader — shown while a sort change reloads the listing
   (see plp-toolbar.js). Full-page: the whole document is being replaced,
   not just the grid.
   ----------------------------------------------- */
.plp-sort-loader {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, .68);
    /* Delayed fade-in: a sort that resolves quickly shouldn't flash an
       overlay the user can't read anyway. */
    opacity: 0;
    animation: plp-sort-loader-in .2s ease .12s forwards;
}

@keyframes plp-sort-loader-in {
    to { opacity: 1; }
}

.plp-sort-loader__spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(0, 0, 0, .12);
    border-top-color: var(--rv-accent);
    border-radius: 50%;
    animation: plp-sort-loader-spin .8s linear infinite;
}

@keyframes plp-sort-loader-spin {
    to { transform: rotate(360deg); }
}

/* Second sort change while the first is still loading would be lost on
   navigation anyway. */
.plp-toolbar.is-sorting .plp-toolbar__sort {
    pointer-events: none;
    opacity: .55;
}

@media (prefers-reduced-motion: reduce) {
    .plp-sort-loader {
        opacity: 1;
        animation: none;
    }

    .plp-sort-loader__spinner {
        animation-duration: 2.4s;
    }
}

/* -----------------------------------------------
   Filter button (mobile only) + count badge
   ----------------------------------------------- */
.plp-toolbar__filter-btn {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    border: 0;
    border-radius: 999px;
    background: var(--rv-toolbar-filter-btn-bg);
    cursor: pointer;
    font-family: var(--rv-toolbar-filter-btn-font);
    font-size: var(--rv-toolbar-filter-btn-size);
    font-weight: var(--rv-toolbar-filter-btn-weight);
    line-height: 17px;
    color: var(--rv-toolbar-filter-btn-text);
}
.plp-toolbar__pill-name {
    text-transform: capitalize;
}
.plp-toolbar__filter-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.plp-toolbar__filter-btn-icon svg {
    display: block;
}

.plp-toolbar__filter-btn-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--rv-accent);
    color: var(--rv-surface);
    font-family: var(--rv-toolbar-filter-btn-font);
    font-size: 14px;
    font-weight: 500;
    line-height: 17px;
    text-align: center;
}

/* -----------------------------------------------
   Mobile layout: collapse pills/count, show Filter btn
   ----------------------------------------------- */
@media (max-width: 1024px) {
    .plp-toolbar__filter-btn {
        display: inline-flex;
        width: 100%;
        justify-content: center;
    }

    .plp-toolbar__pill,
    .plp-toolbar__reset,
    .plp-toolbar__count {
        display: none;
    }

    .plp-toolbar.is-empty .plp-toolbar__left:empty {
        display: flex;
    }

    .plp-toolbar__left {
        display: flex;
    }

    .plp-toolbar__sort {
        border-left: 0;
        padding-left: 0;
    }

    .plp-toolbar__inner {
        gap: 0;
        flex-wrap: nowrap;
    }

    .plp-toolbar__left,
    .plp-toolbar__right {
        flex: 0 0 50%;
        max-width: 50%;
        min-width: 0;
        flex-wrap: nowrap;
    }

    .plp-toolbar__right {
        margin-left: 0;
        justify-content: flex-end;
        overflow: hidden;
    }

    .plp-toolbar__sort {
        flex-wrap: nowrap;
        min-width: 0;
        max-width: 100%;
    }

    .plp-toolbar__sort-label {
        white-space: nowrap;
    }

    .plp-toolbar__sort select {
        max-width: 100%;
        text-overflow: ellipsis;
    }
}
@media (max-width: 480px) {
    .plp-toolbar__sort select{
        width: 100%;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        display: block;
    }
    .plp-toolbar__sort-label {
        display: none;
    }
}