/* ========================================
   UNIFIED TIMELINE SYSTEM - HYBRID FLEX
   Option C: Combines grid precision with scrolling flexibility
   Used by: 10-in-24, Fatigue Calculator, Flight & Duty
   ======================================== */

/* Container */
.unified-timeline-container {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-top: 20px;
    border: 1px solid #dee2e6;
}

/* Header with controls */
.unified-timeline-header {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #2c3e50;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: linear-gradient(135deg, #f5f7fa 0%, #e9ecef 100%);
    border-radius: 8px;
}

.unified-timeline-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Timezone toggle (reuse existing from global) */
.timezone-toggle {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 5px;
    display: flex;
    gap: 5px;
}

.timezone-btn {
    padding: 5px 10px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s;
    color: #495057;
}

.timezone-btn.active {
    background: var(--warm-accent);
    color: white;
}

.timezone-btn:hover {
    background: #f8f9fa;
}

.timezone-btn.active:hover {
    background: var(--warm-accent-dark);
}

/* Scrollable timeline container */
.unified-timeline {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin-top: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    position: relative;
}

.unified-timeline::-webkit-scrollbar {
    height: 10px;
}

.unified-timeline::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.unified-timeline::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--warm-accent) 0%, var(--warm-accent-dark) 100%);
    border-radius: 10px;
}

.unified-timeline::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, var(--warm-accent-dark) 0%, var(--warm-accent) 100%);
}

/* Wrapper - contains sidebar + main */
.unified-timeline-wrapper {
    display: flex;
    min-width: max-content;
}

/* Sticky Sidebar for labels */
.unified-timeline-sidebar {
    position: sticky;
    left: 0;
    z-index: 10;
    background: #f8f9fa;
    border-right: 2px solid #dee2e6;
    min-width: 140px;
    display: flex;
    flex-direction: column;
}

.unified-timeline-sidebar-header {
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #e9ecef;
    border-bottom: 2px solid #dee2e6;
}

.unified-timeline-sidebar-row {
    height: 40px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    font-size: 12px;
    font-weight: 600;
    color: #495057;
    border-bottom: 1px solid #f0f0f0;
    background: linear-gradient(90deg, #f8f9fa 0%, var(--text-inverse) 100%);
}

.unified-timeline-sidebar-row:last-child {
    border-bottom: none;
}

/* Main timeline area with flex grid */
.unified-timeline-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 2400px; /* Minimum width for 48 hours (50px per hour * 48) */
}

/* Hour headers row */
.unified-timeline-header-row {
    display: flex;
    height: 40px;
    background: #e9ecef;
    border-bottom: 2px solid #dee2e6;
}

.unified-timeline-hour-cell {
    flex: 1;
    min-width: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: #495057;
    border-right: 1px solid #dee2e6;
}

.unified-timeline-hour-cell.major {
    background: #d6d6d6;
    font-weight: 700;
}

.unified-timeline-hour-cell.midnight {
    background: linear-gradient(135deg, #c0c0c0 0%, #d6d6d6 100%);
    color: #2c3e50;
}

.unified-timeline-hour-cell.day-break {
    background: linear-gradient(135deg, #a0a0a0 0%, #b8b8b8 100%);
    border-left: 3px solid var(--warm-accent);
    border-right: 3px solid var(--warm-accent);
    font-weight: 700;
    color: var(--warm-accent-dark);
}

.unified-timeline-hour-cell:last-child {
    border-right: none;
}

/* Content rows container */
.unified-timeline-content-rows {
    flex: 1;
    position: relative;
}

/* Individual content row */
.unified-timeline-content-row {
    height: 40px;
    position: relative;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
}

.unified-timeline-content-row:last-child {
    border-bottom: none;
}

/* Hour column backgrounds within rows */
.unified-timeline-hour-bg {
    flex: 1;
    min-width: 50px;
    border-right: 1px solid #f8f8f8;
}

.unified-timeline-hour-bg.major {
    border-right: 1px solid #e9ecef;
}

.unified-timeline-hour-bg.midnight {
    background: #f8f9fa;
    border-right: 2px solid #dee2e6;
}

.unified-timeline-hour-bg.day-break {
    background: #e8eaf6;
    border-left: 3px solid var(--warm-accent);
    border-right: 3px solid var(--warm-accent);
}

/* Timeline bars - positioned absolutely within rows */
.unified-timeline-bar {
    position: absolute;
    height: 28px;
    top: 6px;
    color: white;
    padding: 4px 8px;
    border-radius: 5px;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    white-space: nowrap;
}

.unified-timeline-bar:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.25);
    z-index: 15;
}

/* Color schemes for different data types */
.unified-timeline-bar.flight {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
}

.unified-timeline-bar.wocl {
    background: linear-gradient(135deg, var(--warm-accent-dark) 0%, var(--warm-accent) 100%);
}

.unified-timeline-bar.rest {
    background: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%);
}

.unified-timeline-bar.preflight {
    background: linear-gradient(135deg, #f97316 0%, #fb923c 100%);
}

.unified-timeline-bar.duty {
    background: linear-gradient(135deg, var(--status-success) 0%, #34d399 100%);
}

.unified-timeline-bar.duty-limit {
    background: linear-gradient(135deg, var(--warm-accent) 0%, var(--warm-accent-light) 100%);
    opacity: 0.7;
}

.unified-timeline-bar.postflight {
    background: linear-gradient(135deg, var(--status-danger) 0%, var(--risk-critical) 100%);
}

.unified-timeline-bar.turn {
    background: linear-gradient(135deg, var(--status-warning) 0%, var(--status-warning-light) 100%);
}

.unified-timeline-bar.violation {
    background: repeating-linear-gradient(
        45deg,
        rgba(220, 53, 69, 0.7),
        rgba(220, 53, 69, 0.7) 6px,
        rgba(220, 53, 69, 0.9) 6px,
        rgba(220, 53, 69, 0.9) 12px
    );
    border: 2px solid #dc3545;
}

/* Violation overlay - spans across multiple rows */
.unified-timeline-violation-overlay {
    position: absolute;
    background: repeating-linear-gradient(
        45deg,
        rgba(220, 53, 69, 0.1),
        rgba(220, 53, 69, 0.1) 8px,
        rgba(220, 53, 69, 0.2) 8px,
        rgba(220, 53, 69, 0.2) 16px
    );
    border: 2px solid #dc3545;
    border-radius: 4px;
    z-index: 2;
    pointer-events: none;
}

.unified-timeline-violation-label {
    position: absolute;
    top: 2px;
    left: 4px;
    background: #dc3545;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 600;
    z-index: 3;
}

/* Legend */
.unified-timeline-legend {
    display: flex;
    gap: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-top: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.unified-timeline-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.unified-timeline-legend-color {
    width: 30px;
    height: 12px;
    border-radius: 3px;
}

/* Tooltip */
.unified-timeline-tooltip {
    position: fixed;
    background: rgba(0, 0, 0, 0.95);
    color: white;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 11px;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
    max-width: 300px;
    line-height: 1.5;
    display: none;
}

.unified-timeline-tooltip.visible {
    display: block;
}

.unified-timeline-tooltip-title {
    font-weight: 700;
    color: var(--warm-accent);
    margin-bottom: 4px;
}

.unified-timeline-tooltip-detail {
    margin: 2px 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .unified-timeline-sidebar {
        min-width: 100px;
    }

    .unified-timeline-sidebar-row {
        font-size: 10px;
        padding: 0 8px;
    }

    .unified-timeline-hour-cell {
        font-size: 10px;
        min-width: 40px;
    }

    .unified-timeline-bar {
        font-size: 9px;
        padding: 3px 6px;
    }
}

/* Helper classes */
.unified-timeline-bar.long-label {
    font-size: 9px;
    padding: 3px 6px;
}

.unified-timeline-bar.very-long-label {
    font-size: 8px;
    padding: 2px 4px;
    letter-spacing: -0.3px;
}

/* Duty window background overlay (for Flight & Duty tool) */
.unified-timeline-duty-bg {
    position: absolute;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(52, 211, 153, 0.1) 100%);
    border: 1px dashed var(--status-success);
    border-radius: 4px;
    z-index: 1;
    pointer-events: none;
}
