/* ==========================================================================
   FLEET CARD SYSTEM - ULTIMATE CLEAN VERSION
   Fix: Grid Ghost Elements, 4-Column Layout, Home Carousel
   ========================================================================== */

/* 1. RESET GRID GHOST ELEMENTS
   Rimuoviamo i ::before e ::after di WooCommerce che creano spazi vuoti nella griglia */
.woocommerce ul.products::before,
.woocommerce ul.products::after,
.woocommerce-page ul.products::before,
.woocommerce-page ul.products::after {
    content: none !important;
    display: none !important;
}

/* 2. ARCHIVE / SHOP GRID SETUP (4 COLONNE) */
.archive .products, 
.wcr-fleet-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 25px !important;
    padding: 0 !important;
    list-style: none !important;
    margin: 0 0 120px !important; 
}

/* 3. WOOCOMMERCE RESULT COUNT
   Badge tecnico in alto a sinistra, fuori dalla griglia dei prodotti */
.woocommerce-result-count {
    display: inline-block !important;
    background: var(--dark);
    color: var(--yellow);
    padding: 10px 25px;
    border-radius: 50px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 40px !important;
    border: 1px solid rgba(255, 215, 0, 0.3);
    box-shadow: var(--shadow-premium);
}

/* 4. HOME CAROUSEL FIX 
   Mantiene le card affiancate con larghezza fissa per evitare deformazioni */
.home .fleet-carousel {
    display: flex !important;
    flex-wrap: nowrap !important;
    grid-template-columns: none !important;
    gap: 25px !important;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding: 20px 0 40px !important;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.home .fleet-carousel .fleet-item-card {
    flex: 0 0 380px !important; /* Impedisce all'ultima card di allargarsi */
    width: 380px !important;
    scroll-snap-align: start;
}

/* 5. THE CARD - Design Cockpit */
.fleet-item-card {
    position: relative;
    background: #111;
    border-radius: 35px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    overflow: hidden;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    height: 520px; /* Altezza uniforme */
}

/* Reset larghezze legacy WooCommerce */
.archive ul.products li.product,
.home ul.products li.product {
    width: 100% !important;
    margin: 0 !important;
    float: none !important;
}

.card-glass-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.03) 0%, rgba(0,26,61,0.3) 100%);
    z-index: 1;
    transition: background 0.4s ease;
}

.fleet-item-card .card-content {
    position: relative;
    z-index: 2;
    padding: 25px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

/* Area Immagine */
.car-image-area {
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
}

.car-image-area img {
    max-width: 100%;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 15px 30px rgba(0,0,0,0.5));
}

/* Tipografia Card */
.car-info h3, 
.car-info h3 a {
    font-size: 20px;
    font-weight: 900;
    color: var(--white);
    text-align: center;
    text-transform: uppercase;
    text-decoration: none;
    margin-bottom: 15px;
    display: block;
}


/* Fix per l'ultima voce (Motore) se vogliamo che occupi tutta la riga o stia bene */
.spec-tile:last-child {
    grid-column: span 1; /* Se vuoi che stia su due colonne cambia in span 2 */
}

/* Blocco Prezzo */
.car-price-block {
    margin: 15px 0;
    text-align: center;
}

.price-main {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 4px;
    color: var(--white);
}

.price-main .val, 
.price-main .woocommerce-Price-amount {
    font-size: 26px;
    font-weight: 900;
}

.price-main .unit {
    font-size: 11px;
    color: var(--yellow);
    font-weight: 700;
    text-transform: uppercase;
}

/* Bottone CTA */
.btn-fast-book {
    background: var(--yellow);
    color: var(--dark) !important;
    display: block !important; /* Necessario per il margin auto */
    width: fit-content !important; /* Il tasto si adatta al testo */
    margin: 0 auto !important; /* Centra orizzontalmente */
    padding: 16px 45px !important;
    border-radius: 15px;
    text-decoration: none;
    font-weight: 900;
    text-transform: uppercase;
    font-size: 12px;
    transition: 0.3s;
    min-width: 200px; /* Larghezza minima per consistenza */
    text-align: center;
    border: none;
}

/* HOVER EFFECTS */
.fleet-item-card:hover {
    background: var(--primary);
    border-color: var(--primary);
    transform: translateY(-10px);
}

/* Rimuoviamo il background e il transform dal CSS hover, li gestirà GSAP */
.fleet-item-card:hover {
    transform: none; /* Disabilitiamo il transform CSS per non andare contro GSAP */
    background: transparent; 
}

/* Impediamo all'auto di saltare */
.car-image-area img {
    transition: transform 0.1s linear; /* Transizione cortissima per fluidità manuale */
    will-change: transform;
}

.fleet-item-card:hover .btn-fast-book {
    background: var(--white);
    color: var(--primary) !important;
}

.fleet-item-card:hover h3 a {
    color: var(--yellow);
}


/* --- 1. ETICHETTE DI SEZIONE --- */
.card-section-label {
    display: block;
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--yellow);
    letter-spacing: 1.5px;
    margin-bottom: 8px;
    text-align: center;
}

/* --- 2. DASHBOARD UNIFICATA (CARATTERISTICHE E ACCESSORI) --- */
.car-specs-dashboard {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr); /* 3 colonne uguali */
    gap: 12px 8px !important;
    background: rgba(255, 255, 255, 0.03) !important;
    padding: 10px !important;
    border-radius: 20px !important;
    margin-bottom: 20px !important;
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
}

.inc-list {
    grid-template-columns: repeat(2, 1fr) !important;
    min-height: 90px;
}


/* --- 3. STILE ITEM INTERNI (ICONA -> DATA) --- */
.spec-tile, .inc-item {
    display: flex !important;
    gap: 4px !important;
}

.spec-icon svg, .inc-icon svg {
    width: 20px !important;
    height: 20px !important;
    stroke: var(--yellow) !important;
    opacity: 0.9;
}

/* Container Testi */
.spec-data, .inc-name {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

/* La voce (es: Posti, Porte, Cambio) - ORA VISIBILE */
.spec-label {
    display: block !important;
    font-size: 8px !important;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.4); /* Grigio chiaro per non appesantire */
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* Il valore o il nome dell'accessorio */
.spec-val, .inc-name {
    font-size: 10px !important;
    color: var(--white) !important;
    font-weight: 800;
    text-transform: uppercase;
}

/* --- 4. BLOCCO PREZZO --- */
.car-price-block {
    margin: 15px 0 20px;
    text-align: center;
}



/* --- PAGINA RISULTATI (results-view) --- */
.results-view .hero-search-form, 
.results-view .wcr-search-wrapper {
    margin-top: -100px;
    position: relative;
    z-index: 100;
}

.results-view .wcr-fleet-container {
    background: #171717 !important;
    border: 1px solid rgba(255, 215, 0, 0.2);
    border-radius: 40px;
    padding: 30px !important;
}

/* Invito alla ricerca (quando vuoto) */
.wcr-landing-search-invite {
    text-align: center;
    padding: 100px 40px;
    background: #fff;
    border-radius: 40px;
    box-shadow: var(--shadow-premium);
    margin-top: 40px;
}

.wcr-landing-search-invite .invite-icon {
    font-size: 60px;
    margin-bottom: 20px;
}

.wcr-landing-search-invite h2 {
    color: var(--primary);
    font-weight: 900;
    text-transform: uppercase;
    margin-bottom: 15px;
}

.wcr-landing-search-invite p {
    color: var(--gray);
    font-size: 18px;
    max-width: 600px;
    margin: 0 auto;
}

/* Messaggio "Nessuna Auto" */
.wcr-no-results-premium {
    grid-column: 1 / -1;
    text-align: center;
    padding: 80px 20px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 30px;
    border: 1px dashed rgba(255, 255, 255, 0.1);
}

/* --- WCR AVAILABILITY BADGE SYSTEM --- */

/* 1. Base del Badge (Struttura comune) */
.wcr-availability-badge {
    position: absolute;
    top: 25px;
    right: 25px;
    z-index: 15;
    padding: 8px 18px;
    border-radius: 50px;
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* 2. Stato: DISPONIBILITÀ LIMITATA (Stile Alert Premium) */
.wcr-badge-limited {
    background: linear-gradient(135deg, var(--yellow) 0%, #e6c200 100%);
    color: var(--dark);
    border-color: rgba(255, 215, 0, 0.5);
    /* Animazione a pulsazione discreta per segnalare urgenza */
    animation: wcr-badge-pulse 2s infinite;
}

/* 3. Stato: DISPONIBILE (Stile Success Tech) */
.wcr-badge-available {
    background: rgba(16, 185, 129, 0.85); /* Verde smeraldo con trasparenza */
    color: #ffffff;
    border-color: rgba(16, 185, 129, 0.3);
}

/* 4. Effetto Hover sulla Card (il badge reagisce) */
.fleet-item-card:hover .wcr-availability-badge {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
}

/* Uniforma card su tutti i contesti */
.archive .fleet-item-card,
.wcr-fleet-grid .fleet-item-card,
.results-view .fleet-item-card {
    flex: 0 0 auto !important; /* Annulla il flex fisso della Home se ereditato */
    width: 100% !important;    /* Si adatta alla colonna della griglia */
    height: 520px;             /* Stessa altezza della Home */
    background: #111;
    border-radius: 35px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}


/* --- ANIMAZIONI --- */

@keyframes wcr-badge-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.6);
    }
    70% {
        box-shadow: 0 0 0 12px rgba(255, 215, 0, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 215, 0, 0);
    }
}

/* Responsive Fix */
@media (max-width: 768px) {
    .wcr-availability-badge {
        top: 15px;
        right: 15px;
        padding: 6px 14px;
        font-size: 9px;
    }
}


/* Responsive fix */
@media (max-width: 768px) {
    .results-view .hero-search-form { margin-top: -60px; }
    .wcr-landing-search-invite { padding: 60px 20px; }
}

/* 6. RESPONSIVE */

/* Desktop normali: 3 colonne */
@media (max-width: 1400px) {
    .archive .products {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

/* Tablet: 2 colonne */
@media (max-width: 1024px) {
    .archive .products {
        grid-template-columns: 1fr 1fr !important;
    }
}

/* Mobile: 1 colonna */
@media (max-width: 768px) {
    /* Forza la colonna singola sia nello shop che nei risultati ricerca (Prenota) */
    .archive .products, 
    .wcr-fleet-grid {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    
    /* Resetta le dimensioni delle card per i risultati ricerca */
    .wcr-fleet-grid .fleet-item-card {
        width: 100% !important;
        flex: 0 0 100% !important;
        height: auto !important; /* Permette alla card di adattarsi al contenuto */
        min-height: 450px;
    }

    .home .fleet-carousel .fleet-item-card {
        flex: 0 0 100% !important;
        width: 100% !important;
        scroll-snap-align: center;
    }

    .home .fleet-carousel {
        padding: 0 !important;
        gap: 0 !important;
        scroll-behavior: smooth;
    }

    /* Stile delle Frecce (Carosello Home) */
    .carousel-nav-btn {
        display: flex !important;
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        width: 45px;
        height: 45px;
        background: var(--yellow);
        border: none;
        border-radius: 50%;
        z-index: 100;
        align-items: center;
        justify-content: center;
        box-shadow: var(--shadow-dark);
        cursor: pointer;
    }

    .carousel-nav-btn.prev { left: -10px; }
    .carousel-nav-btn.next { right: -10px; }
    
    .carousel-nav-btn i { font-size: 24px; color: var(--dark); }
}

/* Nascondi frecce su desktop */
@media (min-width: 769px) {
    .carousel-nav-btn { display: none !important; }
}

/* FIX VISIBILITÀ RISULTATI PRENOTA */
.results-view .wcr-results-container .fleet-item-card {
    /* Sovrascriviamo lo stato nascosto di base per i risultati */
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
}

/* Se però vogliamo mantenere l'animazione fluida, usiamo questa variante più raffinata: */
.js-enabled .results-view .wcr-results-container .fleet-item-card.is-visible {
    opacity: 1 !important;
    visibility: visible !important;
}