/**
 * Timeline CSS Personalizado
 * Sin dependencias de Clarity - Compatible con Bootstrap
 * OPEL Tradis
 */

/* ===========================================
   TIMELINE VERTICAL
   =========================================== */

.custom-timeline {
    position: relative;
    padding: 20px 0;
    list-style: none;
}

/* Línea vertical */
.custom-timeline::before {
    content: '';
    position: absolute;
    left: 20px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #e0e0e0;
}

/* Paso del timeline */
.custom-timeline-step {
    position: relative;
    padding-left: 60px;
    padding-bottom: 30px;
    min-height: 80px;
}

.custom-timeline-step:last-child {
    padding-bottom: 0;
}

/* Icono del paso */
.custom-timeline-icon {
    position: absolute;
    left: 8px;
    top: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    font-size: 12px;
    transition: all 0.3s;
}

/* Estados del icono */
.custom-timeline-step.completed .custom-timeline-icon {
    background: #28a745;
    border-color: #28a745;
    color: white;
}

.custom-timeline-step.current .custom-timeline-icon {
    background: #4A90E2;
    border-color: #4A90E2;
    color: white;
    box-shadow: 0 0 0 4px rgba(74, 144, 226, 0.2);
    animation: pulse 2s infinite;
}

.custom-timeline-step.pending .custom-timeline-icon {
    background: #fff;
    border-color: #ddd;
    color: #999;
}

.custom-timeline-step.error .custom-timeline-icon {
    background: #dc3545;
    border-color: #dc3545;
    color: white;
}

/* Animación de pulso para paso actual */
@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 4px rgba(74, 144, 226, 0.2);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(74, 144, 226, 0.1);
    }
}

/* Fecha del evento */
.custom-timeline-date {
    display: block;
    font-size: 11px;
    color: #999;
    font-weight: 600;
    margin-bottom: 3px;
    text-transform: uppercase;
}

/* Título del evento */
.custom-timeline-title {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 3px;
}

.custom-timeline-step.current .custom-timeline-title {
    color: #4A90E2;
}

/* Descripción del evento */
.custom-timeline-description {
    display: block;
    font-size: 14px;
    color: #666;
    line-height: 1;
}

/* ===========================================
   TIMELINE HORIZONTAL
   =========================================== */

.custom-timeline-horizontal {
    display: flex;
    justify-content: space-between;
    position: relative;
    padding: 0; /* ✅ Eliminar padding top */
    margin: 0;
    list-style: none;
    /* Mantener siempre horizontal */
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    /* Scroll suave en móvil */
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Ocultar scrollbar pero mantener funcionalidad */
.custom-timeline-horizontal::-webkit-scrollbar {
    height: 4px;
}

.custom-timeline-horizontal::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.custom-timeline-horizontal::-webkit-scrollbar-thumb {
    background: #4A90E2;
    border-radius: 4px;
}

.custom-timeline-horizontal::-webkit-scrollbar-thumb:hover {
    background: #357ABD;
}

/* Línea horizontal - EN EL CENTRO DEL ICONO */
.custom-timeline-horizontal::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 13px; /* ✅ 13px = centro del icono de 26px */
    height: 2px;
    background: #e0e0e0;
    z-index: 0; /* ✅ DETRÁS de los iconos */
}

.custom-timeline-horizontal .custom-timeline-step {
    flex: 0 0 auto; /* No permitir que se encoja */
    min-width: 120px; /* Ancho mínimo por paso */
    position: relative;
    text-align: center;
    padding: 0 10px;
    padding-top: 0;
    min-height: auto;
    z-index: 1; /* ✅ Por encima de la línea */
}

.custom-timeline-horizontal .custom-timeline-icon {
    position: relative;
    left: auto;
    top: 0;
    margin: 0 auto 10px auto;
    z-index: 2; /* ✅ Por encima de todo */
    background: white; /* ✅ Fondo blanco para tapar la línea */
}

.custom-timeline-horizontal .custom-timeline-date {
    font-size: 10px;
}

.custom-timeline-horizontal .custom-timeline-title {
    font-size: 14px;
    white-space: nowrap; /* No permitir salto de línea */
    overflow: hidden;
    text-overflow: ellipsis;
}

.custom-timeline-horizontal .custom-timeline-description {
    font-size: 12px;
    display: none; /* Ocultar en horizontal por espacio */
}

/* ===========================================
   TIMELINE COMPACTO
   =========================================== */

.custom-timeline-compact .custom-timeline-step {
    padding-bottom: 20px;
    min-height: 50px;
}

.custom-timeline-compact .custom-timeline-icon {
    width: 20px;
    height: 20px;
    left: 10px;
}

.custom-timeline-compact::before {
    left: 18px;
}

.custom-timeline-compact .custom-timeline-step {
    padding-left: 50px;
}

/* ===========================================
   ICONOS PERSONALIZADOS
   =========================================== */

.timeline-icon-check::before {
    content: '✓';
    font-weight: bold;
}

.timeline-icon-clock::before {
    content: '⏱';
}

.timeline-icon-truck::before {
    content: '🚚';
}

.timeline-icon-box::before {
    content: '📦';
}

.timeline-icon-location::before {
    content: '📍';
}

.timeline-icon-error::before {
    content: '✕';
    font-weight: bold;
}

.timeline-icon-warning::before {
    content: '⚠';
}

/* ===========================================
   RESPONSIVE
   =========================================== */

@media (max-width: 768px) {
    /* El timeline horizontal se mantiene horizontal con scroll */
    /* NO convertir a vertical */
    
    .custom-timeline-horizontal .custom-timeline-step {
        min-width: 100px; /* Reducir ancho mínimo en móvil */
        padding: 0 5px;
    }
    
    .custom-timeline-horizontal .custom-timeline-title {
        font-size: 12px;
    }
    
    .custom-timeline-horizontal .custom-timeline-date {
        font-size: 9px;
    }
}

/* ===========================================
   SCROLL EN TIMELINE
   =========================================== */

.custom-timeline-scrollable {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px;
}

/* Personalizar scrollbar */
.custom-timeline-scrollable::-webkit-scrollbar {
    width: 6px;
}

.custom-timeline-scrollable::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.custom-timeline-scrollable::-webkit-scrollbar-thumb {
    background: #4A90E2;
    border-radius: 10px;
}

.custom-timeline-scrollable::-webkit-scrollbar-thumb:hover {
    background: #357ABD;
}

/* ===========================================
   ANIMACIONES
   =========================================== */

.custom-timeline-step {
    opacity: 0;
    transform: translateX(-20px);
    animation: slideInTimeline 0.5s ease forwards;
}

.custom-timeline-step:nth-child(1) { animation-delay: 0s; }
.custom-timeline-step:nth-child(2) { animation-delay: 0.1s; }
.custom-timeline-step:nth-child(3) { animation-delay: 0.2s; }
.custom-timeline-step:nth-child(4) { animation-delay: 0.3s; }
.custom-timeline-step:nth-child(5) { animation-delay: 0.4s; }

@keyframes slideInTimeline {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Deshabilitar animación si el usuario prefiere reduced motion */
@media (prefers-reduced-motion: reduce) {
    .custom-timeline-step {
        animation: none;
        opacity: 1;
        transform: none;
    }
    
    .custom-timeline-step.current .custom-timeline-icon {
        animation: none;
    }
}
