/* SHOP LIST VIEW STYLES */

/* --- VIEW SWITCHER BUTTONS --- */
.view-switcher-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    /* Push to right in flex toolbar */
}

.view-btn {
    background: #f3f4f6;
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 1.1rem;
    color: #6b7280;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.view-btn:hover {
    background: #e5e7eb;
    color: #1f2937;
}

.view-btn.active {
    background: #1a3a52;
    /* Battel Navy */
    color: #fff;
    box-shadow: 0 2px 4px rgba(26, 58, 82, 0.3);
}


/* --- UNIFIED CARD STRUCTURE - DEFAULTS (GRID VIEW) --- */
.product-info {
    display: flex;
    flex-direction: column;
    height: 100%;
    /* Ensure proper spacing in grid */
    justify-content: space-between;
}

/* Default Grid Ordering: Origin Top, Title Next, Details Next, Actions Bottom */
.product-info .vehicle-origin {
    order: -1;
    margin-bottom: 12px;
}

.product-info .product-title {
    order: 0;
    margin-bottom: 8px;
}

.product-info .product-details-group {
    order: 1;
    flex-grow: 1;
}

.product-info .list-actions-row {
    order: 2;
    margin-top: auto;
    padding-top: 12px;
}


/* --- LIST VIEW OVERRIDES (Horizontal Compact Grid) --- */
#products-grid.list-view {
    display: grid !important;
    /* Force Grid Container Override */
    grid-template-columns: 1fr !important;
    /* Single Column Stack */
    gap: 12px;
    /* Ultra compact gap */
}

#products-grid.list-view .product-card {
    display: flex;
    flex-direction: row;
    width: 100%;
    max-width: 100%;
    align-items: stretch;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    height: 210px; /* Aumentata leggermente per contenere tutto */
    max-height: 210px;
}

#products-grid.list-view .product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

#products-grid.list-view .product-image-wrapper {
    width: 25%;
    /* reduced */
    min-width: 200px;
    max-width: 260px;
    height: 100% !important;
    flex-shrink: 0;
}

#products-grid.list-view .product-slider-wrapper {
    height: 100%;
    min-height: 100%;
    max-height: none;
    width: 100%;
    overflow: hidden;
}

#products-grid.list-view .product-slider-track {
    height: 100%;
}

#products-grid.list-view .product-slider-slide {
    height: 100%;
    min-height: 0;
}

#products-grid.list-view .product-image {
    height: 100%;
    width: 100%;
    object-fit: contain; /* Modificato da cover a contain per mostrare foto intera */
    max-height: 100%;
}

/* LIST VIEW - INNER GRID LAYOUT */
#products-grid.list-view .product-info {
    width: 75%;
    flex: 1;
    padding: 12px 16px;
    border-left: 1px solid #f3f4f6;

    display: grid;
    /* Adjusted columns: Origin wider (approx 35-40%), Details takes rest */
    grid-template-columns: 280px 1fr;
    grid-template-rows: auto 1fr auto;
    gap: 4px 20px;
    align-content: start;
}

/* Row 1 Col 2: Title (Moved to right column) */
#products-grid.list-view .product-title {
    grid-column: 2;
    grid-row: 1;
    margin-bottom: 0;
    font-size: 1.1rem;
    line-height: 1.3;
    padding-left: 10px; /* Align with details group */
    
    /* Prevent extra-long titles from breaking height and collapsing to 0 */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    width: 100%;
    min-height: 24px;
}

/* Row 1+2 Col 1: Origin */
#products-grid.list-view .vehicle-origin {
    grid-column: 1;
    grid-row: 1 / span 2;
    align-self: start;
    margin-bottom: 0;
    max-width: 100%;

    /* Compact Origin Style */
    background: linear-gradient(135deg, #0a1929 0%, #1e3a5f 100%);
    border-radius: 12px;
    /* Matched to Card Radius */
    padding: 12px 14px;
    margin-top: 0;

    /* Reduce lateral dimensions by ~10px */
    width: calc(100% - 10px);
    margin-right: 10px;
}

#products-grid.list-view .vehicle-origin-header {
    margin-bottom: 2px;
}

#products-grid.list-view .vehicle-origin-label {
    font-size: 0.65rem;
}

#products-grid.list-view .vehicle-origin-name {
    font-size: 0.85rem;
    margin-bottom: 2px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.2;
}

#products-grid.list-view .vehicle-origin-details {
    font-size: 0.75rem;
    margin-top: 5px;
}


/* Row 2 Col 2: Details (Codes + Grade) */
#products-grid.list-view .product-details-group {
    grid-column: 2;
    grid-row: 2;
    align-self: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding-left: 10px;
}

/* Ensure codes wrap nicely */
#products-grid.list-view .product-codes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* Row 3: Actions (Bottom) */
#products-grid.list-view .list-actions-row {
    grid-column: 1 / -1;
    grid-row: 3;
    margin-top: auto;
    /* Push to bottom */
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-top: 1px solid #f0f0f0;
    padding-top: 8px;
    width: 100%;
}

#products-grid.list-view .product-price {
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap;
    white-space: nowrap;

    /* Ensure it takes available space but leaves room for button */
    flex: 1 1 auto;
    overflow: hidden;
}

#products-grid.list-view .current-price {
    font-size: 1.4rem;
    font-weight: 700;
    color: #D91E36;
    /* Unified Red Price */
}

#products-grid.list-view .original-price {
    color: #9ca3af;
    text-decoration: line-through;
    font-size: 0.95rem;
}

#products-grid.list-view .savings-badge {
    background: #ecfdf5;
    color: #059669;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* BUTTONS: Fixed Dimension */
#products-grid.list-view .add-to-cart-btn,
#products-grid.list-view .go-to-cart-btn,
#products-grid.list-view .notify-btn {
    width: 240px;
    min-width: 240px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0;
    margin: 0;
}


/* MOBILE RESPONSIVE FOR LIST VIEW (Revert to Stack) */
@media (max-width: 768px) {
    #products-grid.list-view .product-card {
        flex-direction: column;
    }

    #products-grid.list-view .product-image-wrapper {
        width: 100%;
        max-width: 100%;
        min-width: auto;
        height: 220px;
    }

    #products-grid.list-view .product-info {
        width: 100%;
        padding: 16px;
        border-left: none;

        /* Revert Grid to Flex Column */
        display: flex;
        flex-direction: column;
        gap: 0;
    }

    /* Revert to Grid Ordering on Mobile */
    #products-grid.list-view .vehicle-origin {
        order: -1;
        grid-column: auto;
        grid-row: auto;
        max-width: 100%;
        width: 100%;
        margin-bottom: 12px;
        /* Reset width override */
    }

    #products-grid.list-view .product-title {
        order: 0;
        grid-column: auto;
        grid-row: auto;
        margin-bottom: 8px;
    }

    #products-grid.list-view .product-details-group {
        order: 1;
        grid-column: auto;
        grid-row: auto;
        padding-left: 0;
    }

    #products-grid.list-view .list-actions-row {
        order: 2;
        grid-column: auto;
        grid-row: auto;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    #products-grid.list-view .product-price {
        justify-content: center;
        flex-wrap: wrap;
        white-space: normal;
    }

    #products-grid.list-view .add-to-cart-btn,
    #products-grid.list-view .go-to-cart-btn,
    #products-grid.list-view .notify-btn {
        width: 100%;
        min-width: auto;
    }
}