/**
 * Frontend Grid Styles - NewGrid SideBar V2
 * Section-Based Architecture with Responsive Layouts
 */

/* Prevent horizontal scroll */
html {
    overflow-x: hidden !important;
    max-width: 100%;
}

body {
    overflow-x: hidden !important;
    max-width: 100%;
}

/* ============================================
   CONTAINER & WRAPPER
   ============================================ */

.ngv2-grid-container {
    width: 100vw !important;
    max-width: 100vw !important;
    margin: 0 !important;
    padding: 0 !important;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw !important;
    margin-right: -50vw !important;
    box-sizing: border-box;
}

.ngv2-grid-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
    max-width: 100%;
    padding: 40px 0;
    overflow-x: hidden;
}

/* ============================================
   SECTION BASE STYLES
   ============================================ */

.ngv2-section {
    display: grid;
    gap: 20px;
    width: 100%;
    max-width: 100%;
    margin-bottom: 80px;
    padding: 0;
    box-sizing: border-box;
    position: relative;
    z-index: 1;
    clear: both;
    overflow-x: hidden;
}

.ngv2-section:last-child {
    margin-bottom: 0;
}

/* ============================================
   PRODUCT BASE STYLES
   ============================================ */

.ngv2-product {
    position: relative;
    overflow: hidden;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    transition: opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    max-width: 100%;
    box-sizing: border-box;
}

.ngv2-product:hover {
    opacity: 0.9;
}

.ngv2-product-link {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    height: auto;
    max-width: 100%;
    box-sizing: border-box;
}

.ngv2-product-image {
    position: relative;
    width: 100%;
    max-width: 100%;
    flex-shrink: 0;
    background: transparent;
    display: block;
    overflow: hidden;
    box-sizing: border-box;
}

.ngv2-product-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    max-width: 100%;
    max-height: 100%;
    box-sizing: border-box;
}

.ngv2-product-info {
    padding: 12px 5px 0 5px;
    background: transparent;
    color: #333;
    text-align: center;
}

.ngv2-product-name {
    font-size: 14px;
    font-weight: 500;
    margin: 0 0 6px 0;
    line-height: 1.3;
    color: #333;
}

.ngv2-product-price {
    font-size: 15px;
    font-weight: 600;
    color: #000;
}

.ngv2-product-price .woocommerce-Price-amount {
    color: #000;
}

/* Empty slot styling */
.ngv2-product.ngv2-empty {
    display: none; /* Hide empty slots on frontend */
}

/* ============================================
   OPTION A: 3 IMAGES IN ROW
   Desktop: Small sides - Large center (portrait 3:2 ratio - height:width)
   ============================================ */

.ngv2-section-option-a {
    display: grid;
    grid-template-columns: 1fr 1.5fr 1fr;
    grid-template-rows: auto;
    width: calc(100% - 40px);
    max-width: calc(100% - 40px);
    margin: 0 20px 20px 20px;
    align-items: center;
    gap: 20px;
    box-sizing: border-box;
}

/* All slots take full column width */
.ngv2-section-option-a .ngv2-slot-0,
.ngv2-section-option-a .ngv2-slot-1,
.ngv2-section-option-a .ngv2-slot-2 {
    width: 100%;
}

/* Center image - portrait 3:2 (height 1.5x width) - aligns to top */
.ngv2-section-option-a .ngv2-slot-1 {
    align-self: start;
}

.ngv2-section-option-a .ngv2-slot-1 .ngv2-product-image {
    width: 100%;
    aspect-ratio: 2/3;
}

.ngv2-section-option-a .ngv2-slot-1 .ngv2-product-image img {
    width: 100%;
    height: auto;
    object-fit: cover;
}

/* Side images - portrait ratio - centered vertically */
.ngv2-section-option-a .ngv2-slot-0,
.ngv2-section-option-a .ngv2-slot-2 {
    align-self: center;
}

.ngv2-section-option-a .ngv2-slot-0 .ngv2-product-image,
.ngv2-section-option-a .ngv2-slot-2 .ngv2-product-image {
    width: 100%;
    aspect-ratio: 2/3;
}

.ngv2-section-option-a .ngv2-slot-0 .ngv2-product-image img,
.ngv2-section-option-a .ngv2-slot-2 .ngv2-product-image img {
    width: 100%;
    height: auto;
    object-fit: cover;
}

/* ============================================
   OPTION B: 4 COLLAGE PHOTOS
   Desktop: 1 Big (left 45%) + 2 Stacked (middle 20%, same total height) + 1 Tall (right 35%)
   ============================================ */

.ngv2-section-option-b {
    display: grid;
    grid-template-columns: 9fr 4fr 7fr;
    grid-template-rows: 1fr 1fr;
    gap: 20px;
    width: calc(100% - 40px);
    max-width: calc(100% - 40px);
    margin: 0 20px 20px 20px;
    overflow: hidden;
    align-items: stretch;
    box-sizing: border-box;
}

.ngv2-section-option-b .ngv2-product {
    overflow: visible;
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

.ngv2-section-option-b .ngv2-product-image {
    width: 100%;
    flex: 1;
    aspect-ratio: 2/3;
    min-height: 0;
}

.ngv2-section-option-b .ngv2-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ngv2-section-option-b .ngv2-product-info {
    padding: 8px 5px 0 5px;
    flex-shrink: 0;
}

/* Slot 0: Big image (left) - spans 2 rows, 40% width */
.ngv2-section-option-b .ngv2-slot-0 {
    grid-column: 1;
    grid-row: 1 / 3;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.ngv2-section-option-b .ngv2-slot-0 .ngv2-product-image {
    flex: 1;
}

/* Slot 1: Small top (middle) - 20% width */
.ngv2-section-option-b .ngv2-slot-1 {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
}

/* Slot 2: Small bottom (middle) - 20% width */
.ngv2-section-option-b .ngv2-slot-2 {
    grid-column: 2;
    grid-row: 2;
    width: 100%;
}

/* Slot 3: Tall image (right) - spans 2 rows, 40% width */
.ngv2-section-option-b .ngv2-slot-3 {
    grid-column: 3;
    grid-row: 1 / 3;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.ngv2-section-option-b .ngv2-slot-3 .ngv2-product-image {
    flex: 1;
}

/* Flipped Option B - Reverse column order (Desktop only) */
@media (min-width: 769px) {
    .ngv2-section-option-b.ngv2-flipped {
        grid-template-columns: 7fr 4fr 9fr;
    }

    .ngv2-section-option-b.ngv2-flipped .ngv2-slot-0 {
        grid-column: 3;
    }

    .ngv2-section-option-b.ngv2-flipped .ngv2-slot-3 {
        grid-column: 1;
    }
}

/* ============================================
   OPTION C: 4 ALTERNATING HEIGHTS
   Desktop: Equal widths (25%), alternating tall-short
   ============================================ */

.ngv2-section-option-c {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: auto;
    gap: 20px;
    width: calc(100% - 40px);
    max-width: calc(100% - 40px);
    margin: 0 20px 20px 20px;
    align-items: end; /* Align to bottom */
    overflow: hidden;
    box-sizing: border-box;
}

.ngv2-section-option-c .ngv2-product {
    overflow: visible;
}

.ngv2-section-option-c .ngv2-product-image {
    aspect-ratio: 2/3;
}

.ngv2-section-option-c .ngv2-slot-0 .ngv2-product-image img,
.ngv2-section-option-c .ngv2-slot-2 .ngv2-product-image img {
    /* Tall items */
    max-height: 800px;
}

.ngv2-section-option-c .ngv2-slot-1 .ngv2-product-image img,
.ngv2-section-option-c .ngv2-slot-3 .ngv2-product-image img {
    /* Short items - 75% of tall */
    max-height: 600px;
}

/* ============================================
   LOADING & END STATES
   ============================================ */

.ngv2-loading-indicator {
    text-align: center;
    padding: 40px 20px;
}

.ngv2-loading-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 15px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #333;
    border-radius: 50%;
    animation: ngv2-spin 1s linear infinite;
}

@keyframes ngv2-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.ngv2-end-message {
    text-align: center;
    padding: 40px 20px;
    font-size: 16px;
    color: #666;
}

.ngv2-no-sections {
    text-align: center;
    padding: 60px 20px;
    font-size: 18px;
    color: #666;
}

/* ============================================
   MOBILE RESPONSIVE STYLES
   ============================================ */

@media (max-width: 768px) {

    .ngv2-grid-container {
        padding: 0;
    }

    .ngv2-grid-wrapper {
        gap: 20px;
    }

    .ngv2-section {
        gap: 10px;
        padding: 0 5px;
        margin-bottom: 20px;
        width: calc(100% - 10px);
        max-width: calc(100% - 10px);
        margin-left: 5px;
        margin-right: 5px;
    }

    .ngv2-section-option-a,
    .ngv2-section-option-b,
    .ngv2-section-option-c {
        width: 100%;
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
    }

    .ngv2-product-info {
        padding: 10px 3px 0 3px;
    }

    .ngv2-product-name {
        font-size: 12px;
        margin-bottom: 4px;
    }

    .ngv2-product-price {
        font-size: 13px;
    }

    /* ============================================
       OPTION A MOBILE: Row 1 = 1 big full width, Row 2 = 2 small 50% each
       ============================================ */

    .ngv2-section-option-a {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
        align-items: stretch;
    }

    /* Row 1: Big image full width */
    .ngv2-section-option-a .ngv2-slot-1 {
        grid-column: 1 / 3;
        grid-row: 1;
        align-self: stretch;
    }

    /* Row 2: Two small images 50% each */
    .ngv2-section-option-a .ngv2-slot-0 {
        grid-column: 1;
        grid-row: 2;
        align-self: stretch;
    }

    .ngv2-section-option-a .ngv2-slot-2 {
        grid-column: 2;
        grid-row: 2;
        align-self: stretch;
    }

    /* ============================================
       OPTION B MOBILE: Row 1 full, Row 2 two 50%, Row 3 full
       ============================================ */

    .ngv2-section-option-b {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto auto;
        gap: 10px;
    }

    .ngv2-section-option-b .ngv2-product-info {
        padding: 8px 3px 0 3px;
    }

    /* Row 1: Slot 0 full width */
    .ngv2-section-option-b .ngv2-slot-0 {
        grid-column: 1 / 3;
        grid-row: 1;
    }

    /* Row 2: Slot 1 and 2 - 50% each */
    .ngv2-section-option-b .ngv2-slot-1 {
        grid-column: 1;
        grid-row: 2;
    }

    .ngv2-section-option-b .ngv2-slot-2 {
        grid-column: 2;
        grid-row: 2;
    }

    /* Row 3: Slot 3 full width */
    .ngv2-section-option-b .ngv2-slot-3 {
        grid-column: 1 / 3;
        grid-row: 3;
    }

    /* ============================================
       OPTION C MOBILE: 2 rows, each with 2 images 50%
       ============================================ */

    .ngv2-section-option-c {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
        height: auto;
        min-height: auto;
        max-height: none;
        align-items: stretch;
        gap: 10px;
    }

    .ngv2-section-option-c .ngv2-slot-0,
    .ngv2-section-option-c .ngv2-slot-1,
    .ngv2-section-option-c .ngv2-slot-2,
    .ngv2-section-option-c .ngv2-slot-3 {
        height: auto;
    }

    .ngv2-section-option-c .ngv2-slot-0 {
        grid-column: 1;
        grid-row: 1;
    }

    .ngv2-section-option-c .ngv2-slot-1 {
        grid-column: 2;
        grid-row: 1;
    }

    .ngv2-section-option-c .ngv2-slot-2 {
        grid-column: 1;
        grid-row: 2;
    }

    .ngv2-section-option-c .ngv2-slot-3 {
        grid-column: 2;
        grid-row: 2;
    }
}

/* ============================================
   TABLET BREAKPOINT (769px - 1024px)
   ============================================ */

@media (min-width: 769px) and (max-width: 1024px) {

    .ngv2-grid-wrapper {
        gap: 30px;
    }

    .ngv2-section {
        gap: 15px;
        padding: 0 15px;
    }

    .ngv2-product-info {
        padding: 10px 4px 0 4px;
    }

    .ngv2-product-name {
        font-size: 13px;
    }

    .ngv2-product-price {
        font-size: 14px;
    }

    .ngv2-section-option-a .ngv2-slot-1 .ngv2-product-image {
        max-height: 750px;
    }

    .ngv2-section-option-a .ngv2-slot-0 .ngv2-product-image,
    .ngv2-section-option-a .ngv2-slot-2 .ngv2-product-image {
        max-height: 560px;
    }

    .ngv2-section-option-b {
        grid-template-columns: minmax(250px, 1fr) minmax(200px, 0.8fr) minmax(250px, 1fr);
        grid-template-rows: 350px 350px;
        gap: 12px;
    }

    .ngv2-section-option-c {
        gap: 15px;
    }
}

/* ============================================
   LARGE DESKTOP (1400px+)
   ============================================ */

@media (min-width: 1400px) {
    /* Full width maintained across all screen sizes */
}

/* ============================================
   ANIMATIONS
   ============================================ */

.ngv2-section {
    opacity: 0;
    animation: ngv2-fadeIn 0.4s ease-in-out forwards;
}

@keyframes ngv2-fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

.ngv2-product-link:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.ngv2-product-link:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .ngv2-section,
    .ngv2-product {
        animation: none;
        transition: none;
    }

    .ngv2-loading-spinner {
        animation: none;
        border-top-color: #333;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .ngv2-loading-indicator,
    .ngv2-end-message {
        display: none;
    }

    .ngv2-product {
        page-break-inside: avoid;
    }
}
