.interactive-carousel {
    position: relative;
    height: 600px;
    overflow: hidden;
}

.carousel-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: opacity 0.8s ease-in-out;
}

.carousel-content {
    position: relative;
    z-index: 2;
    height: 100%;
    background: rgba(0,0,0,0.4);
    /* Ensure content doesn't go under navbar on desktop */
    padding-top: 20px;
}

/* Carousel container positioning */
.carousel-container {
    height: 100%;
    display: flex;
    align-items: center;
}

/* Mobile-safe content positioning */
.mobile-safe-content {
    position: relative;
    z-index: 10;
}

.interactive-3d-viewer {
    position: relative;
    width: 140%; /* Increased to prevent horizontal cutoff */
    height: 650px; /* Increased from 600px */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible; /* Changed from hidden to visible to prevent corner cuts */
    margin-top: 50px;
    margin-left: -20%; /* Center the wider container */
    padding: 40px; /* Increased padding to prevent edge cutoff */
}

.interactive-3d-viewer canvas {
    max-width: 100%;
    max-height: 100%;
    width: auto !important;
    height: auto !important;
    user-select: none;
    -moz-user-select: none;
    cursor: grab;
}

.interactive-3d-viewer canvas:active {
    cursor: grabbing;
}

/* Zoom visual feedback */
.interactive-3d-viewer {
    position: relative;
}

.interactive-3d-viewer:hover::after {
    content: "🔄 Drag to rotate";
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 20;
}

.interactive-3d-viewer:hover::after {
    opacity: 1;
}

/* Mobile touch instructions - hidden on phones */
@media (max-width: 768px) {
    .interactive-3d-viewer:hover::after {
        display: none;
    }
}

/* Removed viewer instructions and progress bar styles */

/* Text transition effects */
#carousel-text-container * {
    transition: opacity 1s ease, transform 1s ease;
}

#carousel-text-container.fade-out * {
    opacity: 0;
    transform: translateY(20px);
}

/* Medium screen adjustments */
@media (min-width: 993px) and (max-width: 1399px) {
    .interactive-3d-viewer {
        height: 600px; /* Reduced from 800px */
        width: 160%; /* Reduced width to prevent overlap */
        transform: translateX(25%) translateY(-5%) scale(1.1); /* Moved further right to create space */
        margin-left: -30%; /* Adjusted margin */
        overflow: visible; /* Ensure no clipping */
    }
    
    /* Add spacing between text and animation */
    .col-lg-6:first-child {
        padding-right: 3rem !important;
    }
}

/* Big screen adjustments */
@media (min-width: 1400px) {
    .interactive-3d-viewer {
        height: 650px; /* Reduced from 900px */
        width: 180%; /* Reduced width to prevent overlap */
        transform: translateX(30%) translateY(-8%) scale(1.2); /* Moved further right to create space */
        margin-left: -40%; /* Adjusted margin */
        overflow: visible; /* Ensure no clipping */
    }
    
    /* Add spacing between text and animation */
    .col-lg-6:first-child {
        padding-right: 4rem !important;
    }
}

/* Responsive design */
@media (max-width: 1200px) {
    .interactive-3d-viewer {
        height: 500px; /* Increased from 400px */
        width: 130%; /* Wider container */
        margin-left: -15%; /* Center the wider container */
        padding: 40px; /* More padding to prevent cutoff */
        transform: scale(1.1); /* Slightly bigger scale */
    }
    
    /* Add top padding to account for sticky navbar on tablets */
    .carousel-content {
        padding-top: 80px;
    }
}

@media (max-width: 992px) {
    .interactive-carousel {
        height: 600px; /* Increased from 520px */
    }
    
    .interactive-3d-viewer {
        height: 400px; /* Increased from 340px */
        width: 140%; /* Even wider for medium screens */
        margin-top: 15px; /* Restored margin */
        margin-left: -20%; /* Center the wider container */
        padding: 50px; /* More padding */
        transform: scale(1.05); /* Slightly bigger scale */
    }
    
    .col-lg-6:last-child {
        margin-top: 15px; /* Reduced from 20px */
    }
    
    /* Minimal top padding for tablets */
    .carousel-content {
        padding: 30px 20px 20px 20px; /* Reduced top padding to 30px */
        align-items: flex-start !important;
    }
    
    .carousel-container {
        align-items: flex-start !important;
    }
    
    /* Add spacing for medium tablets */
    .mobile-safe-content {
        margin-top: 5px; /* Reduced from 10px */
    }
}

/* Medium tablets - bridge the gap between 768px and 991px */
@media (min-width: 769px) and (max-width: 991px) {
    .interactive-carousel {
        height: 650px; /* Increased from 550px */
    }
    
    .interactive-3d-viewer {
        height: 420px; /* Increased from 320px */
        width: 150%; /* Much wider for tablets */
        margin-top: 20px; /* Restored margin */
        margin-left: -25%; /* Center the wider container */
        padding: 60px; /* Even more padding */
        transform: scale(1.1); /* Bigger scale for medium tablets */
    }
    
    .carousel-content {
        padding: 30px 20px 25px 20px; /* Set to exactly 30px top padding */
        align-items: flex-start !important;
    }
    
    .carousel-container {
        align-items: flex-start !important;
    }
    
    .mobile-safe-content {
        margin-top: 5px; /* Reduced to minimal margin */
    }
    
    /* Adjust text sizing for medium tablets */
    #carousel-title {
        font-size: 2.8rem !important;
        line-height: 1.2;
    }
    
    #carousel-subtitle {
        font-size: 1rem;
    }
    
    #carousel-description {
        font-size: 1.1rem;
    }
}

@media (max-width: 768px) {
    .interactive-carousel {
        height: 800px; /* Further increased for bigger 3D viewer */
    }
    
    /* Stack content vertically on mobile */
    .carousel-container .row {
        flex-direction: column !important;
    }
    
    /* Text content takes full width and normal positioning */
    .col-10.col-lg-6 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        order: 1;
        margin-bottom: 20px;
    }
    
    /* Make car viewer column full width and position below text */
    #carViewerColumn {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        width: 100vw !important;
        position: relative;
        margin-left: calc(-50vw + 50%) !important;
        margin-right: 0 !important;
        padding: 0 !important;
        order: 2;
    }
    
    .interactive-3d-viewer {
        height: 400px; /* Increased from original but reduced from 450px */
        width: 100% !important; /* Full device width */
        margin-top: 20px; /* Increased margin */
        margin-left: 0 !important; /* No negative margins */
        padding: 20px; /* Reduced padding for full width */
        transform: scale(1.15); /* Moderate scale increase - reduced from 1.3 */
        display: flex;
        justify-content: center; /* Center the content horizontally */
        align-items: center; /* Center the content vertically */
    }
    
    /* Mobile devices - minimal top padding */
    .carousel-content {
        padding: 30px 20px 10px 20px; /* Reduced bottom padding to 10px */
        align-items: flex-start !important;
    }
    
    .carousel-container {
        align-items: flex-start !important;
        padding-top: 0;
    }
    
    /* Minimal content margin for mobile */
    .mobile-safe-content {
        margin-top: 5px; /* Reduced from 40px */
    }
    
    /* Adjust text sizing for mobile */
    #carousel-title {
        font-size: 2.5rem !important;
        line-height: 1.2;
        margin-bottom: 1rem !important;
    }
    
    #carousel-subtitle {
        font-size: 0.9rem;
        margin-bottom: 1rem !important;
    }
    
    #carousel-description {
        font-size: 1rem;
        margin-bottom: 1.5rem !important;
    }
}

@media (max-width: 576px) {
    /* Stack content vertically on small phones */
    .carousel-container .row {
        flex-direction: column !important;
    }
    
    /* Text content takes full width and normal positioning */
    .col-10.col-lg-6 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        order: 1;
        margin-bottom: 15px;
    }
    
    /* Make car viewer column full width on small phones */
    #carViewerColumn {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        width: 100vw !important;
        position: relative;
        margin-left: calc(-50vw + 50%) !important;
        margin-right: 0 !important;
        padding: 0 !important;
        order: 2;
    }
    
    .interactive-3d-viewer {
        height: 360px; /* Moderate increase from original */
        width: 100% !important; /* Full device width */
        margin-top: 15px; /* Increased margin */
        margin-left: 0 !important; /* No negative margins */
        padding: 15px; /* Reduced padding for small phones */
        transform: scale(1.1); /* Moderate scale increase - reduced from 1.2 */
        display: flex;
        justify-content: center; /* Center the content horizontally */
        align-items: center; /* Center the content vertically */
    }
    
    .interactive-carousel {
        height: 750px; /* Increased height for bigger 3D viewer */
    }
    
    /* Small phones - 30px top padding */
    .carousel-content {
        padding: 30px 15px 10px 15px; /* Reduced bottom padding to 10px */
        align-items: flex-start !important;
    }
    
    .carousel-container {
        align-items: flex-start !important;
    }
    
    /* Minimal content margin for small phones */
    .mobile-safe-content {
        margin-top: 5px; /* Reduced from 60px */
    }
    
    /* Further adjust text sizing */
    #carousel-title {
        font-size: 2rem !important;
        line-height: 1.1;
    }
    
    #carousel-subtitle {
        font-size: 0.8rem;
    }
    
    #carousel-description {
        font-size: 0.9rem;
    }
    
    /* Make CTA button more mobile-friendly */
    #carousel-cta {
        font-size: 0.9rem;
        padding: 12px 20px !important;
    }
}

/* Narrow devices (705px and smaller) */
@media (max-width: 705px) {
    .carousel-content {
        padding-bottom: 20px !important;
    }
}

/* Very small screens (phones in portrait) */
@media (max-width: 480px) {
    .carousel-content {
        padding: 25px 10px 15px 10px; /* Better padding for very small screens */
        align-items: flex-start !important;
    }
    
    .carousel-container {
        align-items: flex-start !important;
    }
    
    /* Minimal content margin for very small phones */
    .mobile-safe-content {
        margin-top: 5px; /* Keep minimal margin */
    }
    
    .interactive-carousel {
        height: 700px; /* Increased for bigger 3D viewer */
    }
    
    /* Stack content vertically on very small phones */
    .carousel-container .row {
        flex-direction: column !important;
    }
    
    /* Text content takes full width and normal positioning */
    .col-10.col-lg-6 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        order: 1;
        margin-bottom: 10px;
    }
    
    /* Make car viewer column full width on very small phones */
    #carViewerColumn {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        width: 100vw !important;
        position: relative;
        margin-left: calc(-50vw + 50%) !important;
        margin-right: 0 !important;
        padding: 0 !important;
        order: 2;
    }
    
    .interactive-3d-viewer {
        height: 300px; /* Moderate increase from original 220px */
        width: 100% !important; /* Full device width */
        margin-top: 8px;
        margin-left: 0 !important; /* No negative margins */
        padding: 10px; /* Minimal padding for tiny screens */
        transform: scale(1.0); /* Normal scale - reduced from 1.1 */
        display: flex;
        justify-content: center; /* Center the content horizontally */
        align-items: center; /* Center the content vertically */
    }
    
    #carousel-title {
        font-size: 1.75rem !important;
    }
}

/* Estimate section mobile layout fixes */
@media (max-width: 768px) {
    #estimatePromoBlock {
        display: flex !important;
        flex-direction: row !important;
        align-items: flex-start !important;
        gap: 15px;
    }
    
    #estimatePromoBlock .bg-light {
        flex-shrink: 0;
        margin-bottom: 0 !important;
    }
    
    #estimatePromoBlock .content-wrapper {
        flex: 1;
    }
}

@media (max-width: 576px) {
    #estimatePromoBlock {
        gap: 12px;
    }
    
    #estimatePromoBlock h4 {
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
    }
    
    #estimatePromoBlock p {
        font-size: 0.85rem;
        margin-bottom: 0.75rem !important;
    }
    
    #estimatePromoBlock .text-primary {
        font-size: 0.75rem;
        margin-bottom: 0.25rem;
    }
}

/* Landscape phones */
@media (max-width: 768px) and (orientation: landscape) {
    .interactive-carousel {
        height: 500px; /* Reduced for landscape */
    }
    
    .interactive-3d-viewer {
        height: 200px; /* Smaller height for landscape */
        width: 140%; /* Wider for landscape */
        margin-left: -20%; /* Center the wider container */
        padding: 30px; /* Good padding for landscape */
        transform: scale(0.8); /* Smaller scale for landscape */
    }
    
    .carousel-content {
        padding: 20px 15px 15px 15px; /* Reduced padding for landscape */
        align-items: flex-start !important;
    }
    
    .carousel-container {
        align-items: flex-start !important;
        flex-direction: row !important; /* Side by side in landscape */
    }
    
    .col-10.col-lg-6 {
        flex: 0 0 50%; /* Half width for text */
        max-width: 50%;
    }
    
    .col-lg-6:last-child {
        flex: 0 0 50%; /* Half width for 3D viewer */
        max-width: 50%;
        margin-top: 0 !important;
    }
    
    /* Minimal margin for landscape */
    .mobile-safe-content {
        margin-top: 0;
    }
    
    #carousel-title {
        font-size: 1.5rem !important;
        line-height: 1.1;
        margin-bottom: 0.5rem !important;
    }
    
    #carousel-subtitle {
        font-size: 0.7rem;
        margin-bottom: 0.5rem !important;
    }
    
    #carousel-description {
        font-size: 0.8rem;
        margin-bottom: 1rem !important;
    }
    
    #carousel-cta {
        font-size: 0.8rem;
        padding: 8px 15px !important;
    }
}

/* Loading animation */
.loader {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 15px;
    z-index: 10;
}

.three-bounce {
    display: flex;
    gap: 5px;
}

.three-bounce div {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background-color: #007bff;
    animation: bounce 1.4s infinite ease-in-out both;
}

.three-bounce .one { animation-delay: -0.32s; }
.three-bounce .two { animation-delay: -0.16s; }
.three-bounce .three { animation-delay: 0s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}
