:root {
    --primary-brown: #8B4513;
    --secondary-brown: #D2691E;
    --light-brown: #F5DEB3;
    --dark-brown: #5D4037;
    --accent-gold: #FFD700;
    --success-green: #4CAF50;
    --error-red: #F44336;
    --text-dark: #333333;
    --text-light: #666666;
    --bg-light: #FFF8F0;
    --bg-white: #FFFFFF;
    --shadow: 0 4px 12px rgba(139, 69, 19, 0.1);
    --shadow-lg: 0 8px 24px rgba(139, 69, 19, 0.15);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s ease;
}

/* Products Section */
.products-section {
    padding: 80px 20px;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
}

.section-header {
    text-align: center;
    margin-bottom: 60px;
    animation: fadeIn 0.8s ease;
}

.section-header h2 {
    font-size: 2.5rem;
    margin-bottom: 16px;
    color: var(--dark-brown);
    font-family: 'Playfair Display', serif;
    font-weight: 600;
    position: relative;
    display: inline-block;
}

.section-header h2::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-brown), var(--accent-gold));
    border-radius: 2px;
}

.section-header p {
    color: var(--text-light);
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Products Container */
/* Products Container */
.products-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 32px;
    position: relative;
}

/* Product Card - REMOVE FIXED HEIGHT */
.product-card {
    background-color: var(--bg-white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    animation: fadeInUp 0.6s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    /* REMOVE: height: 70%; */
    min-height: 380px; /* Add min-height instead */
    border: 1px solid rgba(139, 69, 19, 0.1);
}

/* Product Image - FIX FOR MOBILE */
.product-image {
    height: 180px; /* Fixed height for consistency */
    overflow: hidden;
    position: relative;
    background: linear-gradient(135deg, var(--light-brown), #fff);
    flex-shrink: 0; /* Prevent image from shrinking */
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}


.product-card:hover .product-image img {
    transform: scale(1.05);
}

.product-info {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    flex: 1; /* Take remaining space */
    min-height: 180px; /* Ensure enough space for content */
}

/* Stock Badge */
.out-of-stock {
    position: absolute;
    top: 16px;
    right: 16px;
    background-color: var(--error-red);
    color: white;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(244, 67, 54, 0.3);
}

/* New Badge */
.new-badge {
    position: absolute;
    top: 16px;
    left: 16px;
    background-color: var(--accent-gold);
    color: var(--dark-brown);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.3);
}

/* Sale Badge */
.sale-badge {
    position: absolute;
    top: 16px;
    right: 16px;
    background-color: var(--success-green);
    color: white;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}



.product-name {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--dark-brown);
    font-weight: 600;
    line-height: 1.4;
    min-height: 2.8em; /* Use em instead of px */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-description {
    color: var(--text-light);
    font-size: 0.85rem;
    margin-bottom: 12px;
    line-height: 1.5;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 3.8em; /* Minimum height for 3 lines */
}


/* Product Footer */
.product-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--light-brown);
    gap: 12px; /* Add gap for better spacing */
}

.product-price {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 80px; /* Prevent price from shrinking too much */
}

.current-price {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-brown);
    white-space: nowrap;
}


.current-price::before {
    content: '₹';
    font-size: 0.9em;
}

.original-price {
    font-size: 0.9rem;
    color: var(--text-light);
    text-decoration: line-through;
    display: flex;
    align-items: center;
    gap: 2px;
}

.original-price::before {
    content: '₹';
    font-size: 0.9em;
}

.discount {
    color: var(--success-green);
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 2px;
}

/* Add to Cart Button */
.btn-add-to-cart {
    background: linear-gradient(135deg, var(--primary-brown), var(--secondary-brown));
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 14px;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    flex-shrink: 0; /* Prevent button from shrinking */
    min-width: 120px; /* Minimum button width */
}

.btn-add-to-cart::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.btn-add-to-cart:hover::before {
    left: 100%;
}

.btn-add-to-cart:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--secondary-brown), var(--primary-brown));
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 69, 19, 0.2);
}

.btn-add-to-cart:active:not(:disabled) {
    transform: translateY(0);
}

.btn-add-to-cart:disabled {
    background: var(--text-light);
    cursor: not-allowed;
    opacity: 0.7;
}

.btn-add-to-cart.added {
    background: var(--success-green);
}

.btn-add-to-cart.added i {
    animation: bounce 0.3s ease;
}

@keyframes bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Product Category */
.product-category {
    position: absolute;
    bottom: 16px;
    left: 16px;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    color: var(--primary-brown);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 2;
}

/* Loading State */
.loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
    font-size: 1.1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    animation: fadeIn 0.5s ease;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--light-brown);
    border-top-color: var(--primary-brown);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Empty State */
.empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 80px 20px;
    color: var(--text-light);
    animation: fadeIn 0.5s ease;
}

.empty i {
    font-size: 48px;
    margin-bottom: 20px;
    opacity: 0.3;
}

.empty h3 {
    font-size: 1.5rem;
    margin-bottom: 12px;
    color: var(--dark-brown);
}

.empty p {
    font-size: 1rem;
    max-width: 400px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Error State */
.error {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--error-red);
    animation: fadeIn 0.5s ease;
    background-color: rgba(244, 67, 54, 0.05);
    border-radius: var(--radius);
    border: 1px solid rgba(244, 67, 54, 0.2);
}

.error i {
    font-size: 48px;
    margin-bottom: 20px;
}

.error h3 {
    font-size: 1.5rem;
    margin-bottom: 12px;
}

.error p {
    font-size: 1rem;
    margin-bottom: 20px;
    color: var(--text-dark);
}

.error button {
    background-color: var(--error-red);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.error button:hover {
    background-color: #d32f2f;
    transform: translateY(-2px);
}

/* Chocolate Type Indicators */
.choco-type-dark::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #5D4037;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

.choco-type-milk::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #D2691E;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

.choco-type-white::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #F5DEB3;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
    border: 1px solid #ddd;
}

/* Rating Stars */
.product-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 12px;
}

.stars {
    color: var(--accent-gold);
    font-size: 14px;
}

.rating-count {
    font-size: 12px;
    color: var(--text-light);
    margin-left: 4px;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .products-container {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 24px;
    }
    
    .product-image {
        height: 180px;
    }
    
    .product-name {
        font-size: 1.1rem;
        min-height: 52px;
    }
}

@media (max-width: 768px) {
    .products-section {
        padding: 60px 20px;
    }
    
    .section-header h2 {
        font-size: 2rem;
    }
    
    .section-header p {
        font-size: 1rem;
    }
    
    .products-container {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 20px;
        padding: 0 10px;
    }
    
    .product-card {
        min-height: 350px;
        margin: 0 auto;
        max-width: 100%;
    }
    
    .product-image {
        height: 160px;
    }
    
    .product-info {
        padding: 14px 16px;
        min-height: 170px;
    }
    
    .product-name {
        font-size: 1rem;
        min-height: 2.5em;
        -webkit-line-clamp: 2;
    }
    
    .product-description {
        font-size: 0.8rem;
        margin-bottom: 10px;
        -webkit-line-clamp: 3;
        min-height: 3.6em;
    }
    
    .product-footer {
        padding-top: 12px;
        gap: 10px;
        flex-wrap: nowrap; /* Prevent wrapping on mobile */
    }
    
    .current-price {
        font-size: 1.2rem;
    }
    
    .btn-add-to-cart {
        padding: 8px 14px;
        font-size: 13px;
        min-width: 110px;
    }
    
    .product-price {
        min-width: 70px;
    }
}

@media (max-width: 480px) {
  .products-container {
        grid-template-columns: 1fr;
        max-width: 320px;
        margin: 0 auto;
    }
    
    .product-card {
        min-height: 340px;
        width: 100%;
    }
    
    .product-image {
        height: 150px;
    }
    
    .product-footer {
        flex-direction: row; /* Keep horizontal layout */
        align-items: center;
    }
    
    .product-price {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .btn-add-to-cart {
        flex-shrink: 0;
        width: auto;
    }
    
    /* Ensure text doesn't overflow */
    .product-name,
    .product-description {
        word-break: break-word;
        overflow-wrap: break-word;
    }
    
    .section-header h2 {
        font-size: 1.8rem;
    }
}

/* Product Grid Animation */
.product-card {
    animation-delay: calc(var(--index, 0) * 0.1s);
}

/* Chocolate-themed hover effects */
.product-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-brown), var(--accent-gold), var(--secondary-brown));
    transform: scaleX(0);
    transition: transform 0.3s ease;
    transform-origin: left;
}

.product-card:hover::after {
    transform: scaleX(1);
}

@media (max-width: 360px) {
    .product-footer {
        flex-wrap: wrap; /* Allow wrapping on very small screens */
        justify-content: space-between;
    }
    
    .product-price {
        width: 100%;
        margin-bottom: 10px;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
    
    .btn-add-to-cart {
        width: 100%;
        min-width: 100%;
    }
    
    .product-card {
        min-height: 360px; /* Add more height for wrapped layout */
    }
}