:root {
    --primary: #FFAB00;
    --primary-dark: #FFC757;
    --accent: #ef4444;
    --dark: #1f2937;
    --light: #f3f4f6;
    --white: #ffffff;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --trans: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body { font-family: 'Inter', sans-serif; background: var(--light); margin: 0; padding-bottom: 100px; -webkit-tap-highlight-color: transparent; color: var(--dark); }

.header {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 15px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid #e5e7eb;
}
.header-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; max-width: 1200px; margin: 0 auto 15px auto; }
.brand { font-size: 1.25rem; font-weight: 800; color: var(--primary-dark); letter-spacing: -0.5px; }

.search-container { max-width: 1200px; margin: 0 auto; position: relative; }
.search-input {
    width: 100%;
    padding: 14px 20px 14px 45px;
    border: 2px solid transparent;
    border-radius: 12px;
    background: #f3f4f6;
    font-size: 16px;
    transition: var(--trans);
    box-sizing: border-box;
}
.search-input:focus { background: var(--white); border-color: var(--primary); outline: none; box-shadow: 0 0 0 4px rgba(5, 150, 105, 0.1); }
.search-icon { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); opacity: 0.5; }

/* Floating Cart */
.cart-float {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--dark);
    color: white;
    padding: 15px 25px;
    border-radius: 50px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    z-index: 90;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    transition: var(--trans);
    transform: translateY(100px);
}
.cart-float.visible { transform: translateY(0); }
.cart-float:hover { transform: scale(1.05); background: black; }
.cart-badge { background: var(--accent); color: white; padding: 2px 8px; border-radius: 10px; font-size: 0.8rem; }

/* Product Grid Layout */
.container { max-width: 1200px; margin: 30px auto; padding: 0 15px; }

.product-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    /* Standardized gap for desktop */
    gap: 40px 20px; 
}

/* Card Styling */
.product {
    background: var(--white);
    border-radius: 16px;
    padding: 15px;
    position: relative;
    display: flex;
    flex-direction: column;
    transition: var(--trans);
    border: 1px solid #e5e7eb;
    height: 100%; /* Ensures card takes full height of grid row */
    box-sizing: border-box;
    z-index: 1;
}

/* Hover effect */
.product:hover { 
    transform: translateY(-5px); 
    box-shadow: var(--shadow);
    border-color: var(--primary); 
    z-index: 10;
}

/* Disabled State for Out of Stock */
.product.disabled {
    opacity: 0.7;
    pointer-events: none; /* Prevents clicking */
    filter: grayscale(1);
}

.discount-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--accent);
    color: white;
    font-size: 0.75rem;
    font-weight: 800;
    padding: 4px 8px;
    border-radius: 8px;
    z-index: 11;
    box-shadow: 0 4px 6px rgba(239, 68, 68, 0.2);
}

.stock-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: #374151;
    color: white;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 4px 8px;
    border-radius: 4px;
    z-index: 11;
}

.img-wrapper { height: 140px; display: flex; align-items: center; justify-content: center; overflow: hidden; margin-bottom: 10px; }
.product img { max-height: 100%; max-width: 100%; transition: transform 0.5s ease; }

.part-badge { 
    display: inline-block;
    background: #f3f4f6; 
    color: #000000; 
    font-size: 0.7rem; 
    font-weight: 700; 
    padding: 4px 8px; 
    border-radius: 6px; 
    margin-bottom: 10px;
}

.desc { 
    font-size: 1.1rem;
    font-weight: 600;
    color: #000000;
    line-height: 1.2; 
    margin-bottom: 12px; 
    display: -webkit-box; 
    -webkit-line-clamp: 2; 
    -webkit-box-orient: vertical; 
    overflow: hidden; 
    height: 42px; /* Slightly taller for 1.1rem text */
    letter-spacing: -0.02em;
}
.price-row { margin-top: auto; display: flex; align-items: baseline; gap: 8px; margin-bottom: 15px; }
.price { font-size: 1.1rem; font-weight: 800; color: var(--dark); }
.mrp { font-size: 0.85rem; text-decoration: line-through; color: #d91818; }

.action-area { height: 40px; position: relative; }

.add-btn {
    width: 100%; background: var(--primary); color: white; border: none; padding: 10px;
    border-radius: 8px; font-weight: 600; cursor: pointer; transition: 0.2s; display: block;
}
.add-btn:active { transform: scale(0.95); }

.oos-btn {
    width: 100%; background: #9ca3af; color: white; border: none; padding: 10px;
    border-radius: 8px; font-weight: 600; cursor: not-allowed; display: block;
}

.qty-controls {
    display: none; width: 100%; height: 100%; align-items: center; justify-content: space-between;
    background: #f0fdf4; border: 1px solid var(--primary); border-radius: 8px; overflow: hidden;
}
.qty-controls.active { display: flex; }
.qty-btn { width: 35%; height: 100%; border: none; background: transparent; color: var(--primary-dark); font-weight: bold; font-size: 1.2rem; cursor: pointer; }
.qty-display { font-weight: 700; color: var(--dark); }

/* Responsive Grid Fixes */
@media (max-width: 992px) { 
    .product-grid { grid-template-columns: repeat(3, 1fr); } 
}

@media (max-width: 600px) { 
    .product-grid { 
        grid-template-columns: repeat(2, 1fr); 
        /* INCREASED ROW GAP to prevent overlapping on phones */
        gap: 35px 15px; 
    } 
    .container {
        margin: 20px auto;
    }
}

.spinner { border: 3px solid #f3f3f3; border-top: 3px solid var(--primary); border-radius: 50%; width: 40px; height: 40px; animation: spin 0.8s linear infinite; margin: 40px auto; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 1000; align-items: center; justify-content: center; backdrop-filter: blur(5px); }
.modal-content { background: white; width: 90%; max-width: 450px; border-radius: 20px; padding: 25px; max-height: 85vh; overflow-y: auto; position: relative; }
.input-group input { width: 100%; padding: 12px; margin-bottom: 12px; border: 1px solid #e5e7eb; border-radius: 8px; box-sizing: border-box; }
.primary-btn { width: 100%; background: var(--dark); color: white; padding: 15px; border: none; border-radius: 12px; font-weight: 700; cursor: pointer; }

#toast { visibility: hidden; min-width: 250px; background-color: #333; color: #fff; text-align: center; border-radius: 8px; padding: 12px; position: fixed; z-index: 101; left: 50%; bottom: 30px; transform: translateX(-50%); }
#toast.show { visibility: visible; animation: fadein 0.5s, fadeout 0.5s 2.5s; }
@keyframes fadein { from {bottom: 0; opacity: 0;} to {bottom: 30px; opacity: 1;} }
@keyframes fadeout { from {bottom: 30px; opacity: 1;} to {bottom: 0; opacity: 0;} }

.cart-list-item { display: flex; justify-content: space-between; align-items: center; padding: 15px 0; border-bottom: 1px dashed #e5e7eb; }
.mini-qty-ctrl { display: flex; align-items: center; background: #f3f4f6; border-radius: 6px; }
.mini-qty-btn { padding: 5px 10px; border: none; background: transparent; cursor: pointer; font-weight: bold; }
