/**
 * Layer Timeline & Inline Controls
 * Bottom timeline bar for time-series layers + inline opacity sliders
 */

/* ============================================
   BOTTOM TIMELINE BAR
   ============================================ */

.layer-timeline-bar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: none;
    border-radius: 12px 12px 0 0;
    padding: 10px 24px;
    z-index: 1000;
    display: none;
    box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.3);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.layer-timeline-bar.visible {
    display: block;
}

/* Minimized timeline button */
.timeline-minimized-btn {
    position: fixed;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 8px 16px;
    color: #e2e8f0;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    z-index: 999;
    display: none;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.timeline-minimized-btn.visible {
    display: flex;
}

.timeline-minimized-btn:hover {
    background: rgba(30, 41, 59, 0.98);
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.timeline-minimized-btn i {
    color: #3b82f6;
    font-size: 11px;
}

/* Main row - single horizontal line */
.timeline-main-row {
    display: flex;
    align-items: center;
    gap: 16px;
    height: 36px;
}

/* Timeline Header - Active Layers */
.timeline-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    padding-right: 14px;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

.timeline-layers-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 4px 10px;
    cursor: pointer;
    transition: all 0.15s;
}

.timeline-layers-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.timeline-layer-count {
    font-size: 11px;
    color: #e2e8f0;
    font-weight: 500;
}

.timeline-layers-btn i {
    font-size: 8px;
    color: #64748b;
    transition: transform 0.2s;
}

.timeline-layers-btn.expanded i {
    transform: rotate(180deg);
}

/* Layers dropdown popover */
.timeline-layers-popover {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 8px 0;
    min-width: 200px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
    display: none;
    z-index: 1001;
}

.timeline-layers-popover.visible {
    display: block;
}

.timeline-layers-popover::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 20px;
    width: 10px;
    height: 10px;
    background: rgba(15, 23, 42, 0.98);
    border-right: 1px solid rgba(255, 255, 255, 0.15);
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    transform: rotate(45deg);
}

.timeline-layer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    font-size: 11px;
    color: #e2e8f0;
}

.timeline-layer-item.hidden-layer {
    opacity: 0.4;
}

.timeline-layer-item .status-icon {
    width: 14px;
    font-size: 10px;
    text-align: center;
    flex-shrink: 0;
}

.timeline-layer-item .status-icon.visible {
    color: #10b981;
}

.timeline-layer-item .status-icon.hidden {
    color: #64748b;
}

.timeline-layer-item .name {
    flex: 1;
}

.timeline-layer-item .period {
    font-size: 10px;
    color: #64748b;
}

/* Timeline Periods */
.timeline-periods {
    display: flex;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
}

.timeline-period-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    padding: 5px 10px;
    color: #94a3b8;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

/* Period dates */
.timeline-period-dates {
    font-size: 10px;
    color: #64748b;
    white-space: nowrap;
    flex-shrink: 0;
    padding: 0 8px;
}

/* Close button */
.timeline-close {
    background: transparent;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: all 0.15s;
    flex-shrink: 0;
    margin-left: auto;
}

.timeline-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #94a3b8;
}

.timeline-period-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    border-color: rgba(255, 255, 255, 0.15);
}

.timeline-period-btn.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

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

/* ============================================
   HOURLY SLIDER (for NDFD)
   ============================================ */

.timeline-hourly-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 0;
}

.timeline-hourly-slider-wrapper {
    position: relative;
    padding: 0 4px;
}

.timeline-hourly-slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, #3b82f6 0%, #3b82f6 33%, rgba(255,255,255,0.2) 33%, rgba(255,255,255,0.2) 100%);
    border-radius: 3px;
    cursor: pointer;
    margin: 0;
}

.timeline-hourly-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    border: 2px solid white;
}

.timeline-hourly-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    border: 2px solid white;
}

.timeline-hourly-markers {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    padding: 0 2px;
}

.timeline-hourly-markers span {
    font-size: 10px;
    color: #64748b;
    text-align: center;
}

.timeline-hourly-display {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 4px 0;
}

.timeline-forecast-time {
    font-size: 16px;
    font-weight: 600;
    color: #e2e8f0;
}

.timeline-forecast-date {
    font-size: 12px;
    color: #94a3b8;
}

/* ============================================
   HISTORICAL SLIDER (for Power Outages)
   Single compact horizontal row design
   ============================================ */

.timeline-historical-container {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 0;
    min-width: 500px;
}

/* Play/Pause Button */
.timeline-historical-play-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #f59e0b;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.timeline-historical-play-btn:hover {
    background: #d97706;
    transform: scale(1.08);
}

.timeline-historical-play-btn.playing {
    background: #ef4444;
}

.timeline-historical-play-btn.playing:hover {
    background: #dc2626;
}

.timeline-historical-play-btn i {
    font-size: 10px;
}

/* Timeline Slider */
.timeline-historical-slider-wrapper {
    position: relative;
    flex: 1;
    min-width: 180px;
    max-width: 280px;
}

.timeline-historical-slider {
    width: 100%;
    height: 5px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0.2) 100%);
    border-radius: 3px;
    cursor: pointer;
    margin: 0;
    transition: background 0.15s ease;
}

.timeline-historical-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #f59e0b;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    border: 2px solid white;
    transition: transform 0.1s ease;
}

.timeline-historical-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.timeline-historical-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #f59e0b;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    border: 2px solid white;
}

/* Tick marks under slider */
.timeline-historical-markers {
    display: flex;
    justify-content: space-between;
    margin-top: 2px;
    padding: 0;
}

.timeline-historical-markers span {
    font-size: 8px;
    color: #64748b;
    text-align: center;
}

/* Time Display - Inline */
.timeline-historical-display {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 10px;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    white-space: nowrap;
    flex-shrink: 0;
}

.timeline-historical-time {
    font-size: 12px;
    font-weight: 600;
    color: #f59e0b;
}

.timeline-historical-date {
    font-size: 11px;
    color: #94a3b8;
}

/* Speed Control - Compact Inline with Labels */
.timeline-historical-speed {
    display: flex;
    align-items: center;
    gap: 4px;
    padding-left: 10px;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.timeline-historical-speed-label {
    font-size: 8px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.timeline-historical-speed-slider {
    width: 45px;
    height: 3px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    cursor: pointer;
}

.timeline-historical-speed-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #f59e0b;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.timeline-historical-speed-slider::-moz-range-thumb {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #f59e0b;
    cursor: pointer;
    border: none;
}

/* Responsive adjustments for historical controls */
@media (max-width: 700px) {
    .timeline-historical-container {
        min-width: auto;
        gap: 8px;
    }

    .timeline-historical-slider-wrapper {
        min-width: 120px;
        max-width: 160px;
    }

    .timeline-historical-markers {
        display: none;
    }

    .timeline-historical-date {
        display: none;
    }
}

/* ============================================
   POWER OUTAGE LAYER TRANSITIONS
   Smooth color transitions during animation
   ============================================ */

/* Target Leaflet SVG paths in the powerOutages pane */
.leaflet-powerOutages-pane path {
    transition: fill 0.08s ease-out, fill-opacity 0.08s ease-out;
}

/* Also target any paths that might be in the overlay pane */
.leaflet-overlay-pane path[class*="leaflet-interactive"] {
    transition: fill 0.08s ease-out, fill-opacity 0.08s ease-out;
}

/* Disable transitions during fast animation playback */
.animation-playing .leaflet-powerOutages-pane path,
.animation-playing .leaflet-overlay-pane path[class*="leaflet-interactive"] {
    transition: none !important;
}

/* Opacity Control - inline in main row */
.timeline-opacity {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-left: 12px;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.timeline-opacity label {
    font-size: 9px;
    color: #64748b;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.timeline-opacity-slider {
    width: 70px;
    height: 3px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    cursor: pointer;
}

.timeline-opacity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.timeline-opacity-slider::-moz-range-thumb {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    border: none;
}

.timeline-opacity-value {
    font-size: 10px;
    color: #94a3b8;
    min-width: 28px;
}

/* ============================================
   INLINE OPACITY SLIDERS (Left Sidebar)
   ============================================ */

.layer-opacity-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    margin: 4px 8px 8px;
}

.layer-opacity-inline label {
    font-size: 10px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.layer-opacity-inline input[type="range"] {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    cursor: pointer;
}

.layer-opacity-inline input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
}

.layer-opacity-inline .opacity-value {
    font-size: 10px;
    color: #94a3b8;
    min-width: 28px;
    text-align: right;
}

/* ============================================
   COMPACT SIDEBAR ADDITIONS
   ============================================ */

/* Show opacity slider when layer is expanded/active */
.accordion-panel .layer-item.active + .layer-opacity-inline,
.toggle-row.expanded + .layer-opacity-inline {
    display: flex;
}

/* Day buttons container styling */
.layer-day-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px 8px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    margin: 4px 8px;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 900px) {
    .layer-timeline-bar {
        left: 10px;
        right: 10px;
        transform: none;
        padding: 8px 16px;
    }

    .timeline-main-row {
        gap: 10px;
    }

    .timeline-header {
        display: none;
    }

    .timeline-period-btn {
        padding: 4px 8px;
        font-size: 10px;
    }

    .timeline-period-dates {
        display: none;
    }

    .timeline-opacity-slider {
        width: 50px;
    }
}

@media (max-width: 600px) {
    .timeline-periods {
        flex-wrap: wrap;
        gap: 2px;
    }

    .timeline-period-btn {
        padding: 3px 6px;
        font-size: 9px;
    }

    .timeline-opacity {
        display: none;
    }
}

/* ============================================
   SATELLITE ANIMATION CONTROLS
   ============================================ */

.timeline-animation-container {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 0;
}

.timeline-animation-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.timeline-anim-play-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #3b82f6;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.timeline-anim-play-btn:hover {
    background: #2563eb;
    transform: scale(1.05);
}

.timeline-anim-play-btn.playing {
    background: #ef4444;
}

.timeline-anim-play-btn.playing:hover {
    background: #dc2626;
}

.timeline-anim-play-btn i {
    font-size: 12px;
}

.timeline-anim-progress {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    overflow: hidden;
    min-width: 100px;
}

.timeline-anim-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

.timeline-anim-frame-display {
    font-size: 11px;
    color: #94a3b8;
    white-space: nowrap;
    min-width: 80px;
}

.timeline-animation-speed {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 16px;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.timeline-animation-speed label {
    font-size: 9px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.timeline-anim-speed-slider {
    width: 80px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    cursor: pointer;
}

.timeline-anim-speed-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.timeline-anim-speed-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    border: none;
}

.timeline-anim-speed-value {
    font-size: 10px;
    color: #94a3b8;
    min-width: 28px;
}

.timeline-anim-date-display {
    font-size: 12px;
    color: #e2e8f0;
    font-weight: 500;
    padding-left: 16px;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    white-space: nowrap;
}

/* Responsive adjustments for animation controls */
@media (max-width: 900px) {
    .timeline-animation-container {
        flex-wrap: wrap;
        gap: 10px;
    }

    .timeline-animation-speed {
        border-left: none;
        padding-left: 0;
    }

    .timeline-anim-date-display {
        border-left: none;
        padding-left: 0;
        width: 100%;
        text-align: center;
    }
}

@media (max-width: 600px) {
    .timeline-anim-progress {
        min-width: 60px;
    }

    .timeline-anim-speed-slider {
        width: 50px;
    }

    .timeline-anim-frame-display {
        display: none;
    }
}
