/* ═══ SKELETON (Mimics Layout) ═══════════════════════════════ */
#skeleton {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg); z-index: 9999;
    transition: opacity 0.3s, visibility 0.3s;
}
#skeleton.hide { opacity: 0; visibility: hidden; }
#skeleton.done { display: none; }

.sk-nav { height: var(--nav-h); background: var(--card); border-bottom: 1px solid var(--border); }
.sk-layout { display: flex; height: calc(100vh - var(--nav-h)); margin-top: var(--nav-h); }
.sk-side { 
    width: 260px; background: var(--card); border-right: 1px solid var(--border); 
    position: sticky; top: var(--nav-h); height: calc(100vh - var(--nav-h));
    display: flex; flex-direction: column; gap: 20px; padding: 20px;
}
.sk-filter-head { height: 20px; background: var(--border); width: 60%; }
.sk-filter-item { height: 100px; background: var(--bg-alt); border-radius: 8px; }
.sk-main-content { flex: 1; padding: 24px; overflow-y: auto; }
.sk-head { height: 80px; background: var(--bg-alt); margin-bottom: 24px; border-radius: 8px; }
.sk-grid-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }
.sk-card { height: 280px; background: var(--border); border-radius: 8px; position: relative; overflow: hidden; }
.sk-card::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
    animation: skShimmer 1.5s infinite;
}
@keyframes skShimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

/* ═══ LAYOUT ══════════════════════════════════════════════════ */
.subcat-page-wrapper { background: var(--bg); min-height: 100vh; }
.layout-flex { display: flex; position: relative; align-items: flex-start; }

/* ═══ SIDEBAR ══════════════════════════════════════════════════ */
.filter-sidebar {
    width: 260px; background: var(--card);
    height: calc(100vh - var(--nav-h));
    position: sticky;
    top: calc(var(--nav-h) + 40px);
    border-right: 1px solid var(--border);
    flex-shrink: 0; z-index: 10;
    overflow-y: auto;
    transition: transform 0.3s ease;
}
.filter-inner { padding: 24px; }
.filter-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.filter-title { font-size: 16px; font-weight: 600; }
.close-filter-btn { background: none; border: none; cursor: pointer; padding: 4px; color: var(--muted);display:none; }
.clear-filter-btn { font-size: 13px; color: var(--accent); background: none; border: none; cursor: pointer; margin-bottom: 20px; display: block; }
.filter-group { margin-bottom: 28px; }
.filter-label { font-size: 14px; font-weight: 600; margin-bottom: 12px; display: block; color: var(--text); }
.filter-btn-group { display: flex; flex-wrap: wrap; gap: 8px; }

.size-btn {
    padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px;
    font-size: 12px; cursor: pointer; background: var(--bg); color: var(--muted); transition: all 0.2s;
}
.size-btn:hover { border-color: var(--text); color: var(--text); }
.size-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.checkbox-group { display: flex; flex-direction: column; gap: 10px; }
.checkbox-label { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text); cursor: pointer; }
.filter-checkbox { width: 16px; height: 16px; accent-color: var(--accent); }

/* Price Slider */
.price-slider-wrap { position: relative; height: 6px; margin: 20px 0 10px; }
.price-slider-track { position: absolute; width: 100%; background: var(--border); height: 100%; border-radius: 5px; }
.price-slider-fill { position: absolute; height: 100%; background: var(--accent); border-radius: 5px; left: 0; width: 100%; }
.price-range { position: absolute; width: 100%; height: 6px; background: none; pointer-events: none; appearance: none; top: 0; }
.price-range::-webkit-slider-thumb { height: 18px; width: 18px; border-radius: 50%; background: var(--accent); cursor: pointer; appearance: none; pointer-events: auto; margin-top: -6px; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.price-display { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }

/* Show Filter Button */
#showFilterBtn {
    position: fixed; left: 0; top: 50%; transform: translateY(-50%);
    background: var(--card); border: 1px solid var(--border); border-left: none;
    padding: 12px 8px; border-radius: 0 8px 8px 0; cursor: pointer;
    box-shadow: var(--sh-sm); z-index: 5; display: none;
}

/* ═══ MAIN CONTENT ════════════════════════════════════════════ */
.main-content { flex: 1; padding: 32px; min-width: 0; }
.page-header { margin-bottom: 32px; }
.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb .active { color: var(--text); font-weight: 500; }
.page-title { font-size: clamp(24px, 4vw, 32px); font-weight: 700; margin-bottom: 16px; color: var(--text); font-family: var(--font-heading); }
.header-bar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.sort-select { padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); font-size: 13px; cursor: pointer; outline: none; color: var(--text); }
.mobile-filter-btn { display: none; padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); font-size: 13px; gap: 6px; align-items: center; color: var(--text); cursor: pointer; }

.active-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 24px; }
.filter-tag { padding: 4px 10px; background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 4px; font-size: 12px; color: var(--accent); display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

/* Product Grid */
.product-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }
@media (max-width: 1200px) { .product-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px) { .product-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; } }

/* Product Card */
.product-card-wrap { background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; transition: transform 0.3s, box-shadow 0.3s; }
.product-card-wrap:hover { transform: translateY(-4px); box-shadow: var(--sh-md); }
.prod-badge-discount { position: absolute; top: 10px; left: 10px; font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 4px; z-index: 2; background:#16a34a;color:#fff }
.prod-badge { position: absolute; top: 10px; right: 10px; font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 4px; z-index: 2; background:#6b7280;color:#fff }

.loading-skeleton { padding: 20px 0; }
.end-msg { text-align: center; padding: 40px; color: var(--muted); }
.no-results { text-align: center; padding: 60px 20px; color: var(--muted); }

/* ═══ RESPONSIVE ══════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .mobile-filter-btn { display: inline-flex; }
    .close-filter-btn{display:block;}
    /* Mobile Sidebar: Position Fixed, High Z-Index */
    .filter-sidebar {
        position: fixed; left: 0; top: 40px; height: 100%; z-index: 1100; /* Higher than navbar usually */
        transform: translateX(-100%); box-shadow: var(--sh-lg);
    }
    .filter-sidebar.mobile-open { transform: translateX(0); }
    
    /* IMPORTANT: Push content down so it doesn't hide behind navbar */
    .filter-inner { padding-top: calc(24px + var(--nav-h)); }
    
    .main-content { margin-left: 0 !important; padding: 24px 16px; }
    #showFilterBtn { display: none; }
    
    /* Ensure mobile overlay is below sidebar but above content */
    .mobile-overlay { z-index: 1050; display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); }
}