/* Product Catalog Styles - Based on template design */

/* Main content container */
.main-content {
    min-height: 100vh;
    background: #f8f9fa;
}

.product-catalog-section {
    padding: 40px 0;
}

/* Mobile Filter Toggle */
.mobile-filter-toggle {
    display: none;
    background: #da251c;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 600;
    margin-bottom: 20px;
    cursor: pointer;
    align-items: center;
    gap: 8px;
}

.mobile-filter-toggle .filter-icon {
    width: 16px;
    height: 16px;
    background: currentColor;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 17h4v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V5H3z'/%3E%3C/svg%3E")
        no-repeat center;
    mask-size: contain;
}

/* Catalog Container */
.catalog-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 30px;
    align-items: start;
}

/* Product Filters Sidebar */
.product-filters {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 20px;
    transition: transform 0.3s ease;
}

.filters-content {
    padding: 25px;
}

.filter-header {
    display: flex;
    justify-content: between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e9ecef;
}

.filter-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #2c3e50;
    margin: 0;
}

.mobile-filter-close {
    display: none;
    background: none;
    border: none;
    color: #6c757d;
    font-size: 1.5rem;
    cursor: pointer;
}

/* Filter Groups */
.filter-group {
    margin-bottom: 25px;
}

.filter-group:last-child {
    margin-bottom: 0;
}

.filter-group-title {
    font-size: 1rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 15px;
}

/* Search Form */
.search-form {
    margin-bottom: 0;
}

.search-input-group {
    position: relative;
    display: flex;
}

.search-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: border-color 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: #da251c;
}

.search-button {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: #da251c;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-icon {
    width: 16px;
    height: 16px;
    background: white;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E")
        no-repeat center;
    mask-size: contain;
}

/* Category Navigation */
.category-nav {
    margin: 0;
}

.category-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.category-item {
    margin-bottom: 8px;
}

.category-link {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    text-decoration: none;
    color: #6c757d;
    border-radius: 8px;
    transition: all 0.3s ease;
    position: relative;
}

.category-link:hover {
    background: #f8f9fa;
    color: #da251c;
    text-decoration: none;
}

.category-link.active {
    background: #da251c;
    color: white;
}

.category-icon {
    width: 16px;
    height: 16px;
    margin-right: 10px;
    background: currentColor;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z'/%3E%3C/svg%3E")
        no-repeat center;
    mask-size: contain;
}

.category-text {
    flex: 1;
    font-weight: 500;
}

.product-count {
    font-size: 0.85rem;
    opacity: 0.8;
    margin-left: auto;
}

/* Product List Section */
.product-list-section {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

/* Product List Header */
.product-list-header {
    padding: 25px 30px;
    border-bottom: 1px solid #e9ecef;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-title {
    font-size: 2rem;
    color: #2c3e50;
    margin: 0;
    font-weight: 700;
}

.product-count-display {
    color: #6c757d;
    font-size: 0.9rem;
    margin: 0;
}

/* Product Grid */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    padding: 30px;
    contain: layout style paint; /* Optimize rendering performance */
}

.product-item {
    display: block;
    text-decoration: none;
    border-radius: 12px;
    overflow: hidden;
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    position: relative;
    opacity: 1 !important; /* Ensure all product items are visible */
    transform: translateY(0); /* Ensure consistent initial position */
    will-change: transform; /* Optimize for transforms */
}

.product-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    text-decoration: none;
}

.product-image-container {
    position: relative;
    width: 100%;
    height: 200px;
    overflow: hidden;
    background: #f8f9fa;
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.product-item:hover .product-image {
    transform: scale(1.05);
}

.product-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(218, 37, 28, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    backface-visibility: hidden; /* Prevent flickering during transitions */
    -webkit-backface-visibility: hidden; /* For Safari */
    -webkit-font-smoothing: subpixel-antialiased; /* For smoother rendering */
}

.product-item:hover .product-overlay {
    opacity: 1;
}

.view-product {
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* No Products */
.no-products {
    text-align: center;
    padding: 60px 30px;
    color: #6c757d;
}

.no-products h3 {
    color: #495057;
    margin-bottom: 15px;
}

.no-products .btn {
    background: #da251c;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    text-decoration: none;
    margin-top: 20px;
    display: inline-block;
    transition: background 0.3s ease;
}

.no-products .btn:hover {
    background: #b91d14;
    text-decoration: none;
    color: white;
}

/* Load More Section */
.load-more-section {
    padding: 30px;
    text-align: center;
    border-top: 1px solid #e9ecef;
}

.load-more-btn {
    background: #da251c;
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.load-more-btn:hover {
    background: #b91d14;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(218, 37, 28, 0.3);
}

.load-more-btn.loading {
    opacity: 0.7;
    cursor: not-allowed;
}

.load-more-btn .btn-icon::after {
    content: "↓";
    font-size: 1.2em;
}

.pagination-wrapper {
    display: flex;
    justify-content: center;
}

/* Lightbox Modal Styles */
.lightbox-modal {
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.lightbox-modal.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.lightbox-container {
    background: white;
    border-radius: 15px;
    max-width: 900px;
    max-height: 90vh;
    width: 90%;
    overflow: hidden;
    position: relative;
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.lightbox-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    color: white;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: background 0.3s ease;
}

.lightbox-close:hover {
    background: rgba(0, 0, 0, 0.9);
}

.lightbox-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 400px;
}

.lightbox-image-container {
    position: relative;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

.lightbox-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    gap: 15px;
}

.lightbox-loading .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #da251c;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.lightbox-info {
    padding: 30px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.lightbox-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 10px;
}

.lightbox-category {
    display: inline-block;
    background: #e9ecef;
    color: #495057;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 20px;
    align-self: flex-start;
}

.lightbox-description p {
    color: #6c757d;
    line-height: 1.6;
    margin-bottom: 20px;
}

.lightbox-price-info {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 10px;
}

.lightbox-price {
    font-size: 1.5rem;
    font-weight: 700;
    color: #28a745;
}

.lightbox-unit {
    color: #6c757d;
    font-size: 1rem;
}

.lightbox-weight {
    color: #6c757d;
    font-size: 0.9rem;
    margin-bottom: 25px;
}

.lightbox-actions {
    display: flex;
    gap: 15px;
}

.btn-primary,
.btn-secondary {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn-primary {
    background: #da251c;
    color: white;
}

.btn-primary:hover {
    background: #b91d14;
    color: white;
    text-decoration: none;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    color: white;
    text-decoration: none;
}

/* Filter Overlay for Mobile */
.filter-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* Responsive Design */
@media (max-width: 768px) {
    .mobile-filter-toggle {
        display: flex;
    }

    .catalog-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .product-filters {
        position: fixed;
        top: 0;
        left: 0;
        width: 300px;
        height: 100vh;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        border-radius: 0;
        overflow-y: auto;
    }

    .product-filters.active {
        transform: translateX(0);
    }

    .mobile-filter-close {
        display: block;
    }

    .filter-overlay.active {
        display: block;
    }

    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
        padding: 20px;
    }

    .product-image-container {
        height: 150px;
    }

    .lightbox-content {
        grid-template-columns: 1fr;
        max-height: 80vh;
        overflow-y: auto;
    }

    .lightbox-image-container {
        height: 250px;
    }

    .lightbox-info {
        padding: 20px;
    }

    .lightbox-actions {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 10px;
        padding: 15px;
    }

    .product-image-container {
        height: 120px;
    }

    .section-title {
        font-size: 1.5rem;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}
