/* ==========================================
   TIMELINE VISUALIZATION
   ========================================== */

.timeline-container {
    background-color: white;
    border: 1px solid var(--color-neutral-200);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    width: 100%;
    box-shadow: var(--shadow-sm);
}

.timeline-scroll {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--spacing-sm);
}

.timeline-grid {
    min-width: 100%;
}

.timeline-header-row {
    display: flex;
    border-bottom: 2px solid var(--color-neutral-300);
    position: sticky;
    top: 0;
    background: white;
    z-index: 2;
}

.timeline-corner {
    width: var(--deal-label-width, 200px);
    min-width: var(--deal-label-width, 200px);
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: var(--spacing-sm);
    border-right: 2px solid var(--color-neutral-200);
    cursor: help;
}

.axis-label-y {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    color: var(--color-neutral-500);
    writing-mode: vertical-rl;
    transform: rotate(180deg);
}

.timeline-axis-area {
    flex: 1;
    min-width: 0;
}

.timeline-axis-top {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-bottom: 1px solid var(--color-neutral-100);
    cursor: help;
}

.axis-label-x {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    color: var(--color-neutral-500);
}

.timeline-granularity-badge {
    font-size: var(--font-size-xs);
    background: #e3f2fd;
    color: #1565c0;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: var(--font-weight-medium);
}

.timeline-periods {
    display: flex;
}

.timeline-period {
    flex-shrink: 0;
    text-align: center;
    padding: var(--spacing-sm) 4px;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    color: var(--color-neutral-700);
    border-right: 1px solid var(--color-neutral-200);
    box-sizing: border-box;
}

.timeline-period:last-child {
    border-right: none;
}

.timeline-body {
    display: flex;
    flex-direction: column;
}

.timeline-row {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid var(--color-neutral-100);
    min-height: 52px;
}

.timeline-row:hover {
    background-color: var(--color-neutral-50);
}

.timeline-deal-label {
    width: var(--deal-label-width, 200px);
    min-width: var(--deal-label-width, 200px);
    flex-shrink: 0;
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-neutral-900);
    border-right: 2px solid var(--color-neutral-200);
    display: flex;
    align-items: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.timeline-track {
    position: relative;
    flex-shrink: 0;
    height: 52px;
}

.timeline-grid-bg {
    position: absolute;
    inset: 0;
    display: flex;
    pointer-events: none;
}

.timeline-grid-col {
    flex-shrink: 0;
    height: 100%;
    border-right: 1px dashed var(--color-neutral-200);
    box-sizing: border-box;
}

.timeline-grid-col:last-child {
    border-right: none;
}

.timeline-bar {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    height: 32px;
    min-width: 72px;
    padding: 0 10px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: box-shadow var(--transition-fast), filter var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    z-index: 1;
    box-shadow: var(--shadow-sm);
}

.timeline-bar:hover {
    filter: brightness(1.08);
    box-shadow: var(--shadow-md);
    z-index: 10;
}

.timeline-bar.planned {
    background: linear-gradient(90deg, #3b82f6 0%, #1d4ed8 100%);
}

.timeline-bar.invoiced {
    background: linear-gradient(90deg, #f59e0b 0%, #d97706 100%);
}

.timeline-bar.paid {
    background: linear-gradient(90deg, #22c55e 0%, #16a34a 100%);
}

.timeline-bar-label {
    white-space: nowrap;
    overflow: visible;
}

.timeline-bar:hover .timeline-tooltip {
    display: block;
}

.timeline-tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--color-neutral-900);
    color: white;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    font-size: var(--font-size-xs);
    white-space: nowrap;
    z-index: 100;
    box-shadow: var(--shadow-lg);
    pointer-events: none;
}

.timeline-tooltip-title {
    font-weight: var(--font-weight-semibold);
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
}

.timeline-tooltip-item {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: 3px;
}

.timeline-tooltip-item:last-child {
    margin-bottom: 0;
}

.timeline-tooltip-label {
    font-weight: var(--font-weight-medium);
    min-width: 64px;
    color: #bdbdbd;
}

.timeline-empty {
    text-align: center;
    color: var(--color-neutral-500);
    padding: var(--spacing-2xl);
    font-size: var(--font-size-sm);
}

.timeline-granularity-tag {
    font-size: var(--font-size-xs);
    background: #e8f4fd;
    color: #1565c0;
    padding: 4px 10px;
    border-radius: 999px;
    font-weight: var(--font-weight-medium);
}

.timeline-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-lg);
    align-items: center;
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--color-neutral-200);
    font-size: var(--font-size-sm);
    color: var(--color-neutral-600);
}

.legend-box {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: var(--radius-sm);
    margin-right: var(--spacing-sm);
    vertical-align: middle;
}

.legend-box.planned {
    background: linear-gradient(90deg, #3b82f6 0%, #1d4ed8 100%);
}

.legend-box.invoiced {
    background: linear-gradient(90deg, #f59e0b 0%, #d97706 100%);
}

.legend-box.paid {
    background: linear-gradient(90deg, #22c55e 0%, #16a34a 100%);
}

.legend-hint {
    margin-left: auto;
    font-size: var(--font-size-xs);
    color: var(--color-neutral-400);
    font-style: italic;
}

.timeline-range {
    display: inline-block;
    min-width: 160px;
    text-align: center;
    font-weight: var(--font-weight-semibold);
    color: var(--color-neutral-700);
    font-size: var(--font-size-sm);
}

.timeline-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}
