/* ===========================================
   Global Styles
   =========================================== */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.include {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ===========================================
   Header Styles
   =========================================== */

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e5e5e5;
}

.main-header h1 {
    font-size: 24px;
    font-weight: 600;
    color: #000;
}

.filter-count {
    display: inline-block;
    background: #000;
    color: white;
    font-size: 14px;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 10px;
    font-weight: normal;
}

.result-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

.total-count {
    font-size: 14px;
    color: #666;
}

.sort-options span {
    font-size: 14px;
    color: #000;
    cursor: pointer;
}

/* ===========================================
   Layout
   =========================================== */

.content-wrapper {
    display: flex;
    gap: 30px;
}

/* ===========================================
   Sidebar & Filter Styles
   =========================================== */

.sidebar {
    width: 200px;
    flex-shrink: 0;
}

.filter-section {
    margin-bottom: 25px;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 15px;
}

.filter-section:last-child {
    border-bottom: none;
}

.filter-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
    cursor: pointer;
    color: #000;
}

.filter-title i {
    font-size: 12px;
    color: #666;
}

.filter-content {
    display: block;
}

.filter-item {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    cursor: pointer;
}

.filter-item input[type="checkbox"] {
    margin-right: 10px;
}

.filter-item input[type="checkbox"]:focus {
    outline: none;
}

.filter-item input[type="checkbox"]:focus-visible {
    outline: 2px solid #000;
    outline-offset: 2px;
}

.filter-item label {
    font-size: 14px;
    color: #333;
    cursor: pointer;
    user-select: none;
}

.filter-icon {
    margin-right: 8px;
    font-size: 16px;
}

.filter-label {
    font-size: 14px;
    color: #333;
    margin-right: auto;
}

.filter-selected {
    font-size: 12px;
    color: #666;
}

/* Brand Filter Styles */
.brand-search {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
}

.brand-search:focus {
    border-color: #000;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

.brand-list {
    margin-top: 15px;
    max-height: 300px;
    overflow-y: auto;
}

.brand-list .filter-item:last-child {
    border-bottom: none;
}

.brand-list .filter-item.hidden {
    display: none;
}

.brand-list::-webkit-scrollbar {
    width: 6px;
}

.brand-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.brand-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
}

.brand-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Gender Filter Styles */
.gender-list {
    margin-top: 10px;
}

.gender-list .filter-item {
    margin-bottom: 12px;
    padding: 8px 0;
    border-bottom: 1px solid #f5f5f5;
}

.gender-list .filter-item:last-child {
    border-bottom: none;
}

.gender-list .filter-item label {
    font-size: 14px;
    color: #333;
    font-weight: 500;
}

/* Subcategory Filter Styles */
.subcategory-list {
    margin-left: 5px;
    margin-top: 8px;
    padding-left: 3px;
    border-left: 2px solid #e0e0e0;
    animation: slideDown 0.3s ease-out;
}

.subcategory-list.hidden {
    display: none;
}

.subcategory-item {
    margin-bottom: 8px;
    margin-left: 3px;
}

.subcategory-item input[type="checkbox"] {
    margin-left: 3px;
    margin-right: 8px;
}

.subcategory-item label {
    font-size: 13px;
    color: #555;
}

/* Tertiary Category Filter Styles */
.tertiary-list {
    margin-left: 10px;
    margin-top: 8px;
    padding-left: 5px;
    border-left: 2px solid #d0d0d0;
    animation: slideDown 0.3s ease-out;
}

.tertiary-list.hidden {
    display: none;
}

.tertiary-item {
    margin-bottom: 8px;
    margin-left: 5px;
}

.tertiary-item input[type="checkbox"] {
    margin-left: 5px;
    margin-right: 8px;
}

.tertiary-item label {
    font-size: 12px;
    color: #666;
    font-style: italic;
}

.sidebar::-webkit-scrollbar {
    height: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* ===========================================
   Product Grid & Card Styles
   =========================================== */

.product-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    width: 100%;
    justify-items: center;
    align-items: start;
}

.product-card {
    position: relative;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s ease;
    width: 100%;
    max-width: 100%;
    animation: fadeIn 0.6s ease-out;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.product-image {
    position: relative;
    overflow: hidden;
}

.product-image img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.product-card:hover .product-image img {
    transform: scale(1.05);
}

.wishlist-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255,255,255,0.9);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.wishlist-btn:hover {
    background: rgba(255,255,255,1);
    transform: scale(1.1);
}

.wishlist-btn:focus {
    outline: 2px solid #000;
    outline-offset: 2px;
}

.wishlist-btn i {
    font-size: 16px;
    color: #333;
}

.wishlist-btn:hover i {
    color: #ff6b6b;
}

.cart-btn {
    position: absolute;
    bottom: 12px;
    left: 12px;
    right: 12px;
    background: #333;
    color: white;
    border: none;
    padding: 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.product-card:hover .cart-btn {
    opacity: 1;
    transform: translateY(0);
}

.cart-btn:hover {
    background: #555;
}

.soldout-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.product-info {
    padding: 16px;
}

.brand {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.product-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    line-height: 1.4;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-size {
    font-size: 12px;
    color: #888;
    margin-bottom: 8px;
}

.product-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 12px;
}

.badge {
    display: inline-block;
    padding: 2px 6px;
    background: #f0f0f0;
    color: #666;
    font-size: 10px;
    border-radius: 4px;
    font-weight: 500;
}

.badge.shipping-info {
    background: #e3f2fd;
    color: #1976d2;
}

.product-price {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.price {
    font-size: 16px;
    font-weight: 700;
    color: #333;
}

.shipping {
    font-size: 11px;
    color: #888;
}

/* ===========================================
   Category Styles
   =========================================== */

.sct_ct {
    margin-bottom: 30px;
}

.main-category,
.sub-category,
.sub-sub-category,
.fourth-category {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.main-category li a,
.sub-category li a,
.sub-sub-category li a,
.fourth-category li a {
    display: block;
    padding: 8px 16px;
    background: #f8f9fa;
    border-radius: 20px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
}

.main-category li.active a,
.sub-category li.active a,
.sub-sub-category li.active a,
.fourth-category li.active a {
    background: #333;
    color: #fff;
}

.top_title {
    margin: 50px 0 0;
    padding: 0 20px;
}

.top_title .sub_title {
    font-size: 15px;
    color: #666;
    margin-bottom: 15px;
}

.top_title h2 {
    font-size: 32px;
    font-weight: 600;
    line-height: 1.4;
    color: #333;
}

/* ===========================================
   Animations
   =========================================== */

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
        margin-top: 0;
    }
    to {
        opacity: 1;
        max-height: 500px;
        margin-top: 8px;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===========================================
   Responsive Design
   =========================================== */

/* Large Desktop */
@media (max-width: 1200px) {
    .container {
        max-width: 1400px;
    }
    
    .product-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Tablet */
@media (max-width: 1024px) {
    .include {
        max-width: 100%;
        padding: 0 15px;
    }
}

/* Small Tablet */
@media (max-width: 992px) {
    .content-wrapper {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        display: flex;
        overflow-x: auto;
        gap: 20px;
        padding-bottom: 15px;
        border-bottom: 1px solid #e5e5e5;
        margin-bottom: 20px;
    }
    
    .filter-section {
        min-width: 200px;
        border-bottom: none;
        border-right: 1px solid #f0f0f0;
        padding-right: 20px;
    }
    
    .filter-section:last-child {
        border-right: none;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .main-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .result-info {
        width: 100%;
        justify-content: space-between;
    }
    
    .mobile-filters {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: stretch;
        gap: 10px;
    }

    /* 한 줄 배치: 각 항목 절반 너비, 버튼은 100%로 꽉 차게 */
    .mobile-filter-item {
        flex: 1 1 calc(50% - 5px);
        width: auto;
    }

    .mobile-filter-toggle {
        width: 100%;
    }
    
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
        width: 100%;
        justify-items: stretch;
        align-items: start;
    }
    
    .product-image {
        height: 200px;
    }
    
    .sidebar {
        display: none;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .product-grid {
        grid-template-columns: 1fr;
    }
    
    .main-header h1 {
        font-size: 20px;
    }
    
    .filter-count {
        font-size: 12px;
        padding: 1px 6px;
    }
}

/* ===========================================
   Mobile Filter Dropdown Styles
   =========================================== */

.mobile-filters {
    display: none;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.mobile-filter-item {
    position: relative;
    width: 100%;
}

.mobile-filter-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mobile-filter-toggle:hover {
    background: #fff;
    border-color: #dcdcdc;
}

.mobile-filter-toggle.active {
    background: #fff;
    border-color: #333;
}

.mobile-filter-toggle .filter-label {
    font-weight: 600;
    color: #333;
}

.mobile-filter-toggle .filter-value {
    flex: 1;
    text-align: right;
    color: #666;
    margin-right: 8px;
    font-size: 13px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    max-width: 150px;
}

.mobile-filter-toggle i {
    transition: transform 0.2s ease;
    color: #666;
    font-size: 12px;
}

.mobile-filter-toggle.active i {
    transform: rotate(180deg);
}

.mobile-filter-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    z-index: 1000;
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    transition: all 0.2s ease;
    max-height: 40vh; /* 모바일 40% 높이 */
    overflow: hidden;
    /* 터치 스크롤 최적화 */
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior: contain;
}

.mobile-filter-dropdown.active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}

.mobile-filter-content {
    max-height: calc(40vh - 52px); /* 액션 영역 높이 고려 */
    overflow-y: auto;
    padding: 8px 0;
    /* 스크롤 최적화 */
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
    /* 스크롤 시 터치 이벤트 간섭 방지 */
    touch-action: pan-y;
}

.mobile-category-item,
.mobile-brand-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid #f2f3f5;
    /* 강화된 스크롤 방지 및 터치 최적화 */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: manipulation;
    /* 터치 응답성 향상 */
    min-height: 44px;
    position: relative;
    overflow: hidden;
}

.mobile-category-item:hover,
.mobile-brand-item:hover {
    background: #f8f9fa;
}

/* 모바일에서 활성 상태 스타일 추가 */
.mobile-category-item:active,
.mobile-brand-item:active {
    background: #f0f1f3;
    transform: scale(0.98);
}

.mobile-category-item.selected,
.mobile-brand-item.selected {
    background: #f6f7f9;
    color: #333;
    font-weight: 500;
}

.mobile-category-item.selected::after,
.mobile-brand-item.selected::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #333;
}

.mobile-category-item:last-child,
.mobile-brand-item:last-child {
    border-bottom: none;
}

.mobile-subcategory {
    padding-left: 28px;
    font-size: 13px;
    color: #555;
}

.mobile-subcategory label {
    padding-left: 24px; /* 체크박스 위치 조정 */
}

.mobile-subcategory label::before {
    width: 17px;
    height: 17px;
    border: 1px solid #d0d0d0;
}

.mobile-tertiary {
    padding-left: 44px;
    font-size: 12px;
    color: #666;
    font-style: italic;
}

.mobile-tertiary label {
    font-size: 12px;
    color: #666;
    padding-left: 24px; /* 체크박스 위치 조정 */
}

.mobile-tertiary label::before {
    width: 16px;
    height: 16px;
    border: 1px solid #c8c8c8;
}

.mobile-tertiary-group {
    animation: slideDown 0.3s ease-out;
}

.mobile-tertiary-group.hidden {
    display: none;
}

.mobile-brand-search {
    width: 100%;
    padding: 10px 16px;
    border: none;
    border-bottom: 1px solid #e0e0e0;
    font-size: 14px;
    outline: none;
    background: #f8f9fa;
}

.mobile-brand-search:focus {
    background: #fff;
    border-bottom-color: #333;
}

/* Sticky search on brand dropdown for clean UX */
.mobile-brand-search {
    position: sticky;
    top: 0;
    z-index: 2;
}

/* Clean custom checkboxes like PC */
.mobile-filter-content input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
    z-index: -1;
}

.mobile-category-item label,
.mobile-brand-item label {
    position: relative;
    display: inline-block;
    font-size: 14px;
    padding-left: 28px;
    line-height: 1.4;
    cursor: pointer;
    user-select: none;
    /* 강화된 터치 최적화 */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    touch-action: manipulation;
    pointer-events: none; /* 레이블 자체 클릭 차단 */
    /* 레이블 터치 영역 확대 */
    min-height: 20px;
    display: flex;
    align-items: center;
    flex: 1;
}

.mobile-category-item label::before,
.mobile-brand-item label::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border: 1px solid #d8d8d8;
    border-radius: 4px;
    background: #fff;
    box-sizing: border-box;
}

.mobile-category-item input[type="checkbox"]:checked + label::before,
.mobile-brand-item input[type="checkbox"]:checked + label::before {
    border-color: #333;
    background: #333;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
    background-position: center;
    background-repeat: no-repeat;
}

.mobile-category-item input[type="checkbox"]:checked + label,
.mobile-brand-item input[type="checkbox"]:checked + label {
    color: #222;
    font-weight: 600;
}

.mobile-filter-actions {
    position: sticky;
    bottom: 0;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    padding: 8px;
}

.mobile-filter-apply {
    width: 100%;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.mobile-filter-apply:active {
    transform: translateY(1px);
}

.mobile-filter-content::-webkit-scrollbar {
    width: 4px;
}

.mobile-filter-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.mobile-filter-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 2px;
}

.mobile-filter-content::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* ===========================================
   Utility Classes
   =========================================== */

.hidden {
    display: none !important;
}

/* Ensure mobile filters layout on mobile (override late base rules) */
@media (max-width: 768px) {
    .mobile-filters {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: stretch;
        gap: 10px;
    }
    .mobile-filter-item {
        width: auto; /* override base width:100% */
        flex: 0 0 calc(50% - 5px);
    }
    .mobile-filter-toggle {
        width: 100%;
    }
}