/* ============================================================
   PRODUCT GRID LAYOUT
   ============================================================ */

.product-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    width: 100%;
    margin: 0;
    padding: 0;
}

/* ============================================================
   PRODUCT CARD STYLING
   ============================================================ */

.product-card {
    background: var(--background-color4, #f0efef);
    border: 2px solid var(--border-color2, #3a8a3493);
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 2px 8px var(--shadow-color, rgba(0, 0, 0, 0.6));
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px var(--shadow-color, rgba(0, 0, 0, 0.8));
}

.product-card a {
    display: flex;
    flex-direction: column;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

/* ============================================================
   PRODUCT IMAGE
   ============================================================ */

.product-image {
    position: relative;
    width: 100%;
    padding-top: 75%; /* 4:3 aspect ratio */
    overflow: hidden;
    background: var(--background-color3, #e4e3e3);
}

.product-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.product-card:hover .product-image img {
    transform: scale(1.05);
}

.product-image .no-image {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-color-secondary, #666);
    font-size: 0.9rem;
    text-align: center;
}

.featured-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: var(--primary-color, #1d6316);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
    box-shadow: 0 2px 4px var(--shadow-color, rgba(0, 0, 0, 0.6));
}

/* ============================================================
   PRODUCT INFO
   ============================================================ */

.product-info {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.product-info h3 {
    font-family: var(--main-font-family2, 'Science Gothic', 'Roboto', sans-serif);
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--primary-color, #1d6316);
    margin: 0 0 0.5rem 0;
    line-height: 1.3;
}

.product-sku {
    font-size: 0.875rem;
    color: var(--text-color-secondary, #666);
    margin: 0 0 0.5rem 0;
}

.product-spec {
    font-size: 0.875rem;
    color: var(--text-color, #333);
    margin: 0 0 0.5rem 0;
}

.product-description {
    font-size: 0.875rem;
    color: var(--text-color, #333);
    margin: 0 0 1rem 0;
    line-height: 1.5;
    flex-grow: 1;
}

/* ============================================================
   PRODUCT ACTIONS
   ============================================================ */

.product-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color, #ddd);
}

.product-price {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--primary-color, #1d6316);
}

.product-price .price {
    color: var(--primary-color, #1d6316);
}

.call-for-pricing {
    color: var(--text-color-secondary, #666);
    font-size: 0.9rem;
    font-style: italic;
}

.btn-add-to-cart {
    background: var(--primary-color, #1d6316);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: bold;
    transition: background 0.3s ease;
}

.btn-add-to-cart:hover {
    background: var(--highlight-color, #2e8a25);
}

/* ============================================================
   RESPONSIVE DESIGN
   ============================================================ */

/* Tablet: 2 columns */
@media (max-width: 1023px) {
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }
}

/* Mobile: 1 column */
@media (max-width: 767px) {
    .product-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .product-info h3 {
        font-size: 1.1rem;
    }
    
    .product-price {
        font-size: 1.1rem;
    }
}

/* Account for filter sidebar on category pages */
.listing-container {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 2rem;
}

.products-section {
    width: 100%;
}

@media (max-width: 1023px) {
    .listing-container {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   RECENTLY VIEWED SECTION
   ============================================================ */

.recently-viewed-ribbon {
    margin-top: 3rem;
    padding: 2rem 0;
    background: linear-gradient(
        to bottom,
        var(--background-color4, #f0efef) 0%,
        var(--background-color, #dbdbdb) 100%
    );
    border-radius: 1rem;
    border: 2px solid var(--border-color2, #3a8a3493);
    box-shadow: 0 4px 12px var(--shadow-color, rgba(0, 0, 0, 0.6));
}

.recently-viewed-ribbon h2 {
    font-family: var(--main-font-family2, 'Science Gothic', 'Roboto', sans-serif);
    font-size: 2.52rem;
    font-weight: bold;
    color: var(--primary-color, #1d6316);
    text-align: center;
    margin: 0 0 2rem 0;
    padding: 0 1rem;
}

.recently-viewed-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
    box-sizing: border-box;
}

.recently-viewed-item {
    flex: 0 1 calc(33.333% - 1rem);
    min-width: 280px;
    max-width: 400px;
    background: var(--background-color4, #f0efef);
    border: 2px solid var(--border-color2, #3a8a3493);
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 2px 8px var(--shadow-color, rgba(0, 0, 0, 0.6));
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* When there are 2 items, make them larger */
.recently-viewed-grid .recently-viewed-item:nth-child(1):nth-last-child(2),
.recently-viewed-grid .recently-viewed-item:nth-child(2):nth-last-child(1) {
    flex: 0 1 calc(50% - 0.75rem);
    max-width: 450px;
}

/* When there is only 1 item, center it */
.recently-viewed-grid .recently-viewed-item:only-child {
    flex: 0 1 400px;
    max-width: 400px;
}

.recently-viewed-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px var(--shadow-color, rgba(0, 0, 0, 0.8));
}

.recently-viewed-item a {
    display: flex;
    flex-direction: column;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

.recently-viewed-image {
    position: relative;
    width: 100%;
    padding-top: 75%; /* 4:3 aspect ratio */
    overflow: hidden;
    background: var(--background-color3, #e4e3e3);
}

.recently-viewed-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.recently-viewed-item:hover .recently-viewed-image img {
    transform: scale(1.05);
}

.recently-viewed-image .no-image {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-color-secondary, #666);
    font-size: 0.9rem;
    text-align: center;
}

.recently-viewed-info {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.recently-viewed-item h4 {
    font-family: var(--main-font-family2, 'Science Gothic', 'Roboto', sans-serif);
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--primary-color, #1d6316);
    margin: 0 0 0.5rem 0;
    line-height: 1.3;
}

.recently-viewed-item p {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--primary-color, #1d6316);
    margin: 0;
    padding-top: 1rem;
    margin-top: auto;
    border-top: 1px solid var(--border-color, #ddd);
}

.recently-viewed-item .call-for-pricing {
    color: var(--text-color-secondary, #666);
    font-size: 0.9rem;
    font-style: italic;
    font-weight: normal;
}

/* Responsive design for recently viewed */
@media (max-width: 1023px) {
    .recently-viewed-item {
        flex: 0 1 calc(50% - 0.75rem);
        max-width: 450px;
    }
    
    .recently-viewed-ribbon h2 {
        font-size: 2rem;
    }
}

@media (max-width: 767px) {
    .recently-viewed-grid {
        gap: 1rem;
        padding: 0 1rem;
    }
    
    .recently-viewed-item {
        flex: 0 1 100%;
        max-width: 100%;
        min-width: auto;
    }
    
    .recently-viewed-ribbon {
        margin-top: 2rem;
        padding: 1.5rem 0;
    }
    
    .recently-viewed-ribbon h2 {
        font-size: 1.75rem;
        margin-bottom: 1.5rem;
    }
    
    .recently-viewed-item h4 {
        font-size: 1.1rem;
    }
    
    .recently-viewed-item p {
        font-size: 1.1rem;
    }
}