/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&display=swap');

:root {
    --tl-primary: #3b82f6;
    --tl-success: #10b981;
    --tl-bg: #ffffff;
    --tl-text-main: #1f2937;
    --tl-text-sub: #6b7280;
    --tl-line: #e5e7eb;
    --tl-card-bg: #ffffff;
    --tl-card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --tl-dot-bg: #f3f4f6;
    --tl-dot-border: #e5e7eb;
    --tl-urgent: #ef4444;
    /* Red for Urgency */
}

/* Dark Mode Variables */
@media (prefers-color-scheme: dark) {
    :root {
        --tl-bg: #111827;
        --tl-text-main: #f9fafb;
        --tl-text-sub: #9ca3af;
        --tl-line: #374151;
        --tl-card-bg: #1f2937;
        --tl-card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
        --tl-dot-bg: #1f2937;
        /* Match Card BG */
        --tl-dot-border: #4b5563;
        --tl-urgent: #ef4444;
    }
}

/* ... existing code ... */

/* Status: Active & Urgent */
.timeliner-item.is-active.is-urgent .timeliner-dot {
    background: var(--tl-urgent);
    border-color: rgba(239, 68, 68, 0.3);
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.2);
}

.timeliner-item.is-active.is-urgent .timeliner-card {
    border-left-color: var(--tl-urgent);
}

.timeliner-item.is-active.is-urgent .timeliner-date {
    color: var(--tl-urgent);
}

.timeliner-item.is-active.is-urgent .timeliner-link {
    color: var(--tl-urgent);
}

.timeliner-item.is-active.is-urgent::before {
    background: linear-gradient(to bottom, var(--tl-urgent) 0%, var(--tl-line) 100%);
}

/* Urgent Pulse Animation */
@keyframes pulse-ring-red {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.timeliner-item.is-active.is-urgent .timeliner-dot {
    animation: pulse-ring-red 2s infinite;
}

/* Main Container */
/* Main Container */
.timeliner-wrapper {
    font-family: 'Outfit', sans-serif;
    max-width: 700px;
    margin: 40px auto;
    position: relative;
    padding: 0 10px;
}

.timeliner-wrapper * {
    box-sizing: border-box;
}

/* Remove Global Line */
.timeliner-wrapper::before {
    display: none;
}

/* Individual Event Item */
.timeliner-item {
    position: relative;
    padding-left: 50px;
    padding-bottom: 30px;
    opacity: 0;
    animation: fadeInUp 0.5s ease forwards;
}

.timeliner-item:last-child {
    padding-bottom: 0;
}

/* The Line Segment */
.timeliner-item::before {
    content: '';
    position: absolute;
    left: 19px;
    /* Full height line to ensure connectivity */
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--tl-line);
    z-index: 1;
}

/* First Item: Line starts at Dot */
.timeliner-item:first-child::before {
    top: calc(50% - 15px);
}

/* Last Item: Line ends at Dot */
.timeliner-item:last-child::before {
    display: block;
    /* Show line for last item */
    bottom: calc(50% + 15px);
    /* Stop at center (no padding bottom on last child, wait) */
    /* If last child has padding-bottom: 0 (rule 111), then center is just 50% */
    bottom: 50%;
}

/* Dynamic Line Coloring */
.timeliner-item.is-completed::before {
    background: var(--tl-success);
}

/* Active: Green (Incoming) -> Grey (Outgoing) */
/* The stop point is the dot center: 50% - 15px */
/* But wait, CSS gradients on 'bottom' 0 items might shift? Use calc. */
.timeliner-item.is-active::before {
    background: linear-gradient(to bottom, var(--tl-success) calc(50% - 15px), var(--tl-line) calc(50% - 15px));
}

/* If First Child is Active: Top is hidden, Bottom is Grey. Correct. */

/* Dot Centering */
.timeliner-dot {
    position: absolute;
    left: 8px;
    /* Center Vertically, accounting for 30px padding bottom */
    top: calc(50% - 15px);
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--tl-dot-bg);
    border: 2px solid var(--tl-dot-border);
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Special Case: Last Child Dot Centering */
.timeliner-item:last-child .timeliner-dot {
    top: 50%;
}

/* Status: Completed */
.timeliner-item.is-completed .timeliner-dot {
    background: var(--tl-success);
    border-color: var(--tl-success);
    color: white;
}

/* Status: Active */
.timeliner-item.is-active .timeliner-dot {
    background: var(--tl-primary);
    border-color: rgba(59, 130, 246, 0.3);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
    transform: scale(1.1);
}

/* Card Styling */
.timeliner-card {
    background: var(--tl-card-bg);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--tl-line);
    border-left: 4px solid var(--tl-line);
    box-shadow: var(--tl-card-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Active Card */
.timeliner-item.is-active .timeliner-card {
    border-left-color: var(--tl-primary);
    background: var(--tl-card-bg);
}

/* Completed Card */
.timeliner-item.is-completed .timeliner-card {
    border-left-color: var(--tl-success);
}

/* Hover Effect */
.timeliner-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Typography & Links (Same as before) */
.timeliner-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--tl-text-main);
    margin: 0 0 8px 0;
    line-height: 1.3;
}

.timeliner-date {
    font-size: 0.95rem;
    color: var(--tl-text-sub);
    margin-bottom: 12px;
    font-weight: 500;
}

.timeliner-link {
    display: inline-flex;
    align-items: center;
    font-size: 0.9rem;
    color: var(--tl-primary);
    text-decoration: none;
    font-weight: 600;
    margin-top: 4px;
    transition: color 0.2s;
}

.timeliner-link:hover {
    text-decoration: none;
    color: #2563eb;
}

.timeliner-link span {
    margin-left: 4px;
    transition: transform 0.2s;
}

.timeliner-link:hover span {
    transform: translateX(4px);
}

/* Animations */
@keyframes pulse-ring {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translate3d(0, 20px, 0);
    }

    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

.timeliner-item.is-active .timeliner-dot {
    animation: pulse-ring 2s infinite;
}

/* Header with Title & Calendar */
.timeliner-header {
    display: flex;
    align-items: flex-start;
    /* Align top since title might wrap */
    justify-content: space-between;
    margin-bottom: 4px;
    gap: 10px;
}

.timeliner-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    /* Prevent icons from shrinking */
}

.timeliner-icon-btn {
    color: var(--tl-text-sub);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: transparent;
}

.timeliner-icon-btn svg {
    width: 16px;
    height: 16px;
}

/* Hover Effects */
.timeliner-icon-btn:hover {
    transform: translateY(-1px);
}

.timeliner-icon-btn.is-cal:hover {
    color: var(--tl-primary);
    background: rgba(59, 130, 246, 0.1);
}

.timeliner-icon-btn.is-wa:hover {
    color: #22c55e;
    background: rgba(34, 197, 94, 0.1);
}

.timeliner-icon-btn.is-tg:hover {
    color: #0ea5e9;
    background: rgba(14, 165, 233, 0.1);
}

/* Status Badges */
.timeliner-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: 8px;
    vertical-align: middle;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.timeliner-badge.is-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.timeliner-badge.is-info {
    background: rgba(59, 130, 246, 0.1);
    color: #2563eb;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.timeliner-badge.is-success {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Footer for Link & Countdown */
.timeliner-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
    flex-wrap: wrap;
    gap: 10px;
}

/* Ensure Countdown/Today Tag is always on the right */
.timeliner-countdown,
.timeliner-today-tag {
    margin-left: auto;
}

.timeliner-today-tag {
    display: inline-flex;
    background: var(--tl-urgent);
    color: #fff;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
    animation: pulse-tag 2s infinite;
}

@keyframes pulse-tag {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }

    70% {
        transform: scale(1.02);
        box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* Collapsible Body */
.timeliner-body {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed rgba(229, 231, 235, 0.5);
    font-size: 0.9rem;
    color: var(--tl-text-sub);
    line-height: 1.6;
}

.timeliner-icon-btn.is-toggle {
    cursor: pointer;
    border: 1px solid transparent;
}

.timeliner-icon-btn.is-toggle:hover {
    background: rgba(100, 116, 139, 0.1);
    color: var(--tl-text-main);
}

.timeliner-icon-btn.is-toggle.is-open {
    transform: rotate(180deg);
    background: rgba(100, 116, 139, 0.1);
}

.timeliner-countdown {
    display: inline-flex;
    gap: 8px;
    background: rgba(59, 130, 246, 0.08);
    color: var(--tl-primary);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0;
    /* Reset margin */
    border: 1px solid rgba(59, 130, 246, 0.1);
}

.timeliner-link {
    margin-top: 0;
    /* Reset margin */
}

.timeliner-item.is-urgent .timeliner-countdown {
    background: rgba(239, 68, 68, 0.08);
    color: var(--tl-urgent);
    border-color: rgba(239, 68, 68, 0.1);
    animation: pulse-red-soft 2s infinite;
}

@keyframes pulse-red-soft {
    0% {
        background: rgba(239, 68, 68, 0.08);
    }

    50% {
        background: rgba(239, 68, 68, 0.15);
    }

    100% {
        background: rgba(239, 68, 68, 0.08);
    }
}

/* Checkmark for completed */
.timeliner-item.is-completed .timeliner-dot::after {
    content: '\2713';
    /* Unicode Checkmark because raw chars can break encoding */
    font-weight: bold;
    font-size: 14px;
}

/* Staggered Delay */
.timeliner-item:nth-child(1) {
    animation-delay: 0.1s;
}

.timeliner-item:nth-child(2) {
    animation-delay: 0.2s;
}

.timeliner-item:nth-child(3) {
    animation-delay: 0.3s;
}

.timeliner-item:nth-child(4) {
    animation-delay: 0.4s;
}

.timeliner-item:nth-child(5) {
    animation-delay: 0.5s;
}

/* Responsive */
@media (max-width: 550px) {
    .timeliner-item {
        padding-left: 40px;
    }

    .timeliner-dot {
        left: 8px;
        width: 22px;
        height: 22px;
        top: 2px;
    }

    .timeliner-item::before {
        left: 18px;
    }

    /* Center of 22px dot is 11. 8+11=19 */
    .timeliner-wrapper {
        padding: 0 10px;
    }
}