* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: Arial, sans-serif;
}

body {
    background-color: #f5f5f5;
    color: #333;
}

header {
    background-color: #fff;
    padding: 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

header h1 {
    margin-bottom: 20px;
    color: #2c3e50;
}

.filters {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
}

select, input, button {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.search-container {
    display: flex;
    gap: 5px;
    flex-grow: 1;
}

#searchInput {
    flex-grow: 1;
}

#searchButton {
    button.add-to-cart-btn {
        display: block;
        margin: 0 auto;
        background-color: #3498db;
        color: white;
        border: none;
        padding: 10px 20px;
        cursor: pointer;
        transition: background-color 0.3s ease, transform 0.3s ease;
    }
    
    button.add-to-cart-btn:hover {
        background-color: #2980b9;
        transform: scale(1.05);
    }
    
    button.add-to-cart-btn:active {
        transform: scale(0.95);
    }
}

#searchButton:hover {
    background-color: #2980b9;
}

main {
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
    overflow-y: auto;
    height: calc(100vh - 160px);
}

.products-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.product-card {
    background-color: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
}

.add-to-cart-btn {
    align-self: center;
    margin-top: auto;
    margin-bottom: 10px;
    background-color: rgb(49, 95, 235);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.add-to-cart-btn:active {
    box-shadow: 0 0 10px rgba(49, 95, 235, 0.7);
}
.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.product-image {
    width: 100%;
    height: 200px;
    object-fit: contain;
}

.product-info {
    padding: 15px;
}

.product-name {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 5px;
    height: 40px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-name-en {
    font-size: 12px;
    color: #777;
    margin-bottom: 10px;
    height: 36px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-price {
    font-size: 18px;
    font-weight: bold;
    color: #e74c3c;
    margin-bottom: 5px;
}

.product-original-price {
    font-size: 14px;
    color: #999;
    text-decoration: line-through;
    margin-left: 5px;
}

.product-specs {
    font-size: 12px;
    color: #666;
    margin-bottom: 10px;
}

.product-stock {
    font-size: 12px;
    color: #666;
}

.product-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 10px;
}

.product-tag {
    background-color: #f1c40f;
    color: #333;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
}

.out-of-stock {
    position: relative;
}

.out-of-stock::after {
    content: "Out of Stock";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 18px;
    font-weight: bold;
    

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.cart-icon {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.cart-icon i {
    font-size: 24px;
    color: #333;
}

.cart-icon span {
    font-size: 14px;
    color: #333;
}

/* Lazy Loading Placeholder */
.product-image.lazy {
    /* Optional: Add a placeholder background or low-res image */
    background-color: #eee; /* Simple gray background */
    /* Optional: Add a transition for smoother loading */
    transition: opacity 0.3s ease-in-out;
    opacity: 0.5; /* Start slightly transparent */
}

.product-image:not(.lazy) {
    opacity: 1; /* Fully visible once loaded */
}

/* Pagination Controls Styling */
#paginationControls {
    text-align: center;
    margin-top: 20px;
    margin-bottom: 20px;
}

#paginationControls button {
    padding: 8px 16px;
    margin: 0 5px;
    cursor: pointer;
    border: 1px solid #ccc;
    background-color: #f8f8f8;
    border-radius: 4px;
}

#paginationControls button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

#paginationControls span {
    margin: 0 10px;
    vertical-align: middle;
}

/* Out of stock styling */
.product-card.out-of-stock {
    opacity: 0.6;
    /* Optional: Add a visual indicator */
    /* border: 2px dashed #ccc; */
}

.product-card.out-of-stock .add-to-cart-btn {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Cart Icon Styling */
.cart-icon {
    position: relative;
    display: inline-block;
    color: #333; /* Or your preferred color */
    text-decoration: none;
}

.cart-icon i {
    font-size: 1.5em; /* Adjust size as needed */
}

#cartItemCount {
    position: absolute;
    top: -8px;
    right: -10px;
    background-color: red;
    color: white;
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 0.8em;
    font-weight: bold;
    min-width: 18px; /* Ensure circle shape even for single digit */
    text-align: center;
    line-height: 1;
    display: block; /* Initially hidden if 0 */
}

/* Hide count if zero (handled by JS adding/removing has-items) */
.cart-icon:not(.has-items) #cartItemCount {
   /* display: none; */ /* Let JS handle visibility based on count > 0 */
}

.cart-icon.has-items #cartItemCount {
    display: block;
}}
