/* ==========================================
   SMART CAR RECOMMENDATIONS - FIXED VERSION
   Version: 3.2.0
   
   KEY FIXES:
   - Isolated styles (no page-wide conflicts)
   - Responsive pricing for any digit count
   - Proper overflow handling
   - No !important (theme-friendly)
   - Bulletproof layout
   ========================================== */

/* === WRAPPER & CONTAINER === */
.scr-wrapper {
    max-width: 1600px;
    width: 100%;
    margin: 60px auto;
    padding: 0 20px;
    position: relative;
    box-sizing: border-box;
    /* Prevent layout breaks */
    contain: layout style;
    isolation: isolate;
    /* Never let the section push the page wider than the screen */
    overflow-x: hidden;
}

.scr-wrapper * {
    box-sizing: border-box;
}

/* === TITLE === */
.scr-wrapper .scr-title {
    text-align: center;
    font-size: 32px;
    font-weight: 700;
    margin: 0 0 50px 0;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #000;
    line-height: 1.2;
}

/* === CAROUSEL CONTAINER === */
.scr-wrapper .scr-carousel-container {
    position: relative;
    overflow: hidden;
    width: 100%;
    max-width: 100%;
    padding: 0 70px;
}

/* === GRID/CAROUSEL === */
.scr-wrapper .scr-grid {
    display: flex;
    gap: 25px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 20px;
    /* Prevent height expansion */
    align-items: stretch;
    /* Snap each card cleanly into view (fixes half-cut cards on swipe) */
    scroll-snap-type: x mandatory;
}

.scr-wrapper .scr-grid::-webkit-scrollbar {
    display: none;
}

/* === CARD BASE === */
.scr-wrapper .scr-card {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 0;
    padding: 0;
    position: relative;
    transition: all 0.3s ease;
    flex-shrink: 0;
    flex-grow: 0;
    /* Fixed width calculations */
    min-width: calc((100% - 50px) / 3);
    max-width: calc((100% - 50px) / 3);
    width: calc((100% - 50px) / 3);
    /* Critical: Prevent overflow breaking page */
    overflow: hidden;
    contain: layout paint;
    /* Snap point so card aligns flush, never half-cut */
    scroll-snap-align: start;
}

.scr-wrapper .scr-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.scr-wrapper .scr-card.scr-card-hot {
    background: #e0e0e0;
}

/* === CARD INNER WRAPPER === */
.scr-wrapper .scr-card-inner {
    padding: 25px;
    /* Ensure content doesn't break layout */
    overflow: hidden;
}

/* === CARD LINK === */
.scr-wrapper .scr-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.scr-wrapper .scr-card-link:hover {
    text-decoration: none;
}

/* === TIMESTAMP === */
.scr-wrapper .scr-timestamp {
    font-size: 12px;
    color: #999;
    margin-bottom: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* === CARD TITLE === */
.scr-wrapper .scr-card-title {
    font-size: 20px;
    font-weight: 700;
    color: #000;
    margin: 0 0 20px 0;
    line-height: 1.3;
    min-height: 52px;
    /* Handle long titles */
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* === BADGE === */
.scr-wrapper .scr-badge {
    position: absolute;
    top: 25px;
    right: 25px;
    padding: 8px 16px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 0;
    z-index: 5;
    white-space: nowrap;
}

.scr-wrapper .scr-badge.scr-badge-new {
    background: #000;
    color: #fff;
}

.scr-wrapper .scr-badge.scr-badge-hot {
    background: #808080;
    color: #fff;
}

.scr-wrapper .scr-badge.scr-badge-sold {
    background: #fff;
    color: #000;
    border: 2px solid #000;
    padding: 6px 14px;
}

/* === IMAGE CONTAINER === */
.scr-wrapper .scr-image {
    width: 100%;
    height: 150px;
    background: #fff;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    overflow: hidden;
    position: relative;
}

.scr-wrapper .scr-image img {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
}

.scr-wrapper .scr-no-image {
    color: #ccc;
    font-size: 14px;
    font-weight: 600;
}

/* ========================================
   PRICE - RESPONSIVE SIZING (KEY FIX)
   ======================================== */
.scr-wrapper .scr-price {
    font-weight: 700;
    color: #000;
    margin-bottom: 20px;
    line-height: 1.2;
    /* Critical: Prevent overflow */
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    /* Default size for normal prices (up to 6 digits) */
    font-size: 28px;
}

/* Medium prices - 7 digits ($1,000,000) */
.scr-wrapper .scr-price.scr-price-md {
    font-size: 22px;
}

/* Small prices - 8-9 digits ($10,000,000 - $100,000,000) */
.scr-wrapper .scr-price.scr-price-sm {
    font-size: 18px;
}

/* Extra small prices - 10+ digits ($1,000,000,000+) */
.scr-wrapper .scr-price.scr-price-xs {
    font-size: 15px;
    letter-spacing: -0.5px;
}

/* === SPECS SECTION === */
.scr-wrapper .scr-specs {
    margin-bottom: 25px;
}

.scr-wrapper .scr-spec-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 8px;
}

.scr-wrapper .scr-spec {
    font-size: 13px;
    /* Prevent long values from breaking layout */
    min-width: 0;
}

.scr-wrapper .scr-spec-label {
    color: #666;
    font-weight: 400;
    display: inline-block;
}

.scr-wrapper .scr-spec-value {
    color: #333;
    font-weight: 500;
    margin-left: 3px;
    display: inline-block;
    /* Handle long values */
    word-break: break-word;
}

/* === BUTTON === */
.scr-wrapper .scr-button-wrapper {
    text-align: center;
}

.scr-wrapper .scr-button {
    display: inline-block;
    padding: 12px 35px;
    background: #fff;
    border: 2px solid #000;
    color: #000;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 0;
    transition: all 0.3s;
    text-decoration: none;
}

.scr-wrapper .scr-button:hover {
    background: #000;
    color: #fff;
}

/* === NAVIGATION ARROWS === */
.scr-wrapper .scr-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: opacity 0.3s;
    user-select: none;
    opacity: 0.7;
}

.scr-wrapper .scr-nav:hover {
    opacity: 1;
}

.scr-wrapper .scr-nav svg {
    width: 40px;
    height: 40px;
    display: block;
    pointer-events: none;
    color: #000;
}

.scr-wrapper .scr-nav img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    display: block;
    pointer-events: none;
}

.scr-wrapper .scr-nav.scr-nav-prev {
    left: 10px;
}

.scr-wrapper .scr-nav.scr-nav-next {
    right: 10px;
}

/* ========================================
   RESPONSIVE BREAKPOINTS
   ======================================== */

/* Tablet - 2 cards */
@media (max-width: 1024px) {
    .scr-wrapper .scr-card {
        min-width: calc((100% - 25px) / 2);
        max-width: calc((100% - 25px) / 2);
        width: calc((100% - 25px) / 2);
    }
    
    .scr-wrapper .scr-title {
        font-size: 28px;
        margin-bottom: 40px;
    }
    
    .scr-wrapper .scr-price {
        font-size: 24px;
    }
    
    .scr-wrapper .scr-price.scr-price-md {
        font-size: 20px;
    }
    
    .scr-wrapper .scr-price.scr-price-sm {
        font-size: 17px;
    }
    
    .scr-wrapper .scr-price.scr-price-xs {
        font-size: 14px;
    }
}

/* Mobile - 1 card */
@media (max-width: 640px) {
    .scr-wrapper {
        padding: 0 10px;
        margin: 40px auto;
    }
    
    .scr-wrapper .scr-carousel-container {
        padding: 0 40px;
    }
    
    .scr-wrapper .scr-card {
        min-width: 100%;
        max-width: 100%;
        width: 100%;
        scroll-snap-align: center;
    }
    
    .scr-wrapper .scr-card-inner {
        padding: 20px;
    }
    
    .scr-wrapper .scr-grid {
        gap: 15px;
        padding-bottom: 15px;
    }
    
    .scr-wrapper .scr-image {
        height: 140px;
    }
    
    .scr-wrapper .scr-title {
        font-size: 22px;
        margin-bottom: 30px;
    }
    
    .scr-wrapper .scr-card-title {
        font-size: 18px;
        min-height: auto;
    }
    
    .scr-wrapper .scr-price {
        font-size: 24px;
        margin-bottom: 15px;
    }
    
    .scr-wrapper .scr-price.scr-price-md {
        font-size: 20px;
    }
    
    .scr-wrapper .scr-price.scr-price-sm {
        font-size: 17px;
    }
    
    .scr-wrapper .scr-price.scr-price-xs {
        font-size: 14px;
    }
    
    .scr-wrapper .scr-specs {
        margin-bottom: 20px;
    }
    
    .scr-wrapper .scr-spec-row {
        gap: 10px;
        margin-bottom: 6px;
    }
    
    .scr-wrapper .scr-spec {
        font-size: 12px;
    }
    
    .scr-wrapper .scr-badge {
        top: 20px;
        right: 20px;
        padding: 6px 12px;
        font-size: 10px;
    }
    
    .scr-wrapper .scr-nav {
        width: 35px;
        height: 35px;
        background: rgba(255, 255, 255, 0.9);
        border-radius: 50%;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    }
    
    .scr-wrapper .scr-nav img {
        width: 20px;
        height: 20px;
    }
    
    .scr-wrapper .scr-nav.scr-nav-prev {
        left: 5px;
    }
    
    .scr-wrapper .scr-nav.scr-nav-next {
        right: 5px;
    }
    
    .scr-wrapper .scr-button {
        padding: 10px 25px;
        font-size: 12px;
    }
}

/* Extra small mobile */
@media (max-width: 400px) {
    .scr-wrapper .scr-price {
        font-size: 22px;
    }
    
    .scr-wrapper .scr-price.scr-price-md {
        font-size: 18px;
    }
    
    .scr-wrapper .scr-price.scr-price-sm {
        font-size: 16px;
    }
    
    .scr-wrapper .scr-price.scr-price-xs {
        font-size: 13px;
        letter-spacing: -1px;
    }
    
    .scr-wrapper .scr-card-title {
        font-size: 16px;
    }
}
