body.filter-overlay-open { overflow: hidden; }

.filter-bar {
    display: flex;
    flex-direction: column;
    padding: 14px 16px;
    gap: 20px;
}

.filter-chips {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;

    &::-webkit-scrollbar {
        display: none;
    }

    .filter-chip {
        background: none;
        border: none;
        padding: 0;
        flex-shrink: 0;
        cursor: pointer;

        .value {
            display: flex;
            align-items: center;
            gap: 5px;
            font-size: 14px;
            font-weight: 500;
            line-height: 19px;
            color: var(--gray9-color);
            border-radius: 20px;
            border: 1px solid var(--gray2-color);
            padding: 8px 14px;
            white-space: nowrap;

            &::after {
                content: '';
                display: inline-block;
                width: 16px;
                height: 16px;
                transform: rotate(90deg);
                background: url('/assets/images/icon/ic-arrow-right-small-mono-5cffab2b20639092d4c2262e209b2118.svg') center / contain no-repeat;
            }
        }

        &.active .value {
            border-color: var(--primary-color);
            color: var(--primary-color);
            background: white;
        }

        &:focus-visible {
            outline: 2px solid var(--primary-color);
            outline-offset: 2px;
        }
    }
}

.filter-sorts {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    gap: 6px;

    .filter-sort-divider {
        font-size: 14px;
        color: var(--gray3-color);
        user-select: none;
    }

    .filter-sort {
        background: none;
        border: none;
        padding: 0;
        font-size: 14px;
        font-weight: 500;
        color: var(--gray3-color);
        cursor: pointer;

        &.active {
            color: var(--gray8-color);
        }
    }
}

.filter-overlay {
    position: fixed;
    left: 50%;
    bottom: 0;
    width: 100%;
    height: 100%;
    padding-top: var(--safe-top);
    max-width: 390px;
    z-index: 9999;
    background: #fff;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.08);
    transform: translate(-50%, 100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    visibility: hidden;

    &.open {
        transform: translate(-50%, 0);
        pointer-events: auto;
        visibility: visible;
    }

    @media screen and (max-width: 480px) {
        max-width: 100%;
    }

    /* 헤더 */
    .filter-header {
        position: relative;
        flex: 0 0 50px;
        height: 50px;
        min-height: 50px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #fff;

        .filter-close {
            position: absolute;
            left: 16px;
            top: 50%;
            transform: translateY(-50%);
            width: 24px;
            height: 24px;
            background: none;
            border: none;
            cursor: pointer;
            padding: 0;
        }

        .filter-title {
            font-size: 20px;
            font-weight: 600;
            color: #383838;
            margin: 0;
        }
    }

    /* 본문 */
    .filter-body {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;

        /* 탭 (선택적) */
        .filter-tabs {
            display: flex;
            border-bottom: 1px solid #f0f0f0;
            padding: 0 16px;
            flex-shrink: 0;

            .filter-tab {
                padding: 10px 20px;
                background: #fff;
                border: none;
                border-bottom: 5px solid transparent;
                font-size: 16px;
                font-weight: 500;
                color: #bbb;
                cursor: pointer;

                &.active {
                    color: #358ae3;
                    font-weight: 700;
                    border-bottom-color: #358ae3;
                }
            }
        }

        .filter-tab-panel {
            flex: 1 1 auto;
            min-height: 0;
            display: flex;
            flex-direction: column;

            &.hidden {
                display: none !important;
            }

            &[data-panel-style="chip"] {
                overflow-y: auto;
                padding: 24px 16px;

                .filter-section-title + .filter-chip-group + .filter-section-title {
                    margin-top: 12px;
                }
            }

            .filter-section-title {
                font-size: 18px;
                font-weight: 700;
                color: #383838;
                margin: 0 0 12px;
            }

            .filter-chip-group {
                display: flex;
                flex-wrap: wrap;
                gap: 10px;
                padding: 0 0 24px;

                .filter-chip {
                    padding: 8px 15px;
                    border-radius: 1000px;
                    border: 1px solid #e8e8e8;
                    background: #fff;
                    font-size: 14px;
                    font-weight: 600;
                    color: #555;
                    cursor: pointer;
                    white-space: nowrap;

                    &.active {
                        background: #ebf3fc;
                        border-color: #358ae3;
                        color: #358ae3;
                    }

                    &:focus-visible {
                        outline: 2px solid #358ae3;
                        outline-offset: 2px;
                    }
                }
            }
        }
    }

    /* 하단 */
    .filter-footer {
        flex-shrink: 0;
        border-top: 1px solid #f0f0f0;
        background: #fff;

        .filter-selected-bar {
            padding: 13px 16px 14px;
            border-bottom: 1px solid #f8f8f8;
            overflow-x: auto;

            &.hidden {
                display: none !important;
            }

            .filter-selected-chips {
                display: flex;
                gap: 10px;
                align-items: center;
                flex-wrap: nowrap;

                .filter-selected-chip {
                    display: inline-flex;
                    align-items: center;
                    gap: 3px;
                    padding: 8px 15px;
                    border-radius: 1000px;
                    background: #ebf3fc;
                    border: 1px solid #358ae3;
                    color: #358ae3;
                    font-size: 14px;
                    font-weight: 600;
                    white-space: nowrap;

                    .filter-selected-chip-x {
                        background: none;
                        border: none;
                        color: #358ae3;
                        font-size: 18px;
                        line-height: 1;
                        padding: 0 0 0 4px;
                        cursor: pointer;
                    }
                }
            }
        }

        .filter-actions {
            display: flex;
            align-items: center;
            padding: 16px;
            box-sizing: border-box;

            .filter-btn-reset {
                flex: 1 1 auto;
                display: inline-flex;
                align-items: center;
                justify-content: center;
                gap: 5px;
                padding: 10px 22px;
                background: none;
                border: none;
                color: #717171;
                font-size: 14px;
                font-weight: 600;
                cursor: pointer;
                height: 44px;

                &:focus-visible {
                    outline: 2px solid #358ae3;
                    outline-offset: 2px;
                }
            }

            .filter-btn-apply {
                flex: 0 0 230px;
                width: 230px;
                padding: 10px 20px;
                background: #358ae3;
                border: none;
                border-radius: 10px;
                color: #fff;
                font-size: 15px;
                font-weight: 700;
                cursor: pointer;

                &:active {
                    background: #2a7bd0;
                }

                &:focus-visible {
                    outline: 2px solid #358ae3;
                    outline-offset: 2px;
                }
            }
        }
    }
}
