/* Outils de commissioning de DaqExpert dans le Live (js/commissioning/).
   Comme dans DaqExpert, le bandeau de la page EST la barre de la fenetre : la barre du Live
   s'efface et la page occupe toute la fenetre. */

[data-chart^="cx-"], [data-chart-type^="cx-"] { --type-color: var(--c-commissioning, #2178c4); }

.chart-window.cx-window .chart-titlebar,
.chart-window.cx-window .chart-footer,
.chart-window.cx-window .chart-legend { display: none; }

.chart-window.cx-window .chart-body { position: relative; }
.chart-content.cx-content { position: absolute; inset: 0; overflow: hidden; }
.cx-frame { position: absolute; inset: 0; }

/* Voile de chargement (LoadingOverlay de la fenetre WPF) */
.cx-loading {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 13px;
    z-index: 2;
}

/* Fenêtres flottantes des outils (js/commissioning/toolWindows.js) : au-dessus des panneaux, comme les
   fenêtres d'outils de DaqExpert au-dessus de l'application. La couche ne capte rien elle-même. */
.cx-layer { position: fixed; inset: 0; z-index: 400; pointer-events: none; overflow: hidden; }
.cx-layer .chart-window.cx-floating {
    pointer-events: auto;
    transform-origin: 0 0;
    min-width: 0; min-height: 0;
    box-shadow: 0 18px 48px rgba(0, 0, 0, .38), 0 2px 8px rgba(0, 0, 0, .22);
}
.cx-layer .chart-window.cx-floating.cx-max { border-radius: 0; }
.cx-layer .chart-window.cx-floating.cx-max .chart-resize-handle { display: none; }
/* Pendant un déplacement ou un redimensionnement, les pages ne prennent pas la souris. */
.cx-layer.cx-moving iframe { pointer-events: none; }
.cx-layer.cx-moving { cursor: move; }

/* Barre latérale : les outils de commissioning dans un groupe qui se déroule. */
.nav-group-toggle {
    display: flex; align-items: center; justify-content: space-between; width: 100%;
    background: none; border: 0; cursor: pointer; text-align: left; border-radius: 6px;
}
.nav-group-toggle:hover { color: var(--text-primary); background: var(--bg-hover, rgba(127, 127, 127, .08)); }
.nav-group-toggle:focus-visible { outline: 2px solid var(--accent, #2178c4); outline-offset: -2px; }
.nav-group-chev { flex: 0 0 auto; transition: transform .15s ease; }
.nav-group-toggle[aria-expanded="true"] .nav-group-chev { transform: rotate(90deg); }
.nav-group[hidden] { display: none; }
/* 1.9.0 : section COMMISSIONING (titre + groupe) sans effet sur la mise en page du menu ; masquee sans outil licencie,
   et chaque entree non licenciee masquee (le style .nav-item, display:flex, l'emporterait sinon sur [hidden]). */
.cx-section { display: contents; }
.cx-section[hidden], #cxGroup .nav-item[hidden] { display: none !important; }
/* Menu replié : le groupe reste ouvrable (son chevron seul). */
.sidebar.collapsed .nav-group-toggle { display: flex; justify-content: center; padding: 8px 0; }
.sidebar.collapsed .nav-group-toggle .nav-group-label { display: none; }

/* ── Entree unique « Balancing » : ecran de choix Lite / Pro (BalancingChoiceWindow.xaml de DaqExpert) ──────────
   Bandeau bleu des outils, fond de la fenetre principale, cartes sur la surface du theme. Une carte est toujours
   selectionnee : cadre accent de 2 px pose PAR-DESSUS la carte (rien ne bouge) et pastille cochee. */
:root {
    --bal-accent: #3b82f6;          /* PrimaryColor (sombre) */
    --bal-accent-dark: #2563eb;     /* PrimaryDarkBrush */
    --bal-accent-light: #11203c;    /* PrimaryLightBrush */
}
:root.theme-light {
    --bal-accent: #1976d2;
    --bal-accent-dark: #1565c0;
    --bal-accent-light: #e3f2fd;
}
.bal-choice-backdrop {
    position: fixed; inset: 0; z-index: 900;
    display: flex; align-items: center; justify-content: center; padding: 16px;
    background: rgba(0, 0, 0, .45);
}
.bal-choice {
    display: flex; flex-direction: column; max-width: 100%; max-height: 100%; overflow: auto;
    background: var(--bg-primary); color: var(--text-primary);
    border: 1px solid var(--border-color); box-shadow: 0 18px 48px rgba(0, 0, 0, .45);
    font: 13px/1.35 'Segoe UI', system-ui, -apple-system, sans-serif; outline: none;
}
.bal-choice-bar {
    flex: 0 0 auto; height: 44px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
    background: #2178c4; color: #fff; user-select: none;
}
.bal-choice-brand { display: flex; align-items: center; gap: 8px; margin-left: 12px; }
.bal-choice-brand svg { display: block; }
.bal-choice-lockup { font-weight: 700; font-size: 13px; line-height: 1.1; }
.bal-choice-lockup small { display: block; font-weight: 400; font-size: 10.5px; opacity: .85; }
.bal-choice-title { font-size: 14px; font-weight: 700; margin: 0 16px; }
.bal-choice button.bal-choice-x {
    justify-self: end; margin-right: 12px; width: 30px; height: 26px; border: 0;
    background: transparent; color: #fff; font-size: 15px; cursor: pointer; border-radius: 3px; padding: 0;
}
.bal-choice button.bal-choice-x:hover { background: rgba(255, 255, 255, .2); }
.bal-choice-body { padding: 16px 18px 14px; }
.bal-choice-heading { font-size: 14px; font-weight: 600; margin: 0 6px 6px; color: var(--text-primary); }
.bal-choice-cards { display: flex; flex-wrap: wrap; justify-content: center; }
.bal-choice-card {
    position: relative; box-sizing: border-box; width: 300px; max-width: calc(100vw - 64px); margin: 6px;
    display: grid; grid-template-columns: auto 1fr auto; padding: 14px 14px 16px 16px;
    background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 8px; cursor: pointer;
}
.bal-choice-card:hover { border-color: var(--bal-accent); }
.bal-choice-card::after {
    content: ''; position: absolute; inset: -1px; border: 2px solid var(--bal-accent); border-radius: 8px;
    pointer-events: none; display: none;
}
.bal-choice-card.is-selected::after { display: block; }
.bal-choice-tile {
    width: 44px; height: 44px; border-radius: 8px; background: var(--bal-accent-light);
    display: flex; align-items: center; justify-content: center; align-self: start;
}
.bal-choice-tile svg path { fill: none; stroke: var(--bal-accent); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.bal-choice-text { margin: 1px 8px 0 14px; }
.bal-choice-name { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.bal-choice-desc { font-size: 12px; line-height: 17px; margin-top: 4px; color: var(--text-secondary); }
.bal-choice-dot {
    width: 18px; height: 18px; box-sizing: border-box; border-radius: 50%; margin-top: 1px;
    border: 1.5px solid var(--border-color); display: flex; align-items: center; justify-content: center;
}
.bal-choice-dot svg { display: none; }
.bal-choice-dot svg path { fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bal-choice-card.is-selected .bal-choice-dot { background: var(--bal-accent); border-color: var(--bal-accent); }
.bal-choice-card.is-selected .bal-choice-dot svg { display: block; }
.bal-choice-foot {
    display: flex; align-items: center; gap: 8px; padding: 10px 18px; border-top: 1px solid var(--border-color);
}
.bal-choice-hint { flex: 1 1 auto; max-width: 300px; font-size: 11.5px; color: var(--text-tertiary); margin-right: 4px; }
/* Les themes du Live habillent tout <button> : ces regles, plus precises, rendent ceux de DaqExpert. */
.bal-choice button { transform: none; box-shadow: none; gap: 0; transition: background .12s ease; }
.bal-choice button.bal-choice-cancel, .bal-choice button.bal-choice-launch {
    font: 600 13px 'Segoe UI', system-ui, sans-serif; border-radius: 6px; cursor: pointer; padding: 7px 18px;
}
.bal-choice button.bal-choice-cancel { margin-left: auto; background: transparent; color: var(--text-secondary); border: 1px solid var(--border-color); }
.bal-choice button.bal-choice-cancel:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.bal-choice button.bal-choice-launch {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 120px; padding: 7px 20px;
    background: var(--bal-accent); color: #fff; border: 0;
}
.bal-choice button.bal-choice-launch:hover { background: var(--bal-accent-dark); }
.bal-choice button.bal-choice-launch:active { opacity: .85; }
.bal-choice-play path { fill: #fff; stroke: none; }
