/**
 * =====================================================================================
 * HELLA 3D MANAGEMENT SUITE: CATEGORY / PRODUCT LISTING PAGE (PLP) STYLESHEET
 * =====================================================================================
 * @file        category.css
 * @description Optimized grid layouts and dynamic hero section scaling for category views.
 * @version     1.0.0
 * @cleared     Jul 5, 2026
 * * ARCHITECTURE OVERVIEW:
 * 1. Responsive CSS Grid: Automatically scales columns based on viewport constraints 
 * to eliminate reliance on JS calculation for grid layouts.
 * 2. Hover Query Isolation: Confines intensive visual states (like drop-shadow increases) 
 * to fine-pointer devices using @media (hover: hover) to mitigate WebKit sticky bugs.
 * 3. JS State Hooks: Pre-defines visual logic for Javascript-injected interactions 
 * (such as .is-flipped for the mobile image toggle button).
 * =====================================================================================
 */

.smooth-scroll { scroll-behavior: smooth; }

/* --- 1. PERFORMANCE OVERRIDES & BACKGROUND --- */
.h3d-liquid-bg {
    isolation: isolate; 
    -webkit-mask-image: -webkit-radial-gradient(white, black);
}

.h3d-liquid-bg .blob {
    animation: none !important;
    transition: none !important;
    transform: translate3d(0, 0, 0); 
}

.page-main-content {
    position: relative;
    z-index: 10; 
    padding-top: 60px; 
    display: flex;
    flex-direction: column;
    align-items: center; 
    min-height: 70vh;
}

/* --- 2. DYNAMIC HERO SECTION --- */
.category-hero {
    text-align: center;
    max-width: 900px;
    width: calc(100% - 40px);
    margin: 0 auto 4rem auto;
    background-color: var(--glass-bg);
    background-image: var(--glass-noise);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 24px;
    padding: 3.5rem 2rem;
}

.category-hero h1 {
    font-size: 3.5rem;
    font-weight: 800;
    line-height: 1.1;
    color: #ffffff;
    margin-bottom: 1rem;
    text-transform: capitalize;
}

.category-hero p {
    font-size: 1.15rem;
    color: #b0b0b0;
    line-height: 1.6;
    max-width: 700px;
    margin: 0 auto;
}

/* --- 3. PRODUCT GRID & CARDS --- */
.showcase-wrapper { 
    max-width: 1800px; 
    width: calc(100% - 40px); 
    margin: 0 auto 6rem auto; 
    position: relative; 
    z-index: 10; 
}

.product-grid { 
    display: grid; 
    grid-template-columns: repeat(6, 1fr); 
    gap: 1.5rem; 
}

.product-card { 
    background-color: var(--glass-bg); 
    background-image: var(--glass-noise); 
    backdrop-filter: var(--glass-blur); 
    -webkit-backdrop-filter: var(--glass-blur); 
    border: 1px solid var(--glass-border); 
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); 
    border-radius: 16px; 
    overflow: hidden; 
    text-decoration: none; 
    display: flex; 
    flex-direction: column; 
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.3s ease; 
    -webkit-tap-highlight-color: transparent; /* Kills the mobile blue flash */
}

@media (hover: hover) and (pointer: fine) {
    .product-card:hover { 
        transform: translateY(-8px); 
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.15); 
        border-color: rgba(255, 59, 59, 0.3); 
    }
    .product-card:hover .product-image-container.has-hover img.primary-img { opacity: 0; }
    .product-card:hover .product-image-container.has-hover img.hover-img { opacity: 1; }
    .product-card:hover .product-add-icon { background: #ff3b3b; }
}

/* MOBILE JS TOGGLE OVERRIDE */
.product-card.is-flipped .primary-img { opacity: 0 !important; }
.product-card.is-flipped .hover-img { opacity: 1 !important; }

.product-image-container {
    width: 100%; 
    aspect-ratio: 3 / 2; 
    background: rgba(0, 0, 0, 0.2); 
    position: relative; 
    overflow: hidden; 
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.product-image-container img {
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
    transition: opacity 0.4s ease;
}

.product-image-container img.hover-img { opacity: 0; }

/* Mobile Image Toggle Button */
.mobile-image-toggle-btn {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    background-color: #1e1e1e; 
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    color: #ffffff;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease, transform 0.2s ease;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4); 
    -webkit-tap-highlight-color: transparent; /* Kills the mobile blue flash */
}

.mobile-image-toggle-btn:active {
    transform: scale(0.92);
}

.mobile-image-toggle-btn svg { width: 20px; height: 20px; pointer-events: none; }

.badge-container { 
    position: absolute; 
    top: 12px; 
    left: 12px; 
    display: flex; 
    flex-direction: column; 
    gap: 6px; 
    z-index: 5; 
}

.product-badge { 
    padding: 4px 8px; 
    border-radius: 4px; 
    font-size: 0.7rem; 
    font-weight: 800; 
    text-transform: uppercase; 
    letter-spacing: 1px; 
    color: white; 
    backdrop-filter: blur(4px); 
    -webkit-backdrop-filter: blur(4px); 
}

.badge-sale { background: rgba(255, 59, 59, 0.9); }
.badge-oos { background: rgba(85, 85, 85, 0.9); }
.badge-discontinuing { background: rgba(255, 152, 0, 0.9); color: #000; }

.product-details { 
    padding: 1.25rem 1.25rem 1.5rem 1.25rem; 
    display: flex; 
    flex-direction: column; 
    flex: 1; 
}

.product-tag { 
    font-size: 0.7rem; 
    font-weight: 800; 
    color: #ff3b3b; 
    text-transform: uppercase; 
    letter-spacing: 1.5px; 
    margin-bottom: 0.5rem; 
}

.product-title { 
    color: #ffffff; 
    font-size: 1rem; 
    font-weight: 700; 
    line-height: 1.4; 
    margin-bottom: 1.5rem; 
    display: -webkit-box; 
    -webkit-line-clamp: 2; 
    -webkit-box-orient: vertical; 
    overflow: hidden; 
}

.product-price-row { 
    margin-top: auto; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
}

.price-block { display: flex; align-items: center; gap: 8px; }
.product-price { font-size: 1.2rem; font-weight: 800; color: #ff3b3b; }
.price-original { text-decoration: line-through; color: #888; font-size: 0.9rem; font-weight: 500; }

.product-add-icon { 
    width: 34px; height: 34px; 
    background: rgba(255, 255, 255, 0.15); 
    border-radius: 50%; display: flex; align-items: center; justify-content: center; 
    color: #ffffff; transition: background 0.2s ease; 
}

/* --- 4. ERROR & EMPTY STATES --- */
.db-error-alert {
    color: #ff3b3b; 
    font-weight: 600; 
    grid-column: 1 / -1; 
    text-align: center; 
    padding: 2rem; 
    background: rgba(255,0,0,0.1); 
    border-radius: 8px; 
    border: 1px solid #ff3b3b;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    color: #888;
    font-size: 1.1rem;
    background: rgba(0,0,0,0.2);
    border-radius: 16px;
    border: 1px dashed rgba(255,255,255,0.1);
}

/* --- 5. RESPONSIVENESS --- */
@media (max-width: 1300px) { 
    .product-grid { grid-template-columns: repeat(3, 1fr); } 
}

@media (min-width: 1025px) {
    .hide-desktop { display: none !important; }
}

@media (max-width: 968px) { 
    .category-hero h1 { font-size: 2.5rem; }
    .product-grid { grid-template-columns: repeat(2, 1fr); gap: 1rem; } 
}

@media (max-width: 500px) { 
    .product-grid { grid-template-columns: 1fr; } 
}

/* --- 6. PAGINATION UI --- */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 2rem;
    width: 100%;
    grid-column: 1 / -1;
}

.page-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
    .page-btn:hover:not(:disabled) {
        background: rgba(255, 255, 255, 0.15);
        border-color: rgba(255, 59, 59, 0.5);
    }
}

.page-btn.active {
    background: #ff3b3b;
    border-color: #ff3b3b;
    color: white;
}

.page-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}