/* Custom Timeline Widget Styles */

/* Base Timeline Wrapper */
.custom-timeline-wrapper {
    position: relative;
    width: 100%;
    padding: 40px 0;
}

/* Timeline Container */
.timeline-container {
    position: relative;
    width: 100%;
}

.timeline-mobile {
    display: none;
}

/* Timeline Line Wrapper */
.timeline-line-wrapper {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    height: 100%;
    z-index: 1;
}

/* Timeline Line */
.timeline-line {
    position: relative;
    width: 2px;
    height: 100%;
    background-color: #e5e7eb;
}

/* Timeline Line Progress */
.timeline-line-progress {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background-color: #3b82f6;
    transition: height 0.3s ease;
    z-index: 2;
}

/* Timeline Item */
.timeline-item {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    margin-bottom: 60px;
    z-index: 2;
}

.timeline-item:last-child {
    margin-bottom: 0;
}

/* Timeline Content Areas */
.timeline-content-left,
.timeline-content-right {
    position: relative;
    min-height: 50px;
}

.timeline-content-left {
    padding-right: 40px;
    text-align: right;
}

.timeline-content-right {
    padding-left: 40px;
    text-align: left;
}

/* Timeline Center (Dot Container) */
.timeline-center {
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    position: relative;
    width: 0;
}

/* Remove old static dot styles */
.timeline-dot {
    display: none;
}

/* Moving Timeline Marker - DESKTOP */
.timeline-moving-marker {
    position: absolute !important;
    width: 30px !important;
    height: 30px !important;
    background-color: #3b82f6 !important;
    border: 3px solid #ffffff !important;
    border-radius: 50% !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    top: 0 !important;
    z-index: 10 !important;
    transition: top 0.1s linear !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4) !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: none !important;
    will-change: top, transform !important;
}

.timeline-moving-marker[data-marker-type="icon"] {
    background-color: #ffffff !important;
}

.timeline-moving-marker i,
.timeline-moving-marker svg {
    color: #3b82f6 !important;
    fill: #3b82f6 !important;
    display: block !important;
}

/* Keep icon rotation independent from marker rotation */
.timeline-moving-marker[data-marker-type="icon"] i,
.timeline-moving-marker[data-marker-type="icon"] svg {
    transform: rotate(0deg) !important;
}

/* Pulse Animation for Moving Marker */
.timeline-moving-marker.with-pulse {
    animation: markerPulse 2s infinite;
}

@keyframes markerPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
    }
    70% {
        box-shadow: 0 0 0 20px rgba(59, 130, 246, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
}

/* Force hardware acceleration for smoother animation */
.timeline-moving-marker,
.timeline-line-progress {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Timeline Item Passed State */
.timeline-item {
    transition: opacity 0.3s ease;
}

.timeline-item.passed {
    /* Optional: dim passed items */
    /* opacity: 0.7; */
}

.timeline-item.passed .timeline-inner-container {
    /* Optional: add subtle effect to passed items */
    /* border-left: 3px solid #3b82f6; */
}

/* Mobile Layout */
@media (max-width: 768px) {
    .timeline-desktop {
        display: none !important;
    }

    .timeline-mobile {
        display: block !important;
    }
    
    /* CRITICAL: Mobile line wrapper must be absolute */
    .timeline-mobile .timeline-line-wrapper {
        position: absolute !important;
        left: 20px !important;
        transform: none !important;
        top: 0 !important;
        height: 100% !important;
        width: auto !important;
        z-index: 1 !important;
    }

    /* CRITICAL: Mobile line must be relative for marker to work */
    .timeline-mobile .timeline-line {
        position: relative !important;
        width: 2px !important;
        height: 100% !important;
        background-color: #e5e7eb !important;
    }
    
    /* Mobile progress line - FIXED */
    .timeline-mobile .timeline-line-progress {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 0 !important;
        background-color: #3b82f6 !important;
        transition: height 0.3s ease-out !important;
        z-index: 2 !important;
    }
    
    /* CRITICAL: Mobile marker - OVERRIDE desktop styles */
    /* CRITICAL: Mobile marker - OVERRIDE desktop styles */
    .timeline-mobile .timeline-moving-marker {
        position: absolute !important;
        left: 0 !important;
        transform: translateX(-50%) rotate(0deg) !important;
        top: 0 !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        z-index: 10 !important;
        transition: none !important;
    }

    .timeline-mobile .timeline-dot {
        display: none !important;
    }

    .timeline-mobile .timeline-content-left,
    .timeline-mobile .timeline-content-right {
        padding: 0 !important;
        text-align: left !important;
        margin-bottom: 20px !important;
    }

    .timeline-mobile .timeline-item {
        padding-left: 60px !important;
        position: relative !important;
        margin-bottom: 60px !important;
    }
    .timeline-item{
       grid-template-columns: unset;
    }
    
    .timeline-mobile .timeline-content-wrapper {
        width: 100%;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .custom-timeline-wrapper {
        padding: 20px 0;
    }

    .timeline-item {
        margin-bottom: 40px;
    }

    .timeline-mobile .timeline-item {
        padding-left: 50px !important;
    }

    .timeline-mobile .timeline-line-wrapper {
        left: 15px !important;
    }
}

/* Elementor Editor Support */
.elementor-element.elementor-widget-custom-timeline {
    position: relative;
}

/* Container Styling */
.timeline-content-left .elementor-container,
.timeline-content-right .elementor-container {
    width: 100%;
}

/* Ensure nested elements are properly displayed */
.timeline-content-left > *,
.timeline-content-right > * {
    width: 100%;
}

/* Loading State */
.custom-timeline-wrapper.loading .timeline-item {
    opacity: 0.3;
}

/* Smooth Scroll */
html {
    scroll-behavior: smooth;
}

/* Timeline Placeholder Styles */
.timeline-placeholder,
.timeline-placeholder-editor {
    text-align: center;
    padding: 30px 20px;
    color: #999;
    background: #f8f9fa;
    border: 2px dashed #ddd;
    border-radius: 8px;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.timeline-inner-container {
    width: 100%;
    min-height: 50px;
}

/* Ensure inner content is displayed properly */
.timeline-inner-container > * {
    width: 100%;
}

/* Elementor Editor Specific Styles */
.elementor-editor-active .timeline-placeholder {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-style: dashed;
}

/* Loading Animation */
.timeline-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.timeline-loading i {
    font-size: 24px;
    color: #3b82f6;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.eicon-animation-spin {
    animation: spin 1s linear infinite;
}

/* Prevent flash during template load */
.timeline-inner-container {
    transition: opacity 0.3s ease;
}

.timeline-inner-container.loading {
    opacity: 0.5;
}

/* Animation Classes */
.timeline-item.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Accessibility */
.timeline-moving-marker:focus {
    outline: none;
}

/* Print Styles */
@media print {
    .timeline-moving-marker {
        display: none !important;
    }
    
    .timeline-line-progress {
        height: 100% !important;
    }
    
    .timeline-item {
        page-break-inside: avoid;
    }
}

/* RTL Support */
[dir="rtl"] .timeline-content-left {
    padding-right: 0;
    padding-left: 40px;
    text-align: left;
}

[dir="rtl"] .timeline-content-right {
    padding-left: 0;
    padding-right: 40px;
    text-align: right;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .timeline-line {
        background-color: #000;
    }
    
    .timeline-line-progress {
        background-color: #0066cc;
    }
    
    .timeline-moving-marker {
        border-width: 4px !important;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .timeline-moving-marker,
    .timeline-line-progress,
    .timeline-item {
        transition: none !important;
        animation: none !important;
    }
}

/* Dark Mode Support (Optional) */
@media (prefers-color-scheme: dark) {
    .timeline-placeholder,
    .timeline-placeholder-editor {
        background: #1a1a1a;
        border-color: #333;
        color: #ccc;
    }
}