/* Timeline Page - Modern Colorful Design */
/* Following UI Style Guide principles */

/* ===== Page Header ===== */
#page-timeline .page-header {
    margin-bottom: 24px;
}

#page-timeline .page-title {
    background: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#page-timeline .header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Live Indicator */
#page-timeline .live-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: #22c55e15;
    border: 1px solid #22c55e30;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #22c55e;
}

#page-timeline .live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 8px #22c55e;
    animation: livePulse 1.5s infinite;
}

@keyframes livePulse {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 8px #22c55e;
    }
    50% {
        opacity: 0.5;
        box-shadow: 0 0 16px #22c55e;
    }
}

/* Agent Filter Dropdown */
#page-timeline #timeline-agent-filter {
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
}

#page-timeline #timeline-agent-filter:focus {
    outline: none;
    border-color: #06b6d4;
    box-shadow: 0 0 0 3px #06b6d420;
}

/* ===== Timeline Stats ===== */
#page-timeline .timeline-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

#page-timeline .timeline-stat {
    position: relative;
    padding: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    text-align: center;
    transition: all 0.2s ease;
    overflow: hidden;
}

#page-timeline .timeline-stat::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--stat-color, var(--border-color));
}

#page-timeline .timeline-stat:hover {
    border-color: var(--stat-color, var(--text-muted));
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
}

#page-timeline .timeline-stat:nth-child(1) {
    --stat-color: #3b82f6;
}

#page-timeline .timeline-stat:nth-child(2) {
    --stat-color: #22c55e;
}

#page-timeline .timeline-stat:nth-child(3) {
    --stat-color: #f59e0b;
}

#page-timeline .timeline-stat:nth-child(4) {
    --stat-color: #a855f7;
}

#page-timeline .timeline-stat-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--stat-color, var(--text-primary));
    margin-bottom: 4px;
    text-shadow: 0 0 20px var(--stat-color);
}

#page-timeline .timeline-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== Event Timeline Container ===== */
#page-timeline .event-timeline-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

#page-timeline .event-timeline {
    max-height: 600px;
    overflow-y: auto;
    padding: 16px;
}

/* ===== Timeline Events ===== */
.timeline {
    position: relative;
    padding-left: 24px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(180deg, #3b82f6, #a855f7, #ec4899, #06b6d4);
    border-radius: 1px;
}

.timeline-event {
    position: relative;
    padding: 16px 20px;
    margin-bottom: 16px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    transition: all 0.2s ease;
}

.timeline-event::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 20px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--event-color, #3b82f6);
    border: 2px solid var(--bg-card);
    box-shadow: 0 0 8px var(--event-color, #3b82f6);
}

.timeline-event:hover {
    border-color: var(--event-color, #3b82f640);
    transform: translateX(4px);
}

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

/* Event Types */
.timeline-event.info { --event-color: #3b82f6; }
.timeline-event.success { --event-color: #22c55e; }
.timeline-event.warning { --event-color: #f59e0b; }
.timeline-event.error { --event-color: #ef4444; }
.timeline-event.task { --event-color: #a855f7; }
.timeline-event.agent { --event-color: #ec4899; }
.timeline-event.data { --event-color: #06b6d4; }

/* Agent-specific colors */
.timeline-event.orchestrator { --event-color: #eab308; }
.timeline-event.data_agent { --event-color: #3b82f6; }
.timeline-event.optimizer { --event-color: #22c55e; }
.timeline-event.action { --event-color: #f59e0b; }
.timeline-event.ml { --event-color: #a855f7; }
.timeline-event.monitor { --event-color: #ef4444; }
.timeline-event.reporter { --event-color: #06b6d4; }

.timeline-event-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.timeline-event-type {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    background: var(--event-color, #3b82f6);
    background: linear-gradient(135deg, var(--event-color, #3b82f6), color-mix(in srgb, var(--event-color, #3b82f6) 70%, black));
    color: white;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.timeline-event-title {
    flex: 1;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.timeline-event-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: 'SF Mono', Monaco, monospace;
}

.timeline-event-body {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    padding-left: 2px;
}

/* ===== Agent Icons in Events ===== */
.timeline-event-agent-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--event-color, #3b82f6);
    background: linear-gradient(135deg, color-mix(in srgb, var(--event-color, #3b82f6) 20%, transparent), transparent);
    border: 1px solid var(--event-color, #3b82f6);
    box-shadow: 0 0 12px color-mix(in srgb, var(--event-color, #3b82f6) 30%, transparent);
}

.timeline-event-agent-icon svg {
    width: 14px;
    height: 14px;
    color: var(--event-color, #3b82f6);
}

/* ===== Empty State ===== */
#page-timeline .empty-state {
    padding: 60px 20px;
    text-align: center;
}

#page-timeline .empty-state .icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

#page-timeline .empty-state p {
    color: var(--text-secondary);
}

/* ===== Timeline Container ===== */
#timeline-container {
    padding: 0;
}

/* ===== Animations ===== */
#page-timeline .timeline-stat {
    animation: statAppear 0.4s ease forwards;
    opacity: 0;
}

#page-timeline .timeline-stat:nth-child(1) { animation-delay: 0ms; }
#page-timeline .timeline-stat:nth-child(2) { animation-delay: 80ms; }
#page-timeline .timeline-stat:nth-child(3) { animation-delay: 160ms; }
#page-timeline .timeline-stat:nth-child(4) { animation-delay: 240ms; }

@keyframes statAppear {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.timeline-event {
    animation: eventSlideIn 0.3s ease forwards;
    opacity: 0;
}

@keyframes eventSlideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Staggered event animations */
.timeline-event:nth-child(1) { animation-delay: 0ms; }
.timeline-event:nth-child(2) { animation-delay: 50ms; }
.timeline-event:nth-child(3) { animation-delay: 100ms; }
.timeline-event:nth-child(4) { animation-delay: 150ms; }
.timeline-event:nth-child(5) { animation-delay: 200ms; }
.timeline-event:nth-child(6) { animation-delay: 250ms; }
.timeline-event:nth-child(7) { animation-delay: 300ms; }
.timeline-event:nth-child(8) { animation-delay: 350ms; }
.timeline-event:nth-child(9) { animation-delay: 400ms; }
.timeline-event:nth-child(10) { animation-delay: 450ms; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    #page-timeline .timeline-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    #page-timeline .header-actions {
        flex-wrap: wrap;
    }

    .timeline-event-header {
        flex-wrap: wrap;
    }

    .timeline-event-time {
        width: 100%;
        margin-top: 8px;
    }
}
