/* ===== TRUCK ===== */
/* ===== TRUCK - VERSIÓN CORRECTA CON 4 LLANTAS ===== */
:root {
    --escala-camion: 0.9;
}

@media (max-width: 768px) {
    :root {
        --escala-camion: 0.6;
    }
}

@media (max-width: 480px) {
    :root {
        --escala-camion: 0.5;
    }
}

.truck-container {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    transform: scale(var(--escala-camion));
    transform-origin: left bottom;
    animation: drive 20s linear infinite;
    margin: 40px 0;
    width: fit-content;
    z-index: 1;
    overflow: visible;
    pointer-events: none;
}

@media (max-width: 768px) {
    .truck-container {
        animation: drive 15s linear infinite;
        margin: 20px 0;
        z-index: 0;
    }
}

@media (max-width: 480px) {
    .truck-container {
        animation: drive 12s linear infinite;
        transform: scale(var(--escala-camion));
        margin: 15px 0 70px 0;  /* ✅ Añadido margen inferior para dar espacio al chat */
        z-index: 0;
    }
}

@keyframes drive {
    from {
        transform: translateX(-400px) scale(var(--escala-camion));
    }
    to {
        transform: translateX(110vw) scale(var(--escala-camion));
    }
}

/* TRAILER (PARTE TRASERA) */
.trailer {
    width: 220px;
    height: 80px;
    background: #77b1cc;
    border-radius: 5px;
    margin-right: 2px;
    position: relative;
    border-bottom: 5px solid #2c3e50;
    overflow: visible;
    z-index: 5;
}

.trailer-texto {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-size: 28px;
    font-weight: 900;
    color: white;
    text-shadow: 2px 2px 4px black;
    letter-spacing: 2px;
    z-index: 5;
}

/* CABINA (PARTE DELANTERA) */
.cabin {
    position: relative;
    width: 80px;
    height: 100px;
    background: #0004f8;
    border-radius: 10px 20px 5px 5px;
    z-index: 10;
}

.window {
    position: absolute;
    top: 15px;
    right: 5px;
    width: 40px;
    height: 35px;
    background: #87CEEB;
    border: 3px solid #333;
    border-radius: 5px 12px 2px 2px;
}

.exhaust {
    position: absolute;
    top: -20px;
    left: 10px;
    width: 10px;
    height: 40px;
    background: #555;
}

/* LLANTAS */
.wheel {
    position: absolute;
    bottom: -15px;
    width: 35px;
    height: 35px;
    background: #333;
    border: 4px solid #fff;
    border-radius: 50%;
    animation: spin 0.5s linear infinite;
    z-index: 20;
}

.wheel::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 2px;
    background: white;
    transform: translateY(-50%);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* POSICIONES DE LAS LLANTAS - 2 ADELANTE, 2 ATRÁS */
.wheel.front-left {
    left: 5px;
}

.wheel.front-right {
    left: 40px;
}

.wheel.rear-left {
    right: 175px;
}

.wheel.rear-right {
    right: 135px;
}

/* ===== ANIMACIONES ADICIONALES ===== */
@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.titulo:hover {
    animation: pulse 1s ease;
}

/* ===== Z-INDEX CORREGIDO PARA EVITAR SUPERPOSICIONES ===== */
.navbar {
    z-index: 1000;
    position: fixed;
}

.hamburger {
    z-index: 1001;
}

.chat-icon,
.chat-popup {
    z-index: 9999 !important;
}

/* Asegurar que el carrito esté detrás del menú y el chat */
.truck-container {
    z-index: 1;
    position: relative;
    overflow: visible;
    pointer-events: none;
}

.truck-container .trailer,
.truck-container .cabin {
    pointer-events: none;
}

/* Tablet - Ajustes adicionales */
@media (max-width: 768px) {
    .truck-container {
        z-index: 0;
        margin: 20px 0;
    }
    
    .navbar {
        z-index: 1000;
    }
    
    .chat-icon {
        z-index: 9999 !important;
    }
    
    .chat-popup {
        z-index: 9998 !important;
    }
}

/* Móvil - Correcciones finales */
@media (max-width: 480px) {
    .truck-container {
        animation: drive 12s linear infinite;
        transform: scale(var(--escala-camion));
        margin: 15px 0 70px 0;  /* ✅ Añadido margen inferior para dar espacio al chat */
        z-index: 0;
    }
    
    .navbar {
        z-index: 1000;
    }
    
    .menu.show {
        z-index: 1002;
        position: relative;
        background: var(--azul);
    }
    
    .chat-icon {
        z-index: 9999 !important;
        bottom: 15px;
        right: 15px;
    }
    
    .chat-popup {
        z-index: 9998 !important;
        width: 95%;
        height: 90%;
        bottom: 10px;
        left: 2.5%;
        right: 2.5%;
    }
}

/* TRAILER (PARTE TRASERA) */
.trailer {
    width: 220px;
    height: 80px;
    background: #77b1cc;
    border-radius: 5px;
    margin-right: 2px;
    position: relative;
    border-bottom: 5px solid #2c3e50;
    overflow: visible;
    z-index: 5;
}

.trailer-texto {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-size: 28px;
    font-weight: 900;
    color: white;
    text-shadow: 2px 2px 4px black;
    letter-spacing: 2px;
    z-index: 5;
}

/* CABINA (PARTE DELANTERA) */
.cabin {
    position: relative;
    width: 80px;
    height: 100px;
    background: #0004f8;
    border-radius: 10px 20px 5px 5px;
    z-index: 10;
}

.window {
    position: absolute;
    top: 15px;
    right: 5px;
    width: 40px;
    height: 35px;
    background: #87CEEB;
    border: 3px solid #333;
    border-radius: 5px 12px 2px 2px;
}

.exhaust {
    position: absolute;
    top: -20px;
    left: 10px;
    width: 10px;
    height: 40px;
    background: #555;
}

/* LLANTAS */
.wheel {
    position: absolute;
    bottom: -15px;
    width: 35px;
    height: 35px;
    background: #333;
    border: 4px solid #fff;
    border-radius: 50%;
    animation: spin 0.5s linear infinite;
    z-index: 20;
}

.wheel::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 2px;
    background: white;
    transform: translateY(-50%);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* POSICIONES DE LAS LLANTAS - 2 ADELANTE, 2 ATRÁS */
.wheel.front-left {
    left: 5px;
}

.wheel.front-right {
    left: 40px;
}

.wheel.rear-left {
    right: 175px;
}

.wheel.rear-right {
    right: 135px;
}

/* ===== ANIMACIONES ADICIONALES ===== */
@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.titulo:hover {
    animation: pulse 1s ease;
}

/* ===== Z-INDEX CORREGIDO PARA EVITAR SUPERPOSICIONES ===== */
.navbar {
    z-index: 1000;
    position: fixed;
}

.hamburger {
    z-index: 1001;
}

.chat-icon,
.chat-popup {
    z-index: 9999 !important;
}

/* Asegurar que el carrito esté detrás del menú y el chat */
.truck-container {
    z-index: 1;
    position: relative;
    overflow: visible;
    pointer-events: none;
}

.truck-container .trailer,
.truck-container .cabin {
    pointer-events: none;
}

/* Tablet - Ajustes adicionales */
@media (max-width: 768px) {
    .truck-container {
        z-index: 0;
        margin: 20px 0;
    }
    
    .navbar {
        z-index: 1000;
    }
    
    .chat-icon {
        z-index: 9999 !important;
    }
    
    .chat-popup {
        z-index: 9998 !important;
    }
}

/* Móvil - Correcciones finales */
@media (max-width: 480px) {
    .truck-container {
        animation: drive 12s linear infinite;
        transform: scale(var(--escala-camion));
        margin: 15px 0 70px 0;  /* ✅ Añadido margen inferior para dar espacio al chat */
        z-index: 0;
    }
    
    /* ✅ Asegurar que el menú y chat estén por encima */
    .navbar {
        z-index: 1000;
    }
    
    .menu.show {
        z-index: 1002;
        position: relative;
        background: var(--azul);
    }
    
    .chat-icon {
        z-index: 9999 !important;
        bottom: 15px;
        right: 15px;
    }
    
    .chat-popup {
        z-index: 9998 !important;
        width: 95%;
        height: 90%;
        bottom: 10px;
        left: 2.5%;
        right: 2.5%;
    }
}