:root {
    --glass-bg: rgba(255, 255, 255, 0.9);
    --header-grad: linear-gradient(135deg, #1e3799, #0984e3);
    --ridge-grad: linear-gradient(145deg, #ffffff, #d1d8e0);
    --text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    --accent: #eb4d4b;
    --success: #20bf6b;
    --skeleton: #e1e2e6;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'Segoe UI', Roboto, sans-serif;
    background: #f1f2f6;
    color: #2f3542;
    padding-top: 60px;
    overflow-x: hidden;
}

/* --- GLOBAL PAGE LOADER --- */
#pageLoader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #f1f2f6;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.4s ease, visibility 0.4s;
}

#pageLoader .spinner {
    font-size: 40px;
    color: #0984e3;
    margin-bottom: 15px;
    animation: spin 1s linear infinite;
}

#pageLoader h2 {
    font-size: 16px;
    color: #2f3542;
    letter-spacing: 1px;
}

@keyframes spin { 100% { transform: rotate(360deg); } }

/* --- STYLISH COMPACT HEADER --- */
header {
    background: var(--header-grad);
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1000;
    height: 55px;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    padding: 0 10px;
}

.header-container {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.brand-container {
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    flex-shrink: 0;
}

.brand-container img { height: 30px; width: auto; filter: drop-shadow(0 2px 2px rgba(0,0,0,0.3)); }

.brand-container h1 {
    font-size: 15px;
    color: white;
    font-weight: 800;
    text-shadow: var(--text-shadow);
    white-space: nowrap;
}

.search-wrapper {
    flex-grow: 1;
    position: relative;
    max-width: 100%;
}

.search-wrapper input {
    width: 100%;
    padding: 8px 12px 8px 32px;
    border-radius: 20px;
    border: none;
    outline: none;
    font-size: 13px;
    background: rgba(255,255,255,0.2);
    color: white;
    backdrop-filter: blur(5px);
    transition: 0.3s;
}

.search-wrapper input::placeholder { color: rgba(255,255,255,0.7); }
.search-wrapper input:focus { background: white; color: #333; }
.search-wrapper i {
    position: absolute;
    left: 10px; top: 50%;
    transform: translateY(-50%);
    color: white;
    font-size: 13px;
}

/* --- MOBILE-OPTIMIZED PRODUCT GRID --- */
.content-container { padding: 6px; }

.product-grid {
    display: grid;
    /* Forces 3 columns on mobile perfectly */
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.product-link { text-decoration: none; color: inherit; display: block; }

.product-card {
    background: #fff;
    padding: 5px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    border: 1px solid #e1e2e6;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    
    /* Performance Optimizations */
    content-visibility: auto;
    contain-intrinsic-size: 180px; 
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.product-card.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Image Box with Skeleton Loader */
.img-box {
    width: 100%;
    height: 85px;
    background: var(--skeleton);
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 5px;
    position: relative;
}

/* Shimmer Animation */
.img-box.loading::before {
    content: "";
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
    transform: translateX(-100%);
    animation: shimmer 1.2s infinite;
}

@keyframes shimmer { 100% { transform: translateX(100%); } }

.lazy-image {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lazy-image.loaded { opacity: 1; }

.p-name {
    font-size: 10px;
    font-weight: 700;
    line-height: 1.2;
    height: 24px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-bottom: 2px;
}

.p-price { font-size: 12px; font-weight: 900; color: var(--accent); margin-bottom: 2px; }

.p-location { font-size: 8px; color: #636e72; display: flex; align-items: center; gap: 3px; }

.p-stock {
    margin-top: 4px;
    padding-top: 3px;
    border-top: 1px solid #f1f2f6;
    font-size: 9px;
    font-weight: 800;
    color: var(--success);
}

.out-of-stock { color: var(--accent); }

/* Apply 3D Effects ONLY on devices that support hover (Desktops). Saves massive CPU on mobile */
@media (hover: hover) and (pointer: fine) {
    .product-card {
        border: 3px ridge #f1f2f6;
        box-shadow: 5px 5px 10px rgba(163, 177, 198, 0.4), -5px -5px 10px rgba(255, 255, 255, 0.8);
        transform-style: preserve-3d;
    }
    .product-card:hover {
        transform: translateY(-5px) rotateX(5deg) rotateY(2deg);
        border-color: #0984e3;
    }
    .img-box { transform: translateZ(20px); }
    .product-details { transform: translateZ(10px); }
}

@media (max-width: 360px) {
    .brand-container h1 { display: none; }
    .img-box { height: 75px; }
}