/* ============================================================
   app_bal.css — Stili per l'app Bilanciatore (cost_balance)
   Contiene tutti gli stili per le sezioni bal_*
   ============================================================ */
/* ============================================================
   bal_cdc.css — Sezione Centri di Costo
   ============================================================ */

/* ── Layout wrapper ──────────────────────────────────────── */

.bal-cdc-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 0;
}

.bal-cdc-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    padding: 16px;
}

/* ── Panels ──────────────────────────────────────────────── */

.bal-panel {
    display: flex;
    flex-direction: column;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

.bal-panel-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #000000;
    padding: 10px 14px 6px;
    flex-shrink: 0;
}

.bal-panel-title--sep {
    border-top: 1px solid #e2e8f0;
    margin-top: 4px;
    padding-top: 12px;
}

.bal-inventory-panel {
    flex: 0 0 auto;
    width: 300px;
    min-width: 220px;
    max-width: 600px;
    overflow-y: auto;
}

.bal-tree-panel {
    flex: 1;
    min-width: 280px;
    overflow-y: auto;
}

.bal-re-panel {
    flex: 0 0 auto;
    width: 300px;
    min-width: 220px;
    max-width: 600px;
    overflow-y: auto;
}

/* ── Splitter trascinabile tra pannelli ──────────────────── */

.bal-panel-splitter {
    flex: 0 0 auto;
    width: 17px;
    margin: 0 -0.5px;
    cursor: col-resize;
    display: flex;
    align-items: stretch;
    justify-content: center;
    z-index: 1;
}

.bal-panel-splitter::before {
    content: '';
    width: 2px;
    border-radius: 1px;
    background: transparent;
    transition: background 0.15s;
}

.bal-panel-splitter:hover::before,
.bal-panel-splitter.bal-splitter-active::before {
    background: #a0aec0;
}

.bal-splitter-active,
.bal-splitter-active * {
    user-select: none;
}

/* ── CDC Items (inventario) ──────────────────────────────── */

.bal-cdc-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
    cursor: grab;
    transition: background 0.15s;
}

.bal-cdc-item:hover {
    background: #f8fafc;
}

.bal-cdc-item:last-child {
    border-bottom: none;
}

.bal-cdc-item.bal-dragging {
    opacity: 0.45;
}

.bal-cdc-item--used {
    opacity: 0.75;
}

/* Riga selezionata — stesso rosso chiaro di .tabulator-selected (tabulator_overrides.css) */
.bal-cdc-item.bal-selected,
.bal-tree-row.bal-selected {
    background: #fce7e7;
    color: #991b1b;
}

.bal-cdc-item.bal-selected:hover {
    background: #ffefef;
}

.bal-cdc-item.bal-selected .bal-cdc-desc {
    color: #c53030;
}

.bal-cdc-type-icon {
    flex-shrink: 0;
    object-fit: contain;
    opacity: 0.85;
}

.bal-cdc-info {
    flex: 1;
    min-width: 0;
}

.bal-cdc-name {
    font-size: 12px;
    font-weight: 600;
    color: #2d3748;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bal-cdc-desc {
    font-size: 11px;
    color: #a0aec0;
    margin-top: 2px;
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bal-cdc-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.bal-cdc-item:hover .bal-cdc-actions {
    opacity: 1;
}

/* ── Root Drop Zone ──────────────────────────────────────── */

.bal-root-drop-zone {
    margin: 10px 14px 6px;
    border: 2px dashed #cbd5e0;
    border-radius: 6px;
    padding: 14px;
    text-align: center;
    font-size: 12px;
    color: #a0aec0;
    background: #f7fafc;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
    flex-shrink: 0;
    cursor: default;
}

.bal-root-drop-zone.bal-drop-active {
    border-color: #4299e1;
    color: #4299e1;
}

.bal-root-drop-zone.bal-drop-over {
    background: #ebf8ff;
    border-color: #4299e1;
    color: #2b6cb0;
}

/* ── Tree Nodes ──────────────────────────────────────────── */

.bal-tree-node {
    /* padding-left gestito inline per indentazione dinamica */
}

.bal-tree-row {
    display: flex;
    align-items: center;
    padding: 7px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: white;
    margin-bottom: 3px;
    transition: background 0.15s, border-color 0.15s;
}

.bal-tree-row:hover {
    background: #f8fafc;
    border-color: #cbd5e0;
}

.bal-tree-row.bal-selected:hover {
    background: #ffefef;
}

.bal-tree-row.bal-drop-active {
    border-style: dashed;
    border-color: #4299e1;
}

.bal-tree-row.bal-drop-over {
    background: #ebf8ff;
    border-color: #4299e1;
    box-shadow: 0 0 0 2px rgba(66, 153, 225, 0.2);
}

.bal-node-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.bal-node-name {
    font-size: 12px;
    font-weight: 600;
    color: #2d3748;
}

.bal-node-info {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    flex-shrink: 0;
}

.bal-node-driver {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #718096;
    padding: 2px 8px;
    background: #edf2f7;
    border-radius: 12px;
    white-space: nowrap;
}

.bal-driver-icon {
    flex-shrink: 0;
    object-fit: contain;
    opacity: 0.75;
}

.bal-node-coeff {
    font-size: 11px;
    font-weight: 600;
    color: #d69e2e;
    padding: 2px 6px;
    background: #fef5e7;
    border-radius: 8px;
}

.bal-node-method-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    flex-shrink: 0;
}

.bal-node-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s;
}

.bal-node-toggle {
    flex-shrink: 0;
    width: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.55;
    transition: opacity 0.15s;
}

.bal-node-toggle img {
    display: block;
}

.bal-node-toggle:hover {
    opacity: 1;
}

.bal-node-toggle--placeholder {
    cursor: default;
}

.bal-tree-row:hover .bal-node-actions {
    opacity: 1;
}

/* ── Pannello RE associate (destra) ──────────────────────── */

.bal-re-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-bottom: 1px solid #f1f5f9;
}

.bal-re-row:hover {
    background: #f8fafc;
}

.bal-re-row .bal-cdc-actions {
    opacity: 0;
}

.bal-re-row:hover .bal-cdc-actions {
    opacity: 1;
}

/* ── Modal: RE non Associati a CDC (sola lettura) ────────── */

.bal-unassigned-res-list {
    display: flex;
    flex-direction: column;
}

/* ── Empty state ─────────────────────────────────────────── */

.bal-empty-state {
    padding: 30px 14px;
    text-align: center;
    font-size: 12px;
    color: #a0aec0;
}

/* ── Modal: campi specifici bal_cdc ──────────────────────── */

.bal-modal-fields {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bal-modal-fields small {
    display: block;
    font-size: 11px;
    color: #a0aec0;
    margin-top: 6px;
}

/* ── Scenario status badges ── */
.status-badge.draft     { background: #e2e8f0; color: #475569; }
.status-badge.running   { background: #fed7aa; color: #9a3412; }
.status-badge.completed { background: #dcfce7; color: #166534; }
.status-badge.error     { background: #fee2e2; color: #991b1b; }

/* ── bal_workflow: riga di primo livello (workflow_id = main) ── */
.tabulator .tabulator-row.row-main-flow {
    background: #f5f9ff;
    border-left: 3px solid #378ADD;
}

.tabulator .tabulator-row.row-main-flow .tabulator-cell {
    font-weight: 700;
    color: #1e293b;
}

/* ── Percentuale RE/CDC/Conto: verde se somma=100, arancio altrimenti ── */
.status-badge.partial   { background: #fed7aa; color: #9a3412; }
