
* {
    font-family: 'Inter', sans-serif;
}

:root {
    --card-bg: #fff;
    --muted: #6b7280;
    --accent: #0b74de;
    --shadow: 0 6px 18px rgba(12, 30, 50, 0.06);
    --radius: 5px;
    --gap: 16px;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--gap);
    align-items: start;
    width: 100%;
    box-sizing: border-box;
}

/* Responsive grid adjustments - Fix layout transitions */
@media (max-width: 768px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 12px;
    }
}

/* Ensure 2 cards layout for medium mobile */
@media (max-width: 580px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

/* Single card layout for very small screens */
@media (max-width: 400px) {
    .products-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

/* Card */
.product-card {
    background: transparent;
    border-radius: var(--radius);
    transition: transform .14s ease, box-shadow .14s ease;
    will-change: transform;
}

.product-card:hover,
.product-card:hover,
.product-card:focus-within {
    /* remove hover elevation/translate on the card itself; interaction will be on the button only */
    transform: none;
    filter: none;

    :root {
        --card-bg: #fff;
        --muted: #6b7280;
        --accent: #0b74de;
        --shadow: 0 10px 30px rgba(12, 30, 50, 0.08);
        /* slightly deeper shadow for larger cards */
        --radius: 12px;
        --gap: 20px;
        /* more breathing room between cards */
    }
}

/* inner clickable area */
.product-card-inner {
    background: var(--card-bg);
    border-radius: var(--radius);

    .products-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        /* larger min card width */
        gap: var(--gap);
        align-items: start;
    }

    overflow: hidden;
    display:flex;
    flex-direction:column;
    height:100%;
    box-shadow: var(--shadow);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    /* subtle border around the card for clearer separation */
    border: 1px solid #e6e9ef;

    .product-image {
        position: relative;
        width: 100%;
        height: 220px;
        /* taller image area for a more prominent product display */
        background: #f6f7fb;
        display: flex;
        /* center image to avoid awkward cropping */
        align-items: center;
        justify-content: center;
        overflow: hidden;
    }
}

/* Image */
.product-image {
    position: relative;
    width: 100%;
    height: 160px;

    /* fixed container height to keep card grid alignment */
    .product-info {
        padding: 16px;
        /* more internal padding */
        display: flex;
        flex-direction: column;
        gap: 16px;
        /* increased gap between info rows */
        flex: 1 1 auto;
    }

    background:#f6f7fb;
    display:flex;
    /* center image to avoid awkward cropping */
    align-items:center;
    justify-content:center;
    overflow:hidden;
}

.product-image img {
    /* keep the full image visible without cropping */
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

/* Clearance badge */
.product-name {
    margin: 0;
    font-size: 1.08rem;
    /* slightly larger title */
    line-height: 1.25;
    color: #111827;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    /* allow up to 2 lines, then clamp with ellipsis for long product names */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    /* standard property for newer browsers */
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.clearance-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: #ff4d4f;
    color: #fff;
    font-weight: 600;
    font-size: .75rem;
    padding: 4px 8px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

/* Info area */
.product-card-inner {
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
    box-shadow: var(--shadow);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    /* subtle border around the card for clearer separation */
    border: 1px solid #e6e9ef;
}

.product-info {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1 1 auto;
}

.product-category {
    font-size: .78rem;
    color: var(--muted);
}

.product-name {
    margin: 0;
    font-size: 1rem;
    line-height: 1.2;
    color: #111827;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    /* allow up to 2 lines, then clamp with ellipsis for long product names */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    /* standard property for newer browsers */
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* meta row */
.product-meta {
    display: flex;
    flex-direction: column;
    gap: 12px;
    /* consistent gap between meta rows */
    margin-top: auto;
}

.product-rating i {
    color: #f6b21a;
    margin-right: 4px;
}

.product-rating {
    display: flex;
    align-items: center;
    gap: 1px;
    margin-bottom: 0;
}

.review-count {
    font-size: 0.85rem;
    color: var(--muted);
    margin-left: 4px;
}

.product-price {
    font-weight: 700;
    color: var(--accent);
    text-align: right;
    white-space: nowrap;
    margin-top: 0;
    font-size: 1.16rem;
}

.discounted-price {
    font-size: 1.06rem;
    font-weight: 700;
}

.original-price {
    font-size: 0.95rem;
}

.meta-bottom {
    display: flex;
    align-items: center;
}

.product-price {
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
    padding-left: 12px;
}

.product-price.regular {
    color: var(--accent);
    border-left: 4px solid var(--accent);
}

.product-price.discounted {
    color: #e11d48;
    border-left: 4px solid #e11d48;
}

.price {
    color: var(--accent);
}

.discounted-price {
    color: #e11d48;
    margin-right: 8px;
}

.original-price {
    color: var(--muted);
    text-decoration: line-through;
    font-weight: 500;
    font-size: .92rem;
}

/* Actions */
.product-actions {
    margin-top: 8px;
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: stretch;
    /* allow children to stretch to full width */
}

.add-to-cart-btn {
    background: var(--accent);
    font-family: 'Inter', sans-serif;
    color: #fff;
    border: none;
    padding: 12px 18px;
    /* slightly larger clickable area */
    width: 100%;
    /* fill the available width so it aligns with product name */
    box-sizing: border-box;
    /* include padding in width calculation */
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    /* center icon/label; spinner will remain centered when label hidden */
    transition: background-color .18s ease, opacity .14s ease, transform .12s ease;
}

.add-to-cart-btn:disabled {
    opacity: .7;
    cursor: default;
}

.add-to-cart-btn:hover:not(:disabled) {
    /* subtle color change on hover to indicate interactivity */
    background-color: #095bb8;
    /* slightly darker blue */
    transform: none;
    box-shadow: none;
}

.add-to-cart-btn:focus {
    box-shadow: 0 0 0 3px rgba(11, 116, 222, 0.12);
    outline: none;
}

.add-to-cart-btn .icon {
    width: 18px;
    text-align: center;
}

.add-to-cart-btn .label {
    display: inline-block;
}

/* control spacing between icon and text inside the button */
.add-to-cart-btn .btn-content {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    /* increased gap between icon and label */
}

/* loading state */
.add-to-cart-btn.loading {
    opacity: 0.95;
}

.add-to-cart-btn.loading .icon {
    transform: none;
}

/* Loading state: hide the textual label so only the spinner icon is visible */
.add-to-cart-btn.loading .label {
    display: none !important;
}

/* Make sure the content remains centered when label is hidden */
.add-to-cart-btn.loading .btn-content {
    gap: 0;
}

/* Prevent pointer events while loading to avoid duplicate clicks */
.add-to-cart-btn.loading {
    pointer-events: none;
}

/* ensure spinner rotates smoothly when fa-spin is used */
.fa-spin {
    animation: spin 1s linear infinite;
}

/* Empty and loading */
.empty-state {
    text-align: center;
    padding: 32px;
    color: var(--muted);
}

.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 24px;
}

/* Spinner */
.spinner {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 4px solid rgba(0, 0, 0, 0.06);
    border-top-color: var(--accent);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Accessibility */
.product-card-inner:focus {
    outline: 3px solid rgba(11, 116, 222, 0.12);
    outline-offset: 3px;
}

/* Small screens */
@media (max-width:560px) {
    .product-image {
        height: 140px;
    }

    .product-name {
        font-size: .98rem;
        white-space: normal;
    }
}