/* ================================================
   CASH POOLING HIERARCHY BIS - NEW VISUAL STYLE
   ================================================ */

/* Container overrides */
.cp-hierarchy-container {
    background-color: #121212 !important;
    /* Dark background as in image */
    overflow: hidden;
    position: relative;
    border-radius: 12px;
}

/* Visualization Layer (SVG) */
.cp-links-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    /* Behind nodes */
    pointer-events: none;
    /* Let clicks pass through to nodes */
}

.cp-link-path {
    fill: none;
    stroke: #4ade80;
    /* Green color like in image */
    stroke-width: 2px;
    stroke-linecap: round;
    opacity: 0.8;
    transition: all 0.3s ease;
}

.cp-link-path:hover {
    stroke-width: 4px;
    opacity: 1;
    filter: drop-shadow(0 0 4px #4ade80);
    cursor: pointer;
    pointer-events: auto;
}

/* Entities Container */
.cp-entities-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

/* Workspace - handles transform (zoom + pan) */
.cp-hierarchy-workspace {
    position: relative;
    transform-origin: 0 0;
    width: 100%;
    height: 100%;
}

/* Make sure the parent wrapper can scroll */
.cp-hierarchy-main-content {
    min-height: 70vh !important;
    /* 70% de la hauteur de la fenêtre */
    height: calc(100vh - 280px) !important;
    /* Hauteur dynamique ajustée pour la toolbar plus grande */
}

.cp-hierarchy-main-content>div:first-child {
    overflow: auto !important;
    min-height: 70vh !important;
}

/* Group Container (The dashed box) */
.cp-hierarchy-group {
    position: absolute;
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.03);
    transition: all 0.2s ease;
    z-index: 1;
    /* Below nodes */
    pointer-events: all;
    /* Allow dragging the group */
}

.cp-hierarchy-group:hover {
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.05);
}

.cp-hierarchy-group.selected {
    border-color: var(--color-accent, #3b82f6);
    background: rgba(59, 130, 246, 0.1);
}

.cp-group-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.05);
    /* Slightly lighter header */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px 14px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 40px;
    cursor: grab;
}

.cp-group-title {
    font-weight: 700;
    font-size: 0.8em;
    text-transform: uppercase;
    color: #e2e8f0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cp-group-count {
    font-size: 0.75em;
    color: rgba(255, 255, 255, 0.5);
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 8px;
    border-radius: 10px;
}


/* Entity Node (The Card) */
.cp-node-card {
    position: absolute;
    width: 220px;
    background: #1e1e1e;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    z-index: 10;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.1);
    -webkit-user-select: none;
    user-select: none;
}

.cp-node-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.2);
    z-index: 20;
    /* Bring to front on hover */
}

.cp-node-card.selected {
    border: 2px solid #4ade80;
    /* Green border when selected */
    box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.2);
}

/* Card Header */
.cp-node-header {
    padding: 10px 12px;
    border-radius: 11px 11px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid rgba(0, 0, 0, 0.2);
    cursor: grab;
}

/* Variant colors for header */
.cp-node-card.master .cp-node-header {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    /* Orange */
}

.cp-node-card.subsidiary .cp-node-header {
    background: linear-gradient(135deg, #4ADE80, #22c55e);
    /* Green */
}

.cp-node-card.subsidiary-alt .cp-node-header {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    /* Blue */
}


.cp-node-title {
    font-size: 0.85em;
    font-weight: 700;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    line-height: 1.2;
    flex: 1;
}

.cp-node-badge {
    font-size: 0.6em;
    font-weight: 800;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    color: white;
    letter-spacing: 0.5px;
    margin-left: 8px;
    white-space: nowrap;
}

/* Card Body */
.cp-node-body {
    padding: 12px;
    background: #1e1e1e;
    border-radius: 0 0 12px 12px;
}

.cp-node-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.cp-node-row:last-child {
    margin-bottom: 0;
}

.cp-node-label {
    font-size: 0.75em;
    color: #94a3b8;
}

.cp-node-value {
    font-size: 0.9em;
    font-weight: 600;
    color: #e2e8f0;
}

.cp-node-value.positive {
    color: #4ade80;
}

.cp-node-value.negative {
    color: #f87171;
}

/* Link Handle (Anchor) */
.cp-link-handle {
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 24px;
    background: #1e1e1e;
    border: 2px solid #4ade80;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: crosshair;
    z-index: 15;
    transition: transform 0.2s;
}

.cp-link-handle:hover {
    transform: translateX(-50%) scale(1.2);
    background: #4ade80;
}

.cp-link-handle i {
    font-size: 10px;
    color: #4ade80;
}

.cp-link-handle:hover i {
    color: #1e1e1e;
}

/* Tooltip for dragging connection */
.cp-drag-connection-line {
    fill: none;
    stroke: #4ade80;
    stroke-width: 2px;
    stroke-dasharray: 4;
    pointer-events: none;
    z-index: 100;
}