/* Carte relationnelle « pieuvre » d'un projet : hub central + organisations en étoile.
   Portée depuis la maquette orga-portal (référence design de l'épopée). */

.relation-panel {
    --rm-primary: #086572;
    --rm-primary-dark: #094754;
    --rm-primary-soft: #e9f4f5;
    --rm-muted: #748489;
    --rm-line: #dfe7e9;
}

/* ---- Légende ---- */

.relation-panel .legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 18px;
    min-height: 44px;
    padding: 10px 18px;
    color: var(--rm-muted);
    font-size: 0.72rem;
    border-bottom: 1px solid var(--rm-line);
    background: #fbfcfc;
}

.relation-panel .legend > span {
    display: flex;
    align-items: center;
    gap: 7px;
}

.legend-line {
    display: inline-block;
    width: 25px;
    height: 0;
    border-top: 2px solid #95a4a7;
}

.legend-line.subscription {
    border-color: var(--rm-primary);
    border-top-width: 3px;
}

.legend-line.subcontract {
    border-top-style: dashed;
    border-color: #b08947;
}

/* ---- Carte : hub en tête puis couches (sous-traitants sous leur donneur d'ordre) ---- */

.relation-map {
    position: relative;
    padding: 14px 20px 32px;
    background-color: #f8fafb;
    background-image:
        linear-gradient(rgba(9, 71, 84, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(9, 71, 84, 0.035) 1px, transparent 1px);
    background-size: 28px 28px;
}

.relation-map svg.relation-lines {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
}

.relation-line {
    fill: none;
    stroke: #91a2a6;
    stroke-width: 2;
    opacity: 0.9;
}

.relation-line.subscription {
    stroke: var(--rm-primary);
    stroke-width: 3;
}

/* Lien de sous-traitance : part du nœud du donneur d'ordre, pointillé. */
.relation-line.subcontract {
    stroke: #b08947;
    stroke-dasharray: 6 5;
}

.line-label rect {
    fill: #fff;
    stroke: #dae5e7;
    rx: 7;
}

.line-label text {
    fill: #627377;
    font-size: 9.5px;
    font-weight: 700;
}

/* ---- Hub projet ---- */

.project-hub {
    /* Relative : la pastille application absolue reste ancrée au hub. */
    position: relative;
    z-index: 3;
    width: 215px;
    margin: 14px auto 0;
    padding: 22px 16px 16px;
    text-align: center;
    border: 2px solid #b9d7da;
    border-radius: 19px;
    background: #fff;
    box-shadow: 0 18px 48px rgba(9, 71, 84, 0.15);
}

/* Une couche d'organisations : centrée, passe à la ligne au besoin. */
.map-level {
    position: relative;
    z-index: 3;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: center;
    gap: 18px 26px;
    margin-top: 42px;
}

/* Le titulaire au sommet, son trait de souscription descend vers le hub :
   assez d'espace pour que l'étiquette du lien respire à mi-chemin. */
.map-holder-level {
    margin-top: 6px;
}

.map-holder-level + .project-hub {
    margin-top: 68px;
}

.hub-app {
    position: absolute;
    top: -12px;
    left: 50%;
    padding: 5px 12px;
    color: #fff;
    font-size: 0.61rem;
    font-weight: 900;
    letter-spacing: 0.04em;
    white-space: nowrap;
    border-radius: 999px;
    background: var(--rm-primary);
    transform: translateX(-50%);
}

.hub-icon {
    display: grid;
    width: 44px;
    height: 44px;
    margin: 3px auto 9px;
    place-items: center;
    color: var(--rm-primary);
    font-size: 1.12rem;
    border-radius: 12px;
    background: var(--rm-primary-soft);
}

.project-hub h2 {
    margin: 0;
    font-size: 1.08rem;
    font-weight: 900;
}

.project-hub p {
    margin: 5px 0 11px;
    color: var(--rm-muted);
    font-size: 0.67rem;
}

.hub-meta {
    display: flex;
    justify-content: center;
    gap: 6px;
}

.hub-meta span {
    padding: 3px 6px;
    color: #657579;
    font-size: 0.58rem;
    border-radius: 999px;
    background: #f1f4f5;
}

/* ---- Nœuds organisation ---- */

.org-node {
    z-index: 3;
    display: block;
    width: 238px;
    padding: 14px;
    text-align: left;
    text-decoration: none;
    color: inherit;
    border: 1px solid #dce5e7;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 9px 28px rgba(30, 52, 59, 0.09);
    cursor: pointer;
    transition: 0.18s ease;
}

.org-node:hover {
    z-index: 4;
    color: inherit;
    border-color: #9fc6cc;
    box-shadow: 0 14px 36px rgba(9, 71, 84, 0.15);
    transform: translateY(-3px);
}

.org-node-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.org-node-header > span:nth-child(2) {
    min-width: 0;
    flex: 1;
}

.org-node-header > i {
    margin-top: 4px;
    color: #9aa7aa;
    font-size: 0.7rem;
}

.org-node-title,
.org-node-subtitle {
    display: block;
}

.org-node-title {
    overflow: hidden;
    font-size: 0.82rem;
    font-weight: 900;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.org-node-subtitle {
    margin-top: 2px;
    color: var(--rm-muted);
    font-size: 0.63rem;
}

.org-node-roles {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 12px;
}

.org-node-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 11px;
    padding-top: 9px;
    color: var(--rm-muted);
    font-size: 0.61rem;
    border-top: 1px solid #edf1f2;
}

.org-node-meta span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- Avatars organisation ---- */

.org-avatar {
    display: inline-grid;
    width: 39px;
    height: 39px;
    flex: 0 0 39px;
    overflow: hidden;
    place-items: center;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 900;
    border-radius: 11px;
}

.org-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.org-avatar.teal { background: #086572; }
.org-avatar.green { background: #5c8d50; }
.org-avatar.violet { background: #7161a8; }
.org-avatar.red { background: #c45555; }
.org-avatar.orange { background: #cf7d31; }
.org-avatar.blue { background: #397daf; }
.org-avatar.cyan { background: #3b8e9b; }
.org-avatar.slate { background: #60767c; }
.org-avatar.pink { background: #a85f88; }

/* ---- État vide (recherche sans résultat) ---- */

.empty-map-state {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--rm-muted);
    background: rgba(248, 250, 251, 0.95);
}

.empty-map-state i {
    margin-bottom: 9px;
    font-size: 1.8rem;
}

/* ---- Note de bas de carte ---- */

.project-scope-note {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 18px;
    font-size: 0.78rem;
    color: var(--rm-muted);
    border-top: 1px solid var(--rm-line);
    background: #fbfcfc;
}

.project-scope-note .scope-note-icon {
    display: grid;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    place-items: center;
    color: var(--rm-primary);
    border-radius: 10px;
    background: var(--rm-primary-soft);
}

.project-scope-note strong {
    color: #3c4b50;
}

.project-scope-note p {
    margin: 2px 0 0;
}

/* ---- Responsive : en dessous de lg, pas de traits (JS) et cartes pleine largeur ---- */

@media (max-width: 767.98px) {
    .relation-map {
        padding: 14px 14px 22px;
    }

    .map-level {
        gap: 12px;
        margin-top: 18px;
    }

    .org-node,
    .project-hub {
        width: 100%;
    }
}
