/* Popular Products Collage Styles */

:root {
    --collage-gap: 1.5em;
    --collage-border-radius: 12px;
    --collage-overlay-bg: rgba(0, 0, 0, 0.8);
    --collage-text-light: #ffffff;
    --collage-text-muted: #000000;
    --collage-accent: #007bff;
    --collage-danger: #dc3545;
    --collage-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    --collage-shadow-hover: 0 20px 50px rgba(0, 0, 0, 0.3);
}

/* Collage Container Base */
.popular-products-collage {

}

.collage-header {
    text-align: center;
    margin-bottom: 2rem;
}

.collage-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.collage-description {
    color: var(--collage-text-muted);
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto;
}

/* Navigation Tabs */
.collage-navigation {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.collage-nav-btn {
    background-color: #f8f9fa;
    color: #6c757d;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.collage-nav-btn:hover {
    background-color: var(--collage-accent);
    color: white;
    transform: translateY(-2px);
}

.collage-nav-btn.active {
    background-color: transparent;
    color: white;
    font-weight: 700;
}

/* Layout Tabs */
.layout-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 2rem;
    background-color: #f8f9fa;
    padding: 8px;
    border-radius: 12px;
    flex-wrap: wrap;
}

.layout-tab-btn {
    background-color: transparent;
    color: #6c757d;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.layout-tab-btn:hover {
    background-color: #e9ecef;
    color: #495057;
}

.layout-tab-btn.active {
    background-color: var(--collage-accent);
    color: white;
    font-weight: 700;
}

/* Collage Wrapper */
.collage-wrapper {
    width: 100%;
    margin: 0 auto;
    perspective: 2000px;
    position: relative;
}

.collage-container::after {
  content: "";
  display: table;
  clear: both;
}

.collage-container {
    display: grid;
    width: 100%;
    gap: var(--collage-gap);
    transition: all 0.4s ease-in-out;
    min-height: 400px;
}

/* Collage Items */
.collage-item {
    border-radius: var(--collage-border-radius);
    overflow: hidden;
    box-shadow: var(--collage-shadow);
    transform-style: preserve-3d;
    transition: transform 0.1s linear, box-shadow 0.3s ease;
    cursor: pointer;
    position: relative;
    background-color: white;
}

.collage-item:hover {
    box-shadow: var(--collage-shadow-hover);
}

/* Image Wrapper */
.collage-image-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.collage-image-link {
    display: block;
    width: 100%;
    height: 100%;
}

.collage-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.collage-item:hover .collage-image {
    transform: scale(1.05);
}

/* Sale Badge */
.collage-sale-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
}

.collage-sale-badge .badge {
    font-size: 0.75rem;
    padding: 5px 10px;
    border-radius: 15px;
}

/* Overlay */
.collage-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--collage-overlay-bg);
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.collage-item:hover .collage-overlay {
    opacity: 1;
}

.collage-overlay-content {
    text-align: center;
    color: var(--collage-text-light);
    padding: 20px;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.collage-item:hover .collage-overlay-content {
    transform: translateY(0);
}

.collage-product-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--collage-text-light);
    line-height: 1.3;
}

.collage-product-price {
    margin-bottom: 1rem;
    font-weight: 600;
}

.collage-product-price .sale-price {
    color: var(--yellow);
    font-size: 1.1rem;
    margin-right: 0.5rem;
}

.collage-product-price .regular-price {
    text-decoration: line-through;
    color: var(--yellow);
    font-size: 0.9rem;
}

.collage-product-price .price {
    font-size: 1.1rem;
    color: var(--collage-text-light);
}




/* Layout Definitions */

/* Metro Layout */
.layout-4x2 {
  display: grid;
  grid-template-columns: repeat(4, 1fr); /* 4 columns */
  grid-template-rows: repeat(2, 1fr);   /* 2 rows */
  gap: 10px;
  min-height: 250px;
}

/* Each tile will fill exactly 1x1 cell */
.layout-4x2 .collage-item:nth-child(1) {
  grid-area: 1 / 1 / span 1 / span 1;
}
.layout-4x2 .collage-item:nth-child(2) {
  grid-area: 1 / 2 / span 1 / span 1;
}
.layout-4x2 .collage-item:nth-child(3) {
  grid-area: 1 / 3 / span 1 / span 1;
}
.layout-4x2 .collage-item:nth-child(4) {
  grid-area: 1 / 4 / span 1 / span 1;
}
.layout-4x2 .collage-item:nth-child(5) {
  grid-area: 2 / 1 / span 1 / span 1;
}
.layout-4x2 .collage-item:nth-child(6) {
  grid-area: 2 / 2 / span 1 / span 1;
}
.layout-4x2 .collage-item:nth-child(7) {
  grid-area: 2 / 3 / span 1 / span 1;
}
.layout-4x2 .collage-item:nth-child(8) {
  grid-area: 2 / 4 / span 1 / span 1;
}

.layout-big3 {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 10px; /* optional spacing */
    min-height: 250px;
}

.layout-big3 .collage-item:nth-child(1) {
    grid-area: 1 / 1 / span 2 / span 2; /* row-start / col-start / row-span / col-span */
}

.layout-big3 .collage-item:nth-child(2) {
    grid-area: 1 / 3 / span 2 / span 2;
}

.layout-big3 .collage-item:nth-child(3) {
    grid-area: 1 / 5 / span 2 / span 2;
}

/* Enhanced Metro Layout for 10 items */
.layout-metro {
    grid-template-rows: repeat(4, 1fr); /* Changed from 4 to 5 rows */
}

.layout-metro .collage-item:nth-child(9) {
    grid-area: 4 / 1 / span 1 / span 1; /* Bottom left */
}

.layout-metro .collage-item:nth-child(10) {
    grid-area: 4 / 2 / span 1 / span 1; /* Bottom left-center */
}

.layout-metro .collage-item:nth-child(1) { 
    grid-area: 1 / 1 / span 2 / span 2; 
}
.layout-metro .collage-item:nth-child(6) { 
    grid-area: 3 / 3 / span 2 / span 2; 
}
.layout-metro {
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(2, 1fr);
    min-height: 250px; 
}
.layout-metro .collage-item:nth-child(1) {
    grid-area: 1 / 1 / span 2 / span 2; 
}

/* The next 8 items (items 2 through 9) are 1x1. They will fill columns 3 through 6. */
.layout-metro .collage-item:nth-child(2) {
    grid-area: 1 / 3 / span 1 / span 1;
}
.layout-metro .collage-item:nth-child(3) {
    grid-area: 1 / 4 / span 1 / span 1;
}
.layout-metro .collage-item:nth-child(4) {
    grid-area: 1 / 5 / span 1 / span 1;
}
.layout-metro .collage-item:nth-child(5) {
    grid-area: 1 / 6 / span 1 / span 1;
}
.layout-metro .collage-item:nth-child(6) {
    grid-area: 2 / 3 / span 1 / span 1;
}
.layout-metro .collage-item:nth-child(7) {
    grid-area: 2 / 4 / span 1 / span 1;
}
.layout-metro .collage-item:nth-child(8) {
    grid-area: 2 / 5 / span 1 / span 1;
}
.layout-metro .collage-item:nth-child(9) {
    grid-area: 2 / 6 / span 1 / span 1;
}

/* The last item (item 10) is a 2x2 block. It will occupy the remaining space. */
.layout-metro .collage-item:nth-child(10) {
    grid-area: 1 / 7 / span 2 / span 2; 
}


.layout-metro6 {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 10px; /* optional spacing */
  min-height: 250px;
}

/* Left 2x2 block */
.layout-metro6 .collage-item:nth-child(1) {
  grid-area: 1 / 1 / span 2 / span 2; 
}

/* Middle 1x1 items */
.layout-metro6 .collage-item:nth-child(2) {
  grid-area: 1 / 3 / span 1 / span 1;
}
.layout-metro6 .collage-item:nth-child(3) {
  grid-area: 1 / 4 / span 1 / span 1;
}
.layout-metro6 .collage-item:nth-child(4) {
  grid-area: 2 / 3 / span 1 / span 1;
}
.layout-metro6 .collage-item:nth-child(5) {
  grid-area: 2 / 4 / span 1 / span 1;
}

/* Right 2x2 block */
.layout-metro6 .collage-item:nth-child(6) {
  grid-area: 1 / 5 / span 2 / span 2; 
}


.layout-centro6 {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 10px; /* optional */
    min-height: 250px;
}

/* Left side: Two 1x1 items */
.layout-centro6 .collage-item:nth-child(1) {
    grid-area: 1 / 1 / span 1 / span 1;
}
.layout-centro6 .collage-item:nth-child(2) {
    grid-area: 2 / 1 / span 1 / span 1;
}

/* Center: Two 2x2 items */
.layout-centro6 .collage-item:nth-child(3) {
    grid-area: 1 / 2 / span 2 / span 2;
}
.layout-centro6 .collage-item:nth-child(4) {
    grid-area: 1 / 4 / span 2 / span 2;
}

/* Right side: Two 1x1 items */
.layout-centro6 .collage-item:nth-child(5) {
    grid-area: 1 / 6 / span 1 / span 1;
}
.layout-centro6 .collage-item:nth-child(6) {
    grid-area: 2 / 6 / span 1 / span 1;
}



.layout-centro {
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(2, 1fr);
    min-height: 250px;
}

/* Left side: Four 1x1 images in the first two columns */
.layout-centro .collage-item:nth-child(1) {
    grid-area: 1 / 1 / span 1 / span 1;
}
.layout-centro .collage-item:nth-child(2) {
    grid-area: 2 / 1 / span 1 / span 1;
}
.layout-centro .collage-item:nth-child(3) {
    grid-area: 1 / 2 / span 1 / span 1;
}
.layout-centro .collage-item:nth-child(4) {
    grid-area: 2 / 2 / span 1 / span 1;
}

/* Center: Two 2x2 images */
.layout-centro .collage-item:nth-child(5) {
    grid-area: 1 / 3 / span 2 / span 2;
}
.layout-centro .collage-item:nth-child(6) {
    grid-area: 1 / 5 / span 2 / span 2;
}

/* Right side: Four 1x1 images in the last two columns */
.layout-centro .collage-item:nth-child(7) {
    grid-area: 1 / 7 / span 1 / span 1;
}
.layout-centro .collage-item:nth-child(8) {
    grid-area: 2 / 7 / span 1 / span 1;
}
.layout-centro .collage-item:nth-child(9) {
    grid-area: 1 / 8 / span 1 / span 1;
}
.layout-centro .collage-item:nth-child(10) {
    grid-area: 2 / 8 / span 1 / span 1;
}


.layout-wheel {
    /* 8 columns, 3 rows */
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(3, 1fr);
    min-height: 250px;
}

/* First block: 2x2 image, then two 1x1 images below it */
.layout-wheel .collage-item:nth-child(1) {
    grid-area: 1 / 1 / span 2 / span 2; 
}
.layout-wheel .collage-item:nth-child(2) {
    grid-area: 3 / 1 / span 1 / span 1;
}
.layout-wheel .collage-item:nth-child(3) {
    grid-area: 3 / 2 / span 1 / span 1;
}

/* Second block: Two 1x1 images, then a 2x2 image below them */
.layout-wheel .collage-item:nth-child(4) {
    grid-area: 1 / 3 / span 1 / span 1;
}
.layout-wheel .collage-item:nth-child(5) {
    grid-area: 1 / 4 / span 1 / span 1;
}
.layout-wheel .collage-item:nth-child(6) {
    grid-area: 2 / 3 / span 2 / span 2;
}

/* Third block: Repeat of the first pattern */
.layout-wheel .collage-item:nth-child(7) {
    grid-area: 1 / 5 / span 2 / span 2;
}
.layout-wheel .collage-item:nth-child(8) {
    grid-area: 3 / 5 / span 1 / span 1;
}
.layout-wheel .collage-item:nth-child(9) {
    grid-area: 3 / 6 / span 1 / span 1;
}

/* Fourth block: Repeat of the second pattern */
.layout-wheel .collage-item:nth-child(10) {
    grid-area: 1 / 7 / span 1 / span 1;
}
.layout-wheel .collage-item:nth-child(11) {
    grid-area: 1 / 8 / span 1 / span 1;
}
.layout-wheel .collage-item:nth-child(12) {
    grid-area: 2 / 7 / span 2 / span 2;
}


/* Focus Layout */
.layout-focus {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(auto-fit, 1fr);
    aspect-ratio: unset; /* Allow expansion */
    min-height: 400px;
}

.layout-focus .collage-item:nth-child(5) { 
    grid-area: 2 / 2 / span 2 / span 2; 
}

/* Pinwheel Layout */
.layout-pinwheel {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(auto-fit, 1fr);
    aspect-ratio: unset; /* Allow expansion */
    min-height: 400px;
}

.layout-pinwheel .collage-item:nth-child(1) { 
    grid-area: 1 / 1 / span 2 / span 2; 
}
.layout-pinwheel .collage-item:nth-child(2) { 
    grid-area: 1 / 3 / span 1 / span 1; 
}
.layout-pinwheel .collage-item:nth-child(3) { 
    grid-area: 1 / 4 / span 1 / span 1; 
}
.layout-pinwheel .collage-item:nth-child(4) { 
    grid-area: 2 / 3 / span 2 / span 2; 
}
.layout-pinwheel .collage-item:nth-child(5) { 
    grid-area: 3 / 1 / span 1 / span 1; 
}
.layout-pinwheel .collage-item:nth-child(6) { 
    grid-area: 4 / 1 / span 1 / span 1; 
}
.layout-pinwheel .collage-item:nth-child(7) { 
    grid-area: 4 / 2 / span 1 / span 1; 
}

/* Stairs Layout */
.layout-stairs {
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(auto-fit, 1fr);
    aspect-ratio: unset; /* Allow expansion */
    min-height: 400px;
}

.layout-stairs .collage-item:nth-child(1) { 
    grid-area: 1 / 1 / span 2 / span 2; 
}
.layout-stairs .collage-item:nth-child(2) { 
    grid-area: 2 / 3 / span 2 / span 2; 
}
.layout-stairs .collage-item:nth-child(3) { 
    grid-area: 4 / 4 / span 2 / span 2; 
}

/* Central Layout */
.layout-central {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(auto-fit, 1fr);
    aspect-ratio: unset; /* Allow expansion */
    min-height: 400px;
}

.layout-central .collage-item:nth-child(1) { 
    grid-area: 2 / 2 / span 2 / span 2; 
}
.layout-central .collage-item:nth-child(2) { 
    grid-area: 1 / 1 / span 1 / span 1; 
}
.layout-central .collage-item:nth-child(3) { 
    grid-area: 1 / 4 / span 1 / span 1; 
}
.layout-central .collage-item:nth-child(4) { 
    grid-area: 4 / 1 / span 1 / span 1; 
}
.layout-central .collage-item:nth-child(5) { 
    grid-area: 4 / 4 / span 1 / span 1; 
}

/* Chevron Layout */
.layout-chevron {
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(auto-fit, 1fr);
    aspect-ratio: unset; /* Allow expansion */
    min-height: 400px;
}

.layout-chevron .collage-item:nth-child(1) { 
    grid-area: 1 / 3 / span 2 / span 1; 
}
.layout-chevron .collage-item:nth-child(2) { 
    grid-area: 2 / 2 / span 2 / span 1; 
}
.layout-chevron .collage-item:nth-child(3) { 
    grid-area: 2 / 4 / span 2 / span 1; 
}
.layout-chevron .collage-item:nth-child(4) { 
    grid-area: 3 / 1 / span 2 / span 1; 
}
.layout-chevron .collage-item:nth-child(5) { 
    grid-area: 3 / 5 / span 2 / span 1; 
}

/* Dynamic expansion for additional items (beyond initial layout) */
.collage-container .collage-item:nth-child(n+13) {
    /* Additional items fill remaining grid space naturally */
    grid-area: auto;
}

/* Load More Section */
.collage-load-more {
    text-align: center;
    margin-top: 2rem;
}

.load-more-btn {
    background: linear-gradient(135deg, var(--collage-accent), #0056b3);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.load-more-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 123, 255, 0.3);
    color: white;
}

.load-more-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.load-more-btn .loading-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: none;
}

.load-more-btn.loading .loading-spinner {
    display: block;
}

.load-more-btn.loading .load-more-text {
    display: none;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Loading State */
.collage-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    color: var(--collage-text-muted);
}

.collage-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--collage-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 15px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .collage-wrapper {
        max-width: 100%;
        padding: 0 15px;
    }
    
    .collage-navigation {
        gap: 5px;
    }
    
    .collage-nav-btn,
    .layout-tab-btn {
        padding: 8px 15px;
        font-size: 0.9rem;
    }
    
    .layout-tabs {
        flex-direction: column;
        gap: 5px;
    }
    
    .collage-title {
        font-size: 1.2rem;
    }
    
    .collage-description {
        font-size: 1rem;
    }
    
    .collage-overlay-content {
        padding: 15px;
    }
    
    .collage-product-name {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    :root {
        --collage-gap: 10px;
    }
    
    .collage-title {
        font-size: 1.8rem;
    }
    
    .collage-overlay-content {
        padding: 10px;
    }
    
    .collage-product-name {
        font-size: 0.9rem;
    }
    
    .collage-actions .btn {
        padding: 6px 12px;
        font-size: 0.85rem;
    }
}


@media (max-width: 768px) {
    /* ... your other mobile styles ... */

    /* 1. Reset all collage layout containers to a 2-column grid */
    .layout-metro,
    .layout-metro6,
    .layout-centro,
    .layout-wheel,
    .layout-focus,
    .layout-pinwheel,
    .layout-stairs,
    .layout-central,
    .layout-chevron {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: auto;
        min-height: auto;
    }

    /* 2. Force-reset individual item placement to allow natural flow */
    .collage-item:nth-child(n) {
        grid-area: auto !important; /* overrides any grid-area set in specific layouts */
    }
}
