/**
 * Shop / Category Archive: Dack header + "Alla filter" Panel
 * Header: grey box (title + description), bar (TILLBAKA TILL SÖK + sort).
 * Filters: two rows – row 1: Bredd, Profil, Dimension, Varumärkeslista, Hastighetsindex;
 * row 2: Våtgrepp, NoiceValue, bränsleeffektivitet, SÖK, Rensa filter.
 */

/* ----- Dack archive header (category title, description, back button, sort) ----- */
.autohjul-dack-archive-header {
    width: 100%;
    margin-bottom: 20px;
}

.autohjul-dack-archive-header__box {
    background-color: #f3f4f6;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 16px;
    border: 1px solid #e5e7eb;
}

.autohjul-dack-archive-header__title {
    font-size: 1.75rem;
    font-weight: 700;
    color: #2563eb;
    margin: 0 0 12px 0;
    line-height: 1.3;
    display: flex;
    align-items: center;
    gap: 10px;
}

.autohjul-dack-archive-header__icon {
    flex-shrink: 0;
    color: #2563eb;
}

.autohjul-dack-archive-header__description {
    font-size: 15px;
    line-height: 1.6;
    color: #111827;
    margin: 0;
}

.autohjul-dack-archive-header__bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.autohjul-dack-archive-header__back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    text-decoration: none;
    color: #fff;
    background-color: #2563eb;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.autohjul-dack-archive-header__back:hover {
    background-color: #1d4ed8;
    color: #fff;
}

.autohjul-dack-archive-header__back-icon {
    font-size: 1.2em;
    line-height: 1;
}

.autohjul-dack-archive-header__order select {
    padding: 8px 36px 8px 12px;
    font-size: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #fff;
    min-width: 200px;
}

/* ----- Alla filter panel ----- */
.autohjul-shop-dack-filters {
    width: 100%;
    margin-bottom: 24px;
}

/* Mobile only: bar with "Alla filter" + VISA FILTER button (shown when panel closed) */
.autohjul-shop-filters-mobile-bar {
    display: none;
}

.autohjul-shop-dack-filters__panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

.autohjul-shop-dack-filters__panel-header .autohjul-shop-dack-filters__title {
    margin: 0;
    flex: 1;
}

.autohjul-shop-filters-mobile-toggle--hide {
    display: none;
}

.autohjul-shop-dack-filters__panel {
    background-color: #ffffff;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e7eb;
}

.autohjul-shop-dack-filters__title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
    margin: 0 0 20px 0;
    line-height: 1.3;
}

.autohjul-shop-dack-filters__form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Two rows: row 1 = 5 filters, row 2 = 3 filters + actions */
.autohjul-shop-dack-filters__row {
    display: grid;
    gap: 16px;
}

.autohjul-shop-dack-filters__row--1 {
    grid-template-columns: repeat(5, 1fr);
}

/* Search page: row 1 has only 2 filters (Varumärke, Hastighetsindex) */
.autohjul-shop-dack-filters--search .autohjul-shop-dack-filters__row--1 {
    grid-template-columns: repeat(2, 1fr);
}

.autohjul-shop-dack-filters__row--2 {
    grid-template-columns: repeat(3, 1fr) auto;
    align-items: end;
}
/* Align SÖK + Rensa buttons with bottom of filter dropdowns in row 2 */
.autohjul-shop-dack-filters__row--2 .autohjul-shop-dack-filters__actions {
    display: flex;
    align-items: flex-end;
}

.autohjul-shop-dack-filters__fields {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
}

.autohjul-shop-dack-filters__field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
}

.autohjul-shop-dack-filters__label {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin: 0;
    display: block;
    line-height: 1.4;
}

.autohjul-shop-dack-filters__select {
    width: 100%;
    padding: 8px 36px 8px 12px;
    font-size: 15px;
    line-height: 1.5;
    color: #333;
    background-color: #ffffff;
    border: 1px solid #ddd;
    border-radius: 4px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.autohjul-shop-dack-filters__select:hover {
    border-color: #999;
}

.autohjul-shop-dack-filters__select:focus {
    outline: none;
    border-color: #0066cc;
    box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.15);
}

.autohjul-shop-dack-filters__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.autohjul-shop-dack-filters__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.4;
    text-decoration: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}

.autohjul-shop-dack-filters__btn--search {
    background-color: #2563eb;
    color: #ffffff;
}

.autohjul-shop-dack-filters__btn--search:hover {
    background-color: #1d4ed8;
    color: #ffffff;
}

.autohjul-shop-dack-filters__btn--clear {
    background-color: #dc2626;
    color: #ffffff;
}

.autohjul-shop-dack-filters__btn--clear:hover {
    background-color: #b91c1c;
    color: #ffffff;
}

/* Falgar panel: row 1 = 5 filters, row 2 = 2 filters + actions */
.autohjul-shop-falgar-filters .autohjul-shop-dack-filters__row--1 {
    grid-template-columns: repeat(5, 1fr);
}
.autohjul-shop-falgar-filters .autohjul-shop-dack-filters__row--2 {
    grid-template-columns: repeat(2, 1fr) auto;
}
.autohjul-shop-falgar-filters .autohjul-shop-dack-filters__fields {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1024px) {
    .autohjul-shop-dack-filters__row--1 {
        grid-template-columns: repeat(3, 1fr);
    }
    .autohjul-shop-dack-filters--search .autohjul-shop-dack-filters__row--1 {
        grid-template-columns: repeat(2, 1fr);
    }
    .autohjul-shop-dack-filters__row--2 {
        grid-template-columns: repeat(2, 1fr) auto;
    }
    .autohjul-shop-dack-filters__fields {
        grid-template-columns: repeat(3, 1fr);
    }
    .autohjul-shop-falgar-filters .autohjul-shop-dack-filters__fields {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* AJAX loading state */
.autohjul-shop-ajax-content.autohjul-shop-ajax-loading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

.autohjul-shop-ajax-content.autohjul-shop-ajax-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 32px;
    height: 32px;
    margin: -16px 0 0 -16px;
    border: 3px solid #e5e7eb;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: autohjul-spin 0.8s linear infinite;
}

@keyframes autohjul-spin {
    to { transform: rotate(360deg); }
}

/* No products block + back button – match theme design */
.autohjul-no-products {
    padding: 24px 0;
    text-align: left;
    max-width: 100%;
}

.autohjul-no-products .woocommerce-info {
    margin: 0 0 20px 0;
    padding: 14px 18px;
    background: #f5f5f5;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    color: #374151;
    font-size: 15px;
    line-height: 1.5;
}

.autohjul-no-products__back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 4px;
    transition: background-color 0.2s ease, color 0.2s ease;
    background-color: #2563eb;
    color: #ffffff;
}

.autohjul-no-products__back:hover {
    background-color: #1d4ed8;
    color: #ffffff;
}

@media (max-width: 768px) {
    .autohjul-dack-archive-header__box {
        padding: 16px;
    }
    .autohjul-dack-archive-header__title {
        font-size: 1.35rem;
    }
    .autohjul-dack-archive-header__bar {
        flex-direction: column;
        align-items: stretch;
    }
    .autohjul-shop-dack-filters__row--1,
    .autohjul-shop-dack-filters__row--2 {
        grid-template-columns: 1fr;
    }
    /* Falgar: force single filter per line (same as Däck on mobile) */
    .autohjul-shop-falgar-filters .autohjul-shop-dack-filters__row--1,
    .autohjul-shop-falgar-filters .autohjul-shop-dack-filters__row--2 {
        grid-template-columns: 1fr;
    }
    .autohjul-shop-dack-filters__row--2 .autohjul-shop-dack-filters__actions {
        justify-content: flex-start;
    }
    .autohjul-shop-dack-filters__fields {
        grid-template-columns: 1fr;
    }

    .autohjul-shop-dack-filters__panel {
        padding: 16px;
    }

    .autohjul-shop-dack-filters__title {
        font-size: 1.25rem;
        margin-bottom: 16px;
    }

    /* Mobile: VISA FILTER / DÖLJ FILTER toggle – bar visible, panel hidden by default */
    .autohjul-shop-filters-mobile-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 14px 16px;
        background: #fff;
        border-radius: 8px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
        border: 1px solid #e5e7eb;
        margin-bottom: 12px;
    }
    .autohjul-shop-filters-mobile-bar__title {
        font-size: 1rem;
        font-weight: 700;
        color: #111827;
    }
    .autohjul-shop-filters-mobile-toggle {
        padding: 10px 18px;
        font-size: 13px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.02em;
        color: #fff;
        background: #2563eb;
        border: none;
        border-radius: 4px;
        cursor: pointer;
        transition: background-color 0.2s ease;
    }
    .autohjul-shop-filters-mobile-toggle:hover {
        background: #1d4ed8;
        color: #fff;
    }
    .autohjul-shop-filters-mobile-toggle--hide {
        display: inline-flex !important;
        flex-shrink: 0;
    }
    /* Panel hidden by default on mobile */
    .autohjul-shop-dack-filters .autohjul-shop-dack-filters__panel {
        display: none;
    }
    /* When open: hide bar, show panel */
    .autohjul-shop-dack-filters.is-mobile-open .autohjul-shop-filters-mobile-bar {
        display: none;
    }
    .autohjul-shop-dack-filters.is-mobile-open .autohjul-shop-dack-filters__panel {
        display: block;
    }
    .autohjul-shop-dack-filters__panel-header {
        margin-bottom: 16px;
    }
}

/* Mobile: Falgar + Däck – single filter per line, clean vertical stack */
@media (max-width: 576px) {
    .autohjul-shop-falgar-filters .autohjul-shop-dack-filters__row--1,
    .autohjul-shop-falgar-filters .autohjul-shop-dack-filters__row--2 {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .autohjul-shop-dack-filters__row--1,
    .autohjul-shop-dack-filters__row--2 {
        gap: 12px;
    }
    .autohjul-shop-dack-filters__field {
        width: 100%;
    }
}
