/* 상품 목록 페이지 스타일 */
.products-section {
    padding: 60px 0;
    background-color: #f9fafb;
    min-height: calc(100vh - 400px);
}

.products-header {
    margin-bottom: 40px;
    text-align: center;
}

.products-header h1 {
    font-size: 2.5rem;
    color: #1f2937;
    margin-bottom: 15px;
}

.breadcrumb {
    display: flex;
    justify-content: center;
    gap: 10px;
    color: #6b7280;
    font-size: 0.95rem;
}

.breadcrumb a {
    color: #4b5563;
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumb a:hover {
    color: #3b82f6;
}

.breadcrumb span {
    color: #9ca3af;
}

/* 상품 컨테이너 */
.products-container {
    max-width: 1200px;
    margin: 0 auto;
}

/* 카테고리 필터 (상단) */
.category-filter-top {
    background: white;
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    overflow: visible; /* 서브 카테고리가 잘리지 않도록 */
}

.filter-section {
    margin-bottom: 30px;
    overflow: visible; /* 서브 카테고리가 잘리지 않도록 */
}

.filter-section:last-child {
    margin-bottom: 0;
}

.filter-section h3 {
    font-size: 1.1rem;
    color: #1f2937;
    margin-top: 0;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e5e7eb;
}

/* 카테고리 스크롤 컨테이너 */
.category-scroll-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: 15px;
}

.category-scroll-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: none;
    background: #f3f4f6;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4b5563;
    transition: all 0.2s;
    z-index: 10;
}

.category-scroll-btn:hover {
    background: #6b7280;
    color: white;
    transform: scale(1.1);
}

.category-scroll-btn:active {
    transform: scale(0.95);
}

.category-scroll-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.category-list-wrapper {
    flex: 1;
    overflow: hidden; /* 가로 스크롤 유지 */
    position: relative;
    height: 40px; /* 1줄 높이 */
}

.category-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-rows: 40px; /* 1줄만 */
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    gap: 12px;
    height: 100%;
    overflow-x: auto;
    overflow-y: visible; /* 세로는 넘칠 수 있도록 */
    scroll-behavior: smooth;
    scrollbar-width: none; /* Firefox */
}

/* 스크롤바 숨기기 */
.category-list::-webkit-scrollbar {
    display: none; /* Chrome, Safari */
}

.category-list > li {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.category-list > li > a {
    color: #4b5563;
    text-decoration: none;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    border-radius: 6px;
    background: #f3f4f6;
    white-space: nowrap;
    height: 40px;
    font-weight: 500;
}

.category-list a:hover {
    color: white;
    background: #6b7280;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(107, 114, 128, 0.2);
}

.category-list li.active > a {
    color: white;
    background: #4b5563;
    font-weight: 600;
}

/* Subcategory styles */
.subcategory-list {
    list-style: none;
    padding: 8px;
    margin: 0;
    display: none; /* 기본적으로 숨김 */
    flex-direction: column; /* 세로 레이아웃 */
    gap: 4px;
    width: auto;
    position: fixed; /* fixed로 변경하여 모든 컨테이너 밖으로 */
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 16px rgba(107, 114, 128, 0.15);
    border: 2px solid #e5e7eb;
    z-index: 1000; /* 더 높은 z-index */
    min-width: 180px;
    max-width: 250px;
    max-height: 200px; /* 최대 높이 제한 */
    overflow-y: auto; /* 세로 스크롤 */
}

.subcategory-list li {
    position: relative;
    width: 100%;
}

.subcategory-list a {
    font-size: 0.9rem;
    color: #4b5563;
    display: block;
    padding: 10px 16px;
    border-radius: 8px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
}

.subcategory-list a:hover {
    color: white;
    background: #6b7280;
    border-color: #6b7280;
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(107, 114, 128, 0.2);
}

.subcategory-list li.active a {
    color: white;
    background: #4b5563;
    border-color: #4b5563;
    font-weight: 600;
}

/* Loading state */
.loading-categories {
    color: #6b7280;
    font-size: 0.9rem;
    padding: 10px 0;
    font-style: italic;
}

/* 가격 범위 */
.price-range {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.range-inputs {
    display: flex;
    gap: 10px;
    align-items: center;
}

.range-inputs input {
    width: 80px;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
}

.range-inputs input:focus {
    outline: none;
    border-color: #FF6B35;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.btn-sm {
    padding: 8px 15px;
    font-size: 0.9rem;
}

/* 정렬 셀렉트 */
.sort-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.95rem;
    color: #4b5563;
    background-color: white;
    cursor: pointer;
}

.sort-select:focus {
    outline: none;
    border-color: #FF6B35;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* 상품 그리드 - 3열 고정 */
.products-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
    margin-bottom: 40px;
}

/* 상품 카드 */
.product-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0;
    overflow: hidden;
    transition: box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    position: relative;
}

.product-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.product-badge {
    position: absolute;
    top: 0;
    left: 0;
    background: #dc2626;
    color: white;
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 700;
    z-index: 1;
    border-radius: 0;
}

.product-badge[data-badge="HIT"] { background: #dc2626; }
.product-badge[data-badge="BEST"] { background: #7c3aed; }
.product-badge[data-badge="NEW"] { background: #16a34a; }
.product-badge[data-badge="POPULAR"] { background: #ea580c; }
.product-badge[data-badge="SALE"] { background: #dc2626; }

.product-image {
    width: 100%;
    height: 280px;
    overflow: hidden;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #e5e7eb;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 20px;
    transition: none;
}

.product-card:hover .product-image img {
    transform: none;
}

.product-details {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-category {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-bottom: 6px;
}

.product-card h3 {
    font-size: 0.95rem;
    color: #1f2937;
    margin: 0 0 12px;
    line-height: 1.4;
    font-weight: 400;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    min-height: 2.8rem;
}

.product-description {
    display: none;
}

.product-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
}

.product-features {
    display: none;
}

.product-price {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1f2937;
}

.product-price .original-price {
    font-size: 0.85rem;
    color: #9ca3af;
    text-decoration: line-through;
    margin-right: 6px;
    font-weight: 400;
}

.product-actions {
    display: flex;
    padding: 0 16px 16px;
    margin-top: 0;
}

.product-actions .btn {
    flex: 1;
    text-align: center;
    padding: 12px 16px;
    font-size: 0.9rem;
    border-radius: 0;
    font-weight: 500;
}

.product-actions .btn-outline {
    background: white;
    border: 1px solid #d1d5db;
    color: #374151;
}

.product-actions .btn-outline:hover {
    background: #f9fafb;
}

/* 페이지네이션 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 50px;
}

.page-nav,
.page-num {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border-radius: 8px;
    text-decoration: none;
    color: #4b5563;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.page-nav {
    font-size: 1.1rem;
}

.page-nav:hover:not(.disabled) {
    background: #f9fafb;
    border-color: #d1d5db;
    color: #1f2937;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.page-num:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    color: #1f2937;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.page-num.active {
    background: #4b5563;
    color: white;
    border-color: #4b5563;
    box-shadow: 0 2px 8px rgba(75, 85, 99, 0.3);
    font-weight: 600;
}

.page-nav.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #f9fafb;
    border-color: #e5e7eb;
    color: #9ca3af;
    box-shadow: none;
}

/* 반응형 디자인 */
@media (max-width: 1024px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .products-section {
        padding: 40px 0;
    }
    
    .products-header h1 {
        font-size: 2rem;
    }
    
    .product-actions {
        flex-direction: column;
    }
    
    .product-actions .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .products-header {
        margin-bottom: 30px;
    }
    
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .category-filter-top {
        padding: 20px;
    }
    
    .category-scroll-container {
        gap: 0; /* 버튼 간격 제거 */
    }
    
    .category-scroll-btn {
        display: none; /* 모바일에서 스크롤 버튼 숨김 */
    }
    
    .category-list-wrapper {
        height: 40px; /* 1줄 높이 */
        overflow-x: auto; /* 터치 스크롤 가능 */
        -webkit-overflow-scrolling: touch; /* iOS 부드러운 스크롤 */
    }
    
    .category-list {
        grid-template-rows: 40px; /* 1줄만 */
        gap: 8px;
        padding: 0 8px; /* 좌우 여백 추가 */
    }
    
    .category-list a {
        font-size: 0.85rem;
        padding: 6px 12px;
    }
    
    .filter-section h3 {
        font-size: 1rem;
    }
    
    .product-card h3 {
        font-size: 0.75rem;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        word-break: break-word;
        white-space: normal;
        line-height: 1.3;
    }
    
    .product-image {
        height: 150px;
    }
    
    .product-details {
        padding: 10px;
    }
    
    .product-price {
        font-size: 0.95rem;
    }
    
    .product-actions {
        padding: 0 10px 10px;
    }
    
    .product-actions .btn {
        padding: 8px 10px;
        font-size: 0.75rem;
    }
    
    .pagination {
        gap: 6px;
        margin-top: 30px;
    }
    
    .page-nav,
    .page-num {
        min-width: 36px;
        height: 36px;
        padding: 0 10px;
        font-size: 0.85rem;
    }
    
    .page-nav {
        font-size: 1rem;
    }
}
