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

/* Mobile and Tablet layout - logo centered, contacts menu on right */
/* Esteso fino a 1400px per includere tutti i tablet in orizzontale (incluso iPad Pro 12.9") */
@media (max-width: 1400px) {
    /* Prevent horizontal scroll and ensure centering */
    body {
        overflow-x: hidden;
        width: 100%;
        /* Prevent scroll issues on mobile */
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: none;
    }
    
    /* Header mobile e tablet */
    .header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        background: var(--color-bg-dark);
        padding: 0;
        z-index: 1000;
        height: 80px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.3);
        transition: transform 0.3s ease-in-out;
    }
    
    .header-container {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        position: relative;
        padding: 0;
        gap: 0;
        height: 100%;
    }
    
    .logo {
        position: relative;
        left: auto;
        transform: none;
        margin: 0 auto;
        flex: 0 0 auto;
        width: 100%;
        height: 100%;

        max-width: 80px;
        background: var(--color-bg-dark);
        border-radius: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: none;
        padding: 5px;
    }
    
    .logo img {
        width: 100%;
        height: 100%;
        object-fit: contain;
        max-height: 100%;
        max-width: 100%;
    }
    
    .logo:hover {
        background: #0D0D0D;
        transform: none;
        box-shadow: none;
    }
    
    .logo:active {
        background: #0D0D0D;
        transform: scale(1.05);
        box-shadow: none;
        transition: all 0.3s ease;
    }
    
    /* Nascondi i contatti desktop */
    .contact-info {
        display: none;
    }
    
    /* Bottone menu contatti mobile */
    .mobile-contacts-toggle {
        position: absolute;
        right: 15px;
        background: transparent;
        border: none;
        color: #F2F2E4;
        font-size: 0.95rem;
        font-weight: 600;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-radius: 8px;
        transition: all 0.3s ease;
    }
    
    .mobile-contacts-toggle:hover {
        background: rgba(255,255,255,0.1);
    }
    
    /* Colore rosso quando il menu è aperto */
    .mobile-contacts-toggle.active {
        color: var(--color-primary);
    }
    
    .mobile-contacts-toggle i {
        font-size: 0.8rem;
        transition: transform 0.3s ease;
    }
    
    .mobile-contacts-toggle.active i {
        transform: rotate(180deg);
    }
    
    /* Menu contatti a tendina */
    .mobile-contacts-menu {
        position: absolute;
        top: calc(100% + 10px);
        right: 15px;
        background: #1F1F1F;
        border-radius: 15px;
        padding: 15px;
        min-width: 250px;
        box-shadow: 0 8px 25px rgba(0,0,0,0.4);
        opacity: 0;
        visibility: hidden;
        transform: translateY(-10px);
        transition: all 0.3s ease;
        z-index: 1001;
        border: 1px solid rgba(255,255,255,0.1);
    }
    
    .mobile-contacts-menu.active {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
    
    .mobile-contacts-menu .phone,
    .mobile-contacts-menu .email {
        display: flex;
        align-items: center;
        gap: 10px;
        color: #F2F2E4;
        text-decoration: none;
        padding: 12px;
        border-radius: 10px;
        transition: all 0.3s ease;
        font-size: 0.9rem;
        margin-bottom: 8px;
    }
    
    .mobile-contacts-menu .phone:hover,
    .mobile-contacts-menu .email:hover {
        background: rgba(255,255,255,0.1);
        color: var(--color-primary);
    }
    
    .mobile-contacts-menu .phone i,
    .mobile-contacts-menu .email i {
        font-size: 1rem;
        width: 20px;
        text-align: center;
    }
    
    /* Social links nel menu */
    .mobile-contacts-menu .social-links {
        display: flex;
        justify-content: center;
        gap: 12px;
        margin-top: 15px;
        padding-top: 15px;
        border-top: 1px solid rgba(255,255,255,0.1);
    }
    
    .mobile-contacts-menu .social-links a {
        width: 42px;
        height: 42px;
        font-size: 1.2rem;
        background: rgba(255,255,255,0.1);
        border: 1px solid rgba(255,255,255,0.2);
        border-radius: 50%;
        color: #F2F2E4;
        display: flex;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        transition: all 0.3s ease;
    }
    
    .mobile-contacts-menu .social-links a:hover {
        background: var(--color-primary);
        border-color: var(--color-primary);
        transform: scale(1.1);
        color: white;
    }
    
    /* Disable hover on touch devices completely */
    @media (hover: none) {
        .logo:hover {
            background: #0D0D0D;
            transform: none;
            box-shadow: 0 2px 8px rgba(0,0,0,0.2);
        }
        
        .logo:active {
            background: #0D0D0D;
            transform: scale(1.125);
            box-shadow: 0 4px 12px rgba(0,0,0,0.3);
            transition: all 0.2s ease;
        }
        
        .mobile-contacts-menu .social-links a:active {
            background: #D93829;
            transform: scale(0.95);
        }
    }

    /* Responsive adjustments for mobile brands */
    .filters-and-brands-section {
        margin: 1rem auto;
        border-radius: 15px;
        max-width: 1200px;
    }
    
    .brands-nav {
        padding: 20px 20px 15px 20px;
        position: relative;
    }
    
    .filters-section {
        padding: 15px 20px 25px 20px;
    }
    
    .brands-nav h2 {
        font-size: 1.5rem;
        padding: 0;
    }
    
    .brands-scroll-track {
        padding: 15px 20px;
        gap: 15px;
    }
    
    .scroll-fade-left,
    .scroll-fade-right {
        width: 20px;
    }
    
    .scroll-arrow {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
    
    .scroll-arrow-left {
        left: 5px;
    }
    
    .scroll-arrow-right {
        right: 5px;
    }
    
    .brand-item {
        min-width: 75px;
        padding: 12px 8px;
    }
    
    .brand-item img {
        width: 35px;
        height: 35px;
    }
    
    .brand-item span {
        font-size: 0.8rem;
    }

    /* Mobile filters - new floating circular button system */
    /* Hide desktop filters section completely on mobile and tablet */
    .filters-section {
        display: none !important;
    }
    
    /* Mobile floating filter button - red circle in bottom left (same size as back-to-top) */
    .mobile-filter-button {
        position: fixed;
        bottom: 30px;
        left: 30px;

        width: 50px;
        height: 50px;
        background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
        border: none;
        border-radius: 50%;
        color: white;
        font-size: 20px;
        cursor: pointer;
        z-index: 1000;
        transition: all 0.3s ease;
        box-shadow: 0 4px 20px rgba(220, 38, 38, 0.4);
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .mobile-filter-button:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 25px rgba(220, 38, 38, 0.5);
    }
    
    /* Square style when popup is open */
    .mobile-filter-button.active {
        border-radius: 15px;
        background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
        box-shadow: 0 4px 20px rgba(107, 114, 128, 0.4);
    }
    
    .mobile-filter-button.active:hover {
        box-shadow: 0 6px 25px rgba(107, 114, 128, 0.5);
    }
    
    /* Filter popup overlay */
    .mobile-filter-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1001;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }
    
    .mobile-filter-overlay.active {
        opacity: 1;
        visibility: visible;
    }
    
    /* Filter popup container */
    .mobile-filter-popup {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-radius: 20px 20px 0 0;
        z-index: 1001;
        transform: translateY(100%);
        transition: transform 0.3s ease;
        max-height: calc(80vh - 125px); /* Account for button row space with separator */
        display: flex;
        flex-direction: column;
        padding-bottom: 125px; /* Space for button row with separator */
    }
    
    .mobile-filter-popup.active {
        transform: translateY(0);
    }
    
    /* Popup footer with action buttons aligned with X button - FIXED AT BOTTOM */
    .mobile-filter-header {
        position: fixed;
        bottom: 30px; /* Same as X button */
        left: 0;
        right: 0;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 15px 30px 0; /* Top padding for separator line */
        background: white;
        border-top: 2px solid #e5e7eb; /* Separator line */
        z-index: 1002;
        height: 65px; /* Increased height to accommodate separator */
    }
    
    .mobile-filter-close {
        position: fixed;
        bottom: 30px;
        left: 30px;
        width: 50px;
        height: 50px;
        border: none;
        background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);  /* Grigio scuro come richiesto */
        color: white;
        border-radius: 15px;
        font-size: 20px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
        flex-shrink: 0;
        box-shadow: 0 4px 15px rgba(107, 114, 128, 0.3);
        z-index: 1003;
    }
    
    .mobile-filter-close:hover {
        background: linear-gradient(135deg, #4b5563 0%, #374151 100%);
        transform: scale(1.05);
        box-shadow: 0 6px 20px rgba(107, 114, 128, 0.4);
    }
    
    .mobile-filter-actions {
        display: flex;
        gap: 10px;
        align-items: center;
        height: 50px; /* Same height as X button for perfect alignment */
    }
    
    /* Spacer to push actions to the right while keeping X button in place */
    .mobile-filter-header::before {
        content: '';
        width: 50px; /* Same width as X button to maintain space */
    }
    
    .mobile-filter-apply,
    .mobile-filter-remove {
        padding: 10px 18px;
        border: none;
        border-radius: 20px;  /* Lati molto arrotondati */
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s ease;
        font-size: 14px;
        min-width: 85px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }
    
    .mobile-filter-apply {
        background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);  /* Rosso come desktop */
        color: white;
        box-shadow: 0 4px 15px rgba(220, 38, 38, 0.3);
    }
    
    .mobile-filter-apply:hover {
        background: linear-gradient(135deg, var(--color-primary-dark) 0%, #991b1b 100%);
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(220, 38, 38, 0.4);
    }
    
    .mobile-filter-remove {
        background: linear-gradient(135deg, #4b5563 0%, #374151 100%);  /* Grigio scuro come desktop */
        color: white;
        box-shadow: 0 4px 15px rgba(75, 85, 99, 0.3);
    }
    
    .mobile-filter-remove:hover {
        background: linear-gradient(135deg, #374151 0%, #1f2937 100%);
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(75, 85, 99, 0.4);
    }
    
    /* Scrollable filters content */
    .mobile-filter-content {
        flex: 1;
        overflow-y: auto;
        padding: 20px;
    }
    
    /* Style filters inside popup */
    .mobile-filter-content .filters-row {
        display: grid;
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .mobile-filter-content .main-filters,
    .mobile-filter-content .advanced-row {
        display: grid;
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    /* Show all advanced filters in mobile popup */
    .mobile-filter-content .advanced-filters {
        display: block;
        opacity: 1;
        max-height: none;
    }
    
    .mobile-filter-content .expand-toggle {
        display: none;
    }
    
    /* Hide the duplicate action buttons from desktop filters */
    .mobile-filter-content .filters-actions {
        display: none !important;
    }
    
    .mobile-filter-content .filter-group {
        margin-bottom: 0;
    }
    
    .mobile-filter-content .filter-group label {
        font-size: 16px;
        margin-bottom: 8px;
    }
    
    .mobile-filter-content select,
    .mobile-filter-content input {
        font-size: 16px;
        padding: 12px;
    }

    /* Brands filter button - positioned in brands box (mobile only) */
    .brands-filter-button {
        position: absolute;
        bottom: 15px;
        left: 15px;

        width: 40px;
        height: 40px;
        background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
        border: none;
        border-radius: 50%;
        color: white;
        font-size: 16px;
        cursor: pointer;
        z-index: 100;
        transition: all 0.3s ease;
        box-shadow: 0 3px 15px rgba(220, 38, 38, 0.4);
        display: flex;
        align-items: center;
        justify-content: center;
        opacity: 1;
        transform: scale(1);
    }
    
    .brands-filter-button:hover {
        transform: translateY(-2px) scale(1.05);
        box-shadow: 0 5px 20px rgba(220, 38, 38, 0.5);
    }
    
    /* Hide brands filter button when scrolled */
    .brands-filter-button.hidden {
        opacity: 0;
        transform: scale(0.8);
        pointer-events: none;
    }
    
    /* Show/hide main mobile filter button based on scroll */
    .mobile-filter-button.hidden {
        opacity: 0;
        transform: translateY(100px) scale(0.8);
        pointer-events: none;
    }
    
    /* Show/hide back-to-top button with same animation as filter button */
    .back-to-top.hidden {
        opacity: 0;
        transform: translateY(100px) scale(0.8);
        pointer-events: none;
    }

    /* Responsive lightbox */
    .lightbox-nav {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
    
    .lightbox-prev {
        left: 10px;
    }
    
    .lightbox-next {
        right: 10px;
    }
    
    .lightbox-close {
        top: 10px;
        right: 10px;
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
    }
    
    .lightbox-content {
        max-width: 95%;
        max-height: 85%;
    }
    
    .lightbox-title {
        font-size: 1rem;
        max-width: 300px;
    }

    /* Responsive for car detail modal */
    .car-detail-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        width: 100vw;
        height: 100vh;
        padding: 0;
        gap: 0;
        background: transparent;
        border-radius: 0;
        box-shadow: none;
        position: fixed;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
    }
    
    .car-detail-images {
        padding: 20px;
        height: 45vh;
        background: transparent;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .car-detail-carousel {
        max-height: 450px;
        max-width: 100%;
        border-radius: 15px;
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25);
        background: transparent;
    }
    
    .car-detail-slide {
        border-radius: 15px;
        background: transparent;
    }
    
    .car-detail-slide img {
        border-radius: 15px;
        cursor: pointer;
        transition: transform 0.2s ease;
    }
    
    .car-detail-slide img:active {
        transform: scale(0.98);
    }
    
    .car-detail-info {
        padding: 20px;
        padding-bottom: 100px; /* Extra space at bottom to show social buttons */
        height: 55vh;
        max-height: none;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.15);
        background: white;
        margin: 0;
        overflow-y: auto;
        position: sticky;
        bottom: 0;
    }
    
    .car-detail-nav {
        background: rgba(0, 0, 0, 0.8);
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        border: 2px solid rgba(255, 255, 255, 0.3);
        backdrop-filter: blur(8px);
    }
    
    .car-detail-nav:hover {
        background: rgba(217, 56, 41, 0.9);
        border-color: rgba(217, 56, 41, 0.8);
    }
    
    .car-detail-indicators {
        background: rgba(0, 0, 0, 0.7);
        padding: 10px 15px;
        border-radius: 20px;
        backdrop-filter: blur(8px);
    }
    
    .car-detail-close {
        background: rgba(0, 0, 0, 0.8);
        border: 2px solid rgba(255, 255, 255, 0.3);
        backdrop-filter: blur(10px);
        width: 45px;
        height: 45px;
        top: 20px;
        right: 20px;
    }
    
    .car-detail-close:hover {
        background: rgba(217, 56, 41, 0.8);
        border-color: rgba(217, 56, 41, 0.8);
    }
    
    /* Fullscreen image overlay for mobile */
    .mobile-fullscreen-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.95);
        z-index: 10000;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 0;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        backdrop-filter: blur(10px);
    }
    
    .mobile-fullscreen-overlay.active {
        opacity: 1;
        visibility: visible;
    }
    
    /* Hide car detail modal elements when fullscreen is active */
    .mobile-fullscreen-overlay.active ~ .car-detail-content .car-detail-close,
    .mobile-fullscreen-overlay.active ~ .car-detail-content .car-detail-nav,
    .mobile-fullscreen-overlay.active ~ .car-detail-content .car-detail-indicators {
        opacity: 0;
        pointer-events: none;
        visibility: hidden;
    }
    
    /* Alternative approach - hide elements when body has fullscreen class */
    body.mobile-fullscreen-active .car-detail-close,
    body.mobile-fullscreen-active .car-detail-nav,
    body.mobile-fullscreen-active .car-detail-indicators {
        opacity: 0;
        pointer-events: none;
        visibility: hidden;
        transition: opacity 0.3s ease;
    }
    
    .mobile-fullscreen-image {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 100%;
        height: 100%;
        object-fit: contain;
        border-radius: 0;
        display: block;
        cursor: pointer;
        transition: none;
    }
    
    .mobile-fullscreen-close {
        position: absolute;
        top: 20px;
        right: 20px;
        background: rgba(0, 0, 0, 0.8);
        color: white;
        border: 2px solid rgba(255, 255, 255, 0.3);
        width: 50px;
        height: 50px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        font-size: 1.3rem;
        transition: all 0.3s ease;
        backdrop-filter: blur(10px);
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
        z-index: 10001;
        opacity: 1;
    }
    
    .mobile-fullscreen-close:hover {
        background: rgba(217, 56, 41, 0.9);
        border-color: rgba(217, 56, 41, 0.8);
        transform: scale(1.1);
    }
    
    .mobile-fullscreen-controls {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 20px;
        width: 100%;
        max-width: 400px;
        z-index: 10001;
        position: absolute;
        bottom: 30px;
        left: 50%;
        transform: translateX(-50%);
        opacity: 1;
        transition: opacity 0.3s ease;
    }
    
    /* Nasconde i controlli quando si clicca sull'immagine */
    .mobile-fullscreen-overlay.hide-controls .mobile-fullscreen-controls,
    .mobile-fullscreen-overlay.hide-controls .mobile-fullscreen-close {
        opacity: 0;
        pointer-events: none;
    }
    
    .mobile-fullscreen-nav {
        background: rgba(0, 0, 0, 0.5);
        color: rgba(255, 255, 255, 0.7);
        border: 1px solid rgba(255, 255, 255, 0.2);
        width: 40px;
        height: 40px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        font-size: 1rem;
        transition: all 0.3s ease;
        backdrop-filter: blur(8px);
    }
    
    .mobile-fullscreen-nav:hover {
        background: rgba(217, 56, 41, 0.6);
        color: rgba(255, 255, 255, 0.9);
        border-color: rgba(217, 56, 41, 0.5);
    }
    
    .mobile-fullscreen-indicators {
        display: flex;
        gap: 8px;
        background: rgba(0, 0, 0, 0.5);
        padding: 8px 15px;
        border-radius: 20px;
        backdrop-filter: blur(8px);
        border: 1px solid rgba(255, 255, 255, 0.15);
    }
    
    .mobile-fullscreen-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.4);
        cursor: pointer;
        transition: all 0.3s ease;
        border: 1px solid rgba(255, 255, 255, 0.2);
    }
    
    .mobile-fullscreen-dot.active {
        background: rgba(217, 56, 41, 0.8);
        border-color: rgba(217, 56, 41, 0.6);
        transform: scale(1.2);
    }
    
    .mobile-fullscreen-dot:hover {
        background: rgba(217, 56, 41, 0.6);
        border-color: rgba(217, 56, 41, 0.4);
    }
    
    .mobile-fullscreen-info {
        display: none !important;
    }
    
    .car-detail-title {
        font-size: 1.4rem;
    }
    
    .car-detail-title-sub {
        font-size: 0.85em;
    }
    
    .car-detail-price {
        font-size: 1.2rem;
    }
    
    .car-specs-grid {
        gap: 6px;
        font-size: 0.8rem;
    }
    
    .car-spec-item {
        padding: 6px 10px;
    }
    
    .car-spec-label,
    .car-spec-value {
        font-size: 0.8rem;
    }
    
    .contact-info-direct {
        gap: 6px;
    }
    
    .contact-item {
        padding: 8px 12px;
        font-size: 0.8rem;
        margin-bottom: 4px;
    }
    
    .social-contact-row {
        gap: 10px;
        padding: 8px 0;
    }
    
    .social-contact-item {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
    
    /* Add margin at bottom of contact section to ensure visibility */
    .car-detail-contact {
        margin-bottom: 80px !important;
        padding-bottom: 20px;
    }
    
    /* Mantieni scrollbar arrotondata anche su tablet */
    .car-detail-info::-webkit-scrollbar {
        width: 7px;
    }
    
    .car-detail-info::-webkit-scrollbar-thumb {
        background: rgba(217, 56, 41, 0.7);
        border-radius: 10px;
    }

    /* Mobile notifications - optimized for touch devices */
    .notification {
        top: 90px;
        left: 15px;
        right: 15px;
        transform: translateY(-120px);
        font-size: 1rem;
        padding: 18px 24px;
        border-radius: 16px;
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
        backdrop-filter: blur(20px);
        border: 2px solid rgba(255, 255, 255, 0.15);
        text-align: center;
        min-height: 60px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 12px;
    }
    
    .notification.show {
        transform: translateY(0);
    }
    
    .notification i {
        font-size: 1.3rem;
    }
    
    .notification.success {
        background: linear-gradient(135deg, rgba(5, 150, 105, 0.95) 0%, rgba(4, 120, 87, 0.95) 100%);
        box-shadow: 0 12px 40px rgba(5, 150, 105, 0.4);
    }
    
    .notification.info {
        background: linear-gradient(135deg, rgba(220, 38, 38, 0.95) 0%, rgba(185, 28, 28, 0.95) 100%);
        box-shadow: 0 12px 40px rgba(220, 38, 38, 0.4);
    }

    /* Mobile version dealership gallery */
    .dealership-gallery {
        display: block !important;
        height: 280px; /* Smaller height for mobile */
        margin-top: 70px; /* Esattamente alla fine dell'header mobile */
        background: #0D0D0D; /* Ensure background is visible on mobile */
    }

    .dealership-track {
        padding: 30px 0;
        gap: 15px; /* Smaller gap on mobile */
        transition: transform 0.8s ease; /* Slower transition on mobile */
    }

    /* Mobile slide sizes */
    .dealership-slide {
        width: 280px;
        height: 157px; /* 16:9 ratio for 280px width */
    }

    .dealership-slide.center {
        width: 320px;
        height: 180px; /* 16:9 ratio for 320px width */
        transform: scale(1.05); /* Less scaling on mobile */
    }

    /* Slower transitions for mobile slides */
    .dealership-slide {
        transition: all 0.6s ease; /* Slower transitions on mobile */
    }

    /* Mobile arrows - larger and more touch-friendly */
    .dealership-arrow {
        width: 60px;
        height: 60px;
        font-size: 24px;
        top: auto;
        bottom: 15px; /* Stesso livello degli indicatori */
        transform: none;
    }

    .dealership-arrow-left {
        left: 10px;
    }

    .dealership-arrow-right {
        right: 10px;
    }

    /* Mobile indicators - larger for touch */
    .dealership-dot {
        width: 16px;
        height: 16px;
        border-width: 3px;
    }

    .dealership-indicators {
        bottom: 15px;
        gap: 12px;
    }

    /* Responsive per mobile - recently added */
    /* Container occupa tutta la larghezza orizzontale - ZERO spazi bianchi */
    .recently-added-section {
        margin: 40px 0 60px 0;
        padding: 40px 0;
        border-radius: 15px;
        background: linear-gradient(135deg, #2A2A2A, #1F1F1F);
        max-width: 100%;
        width: 100%;
    }
    
    .recently-added-title {
        font-size: 2rem;
        padding: 0 20px;
        margin-bottom: 30px;
    }
    
    .recently-added-grid {
        grid-template-columns: 350px;
        gap: 20px;
        width: 100%;
        max-width: 350px;
        margin: 0 auto;
        justify-content: center;
        padding: 0 20px;
    }
    
    /* Card con dimensioni FISSE - identiche alle altre */
    .recently-added-section .car-card {
        width: 100% !important;
        max-width: 350px !important;
        min-width: 280px !important;
    }
    
    .recently-added-tag {
        top: 10px;
        right: 10px;
        padding: 6px 12px;
        font-size: 0.75rem;
    }
    
    /* Card usano stili standard - NESSUN override */

    /* Carousel per mobile nella sezione novità */
    .recently-added-carousel {
        position: relative;
        width: 100%;
        overflow: hidden;
        border-radius: 0;
        padding: 0;
    }
    
    .recently-added-carousel-track {
        display: flex;
        transition: transform 0.3s ease;
        width: 100%;
    }
    
    .recently-added-carousel-slide {
        flex: 0 0 100%;
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 0 20px;
    }
    
    /* Card con dimensioni FISSE nel carousel - 350px */
    .recently-added-carousel-slide .car-card {
        margin: 0 auto;
        width: 100% !important;
        max-width: 350px !important;
        min-width: 280px !important;
    }
    
    /* Navigation container with arrows and indicators */
    .recently-added-carousel-navigation {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-top: 20px;
        padding: 0 10px;
    }
    
    /* Navigation arrows */
    .recently-added-carousel-arrow {
        background: rgba(217, 56, 41, 0.9);
        border: none;
        border-radius: 50%;
        width: 45px;
        height: 45px;
        color: white;
        font-size: 16px;
        cursor: pointer;
        transition: all 0.3s ease;
        box-shadow: 0 4px 15px rgba(217, 56, 41, 0.3);
        flex-shrink: 0;
    }
    
    .recently-added-carousel-arrow:active {
        transform: scale(0.9);
        background: rgba(217, 56, 41, 1);
    }
    
    /* Indicators container centered between arrows */
    .recently-added-carousel-indicators {
        display: flex;
        justify-content: center;
        gap: 10px;
        flex: 1;
        margin: 0 20px;
    }
    
    .recently-added-carousel-dot {
        width: 12px;
        height: 12px;
        border-radius: 50%;
        border: 2px solid rgba(255, 255, 255, 0.5);
        background: transparent;
        cursor: pointer;
        transition: all 0.3s ease;
    }
    
    .recently-added-carousel-dot.active {
        background: #D93829;
        border-color: #D93829;
        box-shadow: 0 0 10px rgba(217, 56, 41, 0.5);
    }

    /* General responsive */
    .header {
        padding: 15px 0;
    }

    .main-content {
        margin-top: 0px;
        padding: 40px 20px;
        margin-left: auto;
        margin-right: auto;
        max-width: 100%;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .hero p {
        font-size: 1.1rem;
    }

    .brands-grid {
        gap: 12px;
    }
    
    .brand-link {
        width: 100px;
        height: 120px;
        padding: 12px 8px;
    }
    
    .brand-logo {
        width: 50px;
        height: 50px;
        padding: 6px;
    }
    
    .brand-name {
        font-size: 0.8rem;
        max-width: 85px;
    }

    .cars-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 350px));
        max-width: calc(350px * 3 + 60px);
        margin: 0 auto;
        justify-content: center;
        gap: 30px;
        padding: 0 20px;
    }
    
    /* Card responsive - si adattano allo schermo */
    .car-card {
        width: 100%;
        max-width: 350px;
        min-width: 280px;
    }
    
    /* Layout desktop per modal su dispositivi piccoli in landscape */
    /* Quando in orizzontale con poca altezza (es. iPhone landscape) */
    @media (max-height: 500px) and (orientation: landscape) {
        .car-detail-content {
            grid-template-columns: 1fr 1fr !important;
            grid-template-rows: 1fr !important;
            gap: 20px !important;
            padding: 20px !important;
            width: 95vw !important;
            height: 95vh !important;
        }
        
        .car-detail-images {
            padding: 0 !important;
            height: 100% !important;
            width: 100% !important;
        }
        
        .car-detail-carousel {
            height: 100% !important;
            max-height: 100% !important;
        }
        
        .car-detail-info {
            padding: 20px !important;
            height: 100% !important;
            max-height: 100% !important;
            border-radius: 15px !important;
            box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25) !important;
        }
    }
}

/* Hide mobile toggle and mobile filter buttons on desktop */
/* Cambiato a 1401px per includere tutti i tablet in orizzontale nella versione mobile */
@media (min-width: 1401px) {
    .mobile-filters-toggle {
        display: none;
    }
    
    .mobile-filter-button {
        display: none !important;
    }
    
    .brands-filter-button {
        display: none !important;
    }
    
    /* Hide mobile contacts menu on desktop */
    .mobile-contacts-toggle {
        display: none !important;
    }
    
    .mobile-contacts-menu {
        display: none !important;
    }
    
    /* Hide mobile fullscreen overlay and its controls on desktop */
    .mobile-fullscreen-overlay {
        display: none !important;
    }
    
    .mobile-fullscreen-close,
    .mobile-fullscreen-nav,
    .mobile-fullscreen-controls {
        display: none !important;
    }
}

/* Extra small screens (smartphones) */
@media (max-width: 480px) {
    .header {
        padding: 10px 0;
    }

    .header-container {
        gap: 10px;
        padding: 5px 15px;
    }

    .logo {
        height: 45px;
        width: 160px;
        font-size: 1.3rem;
    }

    .logo img {
        max-height: 170%;
        max-width: 170%;
    }

    .phone {
        font-size: 1rem;
    }

    .social-links a {
        font-size: 1.1rem;
        width: 30px;
        height: 30px;
    }

    .main-content {
        margin-top: 0px;
    }

    .hero h1 {
        font-size: 1.8rem;
    }
    
    .brands-grid {
        gap: 10px;
    }
    
    .brand-link {
        width: 90px;
        height: 110px;
        padding: 10px 6px;
    }
    
    .brand-logo {
        width: 45px;
        height: 45px;
        padding: 5px;
    }
    
    .brand-name {
        font-size: 0.75rem;
        max-width: 75px;
    }

    .car-detail-content {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        grid-template-rows: auto 1fr;
        gap: 0;
        background: transparent;
        box-shadow: none;
    }
    
    .car-detail-images {
        padding: 15px;
        height: 40vh;
        background: transparent;
    }
    
    .car-detail-carousel {
        max-height: 300px;
        border-radius: 12px;
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    }
    
    .car-detail-slide {
        border-radius: 12px;
    }
    
    .car-detail-slide img {
        border-radius: 12px;
    }
    
    .car-detail-info {
        padding: 15px;
        height: 60vh;
        max-height: none;
        border-radius: 15px 15px 0 0;
        margin: 0;
        box-shadow: 0 -8px 25px rgba(0, 0, 0, 0.15);
        overflow-y: auto;
    }
    
    /* Mantieni scrollbar arrotondata anche su mobile */
    .car-detail-info::-webkit-scrollbar {
        width: 6px;
    }
    
    .car-detail-info::-webkit-scrollbar-thumb {
        background: rgba(217, 56, 41, 0.7);
        border-radius: 10px;
    }
    
    .car-detail-title {
        font-size: 1.2rem;
    }
    
    .car-detail-title-sub {
        font-size: 0.85em;
        display: block;
        margin-top: 5px;
    }
    
    .car-detail-price {
        font-size: 1.1rem;
    }
    
    /* Homepage responsive styles */
    .homepage-hero {
        min-height: 60vh;
        padding: 60px 15px;
        margin: 10px;
    }
    
    .homepage-hero h1 {
        font-size: 2.5rem;
    }
    
    .homepage-hero p {
        font-size: 1.2rem;
    }
    
    .cta-button {
        padding: 15px 25px;
        font-size: 1.1rem;
        gap: 10px;
    }
    
    /* Home button responsive */
    .home-button-section {
        padding: 0 15px;
        margin-bottom: 20px;
        margin-top: 55px; /* Esattamente alla fine dell'header mobile */
    }
    
    .home-page-button {
        padding: 10px 16px;
        font-size: 0.9rem;
    }
}

/* ========================================== */
/* MOBILE PERFORMANCE & TOUCH OPTIMIZATIONS */
/* ========================================== */

/* Touch active state for cards */
.car-card.touch-active {
    transform: translateZ(0) scale(0.97);
    box-shadow: 0 4px 16px rgba(217, 56, 41, 0.25);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

/* Reduce animations during scroll for better performance */
body.is-scrolling .car-card {
    pointer-events: none; /* Prevent interactions during scroll */
}

body.is-scrolling .car-card,
body.is-scrolling .car-card::before,
body.is-scrolling .carousel-slide img {
    transition: none !important;
    animation: none !important;
}

/* Visible cards optimization - IMPROVED */
.car-card {
    /* Always visible by default to prevent flickering */
    opacity: 1 !important;
    visibility: visible !important;
}

.car-card.is-visible {
    /* Card is in viewport - ensure full rendering */
    content-visibility: auto;
}

.car-card:not(.is-visible) {
    /* Card is far from viewport - hint browser to deprioritize */
    content-visibility: auto;
    contain-intrinsic-size: 350px 500px; /* Maintain layout space */
}

/* Critical fix for iOS: Force all cards to always render */
@media (max-width: 1400px) {
    .car-card,
    .car-card.card-enter,
    .car-card.card-enter.visible {
        opacity: 1 !important;
        visibility: visible !important;
        display: block !important;
    }
    
    /* Ensure grid doesn't hide cards */
    .cars-grid {
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    /* Force card children to render */
    .car-image,
    .car-info,
    .car-title,
    .car-details,
    .car-price {
        opacity: 1 !important;
        visibility: visible !important;
    }
}

/* Prevent iOS elastic scroll bounce at boundaries */
@supports (-webkit-overflow-scrolling: touch) {
    /* Fix iOS scroll issues without breaking normal scroll */
    html {
        -webkit-overflow-scrolling: touch;
        overflow-scrolling: touch;
    }
    
    body {
        /* Prevent rubber band effect */
        overscroll-behavior-y: none;
        -webkit-overflow-scrolling: touch;
    }
    
    /* iOS-specific fix for disappearing elements */
    .car-card {
        -webkit-transform: translateZ(0) !important;
        -webkit-backface-visibility: hidden !important;
        -webkit-perspective: 1000 !important;
        /* Force repaint on iOS */
        will-change: opacity;
    }
    
    /* Prevent opacity glitches on iOS during scroll */
    .cars-grid {
        -webkit-transform: translateZ(0);
        -webkit-backface-visibility: hidden;
    }
}

/* Improve touch performance on all interactive elements */
@media (max-width: 1400px) {
    .car-card,
    .carousel-nav,
    .carousel-dot,
    button,
    a {
        /* Smooth touch interactions */
        -webkit-tap-highlight-color: rgba(217, 56, 41, 0.1);
        touch-action: manipulation;
    }
    
    /* Prevent text selection during touch interactions */
    .cars-grid,
    .car-card {
        -webkit-user-select: none;
        user-select: none;
    }
    
    /* Allow text selection in card details */
    .car-title,
    .car-details,
    .car-price {
        -webkit-user-select: text;
        user-select: text;
    }
}
