/**
 * Timeline Control Styles
 * Modern glassmorphism design matching the existing UI
 */

.timeline-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 50%;
    max-width: 700px;
    padding: 16px 24px;
    background: rgba(15, 15, 35, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Controls row */
.timeline-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.tl-btn {
    width: 40px;
    height: 40px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.tl-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.25);
    color: white;
    transform: translateY(-1px);
}

.tl-btn:active:not(:disabled) {
    transform: translateY(0);
}

.tl-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.tl-play-btn {
    width: 52px;
    height: 52px;
    font-size: 18px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.3) 0%, rgba(118, 75, 162, 0.3) 100%);
    border-color: rgba(102, 126, 234, 0.4);
}

.tl-play-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.5) 0%, rgba(118, 75, 162, 0.5) 100%);
    border-color: rgba(102, 126, 234, 0.6);
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.3);
}

.tl-play-btn.active {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.6) 0%, rgba(118, 75, 162, 0.6) 100%);
    box-shadow: 0 0 25px rgba(102, 126, 234, 0.4);
}

/* Speed control wrapper */
.tl-speed-wrapper {
    position: relative;
}

.tl-speed-btn {
    width: auto;
    padding: 0 12px;
    font-family: 'Fira Code', monospace;
    font-size: 12px;
    font-weight: 600;
}

/* Speed dropdown menu */
.tl-speed-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 15, 35, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    padding: 6px 0;
    min-width: 70px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(10px);
    transition: all 0.2s ease;
    z-index: 1001;
}

.tl-speed-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.tl-speed-option {
    padding: 8px 16px;
    font-family: 'Fira Code', monospace;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    text-align: center;
    transition: all 0.15s ease;
}

.tl-speed-option:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.tl-speed-option.selected {
    color: #667eea;
    background: rgba(102, 126, 234, 0.15);
    font-weight: 600;
}

/* Slider container */
.timeline-slider-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.timeline-date-display {
    text-align: center;
}

#tl-current-date {
    font-family: 'Fira Code', monospace;
    font-size: 18px;
    font-weight: 600;
    color: white;
    letter-spacing: 1px;
    transition: color 0.15s ease, text-shadow 0.15s ease;
}

/* Date change pulse animation */
#tl-current-date.date-changed {
    animation: date-pulse 0.3s ease-out;
}

@keyframes date-pulse {
    0% {
        color: #667eea;
        text-shadow: 0 0 10px rgba(102, 126, 234, 0.6);
        transform: scale(1.05);
    }
    100% {
        color: white;
        text-shadow: none;
        transform: scale(1);
    }
}

/* Slider wrapper for positioning markers and tooltip */
.timeline-slider-wrapper {
    position: relative;
    width: 100%;
    padding: 8px 0;
}

/* Custom range slider */
.timeline-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    outline: none;
    cursor: pointer;
    position: relative;
}

/* Event markers container */
.timeline-event-markers {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 8px;
    transform: translateY(-50%);
    pointer-events: none;
    z-index: 1;
}

/* Individual event marker */
.event-marker {
    position: absolute;
    width: 4px;
    height: 16px;
    top: 50%;
    transform: translate(-50%, -50%);
    background: #ffd700;
    border-radius: 2px;
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.2s ease;
    box-shadow: 0 0 6px rgba(255, 215, 0, 0.5);
    z-index: 2;
}

.event-marker:hover {
    width: 6px;
    height: 20px;
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.8);
}

/* Event type colors */
.event-marker.event-type-outage {
    background: #ff4757;
    box-shadow: 0 0 6px rgba(255, 71, 87, 0.5);
}
.event-marker.event-type-outage:hover {
    box-shadow: 0 0 12px rgba(255, 71, 87, 0.8);
}

.event-marker.event-type-maintenance {
    background: #ffa502;
    box-shadow: 0 0 6px rgba(255, 165, 2, 0.5);
}
.event-marker.event-type-maintenance:hover {
    box-shadow: 0 0 12px rgba(255, 165, 2, 0.8);
}

.event-marker.event-type-network_event {
    background: #3742fa;
    box-shadow: 0 0 6px rgba(55, 66, 250, 0.5);
}
.event-marker.event-type-network_event:hover {
    box-shadow: 0 0 12px rgba(55, 66, 250, 0.8);
}

.event-marker.event-type-security {
    background: #e84393;
    box-shadow: 0 0 6px rgba(232, 67, 147, 0.5);
}
.event-marker.event-type-security:hover {
    box-shadow: 0 0 12px rgba(232, 67, 147, 0.8);
}

.event-marker.event-type-anomaly {
    background: #00cec9;
    box-shadow: 0 0 6px rgba(0, 206, 201, 0.5);
}
.event-marker.event-type-anomaly:hover {
    box-shadow: 0 0 12px rgba(0, 206, 201, 0.8);
}

/* Deployment event - new site launch (always visible with icon) */
.event-marker.event-type-deployment {
    background: var(--site-color, #4caf50);
    box-shadow: 0 0 6px var(--site-color, rgba(76, 175, 80, 0.5));
    width: 6px;
    height: 20px;
    z-index: 5;
}
.event-marker.event-type-deployment:hover {
    width: 8px;
    height: 24px;
    box-shadow: 0 0 16px var(--site-color, rgba(76, 175, 80, 0.8));
}

/* Always visible marker style */
.event-marker.always-visible {
    opacity: 1 !important;
}

/* Deployment icon above marker */
.deployment-icon {
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    font-size: 14px;
    filter: drop-shadow(0 0 4px currentColor);
    animation: deploymentPulse 2s ease-in-out infinite;
}

@keyframes deploymentPulse {
    0%, 100% {
        transform: translateX(-50%) scale(1);
        opacity: 0.9;
    }
    50% {
        transform: translateX(-50%) scale(1.15);
        opacity: 1;
    }
}

.event-marker.event-type-deployment:hover .deployment-icon {
    animation: none;
    transform: translateX(-50%) scale(1.2);
    opacity: 1;
}

/* Hover tooltip */
.timeline-hover-tooltip {
    position: absolute;
    bottom: calc(100% + 12px);
    transform: translateX(-50%);
    padding: 8px 12px;
    background: rgba(15, 15, 35, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    font-family: 'Fira Code', monospace;
    font-size: 13px;
    color: white;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    z-index: 100;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.timeline-hover-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(15, 15, 35, 0.95);
}

.timeline-hover-tooltip.visible {
    opacity: 1;
    visibility: visible;
}

.timeline-hover-tooltip .tooltip-date {
    display: block;
    font-weight: 600;
    color: white;
}

.timeline-hover-tooltip .tooltip-event {
    display: block;
    font-size: 11px;
    color: #ffd700;
    margin-top: 4px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.timeline-hover-tooltip.has-event {
    border-color: rgba(255, 215, 0, 0.4);
}

/* Event marker tooltip (more detailed) */
.timeline-event-tooltip {
    position: absolute;
    bottom: calc(100% + 16px);
    transform: translateX(-50%);
    padding: 12px 16px;
    background: rgba(15, 15, 35, 0.98);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13px;
    color: white;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 101;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    min-width: 200px;
    max-width: 300px;
}

.timeline-event-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: rgba(15, 15, 35, 0.98);
}

.timeline-event-tooltip.visible {
    opacity: 1;
    visibility: visible;
}

.event-tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    gap: 12px;
}

.event-tooltip-type {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
}

.event-tooltip-type.event-type-outage {
    background: rgba(255, 71, 87, 0.2);
    color: #ff6b7a;
}

.event-tooltip-type.event-type-maintenance {
    background: rgba(255, 165, 2, 0.2);
    color: #ffb732;
}

.event-tooltip-type.event-type-network_event {
    background: rgba(55, 66, 250, 0.2);
    color: #6b7bff;
}

.event-tooltip-type.event-type-security {
    background: rgba(232, 67, 147, 0.2);
    color: #f06ba8;
}

.event-tooltip-type.event-type-anomaly {
    background: rgba(0, 206, 201, 0.2);
    color: #2ee8e3;
}

.event-tooltip-date {
    font-family: 'Fira Code', monospace;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
}

.event-tooltip-title {
    font-weight: 600;
    font-size: 14px;
    color: white;
    margin-bottom: 6px;
    line-height: 1.3;
}

.event-tooltip-summary {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.4;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.event-tooltip-hint {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
    text-align: center;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.timeline-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.4);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.timeline-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.6);
}

.timeline-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.4);
}

.timeline-slider::-webkit-slider-runnable-track {
    background: linear-gradient(90deg,
        rgba(102, 126, 234, 0.5) 0%,
        rgba(118, 75, 162, 0.3) 100%);
    border-radius: 4px;
}

/* Date range labels */
.timeline-range {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    font-family: 'Fira Code', monospace;
}

/* Buffer indicator */
.timeline-buffer-indicator {
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.buffer-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* Collapse button */
.tl-collapse-btn {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 24px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px 8px 0 0;
    background: rgba(15, 15, 35, 0.9);
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    z-index: 10;
}

.tl-collapse-btn:hover {
    background: rgba(102, 126, 234, 0.3);
    color: white;
    border-color: rgba(102, 126, 234, 0.5);
}

/* Collapsed state */
.timeline-container.collapsed {
    padding: 8px 24px;
}

.timeline-container.collapsed .timeline-controls,
.timeline-container.collapsed .timeline-slider-container,
.timeline-container.collapsed .timeline-buffer-indicator {
    display: none;
}

.timeline-container.collapsed .tl-collapse-btn {
    top: -12px;
}

/* Light theme collapse button */
body.light-theme .tl-collapse-btn {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(0, 0, 0, 0.1);
    color: rgba(0, 0, 0, 0.5);
}

body.light-theme .tl-collapse-btn:hover {
    background: rgba(102, 126, 234, 0.2);
    color: #667eea;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .timeline-container {
        width: 95%;
        padding: 12px 16px;
        bottom: 70px;
    }

    .tl-btn {
        width: 36px;
        height: 36px;
        font-size: 12px;
    }

    .tl-play-btn {
        width: 44px;
        height: 44px;
        font-size: 16px;
    }

    #tl-current-date {
        font-size: 16px;
    }

    .timeline-controls {
        gap: 6px;
    }
}

/* Animation for loading state */
@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 10px rgba(102, 126, 234, 0.3);
    }
    50% {
        box-shadow: 0 0 20px rgba(102, 126, 234, 0.5);
    }
}

.timeline-container.loading {
    animation: pulse-glow 1.5s infinite;
}

/* Hide when modern UI controls are visible (optional - can remove) */
.timeline-container.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(20px);
    transition: all 0.3s ease;
}

/* Tooltip styles */
.tl-btn {
    position: relative;
}

.tl-btn[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 12px;
    background: rgba(20, 25, 45, 0.95);
    color: white;
    font-size: 12px;
    font-weight: 500;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 100;
    animation: tooltipFadeIn 0.15s ease-out;
}

.tl-btn[title]:hover::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(20, 25, 45, 0.95);
    pointer-events: none;
    z-index: 100;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ============================================
   LIGHT THEME STYLES
   ============================================ */

body.light-theme .timeline-container {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

body.light-theme .tl-btn {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
    color: rgba(0, 0, 0, 0.7);
}

body.light-theme .tl-btn:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.1);
    border-color: rgba(0, 0, 0, 0.2);
    color: #1a1a2e;
}

body.light-theme .tl-play-btn {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.2) 100%);
    border-color: rgba(102, 126, 234, 0.3);
    color: #667eea;
}

body.light-theme .tl-play-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.35) 0%, rgba(118, 75, 162, 0.35) 100%);
}

body.light-theme .tl-play-btn.active {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.5) 0%, rgba(118, 75, 162, 0.5) 100%);
    color: white;
}

body.light-theme #tl-current-date {
    color: #1a1a2e;
}

body.light-theme .timeline-range {
    color: rgba(0, 0, 0, 0.5);
}

body.light-theme .timeline-slider {
    background: rgba(0, 0, 0, 0.1);
}

body.light-theme .timeline-slider::-webkit-slider-thumb {
    border-color: rgba(0, 0, 0, 0.2);
}

body.light-theme .timeline-slider::-moz-range-thumb {
    border-color: rgba(0, 0, 0, 0.2);
}

body.light-theme .timeline-buffer-indicator {
    background: rgba(0, 0, 0, 0.1);
}

body.light-theme .tl-speed-menu {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

body.light-theme .tl-speed-option {
    color: rgba(0, 0, 0, 0.7);
}

body.light-theme .tl-speed-option:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #1a1a2e;
}

body.light-theme .tl-speed-option.selected {
    color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

/* Light theme - hover tooltip */
body.light-theme .timeline-hover-tooltip {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(0, 0, 0, 0.1);
    color: #1a1a2e;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

body.light-theme .timeline-hover-tooltip::after {
    border-top-color: rgba(255, 255, 255, 0.98);
}

body.light-theme .timeline-hover-tooltip .tooltip-date {
    color: #1a1a2e;
}

body.light-theme .timeline-hover-tooltip .tooltip-event {
    color: #b8860b;
}

body.light-theme .timeline-hover-tooltip.has-event {
    border-color: rgba(184, 134, 11, 0.4);
}

/* Light theme - event markers (keep same colors for visibility) */
body.light-theme .event-marker {
    box-shadow: 0 0 6px rgba(255, 215, 0, 0.7);
}

body.light-theme .event-marker:hover {
    box-shadow: 0 0 12px rgba(255, 215, 0, 1);
}

body.light-theme .deployment-icon {
    filter: drop-shadow(0 0 3px currentColor) drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

/* Light theme - event marker tooltip */
body.light-theme .timeline-event-tooltip {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(0, 0, 0, 0.1);
    color: #1a1a2e;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

body.light-theme .timeline-event-tooltip::after {
    border-top-color: rgba(255, 255, 255, 0.98);
}

body.light-theme .event-tooltip-type {
    background: rgba(0, 0, 0, 0.08);
}

body.light-theme .event-tooltip-type.event-type-outage {
    background: rgba(255, 71, 87, 0.15);
    color: #dc3545;
}

body.light-theme .event-tooltip-type.event-type-maintenance {
    background: rgba(255, 165, 2, 0.15);
    color: #d68c00;
}

body.light-theme .event-tooltip-type.event-type-network_event {
    background: rgba(55, 66, 250, 0.15);
    color: #2a35cc;
}

body.light-theme .event-tooltip-type.event-type-security {
    background: rgba(232, 67, 147, 0.15);
    color: #c43a7b;
}

body.light-theme .event-tooltip-type.event-type-anomaly {
    background: rgba(0, 206, 201, 0.15);
    color: #00a39f;
}

body.light-theme .event-tooltip-date {
    color: rgba(0, 0, 0, 0.5);
}

body.light-theme .event-tooltip-title {
    color: #1a1a2e;
}

body.light-theme .event-tooltip-summary {
    color: rgba(0, 0, 0, 0.65);
}

body.light-theme .event-tooltip-hint {
    color: rgba(0, 0, 0, 0.35);
    border-top-color: rgba(0, 0, 0, 0.08);
}
