/* List page specific styles */
main {
    margin-bottom: 2rem; /* 모바일 기본값 */
}

@media (min-width: 768px) {
    main {
        margin-bottom: 2.5rem; /* 태블릿 */
    }
}

@media (min-width: 1200px) {
    main {
        margin-bottom: 3rem; /* 데스크탑 */
    }
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

@media (max-width: 1199.98px) {
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 575.98px) {
    .product-grid {
        grid-template-columns: 1fr;
    }
}

/* Product Card styles matching main page */
.product-card {
    position: relative;
    border: none;
    background-color: #f8f9fa;
    border-radius: 0.5rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    cursor: pointer;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.product-card.sold-out .product-image-wrapper {
    opacity: 0.7;
}

.btn-sold-out {
    background-color: #999;
    color: white !important;
    cursor: not-allowed;
    opacity: 1 !important;
    border: none;
}

.btn-sold-out:disabled {
    background-color: #999;
    color: white !important;
    opacity: 1 !important;
}

.product-card-header {
    height: 3.2rem;
    min-height: 3.2rem;
    overflow: hidden;
    padding: 0.25rem 0.5rem;
}

.product-badges {
    display: flex;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.badge-custom {
    display: inline-block;
    padding: 0.1em 0.4em;
    font-size: 0.8em;
    line-height: 1.5;
    font-weight: bold;
    color: var(--secondary-color);
    margin-right: 0.3em;
    background: none;
}

.wishlist-icon {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 2;
    font-size: 1.5rem;
    color: #767676;
}

.wishlist-icon:hover {
    color: #f00;
}

.product-image-wrapper {
    padding: 1rem 1.5rem 0.5rem;
    text-align: center;
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Safari ≤14, Samsung Internet ≤13 — aspect-ratio 미지원 폴백 */
@supports not (aspect-ratio: 1 / 1) {
    .product-image-wrapper {
        height: 0;
        padding-top: 100%;
        display: block;
    }
}

.product-card .card-img-top {
    width: 100%;
    height: 100%;
    object-fit: contain;
    position: absolute;
    top: 0;
    left: 0;
    padding: 1rem;
}

.product-card .card-body {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    padding: 1rem;
}

.product-card .card-title {
    font-size: var(--h5-font-size);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* 메인 페이지 카드와 동일한 가격 표시 — 원가 취소선 + 할인가 강조 */
.product-card .price-original {
    text-decoration: line-through;
    color: #777;
    font-size: 0.9em;
}

.product-card .price-discounted {
    font-weight: bold;
    color: var(--accent-color);
    font-size: var(--price-font-size);
}

@media (max-width: 767.98px) {
    .product-card .price-original { font-size: 0.75em; }
    .product-card .price-discounted { font-size: 0.95rem; }
}

.product-card .points {
    font-size: 0.9em;
    color: var(--secondary-color);
}

.product-card .features {
    font-size: 0.9em;
    list-style: circle inside;
    padding-left: 0.5rem;
    margin-bottom: 0.5rem;
    min-height: 2.8em;
    line-height: 1.4;
}

.product-card .features li {
    list-style: circle inside;
}

.product-card .features li:empty {
    list-style: none;
}

.product-card .rating {
    font-size: 0.9em;
    color: #e6a800;
}

.wishlist-count {
    font-size: 0.85em;
    color: var(--accent-color);
    display: inline-flex;
    align-items: center;
    background-color: #e9ecef;
    padding: 0.25rem 0.6rem;
    border-radius: 0.25rem;
    cursor: default;
}

.wishlist-count .bi {
    font-size: 1em;
    color: var(--primary-color);
}

/* Filter sidebar styles */
.filter-sidebar {
    position: relative;
    height: 100%;
    padding: 1.5rem 1.5rem;
    border-right: 1px solid #dee2e6;
    margin-bottom: 0;
    overflow-y: auto;
}

.filter-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    cursor: pointer;
}

.filter-sidebar-header h5 {
    margin-bottom: 0;
}

.filter-sidebar-content {
    padding-bottom: 1rem;
    transition: max-height 0.3s ease-in-out, opacity 0.3s ease-in-out;
    overflow: hidden;
    max-height: calc(100vh - 120px);
    opacity: 1;
}

.filter-sidebar-content.collapsed {
    max-height: 0;
    opacity: 0;
}

@media (max-width: 767.98px) {
    .filter-sidebar {
        padding-bottom: 5rem;
    }
}

@media (min-width: 768px) and (max-width: 1199.98px) {
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.filter-section {
    margin-bottom: 1.5rem;
}

.filter-heading {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    color: var(--accent-color);
    padding: 0.5rem;
    border-radius: 0.25rem;
    background-color: #f8f9fa;
}

.filter-group label {
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.filter-group label span {
    display: flex;
    align-items: center;
}

.form-check {
    display: flex;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-left: 1.5rem;
    cursor: pointer;
}

.form-check-input {
    margin-top: 0;
    margin-right: 0.75rem;
    flex-shrink: 0;
    opacity: 1;
    position: relative;
    display: inline-block;
    width: 18px;
    height: 18px;
    min-width: 18px;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    background-color: #fff;
    -webkit-appearance: checkbox;
    -moz-appearance: checkbox;
    appearance: checkbox;
}

.form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.form-check-input:checked ~ .form-check-label {
    color: var(--primary-color);
    font-weight: 500;
}

.form-check-label {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding-right: 0.5rem;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

.price-range {
    font-size: 0.85rem;
    color: #777;
    margin-left: auto;
    display: flex;
    align-items: center;
}

.sort-options {
    margin-right: 0.5rem;
}

.sort-select {
    max-width: 200px;
}

.size-select {
    /* i18n 안전 폭: EN "12 per page" / JA "12件ずつ" / KO "12개씩" 모두 잘림 없이 표시 */
    min-width: 130px;
}

/* 좁은 폭(<576) 에서 sort/size dropdown + filter button 이 한 줄에 못 들어가면
   타이틀과 컨트롤이 줄바꿈되도록 허용. EN "Recommended" + "12 per page" 가 한 줄에 안 들어가는 케이스 */
@media (max-width: 575.98px) {
    .col-xl-9.col-lg-8.col-md-7 > .d-flex.justify-content-between {
        flex-wrap: wrap;
        row-gap: 0.5rem;
    }
    .col-xl-9.col-lg-8.col-md-7 > .d-flex.justify-content-between > .d-flex {
        flex: 1 1 100%;
        justify-content: flex-end;
    }
    .sort-select {
        min-width: 130px;
    }
}

.pagination {
    margin-top: 2rem;
    justify-content: center;
}

.pagination .page-item .page-link {
    color: var(--accent-color);
}

.pagination .page-item.active .page-link {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

.product-count {
    font-size: 0.9rem;
    color: #777;
    margin-bottom: 1rem;
}

.filter-tag {
    display: inline-block;
    background-color: #f8f9fa;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.85rem;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}

.filter-tag .close {
    margin-left: 0.5rem;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
}

.active-filters {
    margin-bottom: 1rem;
}

/* 768px 이하 화면에서의 필터 레이어 팝업 */
@media (max-width: 767.98px) {
    .filter-container {
        position: fixed;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        z-index: 1050;
        transition: left 0.3s ease;
        background-color: #fff;
        padding: 0;
        margin: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    
    body.filter-open .filter-container {
        left: 0;
    }
    
    .filter-sidebar {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        padding: 0;
        border: none;
        margin: 0;
        height: auto;
    }
    
    .filter-sidebar-header {
        padding: 1rem 1.5rem;
        border-bottom: 1px solid #dee2e6;
        margin: 0;
        flex-shrink: 0;
        background-color: #fff;
        position: sticky;
        top: 0;
        z-index: 5;
    }
    
    .filter-sidebar-content {
        flex: 1;
        overflow-y: auto;
        padding: 1.5rem;
        padding-bottom: 6rem;
    }
    
    .filter-apply-container {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        background-color: #fff;
        padding: 1rem 1.5rem;
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
        z-index: 1060;
        border-top: 1px solid #dee2e6;
        margin: 0;
    }
    
    body:not(.filter-open) .filter-apply-container {
        display: none;
    }
    
    #closeFilterBtn {
        font-size: 1.5rem;
        cursor: pointer;
    }
    
    .filter-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1040;
        display: none;
    }
    
    .filter-overlay.active {
        display: block;
    }
    
    .filter-section {
        margin-bottom: 1.5rem;
        width: 100%;
    }
    
    .filter-group {
        padding: 0.75rem 0.5rem;
        width: 100%;
    }
    
    .form-check {
        padding-left: 2rem;
        margin-bottom: 1rem;
        width: 100%;
    }
    
    .filter-heading {
        padding: 0.75rem 0.5rem;
        background-color: #f8f9fa;
        border-radius: 0.25rem;
        margin-bottom: 0.5rem;
        width: 100%;
    }
}

/* 768px 초과 1024px 이하 화면에서의 필터 너비 제한 */
@media (min-width: 768px) and (max-width: 1199.98px) {
    .filter-container {
        max-width: 30%;
        flex: 0 0 30%;
    }
    
    .filter-sidebar {
        padding: 1.5rem 1rem;
    }
    
    /* 컨텐츠 영역 조정 */
    .col-md-7 {
        flex: 0 0 70%;
        max-width: 70%;
    }
}

/* 모바일용 필터 버튼 */
#showFilterBtn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 4px;
}

#showFilterBtn i {
    font-size: 1.1rem;
}

/* 필터 적용 버튼 컨테이너 스타일 */
.filter-apply-container {
    position: sticky;
    bottom: 0;
    background-color: #fff;
    padding: 1rem;
    margin: 0 -1.5rem -1.5rem;
    border-top: 1px solid #dee2e6;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 10;
}

/* 768px 이상 해상도에서는 적용하기 버튼 숨김 */
@media (min-width: 768px) {
    .filter-apply-container {
        display: none;
    }
}

#applyFilterBtn {
    font-weight: 500;
    transition: all 0.2s ease;
    height: 44px;
    font-size: 1rem;
    border-radius: 0.25rem;
}

/* 필터 태그 스타일 수정 */
.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.filter-tag {
    background-color: #f0f0f0;
    border-radius: 2rem;
    padding: 0.3rem 0.8rem;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-tag .close {
    color: #666;
    font-size: 1.2rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
}

.filter-tag .close:hover {
    background-color: rgba(0,0,0,0.1);
}

/* 모바일에서 적용 버튼 스타일 */
@media (max-width: 767.98px) {
    .filter-apply-container {
        padding: 1rem 1.5rem;
        margin: 0 -1.5rem -1.5rem;
    }
    
    .filter-sidebar {
        padding-bottom: 5rem;
    }
}

/* 필터 그룹에 패딩 추가 */
.filter-group {
    padding: 0.75rem 0.5rem;
}

/* 선택된 항목 스타일 (파란색 세로 막대 대신 체크박스 표시) */
.form-check-input:checked ~ .form-check-label::before {
    display: none;
}

/* 필터 섹션 토글 스타일 */
.toggle-section {
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

.filter-content {
    transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
    max-height: 500px;
    overflow: hidden;
    opacity: 1;
}

.filter-content.collapsed {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin: 0;
}

/* 아이콘 전환 애니메이션 */
.filter-heading i {
    transition: transform 0.3s ease;
}

.filter-heading:hover {
    background-color: #f0f0f0;
}

/* 1400px 이상 해상도에서 체크박스 영역 더 넓게 */
@media (min-width: 1400px) {
    .filter-sidebar {
        padding: 2rem;
    }
    
    .form-check {
        padding-left: 2rem; /* 더 큰 해상도에서 여백 더 증가 */
    }
    
    .filter-section {
        margin-bottom: 2rem;
    }
}

/* 정렬 옵션과 필터 버튼을 담는 컨테이너 */
.d-flex.align-items-center.gap-2 {
    display: flex;
    align-items: center;
}

/* 모바일에서 더 나은 레이아웃을 위한 미디어 쿼리 */
@media (max-width: 767.98px) {
    .d-flex.justify-content-between.align-items-center.mb-3 {
        flex-wrap: wrap;
    }
    
    .h4.mb-0 {
        font-size: 1.3rem;
        margin-bottom: 0.5rem !important;
    }
    
    .sort-select {
        font-size: 0.85rem;
        padding-right: 1.75rem;
    }
}

/* 데스크탑에서는 필터 버튼 숨김 */
@media (min-width: 768px) {
    #showFilterBtn {
        display: none;
    }
}

/* 모바일 필터 버튼 스타일 */
#mobileFilterBtn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 4px;
    background-color: #f8f9fa;
    border-color: #dee2e6;
}

#mobileFilterBtn i {
    font-size: 1.1rem;
    color: #495057;
}

#mobileFilterBtn:hover {
    background-color: #e9ecef;
}

/* 데스크탑에서는 필터 버튼 숨김 */
@media (min-width: 768px) {
    #mobileFilterBtn {
        display: none;
    }
}

/* 768px ~ 1200px 사이 폰트 크기 조정 */
@media (min-width: 768px) and (max-width: 1199.98px) {
    /* 필터 섹션 헤더 폰트 크기 */
    .filter-sidebar-header h5 {
        font-size: 0.95rem;
        margin-bottom: 0;
    }
    
    /* 필터 그룹 헤딩 폰트 크기 */
    .filter-heading {
        font-size: 0.9rem;
        padding: 0.5rem 0.4rem;
    }
    
    /* 체크박스 라벨 폰트 크기 */
    .form-check-label {
        font-size: 0.85rem;
    }
    
    /* 가격 범위 폰트 크기 */
    .price-range {
        font-size: 0.75rem;
    }
    
    /* 필터 섹션 간격 조정 */
    .filter-section {
        margin-bottom: 1.2rem;
    }
    
    /* 체크박스 위치 조정 */
    .form-check {
        margin-bottom: 0.6rem;
        padding-left: 1.2rem;
    }
    
    .form-check-input {
        width: 16px;
        height: 16px;
        min-width: 16px;
        margin-right: 0.5rem;
    }
    
    /* 필터 사이드바 패딩 조정 */
    .filter-sidebar {
        padding: 1.2rem 1rem;
    }
    
    /* 필터 그룹 패딩 조정 */
    .filter-group {
        padding: 0.5rem 0.3rem;
    }
}

/* 992px ~ 1200px 사이 추가 조정 (태블릿 가로 모드) */
@media (min-width: 992px) and (max-width: 1199.98px) {
    /* 필터 영역 너비 조정 - 좀 더 넓게 */
    .col-lg-4 {
        max-width: 33.333%;
        flex: 0 0 33.333%;
    }
    
    .col-lg-8 {
        max-width: 66.667%;
        flex: 0 0 66.667%;
    }
}

/* 768px ~ 992px 사이 추가 조정 (태블릿 세로 모드) */
@media (min-width: 768px) and (max-width: 991.98px) {
    /* 필터 헤더 여백 축소 */
    .filter-sidebar-header {
        margin-bottom: 1rem;
    }
    
    /* 필터 섹션 간격 더 축소 */
    .filter-section {
        margin-bottom: 1rem;
    }
    
    /* 체크박스 타이트하게 */
    .form-check {
        margin-bottom: 0.5rem;
    }
    
    /* 필터 사이드바 패딩 더 축소 */
    .filter-sidebar {
        padding: 1rem 0.8rem;
    }
    
    /* 제품 그리드 조정 - 2열로 설정 */
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
}

/* 제품 목록 타이틀과 정렬 옵션 폰트 크기 조정 */
@media (min-width: 768px) and (max-width: 1199.98px) {
    /* 제품 목록 타이틀 */
    .h4.mb-0 {
        font-size: 1.1rem;
    }
    
    /* 정렬 옵션 */
    .sort-select {
        font-size: 0.85rem;
    }
    
    /* 상품 카운트 */
    .product-count {
        font-size: 0.9rem;
    }
    
    /* 필터 태그 */
    .filter-tag {
        font-size: 0.8rem;
        padding: 0.2rem 0.6rem;
    }
}

/* 체크박스와 라벨에 커서 포인터 적용 */
.form-check-input,
.form-check-label {
    cursor: pointer;
}

/* 체크박스 클릭 영역 확장을 위한 스타일 */
.form-check {
    cursor: pointer;
}

/* 호버 효과 추가 */
.form-check:hover {
    background-color: rgba(0, 0, 0, 0.03);
    border-radius: 0.25rem;
}

/* 체크박스 라벨 스타일 보완 */
.form-check-label span {
    cursor: pointer;
}

/* 체크박스 내부 텍스트 선택 방지 */
.form-check-label {
    -webkit-user-select: none;
    user-select: none;
}

/* Price Range Slider Styles */
.price-range-slider {
    margin: 1rem 0;
    padding: 0 0.5rem;
}

/* noUiSlider 커스터마이징 */
.price-range-slider .noUi-connect {
    background: var(--primary-color, #8b6f47);
}

.price-range-slider .noUi-handle {
    border: 2px solid var(--primary-color, #8b6f47);
    background: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    cursor: pointer;
}

.price-range-slider .noUi-handle:before,
.price-range-slider .noUi-handle:after {
    background: var(--primary-color, #8b6f47);
}

.price-range-slider .noUi-handle:hover {
    border-color: var(--accent-color, #5d4e37);
}

.price-range-slider .noUi-handle:active {
    border-color: var(--accent-color, #5d4e37);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.price-range-slider .noUi-horizontal {
    height: 6px;
}

.price-range-slider .noUi-horizontal .noUi-handle {
    width: 20px;
    height: 20px;
    right: -10px;
    top: -7px;
}

/* 가격 입력 필드 스타일 개선 */
#filterMinPrice,
#filterMaxPrice {
    text-align: center;
    font-weight: 500;
}

/* 가격 입력 필드 포커스 스타일 */
#filterMinPrice:focus,
#filterMaxPrice:focus {
    border-color: var(--primary-color, #8b6f47);
    box-shadow: 0 0 0 0.2rem rgba(139, 111, 71, 0.25);
}

/* Pagination */
.pagination-container {
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.pagination {
    gap: 0.25rem;
}

.pagination .page-link {
    border: 1px solid #dee2e6;
    color: #333;
    padding: 0.5rem 0.75rem;
    min-width: 40px;
    text-align: center;
    border-radius: 0.375rem;
    transition: all 0.15s ease-in-out;
    font-size: 0.9rem;
}

.pagination .page-link:hover {
    background-color: #f0ebe3;
    border-color: var(--primary-color, #8b6f47);
    color: var(--primary-color, #8b6f47);
}

.pagination .page-item.active .page-link {
    background-color: var(--primary-color, #8b6f47);
    border-color: var(--primary-color, #8b6f47);
    color: #fff;
}

.pagination .page-item.disabled .page-link {
    color: #adb5bd;
    background-color: #fff;
    border-color: #dee2e6;
}

@media (max-width: 575.98px) {
    .pagination .page-link {
        padding: 0.4rem 0.6rem;
        min-width: 36px;
        font-size: 0.85rem;
    }
}