﻿:root {
    --mtl-accent: #5b8ef1;
    --mtl-border: #e5e7eb;
    --mtl-bg: #fff;
    --mtl-month-text: #374151;
    --mtl-day-tick: rgba(17,24,39,.04);
    --mtl-hour-tick: rgba(17,24,39,.03);
    --mtl-month-line: rgba(17,24,39,.22);
    --mtl-row-h: 36px;
    --mtl-head-h: 32px;
    --mtl-head-months-h: var(--mtl-head-h);
    --mtl-head-days-h: 0px;
    --mtl-head-hours-h: 0px;
    --mtl-freeze-col: 22px;
    --mtl-actions-col: 48px;
    --mtl-invalid: var(--important-color, #D20062);
    --itc-base: #F2F044; /* couleur des blocs ITC */
    --itc-ovl-bg: rgba(242,240,68,.18); /* fond overlay, discret et transparent */
    --itc-ovl-border: #C7C62A; /* bordure overlay, un peu plus foncée */
}

.mtl-root {
    display: flex;
    flex-direction: column;
    min-height: 0;
    width: 100%;
    overflow-x: hidden;
    min-height: 180px;
}

.mtl-grid {
    position: relative;
    height: 100% !important;
    max-height: none !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    background: var(--mtl-bg);
    border: 2px solid var(--mtl-border);
    border-radius: 10px;
}

.mtl-title {
    text-align: center;
    margin-bottom: 8px;
    color: #111827;
    font-weight: 600;
}

.mtl-header-strip {
    position: sticky;
    top: 0;
    z-index: 800;
    display: grid;
    grid-template-columns: 260px 1fr;
    grid-template-rows: auto auto;
    align-items: stretch;
    background: var(--mtl-bg);
    border-bottom: 1px solid var(--mtl-border);
}

.mtl-header-toolbar {
    grid-column: 1 / -1;
    display: flex;
    gap: 6px;
    padding: 6px 8px 4px;
    border-bottom: 1px solid var(--mtl-border);
}

.mtl-leftcol-header {
    align-self: stretch;
    grid-row: 2;
    height: var(--mtl-head-h);
}

.mtl-frise-header {
    position: relative;
    grid-row: 2;
    height: calc(var(--mtl-head-months-h) + var(--mtl-head-days-h) + var(--mtl-head-hours-h)) !important;
    overflow: visible !important;
    display: flex;
    flex-direction: column;
}

.mtl-months-row {
    position: relative;
    height: var(--mtl-head-months-h);
}

.mtl-month-cell {
    position: absolute;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--mtl-month-text);
    border-left: 1px solid var(--mtl-month-line);
}

.mtl-scroll {
    display: grid;
    grid-template-columns: 260px 1fr;
    align-items: start;
    width: 100%;
}

.mtl-leftcol-body {
    background: #fafafa;
}

.mtl-row-label {
    position: relative;
    height: var(--mtl-row-h);
    display: flex;
    align-items: center;
    padding-left: calc(var(--mtl-freeze-col) + 10px);
    padding-right: calc(var(--mtl-actions-col) + 8px);
    border-bottom: 1px dashed #eee;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px;
    color: #111827;
}

.mtl-freeze-btn {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: var(--mtl-freeze-col);
    height: var(--mtl-freeze-col);
    display: grid;
    place-items: center;
    border: none;
    background: transparent;
    color: #9ca3af;
    opacity: 0;
    cursor: pointer;
}

.mtl-row-label:hover .mtl-freeze-btn {
    opacity: 1;
}

.mtl-freeze-btn:hover {
    background: #f3f4f6;
    border-radius: 4px;
}

.mtl-freeze-btn.is-frozen {
    color: var(--mtl-accent);
    opacity: 1;
}

.mtl-freeze-btn svg {
    width: 12px;
    height: 12px;
    display: block;
}

.mtl-row-actions {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 6px;
    opacity: 0;
}

.mtl-row-label:hover .mtl-row-actions {
    opacity: 1;
}

.mtl-action-btn {
    width: 20px;
    height: 20px;
    display: grid;
    place-items: center;
    border: none;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    border-radius: 4px;
}

    .mtl-action-btn:hover {
        background: #f3f4f6;
    }

    .mtl-action-btn svg {
        width: 12px;
        height: 12px;
        display: block;
    }

.mtl-frise-body {
    position: relative;
    overflow: visible;
}

.mtl-month-lines,
.mtl-days-layer {
    position: absolute;
    inset: 0 0 0 0;
    pointer-events: none;
}

.mtl-month-boundary {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--mtl-month-line);
}

.mtl-day-tick {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--mtl-day-tick);
}

.mtl-hours-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.mtl-hour-tick {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--mtl-hour-tick);
}

.mtl-tracks {
    position: relative;
}

.mtl-track {
    position: relative;
    height: var(--mtl-row-h);
    border-bottom: 1px dashed #f0f0f0;
}

.mtl-block {
    position: absolute;
    top: 6px;
    height: 24px;
    background: color-mix(in srgb, var(--block-color) 85%, white 15%);
    border: 1px solid color-mix(in srgb, var(--block-color) 65%, black 15%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-sizing: border-box;
    box-shadow: 0 2px 6px rgba(0,0,0,.06);
    cursor: default;
}

    .mtl-block.edit-block {
        cursor: grab;
    }

    .mtl-block.edit-block.is-active {
        cursor: grabbing;
    }

    .mtl-block:hover {
        z-index: 2001;
    }

.mtl-block-label {
    font-size: 11px;
    font-weight: 600;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    padding: 0 6px;
    line-height: 1.1;
}

.mtl-block--segment {
    height: 20px;
    top: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
    border-style: solid;
    border-width: 1px;
    border-color: color-mix(in srgb, var(--block-color) 55%, black 10%);
    background: color-mix(in srgb, var(--block-color) 70%, white 30%);
    padding: 0;
    box-sizing: border-box;
}

.mtl-block--marker {
    padding: 0;
    border: 0;
    background: var(--block-color);
    box-shadow: none;
    opacity: .6;
}

    .mtl-block--marker .mtl-block-label {
        display: none;
    }

    .mtl-block--marker::before {
        content: "";
        position: absolute;
        inset: -4px -3px;
    }

/* Tooltip du bloc (CSS only) */
.mtl-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translate(-50%, -6px);
    padding: 6px 8px;
    border-radius: 6px;
    background: #111827;
    color: #fff;
    font-size: 11px;
    line-height: 1.25;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
    display: none;
    pointer-events: none;
    z-index: 3000;
}

    .mtl-tooltip .t1 {
        font-weight: 700;
        margin-bottom: 2px;
    }

    .mtl-tooltip .t2 {
        opacity: .85;
    }

    .mtl-tooltip::after {
        content: "";
        position: absolute;
        top: 100%;
        left: 50%;
        transform: translateX(-50%);
        border: 6px solid transparent;
        border-top-color: #111827;
    }

    .mtl-tooltip .mtl-invalid-msg {
        margin-top: 4px;
        padding-top: 4px;
        border-top: 1px dashed rgba(210,0,98,.4);
        white-space: pre-line; /* pour afficher \n en retour à la ligne */
        font-size: 11px;
        opacity: .95;
    }

.mtl-block:hover .mtl-tooltip {
    display: block;
}

.mtl-block .mtl-tooltip.mtl-tooltip--below {
    top: calc(100% + 6px); /* ↓ en-dessous */
    bottom: auto;
}

    .mtl-block .mtl-tooltip.mtl-tooltip--below::after { /* flèche "bas" */
        content: "";
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        border: 6px solid transparent;
        border-top-color: #111827;
        top: -6px;
        bottom: auto;
        border-top-color: transparent;
        border-bottom-color: rgba(17, 24, 39, .9);
    }

.mtl-tracks > .mtl-track:only-child .mtl-block .mtl-tooltip {
    top: 50%;
    bottom: auto;
    left: auto;
    right: calc(100% + 6px); /* place la tooltip à gauche du bloc */
    transform: translateY(-50%); /* centrage vertical */
}

    /* Flèche à droite (pointe vers le bloc) */
    .mtl-tracks > .mtl-track:only-child .mtl-block .mtl-tooltip::after {
        top: 50%;
        bottom: auto;
        left: 100%;
        transform: translateY(-50%);
        border: 6px solid transparent;
        border-left-color: rgba(17,24,39,.9); /* flèche vers la gauche */
    }

    /* Si tu utilises déjà la variante "below", on neutralise son style dans le cas 1 ligne */
    .mtl-tracks > .mtl-track:only-child .mtl-block .mtl-tooltip.mtl-tooltip--below {
        top: 50% !important;
        left: auto !important;
        right: calc(100% + 6px) !important;
        transform: translateY(-50%) !important;
    }

        .mtl-tracks > .mtl-track:only-child .mtl-block .mtl-tooltip.mtl-tooltip--below::after {
            left: 100% !important;
            top: 50% !important;
            bottom: auto !important;
            transform: translateY(-50%) !important;
            border: 6px solid transparent !important;
            border-left-color: rgba(17,24,39,.9) !important;
        }
/* --- Zoom/sélection --- */
.mtl-zoom-toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 6px 0 10px;
}

.mtl-btn {
    height: 26px;
    padding: 0 10px;
    font-size: 11px;
    border: 1px solid var(--mtl-border);
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 1px 0 rgba(0,0,0,.02) inset;
}

    .mtl-btn.toggle.is-active {
        background: rgba(0,0,0,.04);
    }

.mtl-zoom-ghost {
    position: absolute;
    top: 0;
    bottom: 0;
    border: 1px solid var(--mtl-accent);
    background: color-mix(in srgb, var(--mtl-accent) 18%, transparent);
    pointer-events: none;
    z-index: 60;
    box-sizing: border-box;
}

/* Échelle → on “ouvre” des lignes supplémentaires */
.mtl-root.mtl-scale-days {
    --mtl-head-days-h: 18px;
}

.mtl-root.mtl-scale-hours {
    --mtl-head-days-h: 18px;
    --mtl-head-hours-h: 18px;
}

/* La ligne des mois garde sa propre hauteur */
.mtl-days-row, .mtl-hours-row {
    position: relative;
    height: 20px;
    border-top: 1px solid var(--mtl-border);
}

.mtl-day-cell, .mtl-hour-cell {
    position: absolute;
    top: 0;
    bottom: 0;
    box-sizing: border-box;
    border-left: 1px dashed rgba(0,0,0,.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    line-height: 1;
    user-select: none;
    pointer-events: none;
}

.mtl-day-label {
    opacity: .7;
}

.mtl-hour-label {
    opacity: .6;
    font-size: 10px;
}

/* ==== MASSIFICATION ==== */
.mtl-row-label--mass {
    background: color-mix(in srgb, var(--mass-color, #93c5fd) 14%, white);
    font-weight: 600;
    border-left: 4px solid var(--mass-color, #2563eb);
    box-shadow: 0 1px 0 rgba(0,0,0,.04) inset;
}

.mtl-mass-badge {
    display: inline-block;
    margin-right: 8px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 800;
    color: #0f172a;
    background: color-mix(in srgb, var(--mass-color, #93c5fd) 32%, white);
    border: 1px solid color-mix(in srgb, var(--mass-color, #93c5fd) 50%, black 10%);
}

.mtl-track--mass {
    background: color-mix(in srgb, var(--mass-color, #93c5fd) 10%, transparent);
    box-shadow: 0 1px 0 rgba(0,0,0,.06) inset, 0 2px 8px rgba(0,0,0,.05);
    border-radius: 0;
}

.mtl-row-label.mtl-group-start,
.mtl-track.mtl-group-start {
    margin-top: 10px;
}

.mtl-row-label.mtl-group-end,
.mtl-track.mtl-group-end {
    margin-bottom: 10px;
}

.mtl-track.mtl-group-start {
    border-top: 1px solid color-mix(in srgb, var(--mass-color, #93c5fd) 35%, black 10%);
}

.mtl-track.mtl-group-end {
    border-bottom: 1px solid color-mix(in srgb, var(--mass-color, #93c5fd) 35%, black 10%);
}

.mtl-mass-badge-track {
    position: absolute;
    top: -8px;
    left: 6px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 800;
    color: #0f172a;
    background: color-mix(in srgb, var(--mass-color, #93c5fd) 32%, white);
    border: 1px solid color-mix(in srgb, var(--mass-color, #93c5fd) 55%, black 8%);
    z-index: 3;
}

.mtl-section-sep {
    height: 14px;
    display: flex;
    align-items: center;
    position: relative;
    margin: 6px 0;
}

.mtl-section-sep--labels {
    background: #fafafa;
}

    .mtl-section-sep--labels span {
        margin-left: 8px;
        font-size: 11px;
        font-weight: 700;
        color: #6b7280;
    }

.mtl-section-sep--tracks::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 0;
    border-top: 2px dashed rgba(0,0,0,.08);
}

.mtl-track--first .mtl-tooltip {
    top: 100%;
    bottom: auto;
    transform: translate(-50%, 6px);
}

    .mtl-track--first .mtl-tooltip::after {
        top: auto;
        bottom: 100%;
        border-top-color: transparent;
        border-bottom-color: #111827;
    }

/* ==== Highlight d’une ligne (édition/visualisation) ==== */
.mtl-row-label--hi {
    position: relative;
    background: color-mix(in srgb, var(--mtl-accent) 10%, white);
    font-weight: 700;
}

    .mtl-row-label--hi::before {
        content: "";
        position: absolute;
        inset: 0 auto 0 0;
        width: 3px;
        background: var(--mtl-accent);
    }

/* le track entier a un léger focus */
.mtl-track--hi {
    background: color-mix(in srgb, var(--mtl-accent) 8%, transparent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--mtl-accent) 30%, transparent) inset, 0 2px 6px rgba(0,0,0,.06);
    position: relative;
    z-index: 2; /* passe au-dessus du fond voisin mais reste sous le header sticky */
}

    /* renforce le contraste des blocs de la ligne en surbrillance */
    .mtl-track--hi .mtl-block {
        border-color: color-mix(in srgb, var(--block-color) 75%, black 10%);
        box-shadow: 0 3px 8px rgba(0,0,0,.10);
    }


/* ===== Invalidités (MultiTimeline uniquement) ===== */
/* Bouton header : séparation visuelle + état “dispo” */
.mtl-toolbar-sep {
    width: 1px;
    height: 22px;
    background: var(--mtl-border);
    margin: 0 6px;
}

.mtl-btn.invalid-toggle.is-available {
    border-color: color-mix(in srgb, var(--mtl-invalid) 50%, var(--mtl-border));
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--mtl-invalid) 12%, transparent);
}

.mtl-btn.invalid-toggle.is-active {
    background: color-mix(in srgb, var(--mtl-invalid) 10%, #fff);
    border-color: color-mix(in srgb, var(--mtl-invalid) 45%, var(--mtl-border));
}

.mtl-btn .mtl-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 0 6px;
    font-size: 10px;
    font-weight: 800;
    line-height: 16px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--mtl-invalid) 20%, #fff);
    border: 1px solid color-mix(in srgb, var(--mtl-invalid) 50%, #000 10%);
}

/* Bordure pointillée foncée + atténuation de la couleur du bloc */
.mtl-block.is-invalid {
    /* on écrase la bordure par défaut */
    border-style: dashed !important;
    border-width: 3px !important;
    border-color: color-mix(in srgb, var(--block-color) 70%, black 25%) !important;
    /* atténuation de la teinte du bloc */
    background: color-mix(in srgb, var(--block-color) 35%, white 65%) !important;
}

/* Segments (mode détail) */
.mtl-block--segment.is-invalid {
    border-style: dashed !important;
    border-width: 3px !important;
    border-color: color-mix(in srgb, var(--block-color) 70%, black 25%) !important;
    background: color-mix(in srgb, var(--block-color) 30%, white 70%) !important;
}

/* Marqueurs fins (segments < 1px) – on garde la lisibilité */
.mtl-block--marker.is-invalid {
    /* les marqueurs utilisent plutôt un “trait” : on renforce l’opacité mais on conserve le repère */
    opacity: 0.9 !important;
}

/* Toujours laisser sortir l'icône au-dessus de la piste */
.mtl-track {
    overflow: visible;
}

/* Petit badge "!" dans un cercle rouge, centré au-dessus du bloc invalide */
.mtl-block.is-invalid::after {
    content: "!";
    position: absolute;
    left: 50%;
    top: -9px; /* au-dessus du bloc */
    transform: translateX(-50%);
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--mtl-invalid, #D20062);
    color: #fff;
    font-size: 10px;
    line-height: 14px;
    font-weight: 800;
    text-align: center;
    box-shadow: 0 0 0 1px #fff, 0 1px 3px rgba(0,0,0,.25);
    pointer-events: none;
    z-index: 600
}

.mtl-root.mtl-highlight-invalids .mtl-block:not(.is-invalid) {
    opacity: .28;
    filter: saturate(.3) grayscale(.4);
}

/* Segments d’overlay par ligne, “cousus” visuellement en un seul bloc */
.mtl-itc-overlay-stitch {
    position: absolute;
    top: -5px;
    bottom: -5px;
    left: 0;
    background: var(--itc-ovl-bg);
    border-left: 3px dashed var(--itc-ovl-border);
    border-right: 3px dashed var(--itc-ovl-border);
    pointer-events: auto;
    cursor: grab;
    z-index: 1200;
}

    .mtl-itc-overlay-stitch.is-first {
        border-top: 3px dashed var(--itc-ovl-border);
        border-top-left-radius: 8px;
        border-top-right-radius: 8px;
    }

    .mtl-itc-overlay-stitch.is-last {
        border-bottom: 3px dashed var(--itc-ovl-border);
        border-bottom-left-radius: 8px;
        border-bottom-right-radius: 8px;
    }

/* Blocs non-ITC en massification : visuels mais inactifs */
.mtl-block--muted {
    opacity: .35;
    filter: saturate(.35) grayscale(.2);
    cursor: default !important;
    pointer-events: none;
}

/* (facultatif) marquer explicitement les ITC si besoin de style dédié */
.mtl-block--itc { /* pas de changements nécessaires */
}

/* Tooltips à gauche pour les lignes marquées mtl-tip-left (ex. lignes 2 et 3) */
.mtl-tracks > .mtl-track.mtl-tip-left .mtl-block .mtl-tooltip {
    top: 50% !important;
    bottom: auto !important;
    left: auto !important;
    right: calc(100% + 6px) !important; /* place à gauche du bloc */
    transform: translateY(-50%) !important; /* centrage vertical */
}

    /* Flèche qui pointe vers le bloc depuis la gauche */
    .mtl-tracks > .mtl-track.mtl-tip-left .mtl-block .mtl-tooltip::after {
        top: 50% !important;
        bottom: auto !important;
        left: 100% !important;
        transform: translateY(-50%) !important;
        border: 6px solid transparent !important;
        border-left-color: rgba(17,24,39,.9) !important;
    }

    /* Si une tooltip utilise déjà la variante "below", on neutralise pour mtl-tip-left */
    .mtl-tracks > .mtl-track.mtl-tip-left .mtl-block .mtl-tooltip.mtl-tooltip--below {
        top: 50% !important;
        bottom: auto !important;
        left: auto !important;
        right: calc(100% + 6px) !important;
        transform: translateY(-50%) !important;
    }

        .mtl-tracks > .mtl-track.mtl-tip-left .mtl-block .mtl-tooltip.mtl-tooltip--below::after {
            top: 50% !important;
            bottom: auto !important;
            left: 100% !important;
            transform: translateY(-50%) !important;
            border: 6px solid transparent !important;
            border-left-color: rgba(17,24,39,.9) !important;
        }

/* Empêche la sélection de texte pendant un zoom/sélection */
.mtl-frise-body,
.mtl-tracks,
.mtl-track,
.mtl-block {
    user-select: none;
}


.mtl-block:hover .mtl-tooltip {
    display: none !important;
}