/* Smart filters inspired by the reference layout */
:root {
    --km-spf-accent: var(--km-color-accent, #b72129);
    --km-spf-accent-dark: #8d1620;
    --km-spf-border: #e4e4e7;
    --km-spf-muted: #6d6d76;
    --km-spf-heading: #1b1b1f;
}

.km-smart-filters-layout {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin-bottom: 2.5rem;
}

.km-smart-filters-layout__products {
    flex: 1;
    min-width: 0;
}

.km-smart-filters {
    width: 100%;
    border: none;
    padding: 0;
    background: transparent;
    position: relative;
}

.km-smart-filters__block + .km-smart-filters__block {
    margin-top: 2rem;
}

.km-smart-filters__block-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
}

.km-smart-filters__block-header h3 {
    margin: 0;
    font-size: 1rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.km-smart-filters__back-link {
    font-size: 0.9rem;
    color: var(--km-spf-muted);
    text-decoration: none;
}

.km-smart-filters__back-link:hover {
    color: var(--km-spf-accent);
}

.km-smart-filters__categories {
    list-style: none;
    margin: 1rem 0 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
}

.km-smart-filters__category a {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.6rem 1.35rem;
    border-radius: 999px;
    border: 1px solid #d1d5db;
    background: #fff;
    color: #1f1f22;
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.km-smart-filters__category.is-active a {
    border-color: var(--km-spf-accent);
    color: var(--km-spf-accent);
}

.km-smart-filters__category small {
    font-weight: 600;
}

.km-smart-filters__toolbar {
    margin-top: 1.5rem;
    background: #f5f5f5;
    border: 1px solid #e1e1e5;
    border-radius: 18px;
    padding: 1.25rem;
}

.km-smart-filters__toolbar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.9rem;
}

.km-smart-filters__toolbar-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.km-smart-filters__toolbar-count {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: #4b5563;
}

.km-smart-filters__form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.km-smart-filter {
    position: relative;
}

.km-smart-filter__header {
    margin: 0;
}

.km-smart-filter__title {
    width: 100%;
    margin: 0;
    padding: 0.55rem 1.25rem;
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid #d1d5db;
    border-radius: 999px;
    background: #fff;
    color: #1f1f22;
    text-transform: capitalize;
    letter-spacing: 0.03em;
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.85rem;
    min-width: 140px;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.km-smart-filter__title:focus-visible {
    outline: 2px solid var(--km-spf-accent);
    outline-offset: 2px;
}

.km-smart-filter__chevron {
    position: relative;
    width: 0.7rem;
    height: 0.7rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.km-smart-filter__chevron::before {
    content: '';
    width: 0.45rem;
    height: 0.45rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
}

.km-smart-filter.is-open .km-smart-filter__chevron::before {
    transform: rotate(225deg);
}

.km-smart-filter__body {
    position: absolute;
    top: calc(100% + 0.4rem);
    left: 0;
    min-width: 240px;
    padding: 0.75rem 1rem;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.18);
    z-index: 40;
}

.km-smart-filter__body[hidden] {
    display: none;
}

.km-smart-filter__terms {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 240px;
    overflow-y: auto;
}

.km-smart-filter__term {
    position: relative;
}

.km-smart-filter__term label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.45rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    font-size: 0.92rem;
    color: var(--km-spf-heading);
    cursor: pointer;
}

.km-smart-filter__term:last-child label {
    border-bottom: none;
}

.km-smart-filter__term label:hover {
    color: var(--km-spf-accent);
}

.km-smart-filter__checkbox {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.km-smart-filter__term small {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--km-spf-heading);
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 999px;
    padding: 0.1rem 0.55rem;
    min-width: 2.1rem;
    text-align: center;
}

.km-smart-filter__counter {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--km-spf-heading);
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 999px;
    padding: 0.08rem 0.5rem;
    min-width: 1.9rem;
    text-align: center;
}

.km-smart-filter__term.is-selected label {
    color: var(--km-spf-accent);
}

.km-smart-filter__term.is-selected small {
    color: var(--km-spf-accent);
    border-color: var(--km-spf-accent);
}

.km-smart-filter__term.is-disabled label {
    color: var(--km-spf-muted);
    cursor: not-allowed;
    opacity: 0.6;
}

.km-smart-filter__term.is-disabled label:hover {
    color: var(--km-spf-muted);
}

.km-smart-filter__term.is-disabled small {
    color: var(--km-spf-muted);
    border-color: rgba(0, 0, 0, 0.1);
}


.km-smart-filters__actions {
    margin-top: 0.75rem;
}

.km-smart-filters__actions--attributes {
    width: 100%;
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.km-smart-filters__reset {
    font-size: 0.9rem;
    color: var(--km-spf-muted);
    text-decoration: none;
}

.km-smart-filters__reset:hover {
    color: var(--km-spf-accent);
}

.km-smart-filters__apply.button {
    background: var(--km-spf-accent);
    color: #fff;
    border: none;
    padding: 0.65rem 1.8rem;
    border-radius: 999px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
}

.km-smart-filters__apply.button:hover {
    background: var(--km-spf-accent-dark);
}

.km-smart-filters__drawer-toggle {
    margin-bottom: 1rem;
}

.km-smart-filters__drawer-toggle-icon span {
    width: 18px;
    height: 2px;
    background: #fff;
}

.km-smart-filters__drawer-backdrop {
    display: none;
}

body.km-smart-filters-drawer-open .km-smart-filters__drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(3, 4, 10, 0.4);
    z-index: 1000;
}

.km-smart-filters__drawer-close {
    display: none;
}

@media (max-width: 1024px) {
    .km-smart-filters__drawer-toggle {
        display: inline-flex;
    }

    .km-smart-filters__drawer-backdrop {
        display: block;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    body.km-smart-filters-drawer-open .km-smart-filters__drawer-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .km-smart-filters {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: min(420px, 90vw);
        max-width: none;
        overflow-y: auto;
        transform: translateX(-110%);
        transition: transform 0.3s ease;
        z-index: 1001;
        background: #fff;
        padding: 2rem 1.5rem 2.5rem;
    }

    .km-smart-filters.is-drawer-open {
        transform: translateX(0);
    }

    .km-smart-filter__body {
        position: static;
        width: 100%;
        margin-top: 0.4rem;
        padding: 0.65rem 0 0;
        border: none;
        box-shadow: none;
    }

    .km-smart-filters__drawer-close {
        display: inline-flex;
        position: absolute;
        top: 1rem;
        right: 1rem;
        width: 34px;
        height: 34px;
        border-radius: 50%;
        border: 1px solid rgba(0, 0, 0, 0.1);
        background: #fff;
        justify-content: center;
        align-items: center;
    }

    body.km-smart-filters-drawer-open {
        overflow: hidden;
    }
}

@media (min-width: 1025px) {
    .km-smart-filters__drawer-toggle,
    .km-smart-filters__drawer-backdrop,
    .km-smart-filters__drawer-close {
        display: none !important;
    }
}
