/* ================= GENERAL ================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    color: #333;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

.page-title {
    text-align: center;
    margin: 15px 0 10px;
    font-weight: 700;
    color: #222;
    font-size: 20px;
    position: relative;
    padding: 0 12px;
}

.page-title::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 3px;
    background: linear-gradient(90deg, #007bff, #ff0011);
    border-radius: 2px;
}

/* ================= CONTAINER ================= */
.container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0 10px 15px;
    max-width: 100%;
    margin: 0 auto;
    width: 100%;
}

/* ================= FILTER SIDEBAR ================= */
.filters {
    width: 100%;
    padding: 15px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.08);
    border: 1px solid #e0e0e0;
    margin-bottom: 10px;
    order: -1;
}

.filters h4 {
    margin-bottom: 15px;
    font-weight: 700;
    color: #333;
    font-size: 17px;
    border-bottom: 2px solid #007bff;
    padding-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.filters h4::before {
    content: '⚙️';
    font-size: 15px;
}

.filters label {
    display: block;
    margin: 10px 0 5px;
    font-weight: 600;
    color: #555;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.filters input, .filters select {
    width: 100%;
    padding: 14px 12px;
    margin-top: 4px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    background: #fafafa;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    touch-action: manipulation;
    min-height: 48px;
}

.filters input:focus, .filters select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
    background: #fff;
}

/* Price Range Inputs */
.price-range-container {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.price-input-group {
    flex: 1;
}

.price-input-group label {
    font-size: 12px;
    color: #777;
    margin-bottom: 4px;
}

.price-input-group input {
    width: 100%;
    font-size: 14px;
    padding: 12px;
}

/* Reset Button */
.reset-filters-btn {
    width: 100%;
    padding: 15px;
    margin-top: 15px;
    background: linear-gradient(135deg, #ff0011 0%, #cc0000 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: 0 3px 10px rgba(255, 0, 17, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    touch-action: manipulation;
    min-height: 50px;
}

.reset-filters-btn:active {
    transform: scale(0.97);
    box-shadow: 0 2px 8px rgba(255, 0, 17, 0.2);
}

/* ================= CONTENT AREA ================= */
.contents {
    width: 100%;
    display: flex;
    flex-direction: column;
}

.content-top {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 12px;
    padding: 10px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    gap: 12px;
}

#result-count {
    font-weight: 700;
    font-size: 15px;
    color: #333;
    background: linear-gradient(90deg, #f8f9fa, #fff);
    padding: 10px 12px;
    border-radius: 6px;
    border-left: 3px solid #007bff;
    text-align: center;
}

#sort-price {
    width: 100%;
    padding: 14px 12px;
    border-radius: 8px;
    border: 2px solid #ddd;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: #fff;
    touch-action: manipulation;
    min-height: 50px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

#sort-price:active {
    border-color: #007bff;
    transform: scale(0.98);
}

/* ================= PRODUCTS GRID - MOBILE FIRST ================= */
.productsC {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    width: 100%;
}

/* Product Cards */
.products1 {
    background: #fff;
    padding: 0;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid #f0f0f0;
    overflow: hidden;
    position: relative;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    display: flex;
    flex-direction: column;
    height: 100%;
    text-decoration: none !important;
}

.products1:active {
    transform: scale(0.97);
    box-shadow: 0 1px 6px rgba(0,0,0,0.1);
}

.product-image {
    width: 100%;
    height: 120px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    background: #f8f9fa;
    flex-shrink: 0;
}

.products1 img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 4px;
}

.product-info {
    padding: 10px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.product-brand {
    font-size: 11px;
    color: #007bff;
    font-weight: 600;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.products1 h3 {
    font-size: 13px;
    margin: 0 0 6px;
    color: #222;
    font-weight: 600;
    line-height: 1.3;
    height: 40px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    display: -moz-box;
    -moz-box-orient: vertical;
    display: box;
    line-clamp: 2;
    box-orient: vertical;
    text-overflow: ellipsis;
    flex-grow: 1;
    text-decoration: none !important;
}

.price {
    margin-top: auto;
    padding-top: 8px;
    text-decoration: none !important;
}

.new-price {
    display: block;
    color: #ff0011;
    font-weight: 700;
    font-size: 14px;
    text-decoration: none !important;
}

.old-price {
    display: block;
    font-size: 11px;
    color: #888;
    margin-bottom: 2px;
    text-decoration: line-through;
}

/* No Results */
.no-results {
    grid-column: 1 / span 2;
    text-align: center;
    padding: 30px 15px;
    color: #666;
}

.no-results i {
    font-size: 35px;
    color: #ccc;
    margin-bottom: 12px;
    opacity: 0.7;
}

.no-results h3 {
    font-size: 16px;
    color: #444;
    margin-bottom: 8px;
}

.no-results p {
    font-size: 14px;
    color: #777;
}

/* HR Styling */
.filters hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, #007bff 0%, transparent 100%);
    margin: 12px 0 18px;
}

/* ================= MOBILE SPECIFIC IMPROVEMENTS ================= */
html, body {
    overflow-x: hidden;
    position: relative;
    max-width: 100vw;
}

/* Improve touch targets */
button, input[type="button"], input[type="submit"], select, .products1 {
    min-height: 44px;
    min-width: 44px;
}

/* Fix for custom PC card */
.custom-pc-card {
    display: block;
    text-decoration: none !important;
    color: inherit;
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    .products1 {
        -webkit-touch-callout: none;
    }
    
    input, select {
        font-size: 16px !important;
    }
}

/* Safe area insets */
@supports (padding: max(0px)) {
    .container {
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
        padding-bottom: max(15px, env(safe-area-inset-bottom));
    }
    
    .page-title {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }
}

/* ================= RESPONSIVE DESIGN ================= */

/* Extra Small Mobile */
@media screen and (max-width: 375px) {
    .productsC {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .product-image {
        height: 100px;
        padding: 8px;
    }
    
    .product-brand {
        font-size: 10px;
    }
    
    .products1 h3 {
        font-size: 12px;
        height: 36px;
        line-height: 1.2;
    }
    
    .product-info {
        padding: 8px;
    }
    
    .new-price {
        font-size: 13px;
    }
    
    .filters {
        padding: 12px;
    }
    
    .page-title {
        font-size: 18px;
        margin: 12px 0 10px;
    }
}

/* Small Mobile */
@media screen and (min-width: 376px) and (max-width: 414px) {
    .productsC {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .product-image {
        height: 110px;
    }
    
    .products1 h3 {
        font-size: 13px;
        height: 40px;
    }
    
    .new-price {
        font-size: 14px;
    }
}

/* Small Tablets */
@media screen and (min-width: 600px) {
    .container {
        padding: 0 15px 20px;
    }
    
    .productsC {
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
    }
    
    .product-image {
        height: 140px;
    }
    
    .product-brand {
        font-size: 12px;
    }
    
    .products1 h3 {
        font-size: 14px;
        height: 45px;
        -webkit-line-clamp: 3;
        line-clamp: 3;
    }
    
    .new-price {
        font-size: 16px;
    }
    
    .page-title {
        font-size: 22px;
    }
}

/* Tablets */
@media screen and (min-width: 768px) {
    .container {
        flex-direction: row;
        gap: 20px;
        padding: 0 15px 25px;
    }
    
    .filters {
        flex: 0 0 250px;
        order: 1;
        margin-bottom: 0;
        padding: 18px;
        position: sticky;
        top: 20px;
        align-self: flex-start;
        max-height: calc(100vh - 100px);
        overflow-y: auto;
    }
    
    .contents {
        order: 2;
        flex: 1;
    }
    
    .content-top {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 15px;
    }
    
    #result-count {
        text-align: left;
        width: auto;
        flex: 1;
    }
    
    #sort-price {
        width: auto;
        min-width: 180px;
        flex: 0 0 auto;
    }
    
    .productsC {
        grid-template-columns: repeat(3, 1fr);
        gap: 18px;
    }
    
    .product-image {
        height: 160px;
        padding: 15px;
    }
    
    .product-brand {
        font-size: 13px;
    }
    
    .products1 h3 {
        font-size: 15px;
        height: 55px;
        -webkit-line-clamp: 3;
        line-clamp: 3;
    }
    
    .new-price {
        font-size: 18px;
    }
    
    .products1:hover {
        transform: translateY(-5px);
        box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    }
    
    .products1:hover img {
        transform: scale(1.08);
    }
}

/* Laptops */
@media screen and (min-width: 1024px) {
    .container {
        gap: 25px;
        padding: 0 20px 30px;
        max-width: 1400px;
    }
    
    .filters {
        flex: 0 0 280px;
        padding: 20px;
    }
    
    .filters h4 {
        font-size: 20px;
    }
    
    .page-title {
        font-size: 28px;
        margin: 30px 0 20px;
    }
    
    .page-title::after {
        width: 60px;
    }
    
    .productsC {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
    }
    
    .product-image {
        height: 180px;
    }
    
    .products1 h3 {
        font-size: 15px;
        height: 60px;
        -webkit-line-clamp: 3;
        line-clamp: 3;
    }
    
    .new-price {
        font-size: 20px;
    }
}

/* Large Desktops */
@media screen and (min-width: 1200px) {
    .productsC {
        grid-template-columns: repeat(4, 1fr);
        gap: 25px;
    }
    
    .product-image {
        height: 200px;
    }
}

/* Loading animation */
.loading-products {
    grid-column: 1 / span 2;
    text-align: center;
    padding: 40px 20px;
}

.fa-spinner {
    color: #007bff;
    margin-bottom: 15px;
}

/* For tablets and up loading */
@media screen and (min-width: 600px) {
    .loading-products,
    .no-results {
        grid-column: 1 / span 3;
    }
}

@media screen and (min-width: 1024px) {
    .loading-products,
    .no-results {
        grid-column: 1 / span 4;
    }
}