/* ============================================================
   Timeline View — bottom bar control
   ============================================================ */

/* ---- Loading overlay ---- */
.tl-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: all;
}

.tl-loading-overlay.visible {
    opacity: 1;
}

.tl-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: tl-spin 0.8s linear infinite;
}

.tl-loading-text {
    margin-top: 12px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
}

@keyframes tl-spin {
    to { transform: rotate(360deg); }
}

.timeline-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 90px;
    background: var(--bg-surface);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--border-color);
    z-index: 500;
    display: flex;
    flex-direction: column;
    padding: 6px 16px 8px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    font-family: inherit;
    color: var(--text-primary);
}

.timeline-bar.visible {
    transform: translateY(0);
}

/* ---- Top row: controls ---- */
.timeline-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 28px;
    flex-shrink: 0;
}

.timeline-controls .tl-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    cursor: pointer;
    padding: 2px 8px;
    font-size: 12px;
    line-height: 1.4;
    transition: background 0.15s;
}

.timeline-controls .tl-btn:hover {
    background: var(--bg-elevated);
}

.timeline-controls .tl-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

.timeline-controls .tl-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
    line-height: 1;
}

.timeline-controls .tl-close:hover {
    color: #ff4757;
}

.timeline-controls select {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 11px;
    padding: 2px 6px;
    cursor: pointer;
}

.timeline-controls .tl-separator {
    width: 1px;
    height: 18px;
    background: var(--border-color);
}

.timeline-controls .tl-label {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.timeline-controls .tl-layers {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
    overflow: hidden;
}

.timeline-controls .tl-layer-chip {
    background: var(--bg-elevated);
    border-radius: 10px;
    padding: 1px 8px;
    font-size: 10px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.timeline-controls .tl-layer-chip .chip-remove {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1;
}

.timeline-controls .tl-layer-chip .chip-remove:hover {
    color: #ff4757;
}

.tl-null-badge {
    font-size: 10px;
    color: #fbbf24;
    cursor: help;
}

/* ---- Middle row: slider ---- */
.timeline-slider-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-height: 0;
}

.timeline-slider-wrap {
    flex: 1;
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
}

.timeline-slider-wrap input[type="range"] {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-elevated);
    outline: none;
}

.timeline-slider-wrap input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: 2px solid var(--text-primary);
    box-shadow: 0 0 4px var(--shadow-color);
}

.timeline-slider-wrap input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: 2px solid var(--text-primary);
    box-shadow: 0 0 4px var(--shadow-color);
}

.timeline-tick-labels {
    position: absolute;
    top: 24px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    font-size: 9px;
    color: var(--text-muted);
    pointer-events: none;
    padding: 0 8px;
}

.timeline-current-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 80px;
    text-align: center;
    white-space: nowrap;
}

/* ---- Window size control ---- */
.tl-window-control {
    display: none;
    align-items: center;
    gap: 4px;
}

.tl-window-control.visible {
    display: flex;
}

.tl-window-control input[type="number"] {
    width: 48px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 11px;
    padding: 2px 4px;
    text-align: center;
}

/* ---- Baseline control (compare mode only) ---- */
.tl-baseline-control {
    display: none;
    align-items: center;
    gap: 4px;
}

.tl-baseline-control.visible {
    display: flex;
}

.tl-baseline-control select {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 11px;
    padding: 2px 6px;
    cursor: pointer;
}

/* ---- Map padding when bar is visible ---- */
#mapWrapper.timeline-active #map-left,
#mapWrapper.timeline-active #map-right {
    margin-bottom: 90px;
}

/* ---- Hex Grid Tooltip ---- */
.tl-hex-tooltip {
    position: fixed; pointer-events: none;
    background: var(--bg-surface); border: 1px solid var(--border-color);
    border-radius: 6px; padding: 8px 12px; font-size: 12px;
    color: var(--text-primary); z-index: 10000;
    box-shadow: 0 4px 12px var(--shadow-color); max-width: 220px; line-height: 1.5;
}
.tl-hex-tooltip .tooltip-title { font-weight: 600; margin-bottom: 4px; color: var(--primary-color); }
.tl-hex-tooltip .tooltip-row { display: flex; justify-content: space-between; gap: 12px; }
.tl-hex-tooltip .tooltip-label { color: var(--text-muted); }
.tl-hex-tooltip .tooltip-value { font-weight: 500; }
.tl-hex-tooltip .tooltip-hint { margin-top: 4px; font-size: 10px; color: var(--text-muted); font-style: italic; }

/* ---- Compare Legend ---- */
.tl-compare-legend {
    position: absolute; bottom: 100px; right: 16px;
    background: var(--bg-surface); border: 1px solid var(--border-color);
    border-radius: 6px; padding: 8px 12px; font-size: 11px;
    color: var(--text-primary); z-index: 501;
    box-shadow: 0 2px 8px var(--shadow-color); display: none;
}
.tl-compare-legend.visible { display: block; }
.tl-compare-legend .legend-title {
    font-weight: 600; margin-bottom: 6px; font-size: 10px;
    color: var(--text-muted); text-transform: uppercase;
}
.tl-compare-legend .legend-bar {
    display: flex; height: 12px; border-radius: 3px; overflow: hidden; margin-bottom: 4px;
}
.tl-compare-legend .legend-labels {
    display: flex; justify-content: space-between; font-size: 10px; color: var(--text-muted);
}

/* ---- Compare metric controls ---- */
.tl-compare-metric {
    display: none; align-items: center; gap: 4px;
}
.tl-compare-metric.visible { display: flex; }
.tl-compare-metric select {
    background: var(--input-bg); border: 1px solid var(--input-border);
    border-radius: 4px; color: var(--text-primary); font-size: 11px;
    padding: 2px 6px; cursor: pointer;
}

/* ---- Color scheme control ---- */
.tl-color-control {
    display: none; align-items: center; gap: 4px;
}
.tl-color-control select {
    background: var(--input-bg); border: 1px solid var(--input-border);
    border-radius: 4px; color: var(--text-primary); font-size: 11px;
    padding: 2px 6px; cursor: pointer;
}
