﻿/* ==========================================================================
   Produktlistning (kategori/"Product Type"-sida)
   Återanvänder CSS-variablerna från header/css/base.css: --color-text,
   --color-text-muted, --color-border, --color-accent, --font-size-sm,
   --font-size-base, --header-max-width, --header-side-padding, --transition-fast
   ========================================================================== */

.product-listing__container {
    max-width: var(--header-max-width);
    margin: 0 auto;
    padding: 32px var(--header-side-padding) 64px;
}

.product-listing__header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 32px;
}

.product-listing__heading {
    text-align: left;
}

.product-listing__heading .content-page__title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.product-listing__title-icon {
    display: grid;
    place-items: center;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    border: 1px solid rgba(176, 42, 42, 0.14);
    border-radius: 12px;
    background: rgba(176, 42, 42, 0.07);
    color: var(--color-accent);
}

.product-listing__title-icon svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.product-listing__title-text {
    min-width: 0;
}

.product-listing__count {
    display: inline-block;
    margin: 0;
    padding: 8px 12px;
    border-radius: 8px;
    background-color: #ededed;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

.product-listing__description {
    max-width: 640px;
    margin: 12px 0 0;
    color: var(--color-text-muted);
    font-size: var(--font-size-base);
    line-height: 1.5;
}

/* ---------- "Filtrera"-knappen i headern ---------- */

.product-filters-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    padding: 10px 16px;
    border-radius: 999px;
    font-family: inherit;
    font-size: var(--font-size-sm);
    color: var(--color-text);
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

    .product-filters-trigger:hover {
        border-color: var(--color-text);
    }

.product-filters-trigger__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--color-text);
    color: #fff;
    font-size: 11px;
    line-height: 1;
}

/* ---------- Panel: sortering + filter, glider in från höger ----------
   Samma mönster som varukorgen (#mini-cart-dropdown/#mini-cart-backdrop i
   cart.css) - fullhöjds-panel + dimmande bakgrunds-overlay. */

.filters-panel-backdrop {
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 280ms ease, visibility 280ms;
}

    .filters-panel-backdrop.active {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

.filters-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    width: 400px;
    max-width: 100vw;
    height: 100vh;
    background: var(--header-bg, #fff);
    box-shadow: -16px 0 32px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 320ms ease;
}

    .filters-panel.active {
        transform: translateX(0);
    }

.filters-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--color-border);
    font-size: 18px;
}

.filters-panel__title {
    margin: 0;
    font-weight: 600;
}

.filters-panel__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    color: var(--color-text);
    cursor: pointer;
}

.filters-panel__body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.filters-panel__group-title {
    margin: 0 0 14px;
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-muted);
}

.filters-panel__sort-options {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filters-panel__sort-option {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    background: none;
    padding: 10px 12px;
    border-radius: 8px;
    font-family: inherit;
    font-size: var(--font-size-base);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

    .filters-panel__sort-option:hover {
        background: var(--color-bg);
        color: var(--color-text);
    }

    .filters-panel__sort-option.is-selected {
        background: var(--color-bg);
        color: var(--color-text);
        font-weight: 600;
    }

.filters-panel__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 24px;
    border-top: 1px solid var(--color-border);
}

.filters-panel__clear {
    border: none;
    background: none;
    padding: 0;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    text-decoration: underline;
    cursor: pointer;
}

    .filters-panel__clear[hidden] {
        display: none;
    }

    .filters-panel__clear:hover {
        color: var(--color-text);
    }

.filters-panel__apply {
    flex: 1;
    padding: 14px 24px;
    border: 1px solid var(--color-text);
    background: var(--color-text);
    color: #fff;
    border-radius: 8px;
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

    .filters-panel__apply:hover {
        background: var(--color-bg);
        color: var(--color-text);
    }

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- Prisintervall: textfält + dubbel-slider tillsammans ---------- */

.product-filters__price-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.product-filters__price-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

    .product-filters__price-field label {
        font-size: 11px;
        color: var(--color-text-muted);
        text-transform: uppercase;
        letter-spacing: 0.02em;
    }

    .product-filters__price-field input {
        width: 100%;
        border: 1px solid var(--color-border);
        border-radius: 8px;
        padding: 10px 12px;
        font-family: inherit;
        font-size: var(--font-size-base);
        color: var(--color-text);
    }

        .product-filters__price-field input:focus {
            outline: none;
            border-color: var(--color-text);
        }

.product-filters__price-sep {
    padding-bottom: 11px;
    color: var(--color-text-muted);
}

.price-slider {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.price-slider__track-wrap {
    position: relative;
    height: 20px;
}

.price-slider__track {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    transform: translateY(-50%);
    background: var(--color-border);
}

.price-slider__range {
    position: absolute;
    top: 50%;
    height: 2px;
    transform: translateY(-50%);
    background: var(--color-text);
}

.price-slider__input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 20px;
    margin: 0;
    background: none;
    -webkit-appearance: none;
    appearance: none;
    pointer-events: none;
}

    .price-slider__input::-webkit-slider-runnable-track {
        -webkit-appearance: none;
        background: none;
    }

    .price-slider__input::-moz-range-track {
        background: none;
        border: none;
    }

    .price-slider__input::-webkit-slider-thumb {
        -webkit-appearance: none;
        pointer-events: auto;
        width: 18px;
        height: 18px;
        border-radius: 50%;
        background: var(--color-text);
        border: 2px solid var(--header-bg, #fff);
        box-shadow: 0 0 0 1px var(--color-text);
        cursor: pointer;
        margin-top: 0;
    }

    .price-slider__input::-moz-range-thumb {
        pointer-events: auto;
        width: 18px;
        height: 18px;
        border-radius: 50%;
        background: var(--color-text);
        border: 2px solid var(--header-bg, #fff);
        box-shadow: 0 0 0 1px var(--color-text);
        cursor: pointer;
    }

.product-filters__checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: var(--font-size-base);
    cursor: pointer;
}

.product-filters__no-matches {
    text-align: center;
    color: var(--color-text-muted);
    padding: 48px 0;
}

/* ---------- Produktgrid ---------- */

.product-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 28px 20px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.product-card[data-reveal] {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 450ms ease, transform 450ms ease;
}

    .product-card[data-reveal].is-visible {
        opacity: 1;
        transform: translateY(0);
    }

@media (prefers-reduced-motion: reduce) {
    .product-card[data-reveal] {
        opacity: 1;
        transform: none;
        transition: none;
    }
}

.product-card__link {
    display: flex;
    flex-direction: column;
    height: 100%;
    color: inherit;
    text-decoration: none;
    padding: 10px;
    border-radius: 16px;
    background: linear-gradient(180deg, #ffffff 0%, #fcfbfa 100%);
    border: 1px solid rgba(24, 24, 27, 0.08);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03);
    transition: transform 240ms ease, box-shadow 240ms ease, border-color 240ms ease, background 240ms ease;
}

    .product-card__link:hover {
        transform: translateY(-4px);
        background: linear-gradient(180deg, #ffffff 0%, #fff7f7 100%);
        box-shadow: 0 14px 26px -10px rgba(185, 28, 28, 0.14);
        border-color: rgba(220, 38, 38, 0.28);
    }

.product-card__image-wrap {
    position: relative;
    aspect-ratio: 4 / 5;
    overflow: hidden;
    border-radius: 12px;
    background: var(--card-color, #f3f1ee);
    margin-bottom: 12px;
}

.product-card__image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity var(--transition-fast), transform 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

.product-card__image--hover {
    opacity: 0;
}

    .product-card__link:hover .product-card__image--hover {
        opacity: 1;
    }

    .product-card__link:hover .product-card__image {
        transform: scale(1.04);
    }

.product-card__badge {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(185, 28, 28, 0.9);
    backdrop-filter: blur(6px);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.product-card__info {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 4px;
    padding: 0 2px 2px;
}

.product-card__type {
    margin: 0;
    align-self: flex-start;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(220, 38, 38, 0.08);
    color: #b91c1c;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.product-card__sku {
    margin: 0;
    color: #71717a;
    font-size: 12px;
    line-height: 1.3;
}

.product-card__name {
    margin: 2px 0;
    font-size: var(--font-size-base);
    font-weight: 600;
    line-height: 1.35;
    color: #18181b;
    transition: color 200ms ease;
}

    .product-card__link:hover .product-card__name {
        color: #b91c1c;
    }

    .product-card__stock {
        margin: 0;
        font-size: 12px;
        font-weight: 600;
        line-height: 1.3;
    }

    .product-card__stock--in-stock {
        color: #166534;
    }

    .product-card__stock--low {
        color: #a16207;
    }

    .product-card__stock--backorder {
        color: #71717a;
    }

.product-card__price {
    margin: auto 0 0;
    padding: 5px 9px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: rgba(24, 24, 27, 0.035);
    font-size: var(--font-size-base);
    font-weight: 700;
    color: #18181b;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    transition: background 220ms ease, border-color 220ms ease, color 220ms ease;
}

    .product-card__price::after {
        content: "→";
        font-size: 13px;
        font-weight: 600;
        color: #b91c1c;
        opacity: 0.55;
        transform: translateX(0);
        transition: opacity 220ms ease, transform 220ms ease;
    }

.product-card__link:hover .product-card__price {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(22, 101, 52, 0.24);
    color: #18181b;
}

.product-card__link:hover .product-card__price::after {
    opacity: 1;
    transform: translateX(3px);
}

.product-card__price--sale {
    color: #dc2626;
    font-weight: 700;
}

.product-card__link:hover .product-card__price--sale {
    color: #18181b;
}

.product-card__price--compare {
    text-decoration: line-through;
    color: #71717a;
    font-size: 0.88em;
    font-weight: 400;
}

.product-listing__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 64px 24px;
}

.product-listing__empty-icon {
    color: var(--color-text-muted);
    margin-bottom: 16px;
}

.product-listing__empty-title {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text);
}

.product-listing__empty-text {
    margin: 0 0 20px;
    max-width: 420px;
    color: var(--color-text-muted);
    font-size: var(--font-size-base);
    line-height: 1.5;
}

.product-listing__empty-link {
    padding: 12px 28px;
    background: var(--color-text);
    color: #fff;
    border-radius: 8px;
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    transition: opacity var(--transition-fast);
}

    .product-listing__empty-link:hover {
        opacity: 0.85;
    }

/* ---------- Mellanläge (surfplatta) ---------- */

@media (max-width: 1100px) {
    .product-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 860px) {
    .product-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ---------- Mobilanpassning ---------- */

@media (max-width: 768px) {
    .product-listing__header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 20px 14px;
    }
}

@media (max-width: 480px) {
    .filters-panel {
        width: 100vw;
    }

    .product-listing__title-icon {
        flex-basis: 36px;
        width: 36px;
        height: 36px;
    }
}