/**
 * Emex Cars — Cards
 * Tarjetas interactivas, slider de fotos, reproductor de video y navegación
 */

/* === TARJETAS INTERACTIVAS (SLIDER) === */

.emex-card-media-wrapper {
    position: relative;
    height: 240px; 
    background-color: #000; 
    overflow: hidden;
}

/* --- ETIQUETAS DE PRECIO Y FINANCIACIÓN (NUEVO) --- */
.emex-tag-container {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
    z-index: 50;
    pointer-events: none; /* No bloquear clics del slider */
}

/* Precio principal */
.emex-tag-price {
    background-color: var(--emex-night-bordeaux);
    color: var(--emex-white);
    padding: 6px 12px;
    border-radius: var(--emex-radius-sm);
    font-size: 0.95rem;
    font-weight: 800;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    backdrop-filter: blur(4px);
}

/* Cuota de financiación (Efecto Glass + Pulso) */
.emex-tag-finance {
    background: rgba(101, 14, 24, 0.3); /* Cristal */
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: #ffffff;
    padding: 4px 7px;
    border-radius: var(--emex-radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    /* Sutil resplandor verde oscuro */
    text-shadow: 0 1px 3px rgba(0,0,0,0.8); 
    
    /* Animación de latido sutil */
    animation: emexFinancePulse 3s infinite ease-in-out;
}
.emex-tag-finance strong {
    font-size: 0.9rem;
    font-weight: 800;
    color: #4ade80; /* Verde brillante para destacar el número */
}

@keyframes emexFinancePulse {
    0% { transform: scale(1); box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2); }
    50% { transform: scale(1.03); box-shadow: 0 4px 20px rgba(74, 222, 128, 0.3); border-color: rgba(74, 222, 128, 0.5); }
    100% { transform: scale(1); box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2); }
}


/* === NAVEGACIÓN Y SCROLL === */

.emex-card-slider {
    display: flex;
    width: 100%;
    height: 100%;
    overflow-x: auto;
    touch-action: pan-x pan-y; 
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scroll-snap-stop: always; 
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.emex-card-slider::-webkit-scrollbar { 
    display: none; 
}

.emex-slider-item {
    flex: 0 0 100%; 
    width: 100%;
    min-width: 100%;
    height: 100%;
    scroll-snap-align: center;
    position: relative;
}

.emex-slide-touch-handler {
    width: 100%;
    height: 100%;
    position: relative;
    pointer-events: auto; 
}

.emex-slider-img {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    /* CAMBIO: De 'cover' a 'contain' para que el coche salga entero */
    object-fit: contain; 
    background-color: #f8f8f8; /* Fondo sutil para que no sea negro donde no llega la foto */
    scroll-snap-align: center;
    pointer-events: none;
}

.emex-interactive-card {
    touch-action: auto;
}

/* === REPRODUCTOR DE VIDEO PERSONALIZADO === */

.emex-custom-player {
    position: relative;
    width: 100%;
    height: 100%;
    background: black;
    overflow: hidden;
    pointer-events: none; 
}

.emex-video-placeholder {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    position: relative;
}

.emex-video-overlay,
.emex-play-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
    transition: background-color 0.3s;
}

.emex-player-click-layer {
    position: absolute;
    top: 0; left: 0; width: 100%; height: calc(100% - 10px); 
    z-index: 10;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    pointer-events: auto !important; 
}

.emex-play-icon {
    font-size: 2rem;
    color: white;
    background: rgba(255, 255, 255, 0.2);
    width: 60px; height: 60px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    padding-left: 5px;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    transition: all 0.3s ease;
}

@media (min-width: 769px) {
    .emex-video-placeholder:hover .emex-play-icon,
    .emex-player-click-layer:hover .emex-play-icon {
        transform: scale(1.1);
        background: rgba(238, 33, 57, 0.8);
        border-color: transparent;
    }
}

.emex-player-controls {
    position: absolute;
    bottom: 0; left: 0; width: 100%;
    height: 10px; 
    z-index: 20;
    background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
    display: flex; align-items: flex-end;
}

.emex-video-seeker {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 3px; 
    background: rgba(255,255,255,0.3); 
    outline: none;
    transition: height 0.2s;
    cursor: pointer;
    pointer-events: auto; 
    background-image: linear-gradient(var(--emex-punch-red), var(--emex-punch-red));
    background-repeat: no-repeat;
}

.emex-video-seeker::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 0; width: 0; 
    background: var(--emex-punch-red);
    border-radius: 50%;
    transition: all 0.2s;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
}

.emex-player-controls:hover .emex-video-seeker,
.emex-video-seeker:active {
    height: 5px; 
}

.emex-player-controls:hover .emex-video-seeker::-webkit-slider-thumb,
.emex-video-seeker:active::-webkit-slider-thumb {
    width: 12px; height: 12px; 
    background: white; 
}

.emex-video-seeker::-moz-range-thumb {
    width: 0; height: 0; border: none;
    transition: all 0.2s;
}
.emex-player-controls:hover .emex-video-seeker::-moz-range-thumb,
.emex-video-seeker:active::-moz-range-thumb {
    width: 12px; height: 12px; background: white; border-radius: 50%;
}

.video-slide iframe, #yt-player iframe { pointer-events: none; }

/* === ESTILOS DE LA TARJETA (BODY) === */
.emex-card-body {
    padding: 20px;
}
.emex-card-body h3 {
    margin: 0 0 10px 0;
    font-size: 1.1rem;
    color: var(--emex-coffee-beam);
}
.emex-card-specs {
    display: flex; gap: 10px;
    font-size: 0.85rem; color: #616161;
    margin-bottom: 10px;
}
.emex-card-desc {
    font-size: 0.9rem; color: #444;
    line-height: 1.4;
    margin-bottom: 15px;
    height: 40px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2; 
    -webkit-box-orient: vertical;
}
.emex-card-actions {
    display: flex; gap: 10px;
}
.emex-btn-icon {
    background: #25D366; color: white;
    width: 42px; height: 42px;
    border-radius: 8px;
    display: flex; align-items: center; 
    justify-content: center; 
    text-decoration: none;
    font-size: 1.2rem;
}

/* === NAVEGACIÓN DE TARJETAS (FLECHAS, PUNTOS E ICONOS) === */

.emex-slider-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px; height: 36px;
    background: rgba(255, 255, 255, 0.9);
    border: none; border-radius: 50%;
    color: var(--emex-night-bordeaux);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    z-index: 100 !important; 
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
    opacity: 0; 
}
.emex-arrow-prev { left: 10px; padding-right: 3px; }
.emex-arrow-next { right: 10px; padding-left: 3px; }

.emex-card-media-wrapper:hover .emex-slider-arrow { opacity: 1; }
.emex-slider-arrow:hover { background: white; transform: translateY(-50%) scale(1.1); }

.emex-slider-dots {
    position: absolute;
    bottom: 12px;
    left: 20px; right: 20px;
    height: 3px;
    display: flex;
    gap: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
    overflow: hidden;
    z-index: 50;
    pointer-events: none;
}

.emex-dot {
    flex: 1; /* Todos los puntos ocupan espacio proporcional */
    height: 100%;
    background: rgba(255,255,255,0.3);
    transition: background 0.3s;
}

.emex-dot.active {
    background: var(--emex-punch-red); /* Nuestra marca */
}

.emex-has-video-icon {
    position: absolute;
    bottom: 15px; 
    left: 15px;   
    width: 28px; height: 28px;
    background-color: rgba(238, 33, 57, 0.9);
    color: white; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    z-index: 50; 
    pointer-events: none;
    font-size: 0.8rem;
    animation: emexPulseRed 3s infinite;
}
.emex-has-video-icon::before { content: "▶"; font-size: 10px; margin-left: 1px; }

@keyframes emexPulseRed {
    0%   { box-shadow: 0 0 0 0 rgba(238, 33, 57, 0.7); }
    70%  { box-shadow: 0 0 0 6px rgba(238, 33, 57, 0); }
    100% { box-shadow: 0 0 0 0 rgba(238, 33, 57, 0); }
}

@media (max-width: 768px) {
    .emex-slider-arrow { display: none !important; }
    .emex-slider-dots  { bottom: 10px; }
    .emex-has-video-icon { bottom: 10px; left: 10px; }
}