/* ========================================
   App-style Filter (from React mobile app)
   Design tokens: black=#061C1E, white=#FFF,
   border=#DAE2E5, bg=#F5F5F5, gray=#8C8C8C,
   orange=#F5A623
   ======================================== */

/* --- Overlay (mobile: fixed modal; desktop: inline block) --- */
.app-filter-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.4);
    display: none;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}
.app-filter-overlay.open {
    display: flex;
    opacity: 1;
    visibility: visible;
}

/* --- Bottom Sheet --- */
.app-filter-sheet {
    width: 100%;
    max-width: 480px;
    background: #fff;
    border-radius: 20px 20px 0 0;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}
.app-filter-overlay.open .app-filter-sheet {
    transform: translateY(0);
}

/* --- Header --- */
.app-filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid #DAE2E5;
    background: #fff;
    flex-shrink: 0;
}
.app-filter-header__spacer {
    width: 24px;
}
.app-filter-header__title {
    font-size: 16px;
    font-weight: 600;
    color: #061C1E;
}
.app-filter-header__close {
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 0;
}
.app-filter-header__close svg {
    width: 24px;
    height: 24px;
    stroke: #061C1E;
    stroke-width: 2;
    fill: none;
}

/* --- Scrollable content --- */
.app-filter-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* --- Section (collapsible) --- */
.app-filter-section {
    border-bottom: 1px solid #DAE2E5;
}
.app-filter-section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    cursor: pointer;
    user-select: none;
}
.app-filter-section__title {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: #061C1E;
    text-transform: uppercase;
}
.app-filter-section__chevron {
    width: 18px;
    height: 18px;
    color: #8C8C8C;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}
.app-filter-section.open .app-filter-section__chevron {
    transform: rotate(180deg);
}
.app-filter-section__body {
    padding: 0 20px 16px;
    display: none;
}
.app-filter-section.open .app-filter-section__body {
    display: block;
}

/* --- Chips container --- */
.app-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* --- Chip --- */
.app-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    border-radius: 20px;
    border: 1px solid #DAE2E5;
    background: #fff;
    color: #061C1E;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
    user-select: none;
    font-family: inherit;
    line-height: 1;
}
.app-filter-chip:hover {
    border-color: #061C1E;
}
.app-filter-chip--active {
    background: #061C1E;
    color: #fff;
    border-color: #061C1E;
}
.app-filter-chip--disabled {
    opacity: 0.35;
    pointer-events: none;
}

/* Color swatch inside chip */
.app-filter-chip__color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
}
.app-filter-chip__color--white {
    border: 1px solid #DAE2E5;
}

/* --- Radio button --- */
.app-filter-radio-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    cursor: pointer;
    border-bottom: 1px solid #F5F5F5;
}
.app-filter-radio-row:last-child {
    border-bottom: none;
}
.app-filter-radio {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid #DAE2E5;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s;
    flex-shrink: 0;
}
.app-filter-radio--selected {
    border-color: #061C1E;
}
.app-filter-radio__dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #061C1E;
}
.app-filter-radio-row span {
    font-size: 15px;
    color: #061C1E;
}

/* --- Checkbox --- */
.app-filter-checkbox-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    cursor: pointer;
}
.app-filter-checkbox {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 2px solid #DAE2E5;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    background: transparent;
}
.app-filter-checkbox--checked {
    background: #061C1E;
    border-color: #061C1E;
}
.app-filter-checkbox__check {
    width: 14px;
    height: 14px;
    stroke: #fff;
    stroke-width: 3;
    fill: none;
}
.app-filter-checkbox-row > span {
    font-size: 15px;
    color: #061C1E;
}

/* --- Price inputs --- */
.app-filter-price-inputs {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    margin: 16px 0;
}
.app-filter-price-field {
    flex: 1;
}
.app-filter-price-field label {
    display: block;
    font-size: 11px;
    color: #8C8C8C;
    text-transform: uppercase;
    margin-bottom: 6px;
}
.app-filter-price-input {
    width: 100%;
    height: 48px;
    padding: 0 14px;
    border: 1px solid #DAE2E5;
    border-radius: 12px;
    font-size: 15px;
    font-family: inherit;
    background: #F5F5F5;
    outline: none;
    color: #061C1E;
    box-sizing: border-box;
    -moz-appearance: textfield;
}
.app-filter-price-input::-webkit-inner-spin-button,
.app-filter-price-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.app-filter-price-input:focus {
    border-color: #061C1E;
}
.app-filter-price-dash {
    padding-bottom: 14px;
    color: #8C8C8C;
    font-size: 16px;
}

/* --- Price quick buttons --- */
.app-filter-price-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

/* --- Show more / Hide --- */
.app-filter-show-more {
    display: inline-block;
    margin-top: 10px;
    font-size: 13px;
    color: #8C8C8C;
    cursor: pointer;
    user-select: none;
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
}
.app-filter-show-more:hover {
    color: #061C1E;
}

/* --- Footer --- */
.app-filter-footer {
    padding: 16px 20px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #DAE2E5;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
}
.app-filter-btn-apply {
    width: 100%;
    height: 50px;
    border-radius: 12px;
    background: #061C1E;
    border: none;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.15s;
}
.app-filter-btn-apply:hover {
    opacity: 0.9;
}
.app-filter-btn-reset {
    width: 100%;
    height: 50px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid #DAE2E5;
    color: #061C1E;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.15s;
}
.app-filter-btn-reset:hover {
    border-color: #061C1E;
}

/* --- Badge (active filter count) --- */
.app-filter-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #F5A623;
    color: #fff;
    font-size: 9px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0 3px;
}

/* Filter trigger button (mobile only) */
.app-filter-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: transparent;
    border: 1px solid #DAE2E5;
    border-radius: 20px;
    cursor: pointer;
    position: relative;
    font-family: inherit;
    transition: border-color 0.15s;
}
.app-filter-trigger:hover {
    border-color: #061C1E;
}
.app-filter-trigger__icon svg {
    width: 16px;
    height: 16px;
    stroke: #061C1E;
    stroke-width: 2;
    fill: none;
}
.app-filter-trigger__text {
    font-size: 13px;
    font-weight: 500;
    color: #061C1E;
}

/* --- Price Histogram --- */
.price-histogram {
    height: 60px;
    display: flex;
    align-items: flex-end;
    gap: 2px;
    margin-bottom: 8px;
}
.price-histogram__bar {
    flex: 1;
    min-height: 2px;
    background: #E5E5E5;
    border-radius: 2px;
    transition: background 0.15s, height 0.2s;
}
.price-histogram__bar--active {
    background: #061C1E;
}

/* --- Custom Price Slider --- */
.price-slider {
    position: relative;
    height: 24px;
    touch-action: none;
    user-select: none;
}
.price-slider__rail {
    position: absolute;
    top: 10px;
    left: 0;
    right: 0;
    height: 4px;
    border-radius: 2px;
    background: #E5E5E5;
}
.price-slider__connect {
    position: absolute;
    top: 10px;
    height: 4px;
    border-radius: 2px;
    background: #061C1E;
}
.price-slider__handle {
    position: absolute;
    top: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #061C1E;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    cursor: grab;
    z-index: 2;
    transform: translateX(-50%);
}
.price-slider__handle--active {
    cursor: grabbing;
    z-index: 3;
}

/* --- Tick Marks --- */
.price-ticks {
    position: relative;
    height: 20px;
    margin-top: 4px;
}
.price-ticks__tick {
    position: absolute;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
}
.price-ticks__line {
    width: 1px;
    height: 4px;
    background: #CCC;
}
.price-ticks__label {
    font-size: 9px;
    color: #8C8C8C;
    margin-top: 2px;
    white-space: nowrap;
}

/* --- Body scroll lock when filter modal is open --- */
body.app-filter-lock {
    overflow: hidden;
}


/* ============================================================
   DESKTOP (>= 768px): Filter as inline sidebar
   ============================================================ */
@media (min-width: 768px) {
    /* Overlay becomes a normal block element, always visible */
    .app-filter-overlay {
        position: static !important;
        background: none !important;
        opacity: 1 !important;
        visibility: visible !important;
        z-index: auto !important;
        display: block !important;
        inset: auto !important;
    }

    .app-filter-sheet {
        max-width: none !important;
        border-radius: 0 !important;
        max-height: none !important;
        overflow: visible !important;
        transform: none !important;
        transition: none !important;
    }

    /* No modal header/footer on desktop */
    .app-filter-header {
        display: none !important;
    }
    .app-filter-footer {
        border-top: none;
        padding: 10px 0;
    }
    .app-filter-footer .app-filter-btn-apply {
        display: none;
    }
    .app-filter-footer .app-filter-btn-reset {
        height: 40px;
        font-size: 13px;
    }

    .app-filter-content {
        overflow: visible !important;
    }

    /* Section padding adapted for sidebar */
    .app-filter-section__header {
        padding: 14px 0;
    }
    .app-filter-section__body {
        padding: 0 0 14px;
    }

    /* Hide the mobile filter trigger button on desktop */
    .app-filter-trigger {
        display: none !important;
    }

    /* Hide old filter button on desktop */
    .filter-btn-open.js-filter__btn {
        display: none !important;
    }

    /* Never lock scroll on desktop */
    body.app-filter-lock {
        overflow: auto !important;
    }

    /* Price inputs slightly smaller for sidebar */
    .app-filter-price-input {
        height: 40px;
        font-size: 13px;
        border-radius: 10px;
    }
    .app-filter-price-field label {
        font-size: 10px;
    }
    .app-filter-chip {
        padding: 8px 12px;
        font-size: 12px;
    }
    .app-filter-radio-row span {
        font-size: 13px;
    }
}


/* ============================================================
   MOBILE (< 768px): Filter as bottom-sheet modal
   ============================================================ */
@media (max-width: 767.98px) {
    /*
     * Override the original .main-filter slide-in panel positioning.
     * We use the Vue overlay (.app-filter-overlay) instead.
     */
    .main-filter.js-filter {
        position: static !important;
        right: auto !important;
        width: auto !important;
        height: auto !important;
        z-index: auto !important;
        padding: 0 !important;
        overflow: visible !important;
        background: transparent !important;
        display: block !important;
        flex-direction: unset !important;
        transition: none !important;
    }

    /* Hide old filter button (replaced by .app-filter-trigger) */
    .filter-btn-open.js-filter__btn {
        display: none !important;
    }

    /* Hide old filter close button */
    .main-filter__close {
        display: none !important;
    }

    /*
     * Left sidebar: take no layout space, but keep overflow visible
     * so the position:fixed overlay inside can render on the viewport.
     */
    .catalog-page__left {
        flex: 0 0 0px !important;
        width: 0 !important;
        height: 0 !important;
        overflow: visible !important;
        padding: 0 !important;
        margin: 0 !important;
        border: 0 !important;
    }

    /* Right side takes full width */
    .catalog-page__right {
        width: 100% !important;
        flex: 1 1 100% !important;
        max-width: 100% !important;
    }
}
