/* ==========================================================
   GANTT_CHART // Composant timeline
   ========================================================== */

.gantt-wrapper {
    background: var(--surface);
    border: 2px solid var(--ink);
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
}

.gantt-container {
    overflow: hidden;
}

.gantt-scroll {
    display: flex;
    overflow: auto;
    min-height: 60vh;
    max-height: 82vh;
    scroll-behavior: smooth;
}

/* scrollbar custom */
.gantt-scroll::-webkit-scrollbar {
    height: 12px;
    width: 12px;
}
.gantt-scroll::-webkit-scrollbar-track { background: var(--surface-alt); }
.gantt-scroll::-webkit-scrollbar-thumb {
    background: var(--ink);
    border-radius: 0;
    border: 2px solid var(--surface-alt);
}
.gantt-scroll::-webkit-scrollbar-thumb:hover { background: var(--accent); }
.gantt-scroll::-webkit-scrollbar-corner { background: var(--surface-alt); }

/* ============ SIDEBAR (liste des tâches) ============ */
.gantt-sidebar {
    flex-shrink: 0;
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 2px solid var(--ink);
    position: sticky;
    left: 0;
    z-index: 5;
}

.sidebar-header {
    display: grid;
    grid-template-columns: 1fr 60px 50px;
    gap: 8px;
    padding: 0 14px;
    height: 88px;
    align-items: center;
    background: var(--ink);
    color: var(--surface);
    border-bottom: 2px solid var(--ink);
    position: sticky;
    top: 0;
    z-index: 6;
}
.sidebar-th {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 600;
}
.sidebar-th-small { text-align: center; }

.sidebar-body {
    display: flex;
    flex-direction: column;
}

.sidebar-row {
    display: grid;
    grid-template-columns: 1fr 60px 50px;
    gap: 8px;
    padding: 0 14px;
    height: var(--gantt-row-height);
    align-items: center;
    border-bottom: 1px solid var(--border-grid);
    cursor: pointer;
    transition: background .15s;
    position: relative;
}
.sidebar-row:hover { background: var(--bg-soft); }
.sidebar-row:hover .sidebar-name { color: var(--accent); }

/* Bouton de suppression rapide d'une tâche (× au survol) */
.sidebar-del {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    border: 1.5px solid transparent;
    background: transparent;
    color: var(--ink-muted);
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .15s, background .15s, color .15s, border-color .15s;
}
.sidebar-row:hover .sidebar-del { opacity: 1; }
.sidebar-del:hover {
    background: var(--status-blocked);
    color: var(--surface);
    border-color: var(--status-blocked);
}

.sidebar-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 8px;
}
.sidebar-name::before {
    content: '';
    width: 6px; height: 6px;
    background: var(--proj-color, var(--accent));
    flex-shrink: 0;
}

.sidebar-owner {
    text-align: center;
    font-size: 10px;
    font-weight: 600;
    background: var(--bg);
    padding: 4px 6px;
    border-radius: 2px;
    color: var(--ink-soft);
    border: 1px solid var(--border-soft);
    text-transform: uppercase;
}
.sidebar-owner:empty { background: transparent; border: 0; }

.sidebar-progress {
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--ink);
}

.sidebar-empty {
    padding: 60px 24px;
    text-align: center;
    color: var(--ink-muted);
    font-size: 12px;
    line-height: 1.6;
}
.sidebar-empty strong { color: var(--ink); display: block; margin-bottom: 6px; font-size: 13px; letter-spacing: 1px; }

/* ============ DOSSIERS (groupes par projet) ============ */
.sidebar-group {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    height: var(--gantt-group-height, 40px);
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border-soft);
    border-top: 1px solid var(--border-soft);
    cursor: pointer;
    user-select: none;
    transition: background .15s;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 700;
    color: var(--ink);
}
.sidebar-group:hover { background: var(--bg); }
.sidebar-group .group-chevron {
    width: 14px;
    color: var(--ink-soft);
    font-size: 12px;
    transition: transform .2s;
    text-align: center;
}
.sidebar-group.is-collapsed .group-chevron { transform: rotate(-90deg); }
.sidebar-group .group-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    border: 1.5px solid var(--ink);
    flex-shrink: 0;
}
.sidebar-group .group-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-group .group-count {
    background: var(--ink);
    color: var(--surface);
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0;
}

/* Bandeau correspondant dans la timeline body (juste un séparateur visuel) */
.timeline-row-group-bg {
    height: var(--gantt-group-height, 40px);
    background: rgba(0, 0, 0, .04);
    border-top: 1px solid var(--border-soft);
    border-bottom: 1px solid var(--border-soft);
    pointer-events: none;
    position: relative;
    z-index: 1;
}

/* ============ TIMELINE (header + corps) ============ */
.gantt-timeline {
    flex: 1;
    min-width: 0;
    position: relative;
    background: var(--surface);
}

.timeline-headers {
    position: sticky;
    top: 0;
    z-index: 4;
    background: var(--ink);
    color: var(--surface);
    border-bottom: 2px solid var(--ink);
}

.timeline-row-month,
.timeline-row-week,
.timeline-row-day,
.timeline-row-hour {
    display: flex;
    height: 28px;
}
.timeline-row-day { height: 32px; }
.timeline-row-hour { height: 22px; border-top: 1px solid rgba(255,255,255,.15); }
.timeline-row-month,
.timeline-row-week {
    border-bottom: 1px solid rgba(255,255,255,.15);
}

.timeline-week {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.2px;
    color: rgba(255,255,255,.7);
    border-right: 1px solid rgba(255,255,255,.15);
}

.timeline-hour {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 600;
    color: rgba(255,255,255,.55);
    border-right: 1px solid rgba(255,255,255,.08);
}
.timeline-hour.off {
    color: rgba(255,255,255,.35);
    background: repeating-linear-gradient(45deg, transparent 0 4px, rgba(255,255,255,.08) 4px 8px);
}

.timeline-month {
    flex-shrink: 0;
    padding: 0 12px;
    display: flex;
    align-items: center;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    border-right: 1px solid rgba(255,255,255,.15);
    color: var(--surface);
}
.timeline-month::before {
    content: '';
    width: 6px; height: 6px;
    background: var(--accent);
    margin-right: 8px;
}

.timeline-day {
    flex-shrink: 0;
    /* width set inline (variable per column model) */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-right: 1px solid rgba(255,255,255,.15);
    font-size: 10px;
    color: var(--surface);
}
.timeline-day-num {
    font-weight: 700;
    font-size: 12px;
    line-height: 1;
}
.timeline-day-name {
    font-size: 9px;
    color: rgba(255,255,255,.65);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.timeline-day.is-off { background: rgba(255,255,255,.06); }
.timeline-day.is-holiday {
    background: rgba(220, 38, 38, .35);
}
.timeline-day.is-holiday .timeline-day-name {
    color: rgba(255, 220, 220, .9);
}
.timeline-day.is-week-start { border-left: 2px solid var(--accent); }
.timeline-day.is-today {
    background: var(--accent);
    color: var(--ink);
}
.timeline-day.is-today .timeline-day-name { color: rgba(0,0,0,.7); }

/* corps */
.timeline-body {
    position: relative;
    min-height: 200px;
}

.timeline-row {
    position: relative;
    height: var(--gantt-row-height);
    border-bottom: 1px solid var(--border-grid);
}
.timeline-row.is-weekend-row {
    /* alternance via fond — pas utilisé directement */
}

/* Overlay des jours OFF (week-end paramétré + jours non travaillés) */
.off-col {
    position: absolute;
    top: 0; bottom: 0;
    background: rgba(0, 0, 0, .045);
    pointer-events: none;
    z-index: 0;
}
/* Jours fériés / congés : overlay diagonal rouge */
.off-col.is-holiday {
    background:
        repeating-linear-gradient(
            45deg,
            rgba(220, 38, 38, .12) 0,
            rgba(220, 38, 38, .12) 6px,
            rgba(220, 38, 38, .22) 6px,
            rgba(220, 38, 38, .22) 12px
        );
}

/* Séparateurs verticaux : un trait à la fin de chaque jour */
.day-divider {
    position: absolute;
    top: 0; bottom: 0;
    width: 0;
    border-left: 1px solid var(--border-grid);
    pointer-events: none;
    z-index: 0;
}

/* Lignes de séparation entre semaines (chaque lundi) */
.week-start-col {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 0;
    border-left: 1.5px solid rgba(0, 0, 0, .25);
    pointer-events: none;
    z-index: 0;
}

/* ligne d'aujourd'hui */
.today-line {
    position: absolute;
    top: 0; bottom: 0;
    width: 2px;
    background: var(--accent);
    z-index: 3;
    pointer-events: none;
}
.today-line::before {
    content: 'TODAY';
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: var(--ink);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 2px 6px;
    white-space: nowrap;
    border-radius: 2px;
}

/* ============ BARRES ============ */
.gantt-bar {
    position: absolute;
    height: 30px;
    top: 9px;
    border: 1.5px solid var(--ink);
    border-radius: 4px;
    background: var(--bar-bg, var(--accent));
    cursor: grab;
    overflow: hidden;
    z-index: 2;
    transition: box-shadow .15s, transform .15s;
    user-select: none;
}
.gantt-bar:hover {
    box-shadow: 3px 3px 0 var(--ink);
    transform: translate(-1px, -1px);
    z-index: 4;
}
.gantt-bar:active { cursor: grabbing; }

.gantt-bar.status-todo {
    background: var(--surface);
    border-color: var(--ink);
}
.gantt-bar.status-todo .bar-progress { background: rgba(0, 0, 0, .12); }

.gantt-bar.status-progress { background: var(--accent); border-color: var(--ink); }
.gantt-bar.status-progress .bar-progress { background: var(--accent-dark); }

.gantt-bar.status-done { background: var(--status-done); border-color: var(--ink); }
.gantt-bar.status-done .bar-label { color: #fff; }

.gantt-bar.status-blocked {
    background: var(--status-blocked);
    border-color: var(--ink);
    background-image: repeating-linear-gradient(
        45deg,
        transparent 0,
        transparent 6px,
        rgba(0, 0, 0, .15) 6px,
        rgba(0, 0, 0, .15) 12px
    );
}
.gantt-bar.status-blocked .bar-label { color: #fff; }

.bar-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: rgba(0, 0, 0, .2);
    z-index: 1;
    transition: width .3s ease;
}

.bar-label {
    position: relative;
    z-index: 2;
    padding: 0 10px;
    font-size: 11px;
    font-weight: 600;
    line-height: 27px;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 6px;
}
.bar-percent {
    margin-left: auto;
    font-size: 10px;
    opacity: .8;
}

/* poignées resize */
.bar-handle {
    position: absolute;
    top: 0;
    width: 6px;
    height: 100%;
    cursor: ew-resize;
    z-index: 3;
}
.bar-handle-left  { left: 0; }
.bar-handle-right { right: 0; }
.bar-handle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 12px;
    background: rgba(0, 0, 0, .35);
    border-radius: 1px;
    opacity: 0;
    transition: opacity .15s;
}
.gantt-bar:hover .bar-handle::after { opacity: 1; }

/* Bouton de liaison (drag pour relier deux tâches)
   Positionné comme un siblings de .gantt-bar à l'intérieur de .timeline-row,
   nettement à droite de la barre pour ne pas être confondu avec la poignée
   de redimensionnement. */
.bar-link-handle {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--surface);
    color: var(--ink);
    border: 2px solid var(--ink);
    cursor: crosshair;
    z-index: 5;
    opacity: .35;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    box-shadow: 1px 1px 0 var(--ink);
    user-select: none;
    transition: opacity .15s, transform .15s, background .15s, color .15s, box-shadow .15s;
}
.timeline-row:hover .bar-link-handle { opacity: .9; }
.bar-link-handle:hover {
    opacity: 1;
    background: var(--accent);
    transform: translateY(-50%) scale(1.2);
    box-shadow: 2px 2px 0 var(--ink);
}
.gantt-bar.link-target {
    box-shadow: 0 0 0 3px var(--accent), 3px 3px 0 var(--ink);
    transform: translate(-1px, -1px);
}

/* Couche SVG des dépendances (flèches) */
.dep-layer {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 6;
    overflow: visible;
    color: var(--ink);
}
.dep-arrow { pointer-events: auto; cursor: pointer; }
.dep-line {
    fill: none;
    stroke: var(--ink);
    stroke-width: 1.6;
    transition: stroke .15s, stroke-width .15s;
}
.dep-hit {
    fill: none;
    stroke: transparent;
    stroke-width: 12;
}
.dep-arrow:hover .dep-line {
    stroke: var(--status-blocked);
    stroke-width: 2.4;
}
.dep-arrow:hover { color: var(--status-blocked); }

.dep-ghost {
    stroke: var(--accent);
    stroke-dasharray: 4 4;
    stroke-width: 2;
    pointer-events: none;
}

/* tooltip hover */
.gantt-bar[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--ink);
    color: var(--surface);
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 10px;
    line-height: 1.5;
    white-space: pre;
    z-index: 10;
    box-shadow: 3px 3px 0 var(--accent);
    pointer-events: none;
}
