/* ============================================================
   gantt.css — Gantt chart core: container, timeline, bars, deps
   ============================================================ */

.gantt-view {
    animation: fadeIn var(--transition-normal) ease-out;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 64px);
    margin: calc(-1 * var(--space-8));
    padding: var(--space-4) var(--space-6);
}

/* ── Main Container ──────────────────────────────────────── */
.gantt-container {
    display: grid;
    grid-template-columns: var(--gantt-sidebar-width, 280px) 1fr;
    grid-template-rows: 52px minmax(0, 1fr);
    flex: 1;
    overflow: hidden;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-top: var(--space-4);
    background: var(--bg-secondary);
    position: relative;
}

/* ── Timeline Header ─────────────────────────────────────── */
.gantt-timeline-header {
    grid-column: 2;
    grid-row: 1;
    overflow: hidden;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    position: relative;
    height: 100%;
    min-height: 0;
    box-sizing: border-box;
}

.gantt-header-row {
    display: flex;
    height: 26px;
    position: relative;
}

.gantt-header-cell {
    position: absolute;
    top: 0;
    height: 100%;
    display: flex;
    align-items: center;
    padding-left: var(--space-2);
    font-size: var(--text-xs);
    color: var(--text-secondary);
    border-right: 1px solid var(--border-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
}

.gantt-header-cell.primary {
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

.gantt-header-cell.secondary {
    font-size: 8px;
    color: var(--text-tertiary);
}

/* ── Body (bars area) ────────────────────────────────────── */
.gantt-body {
    grid-column: 2;
    grid-row: 2;
    overflow: auto;
    position: relative;
    background: var(--bg-secondary);
}

.gantt-body-inner {
    position: relative;
    min-height: 100%;
}

/* ── Grid Lines ──────────────────────────────────────────── */
.gantt-grid-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--border-color);
    pointer-events: none;
}

.gantt-grid-line.weekend {
    width: 0;
    background: rgba(107, 114, 128, 0.06);
}

.gantt-row-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border-color);
    pointer-events: none;
}

.gantt-row-highlight {
    position: absolute;
    left: 0;
    right: 0;
    pointer-events: none;
    background: rgba(148, 163, 184, 0.14);
    opacity: 0;
    transition: opacity 0.08s linear;
    z-index: 1;
}

.gantt-row-highlight.active {
    opacity: 1;
}

/* ── Today Line ──────────────────────────────────────────── */
.gantt-today-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--accent-warning);
    z-index: 5;
    pointer-events: none;
}

.gantt-today-label {
    position: absolute;
    top: -20px;
    transform: translateX(-50%);
    font-size: 9px;
    color: var(--accent-warning);
    font-weight: var(--font-semibold);
    white-space: nowrap;
    pointer-events: none;
}

/* ── Bars ────────────────────────────────────────────────── */
.gantt-bar {
    position: absolute;
    height: 28px;
    border-radius: var(--radius-sm);
    cursor: grab;
    transition: box-shadow var(--transition-fast);
    display: flex;
    align-items: center;
    overflow: hidden;
    z-index: 2;
    min-width: 4px;
}

.gantt-bar:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    z-index: 10;
}

.gantt-bar.dragging {
    opacity: 0.85;
    cursor: grabbing;
    z-index: 20;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.gantt-bar.critical {
    outline: 2px solid var(--accent-danger);
    outline-offset: 1px;
}

.gantt-bar.selected {
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.55);
}

.gantt-bar-progress {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    pointer-events: none;
}

.gantt-bar-label {
    padding: 3px var(--space-2);
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    position: relative;
    z-index: 1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    line-height: 1.1;
    width: 100%;
    min-width: 0;
}

.gantt-bar-title {
    font-size: 11px;
    font-weight: var(--font-semibold);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gantt-bar-team {
    font-size: 8px;
    font-weight: var(--font-medium);
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gantt-bar-project {
    font-size: 8px;
    font-weight: var(--font-medium);
    color: rgba(255, 255, 255, 0.9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gantt-bar-label.hidden {
    display: none;
}

.gantt-bar-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 8px;
    cursor: col-resize;
    opacity: 0;
    transition: opacity var(--transition-fast);
    z-index: 3;
}

.gantt-bar:hover .gantt-bar-handle {
    opacity: 1;
    background: rgba(255, 255, 255, 0.2);
}

.gantt-bar-handle-left { left: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.gantt-bar-handle-right { right: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ── Milestones ──────────────────────────────────────────── */
.gantt-milestone-marker {
    position: absolute;
    width: 16px;
    height: 16px;
    transform: rotate(45deg);
    transform-origin: center;
    cursor: pointer;
    z-index: 3;
    border: 2px solid white;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.gantt-milestone-marker.selected {
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.55), 0 1px 4px rgba(0, 0, 0, 0.3);
}

/* ── Dependencies (SVG) ──────────────────────────────────── */
.gantt-dependencies-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
    overflow: visible;
}

/* Invisible wider hit area for clicking arrows */
.gantt-dep-hit {
    fill: none;
    stroke: transparent;
    stroke-width: 14;
    pointer-events: stroke;
    cursor: pointer;
}

.gantt-dep-path {
    fill: none;
    stroke: #6b7280;
    stroke-width: 1.5;
    pointer-events: none;
    transition: stroke 0.15s, stroke-width 0.15s;
}

.gantt-dep-hit:hover ~ .gantt-dep-path,
.gantt-dep-path.hover {
    stroke-width: 2.5;
    stroke: #818cf8;
    marker-end: url(#arrowhead-hover);
}

.gantt-dep-path.critical {
    stroke: var(--accent-danger);
    stroke-width: 2;
}

/* Lag badge on arrows */
.gantt-dep-badge {
    pointer-events: all;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
}

.gantt-dependencies-svg:hover .gantt-dep-badge {
    opacity: 1;
}

.gantt-dep-badge rect {
    fill: #1e293b;
    stroke: #475569;
    stroke-width: 1;
}

.gantt-dep-badge text {
    fill: #94a3b8;
    font-size: 10px;
    text-anchor: middle;
    font-family: var(--font-sans);
    font-weight: 500;
}

.gantt-dep-badge:hover rect {
    fill: #334155;
    stroke: #818cf8;
}

.gantt-dep-badge:hover text {
    fill: #c7d2fe;
}

/* ── Link Mode ──────────────────────────────────────────── */
.gantt-body.link-mode .gantt-bar {
    cursor: crosshair;
}

.gantt-body.link-mode .gantt-milestone-marker {
    cursor: crosshair;
}

.gantt-body.link-mode .gantt-bar:hover {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.gantt-body.link-mode .gantt-milestone-marker:hover {
    box-shadow: 0 0 0 2px var(--accent-primary), 0 1px 4px rgba(0, 0, 0, 0.3);
}

.gantt-bar.link-source {
    outline: 2px solid var(--accent-success, #10b981);
    outline-offset: 2px;
    animation: pulse 1.5s infinite;
}

.gantt-milestone-marker.link-source {
    box-shadow: 0 0 0 2px var(--accent-success, #10b981), 0 1px 4px rgba(0, 0, 0, 0.3);
    animation: pulse 1.5s infinite;
}

/* ── Empty State ─────────────────────────────────────────── */
.gantt-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    grid-column: 1 / -1;
    grid-row: 2;
    padding: var(--space-12);
}
