/* ==========================================================================
   SHOP FILTERS
   ========================================================================== */

.em-filters {
    position: fixed;
    top: 0;
    left: 0;
    width: 360px;
    max-width: 100%;
    height: 100vh;
    background: var(--surface-card);
    box-shadow: var(--shadow-xl);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform var(--dur-slow) var(--ease-out);
}

.em-filters.is-open {
    transform: translateX(0);
}

/* Overlay */
.em-shop__filter-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(22, 21, 19, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all var(--dur-base);
    backdrop-filter: blur(4px);
}

.em-shop__filter-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

/* Filter Header */
.em-filters__header {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-5);
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.em-filters__title {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-family: var(--font-display);
    font-size: var(--fs-h4);
    font-weight: var(--fw-bold);
    color: var(--text-strong);
    margin: 0;
    flex: 1;
}

.em-filters__title .em-icon {
    width: 20px;
    height: 20px;
    color: var(--surface-brand);
}

.em-filters__count {
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-brand);
    color: var(--em-white);
    font-size: 11px;
    font-weight: var(--fw-bold);
    border-radius: var(--r-full);
    padding: 0 var(--sp-2);
}

.em-filters__clear {
    font-size: var(--fs-body-sm);
    color: var(--text-link);
    text-decoration: none;
}

.em-filters__clear:hover {
    text-decoration: underline;
}

.em-filters__close {
    color: var(--text-muted);
}

/* Filter Content */
.em-filters__content {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-4) 0;
}

.em-filters__content::-webkit-scrollbar {
    width: 6px;
}

.em-filters__content::-webkit-scrollbar-track {
    background: transparent;
}

.em-filters__content::-webkit-scrollbar-thumb {
    background: var(--border-subtle);
    border-radius: var(--r-full);
}

/* Filter Group */
.em-filter-group {
    border-bottom: 1px solid var(--border-subtle);
}

.em-filter-group__header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-4) var(--sp-5);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background var(--dur-fast);
}

.em-filter-group__header:hover {
    background: var(--surface-page);
}

.em-filter-group__header .em-icon {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    transition: transform var(--dur-fast);
}

.em-filter-group__header.is-active .em-icon {
    transform: rotate(180deg);
}

.em-filter-group__title {
    font-family: var(--font-display);
    font-size: var(--fs-body);
    font-weight: var(--fw-semibold);
    color: var(--text-strong);
}

.em-filter-group__content {
    display: none;
    padding: 0 var(--sp-5) var(--sp-5);
}

.em-filter-group__content.is-open {
    display: block;
}

/* Filter List */
.em-filter-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.em-filter-list__item {
    display: flex;
}

/* Checkbox */
.em-checkbox,
.em-radio {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    cursor: pointer;
    width: 100%;
}

.em-checkbox input,
.em-radio input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.em-checkbox__mark,
.em-radio__mark {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    border: 2px solid var(--border-strong);
    border-radius: var(--r-sm);
    background: var(--surface-card);
    transition: all var(--dur-fast);
    position: relative;
}

.em-radio__mark {
    border-radius: var(--r-full);
}

.em-checkbox.is-checked .em-checkbox__mark,
.em-radio.is-checked .em-radio__mark {
    background: var(--surface-brand);
    border-color: var(--surface-brand);
}

.em-checkbox.is-checked .em-checkbox__mark::after,
.em-radio.is-checked .em-radio__mark::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.em-checkbox.is-checked .em-checkbox__mark::after {
    width: 6px;
    height: 10px;
    border: solid var(--em-white);
    border-width: 0 2px 2px 0;
    transform: translate(-50%, -60%) rotate(45deg);
}

.em-radio.is-checked .em-radio__mark::after {
    width: 8px;
    height: 8px;
    background: var(--em-white);
    border-radius: var(--r-full);
}

.em-checkbox__label,
.em-radio__label {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--fs-body-sm);
    color: var(--text-body);
    flex: 1;
}

.em-checkbox__count {
    color: var(--text-muted);
    font-size: var(--fs-caption);
}

/* Price Range */
.em-price-range {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
}

.em-price-range__inputs {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
}

.em-price-range__inputs input {
    flex: 1;
    text-align: center;
}

.em-price-range__separator {
    color: var(--text-muted);
}

.em-price-range__slider {
    position: relative;
    height: 6px;
    margin: var(--sp-3) 0;
}

.em-price-range__track {
    position: absolute;
    top: 50%;
    left: 10px;
    right: 10px;
    height: 4px;
    background: var(--border-subtle);
    border-radius: var(--r-full);
    transform: translateY(-50%);
    z-index: 0;
}

.em-price-range__input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
    z-index: 1;
    outline: none;
}

.em-price-range__input::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    background: transparent;
    border: 0;
}

.em-price-range__input::-moz-range-track {
    width: 100%;
    height: 4px;
    background: transparent;
    border: 0;
}

.em-price-range__input::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--surface-brand);
    border: 3px solid var(--surface-card);
    border-radius: var(--r-full);
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    margin-top: -8px;
}

.em-price-range__input::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--surface-brand);
    border: 3px solid var(--surface-card);
    border-radius: var(--r-full);
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.em-price-range__labels {
    display: flex;
    justify-content: space-between;
    font-size: var(--fs-caption);
    color: var(--text-muted);
}

/* Rating Filter */
.em-filter-rating {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.em-stars {
    display: flex;
    gap: 2px;
}

.em-stars .em-icon {
    width: 14px;
    height: 14px;
    color: var(--em-line-strong);
    fill: transparent;
}

.em-stars .em-icon.is-active {
    color: var(--em-yellow-500);
    fill: currentColor;
}

.em-filter-rating .em-radio__label {
    min-width: 0;
}

.em-filter-rating .em-stars {
    flex: 1;
    min-width: 82px;
}

.em-radio__text {
    font-size: var(--fs-caption);
    color: var(--text-muted);
}

/* Color Swatches */
.em-filter-colors {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
}

.em-color-swatch {
    position: relative;
    cursor: pointer;
}

.em-color-swatch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.em-color-swatch__preview {
    display: block;
    width: 32px;
    height: 32px;
    border-radius: var(--r-md);
    border: 2px solid var(--border-subtle);
    transition: all var(--dur-fast);
}

.em-color-swatch.is-selected .em-color-swatch__preview {
    border-color: var(--surface-brand);
    box-shadow: 0 0 0 2px var(--surface-brand-soft);
}

.em-color-swatch:hover .em-color-swatch__preview {
    border-color: var(--surface-brand);
}

/* Size Chips */
.em-filter-sizes {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
}

.em-size-chip {
    position: relative;
    cursor: pointer;
}

.em-size-chip input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.em-size-chip span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 36px;
    padding: 0 var(--sp-3);
    background: var(--surface-page);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
    font-size: var(--fs-body-sm);
    font-weight: var(--fw-medium);
    color: var(--text-body);
    transition: all var(--dur-fast);
}

.em-size-chip:hover span {
    border-color: var(--surface-brand);
    color: var(--surface-brand);
}

.em-size-chip.is-selected span {
    background: var(--surface-brand);
    border-color: var(--surface-brand);
    color: var(--em-white);
}

/* Filter Footer */
.em-filters__footer {
    padding: var(--sp-4) var(--sp-5);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    flex-shrink: 0;
}

/* ==========================================================================
   ACTIVE FILTERS BAR
   ========================================================================== */

.em-shop__active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    padding: var(--sp-3) 0;
    margin-bottom: var(--sp-4);
}

.em-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    background: var(--surface-brand-soft);
    border-radius: var(--r-pill);
    font-size: var(--fs-caption);
    color: var(--text-link);
    text-decoration: none;
    transition: all var(--dur-fast);
}

.em-badge:hover {
    background: var(--surface-brand);
    color: var(--em-white);
}

.em-badge .em-icon {
    width: 14px;
    height: 14px;
}

.em-badge--filter {
    background: var(--surface-page);
    border: 1px solid var(--border-subtle);
    color: var(--text-body);
}

.em-badge--filter:hover {
    background: var(--status-error-bg);
    border-color: var(--status-error-text);
    color: var(--status-error-text);
}

/* ==========================================================================
   FILTER BUTTON (Mobile)
   ========================================================================== */

.em-shop__filter-btn {
    display: none;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-4);
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
    font-family: var(--font-display);
    font-size: var(--fs-body-sm);
    font-weight: var(--fw-semibold);
    color: var(--text-body);
    cursor: pointer;
    transition: all var(--dur-fast);
}

.em-shop__filter-btn:hover {
    border-color: var(--surface-brand);
    color: var(--surface-brand);
}

.em-shop__filter-btn .em-icon {
    width: 18px;
    height: 18px;
}

.em-shop__filter-btn .em-shop__filter-count {
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-brand);
    color: var(--em-white);
    font-size: 10px;
    font-weight: var(--fw-bold);
    border-radius: var(--r-full);
}

@media (max-width: 1023px) {
    .em-shop__filter-btn {
        display: flex;
    }
}

/* ==========================================================================
   DESKTOP SIDEBAR
   ========================================================================== */

@media (min-width: 1024px) {
    .em-filters {
        position: static;
        width: 248px;
        height: auto;
        box-shadow: none;
        transform: none;
        border-radius: var(--r-lg);
        background: var(--surface-card);
    }

    .em-filters__header {
        padding: var(--sp-4) var(--sp-5);
    }

    .em-filters__close {
        display: none;
    }

    .em-filters__content {
        padding-top: 0;
    }

    .em-filters__footer {
        display: none;
    }

    .em-filter-group__content {
        display: block;
    }

    .em-filter-group__header .em-icon {
        display: none;
    }
}

/* ==========================================================================
   MOBILE FILTER TOGGLE IN TOOLBAR
   ========================================================================== */

@media (max-width: 1023px) {
    .em-shop__toolbar-left {
        flex: 1;
    }

    .em-shop__toolbar-right {
        display: flex;
        align-items: center;
        gap: var(--sp-2);
    }
}

/* ==========================================================================
   LOADING STATE
   ========================================================================== */

.em-filters.is-loading {
    opacity: 0.6;
    pointer-events: none;
}

.em-filters.is-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 2px solid var(--surface-brand);
    border-right-color: transparent;
    border-radius: 50%;
    animation: emSpin 0.6s linear infinite;
}

@keyframes emSpin {
    to { transform: rotate(360deg); }
}
