/* ── 1.6.0 : FENETRE DE GRAPHE DE DAQEXPERT ────────────────────────────────────────────────
   Mise en page, elements et proportions de ChartWindowView.xaml (en-tete 28 px, barre d'outils
   28 px, boutons de 22 px, legende repliable). Les FONDS suivent les themes du live ; les
   elements du trace et des outils gardent les couleurs des themes de l'application
   (Themes/LightTheme.xaml, DarkTheme.xaml). Charge APRES theme-light.css / theme-dark.css. */

:root {
    --dx-ink: #9fb0c7;          /* IconButtonForegroundColor (sombre) */
    --dx-header-icon: #9fb0c7;  /* ChartHeaderIconBrush = TextSecondaryColor */
    --dx-primary: #3b82f6;      /* PrimaryColor */
    --dx-accent: #3b82f6;       /* AccentColor */
    --dx-muted: #a0a8b8;        /* ChartToolIconMutedColor */
    --dx-live-bg: #143a2c;      /* CardInRangePillBrush */
    --dx-live-fg: #34d399;      /* CardInRangePillTextBrush */
    --dx-scroll-bg: #0f1626;    /* ScrollBarBgColor */
    --dx-scroll-thumb: #2e3b52; /* ScrollBarThumbColor */
    --dx-legend-title: #60a5fa;
    --dx-text: #e6ebf4;
    --dx-text2: #9fb0c7;
}
:root.theme-light {
    --dx-ink: #555555;
    --dx-header-icon: #616161;
    --dx-primary: #1976d2;
    --dx-accent: #f57c00;
    --dx-muted: #888888;
    --dx-live-bg: #dcfae6;
    --dx-live-fg: #067647;
    --dx-scroll-bg: #f0f0f0;
    --dx-scroll-thumb: #c0c0c0;
    --dx-legend-title: #0d47a1;
    --dx-text: #212121;
    --dx-text2: #616161;
}

/* ── En-tete : liseré d'accent, titre, pastille, ☰ □ × ─────────────────────── */
#appPage .chart-window .chart-titlebar {
    height: 28px;
    gap: 8px;
    padding: 0 2px 0 16px;
}
#appPage .chart-window .chart-titlebar::before {   /* Border Width=3 CornerRadius=2 Margin=5,7,0,7 */
    left: 5px; top: 7px; bottom: 7px; width: 3px; border-radius: 2px;
}
#appPage .chart-window .chart-title {
    flex: 0 1 auto;
    font-family: var(--font-sys);
    font-size: 12px;
    font-weight: 600;
    color: var(--dx-text);
}
#appPage .chart-titlebar-fill { flex: 1; min-width: 0; }
#appPage .chart-status {
    flex-shrink: 0;
    padding: 1px 7px;
    border-radius: 9px;
    font-family: var(--font-sys);
    font-size: 8.5px;
    font-weight: 700;
    line-height: 14px;
    letter-spacing: 0.02em;
    white-space: nowrap;
    background: rgba(128,128,128,0.133);   /* StatusPillIdleColor #22808080 */
    color: var(--dx-header-icon);
}
#appPage .chart-status[data-state="live"] { background: var(--dx-live-bg); color: var(--dx-live-fg); }
#appPage .chart-status[data-state="paused"] { background: rgba(255,193,7,0.18); color: var(--dx-header-icon); }
#appPage .chart-window .titlebar-btn {
    width: 24px; height: 24px;
    border-radius: 4px;
    color: var(--dx-header-icon);
    background: transparent; border: 0; padding: 0;
}
#appPage .chart-window .titlebar-btn:hover { background: var(--bg-hover); color: var(--dx-text); transform: none; box-shadow: none; }
#appPage .chart-window .titlebar-btn.close-btn-tb:hover { background: rgba(244,67,54,0.18); color: #f44336; }
#appPage .chart-window .titlebar-btn.chart-settings-btn.active { color: var(--dx-primary); background: rgba(59,130,246,0.14); }

/* ── Barre d'outils du bas ─────────────────────────────────────────────── */
#appPage .chart-window .chart-footer {
    height: 28px;
    padding: 0 0 0 6px;
    gap: 0;
    background: var(--card-header-bg);
    border-top: 1px solid var(--border);
    backdrop-filter: none;
}
#appPage .chart-window .chart-footer-left { gap: 2px; }
#appPage .chart-window .chart-footer-right { gap: 4px; padding-right: 18px; }
#appPage .chart-window .tb-sep { width: 1px; align-self: stretch; margin: 5px 6px; background: var(--border); }
#appPage .chart-window .footer-btn.tb-btn {
    width: 22px; height: 22px; min-width: 22px;
    padding: 0; gap: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 3px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--dx-ink);
    box-shadow: none; transform: none;
}
#appPage .chart-window .footer-btn.tb-btn:hover { background: var(--bg-hover); border-color: var(--border); transform: none; box-shadow: none; }
/* PushButtonStyle coche : cadre bleu, fond bleu pale */
#appPage .chart-window .footer-btn.tb-btn.active { background: rgba(25,118,210,0.14); border-color: var(--dx-primary); color: var(--dx-ink); box-shadow: none; }
#appPage .chart-window .tb-discreet { opacity: 0.7; }
#appPage .chart-window .tb-discreet:hover { opacity: 1; }
#appPage .tb-btn svg { width: 14px; height: 14px; display: block; }
#appPage .tb-btn .tb-ink { fill: var(--dx-ink); }
#appPage .tb-btn .tb-primary { fill: var(--dx-primary); }
#appPage .tb-btn .tb-accent2 { fill: #dc322f; }   /* 1.6.3 : barre du curseur 2 = couleur du curseur 2 (C2 #DC322F), clair comme sombre */
#appPage .tb-btn .tb-muted { fill: var(--dx-muted); }
#appPage .tb-btn .tb-muted-line { stroke: var(--dx-muted); stroke-width: 1; fill: none; }
#appPage .tb-btn .tb-lens { fill: #ffffff; stroke: var(--dx-ink); stroke-width: 2; }
#appPage .tb-btn .tb-handle { stroke: var(--dx-ink); stroke-width: 3; stroke-linecap: round; fill: none; }
#appPage .tb-btn .tb-plus { stroke: #4caf50; stroke-width: 2; stroke-linecap: round; fill: none; }
#appPage .tb-btn .tb-minus { stroke: #f44336; stroke-width: 2; stroke-linecap: round; fill: none; }
#appPage .tb-btn .tb-dash { fill: none; stroke: #2196f3; stroke-width: 2; stroke-dasharray: 3 2; }
#appPage .tb-btn .tb-lens-s { fill: #ffffff; stroke: var(--dx-ink); stroke-width: 1.5; }
#appPage .tb-btn .tb-handle-s { stroke: var(--dx-ink); stroke-width: 2; stroke-linecap: round; fill: none; }
#appPage .tb-btn .tb-arc { fill: none; stroke: var(--dx-ink); stroke-width: 2.5; stroke-linecap: round; }
#appPage .tb-btn .tb-dot { fill: var(--dx-primary); }
#appPage .tb-btn .tb-inner { fill: #ffffff; }
#appPage .tb-btn .tb-lens-c { fill: #2196f3; }
#appPage .tb-btn .tb-warn { fill: #ffc107; }
#appPage .tb-btn .tb-line { fill: none; stroke: var(--dx-ink); stroke-width: 1.8; stroke-linejoin: round; }
/* Reprendre (Resume_in / _out) : gris pendant le direct, vert quand le trace est en pause ;
   Pause (Pause_in / _out) : rouge pendant le direct, gris en pause. */
#appPage .tb-btn .tb-play { fill: #9e9e9e; }
#appPage .tb-btn .tb-pause { fill: #e53935; }
#appPage .chart-paused .tb-btn .tb-play { fill: #4caf50; }
#appPage .chart-paused .tb-btn .tb-pause { fill: #9e9e9e; }
#appPage .chart-window .chart-resize-handle { z-index: 3; }

/* ── Zone de trace du Time chart ──────────────────────────────────────── */
.chart-content .tc-plot { position: absolute; left: 0; top: 0; right: 0; bottom: 12px; }
.chart-content .tc-scroll {      /* hScrollBar1 : barre grise sous l'axe X */
    position: absolute; bottom: 0; height: 12px; left: 0; width: 0;
    background: var(--dx-scroll-bg);
    cursor: default;
}
.chart-content .tc-scroll-thumb {
    position: absolute; top: 1px; bottom: 1px; left: 0; width: 100%;
    background: var(--dx-scroll-thumb);
    border-radius: 1px;
    cursor: grab;
}
.chart-content .tc-scroll-thumb:active { cursor: grabbing; }
.chart-content .tc-hint {
    position: absolute; inset: 0 0 40px 50px;
    height: auto;
    font-family: var(--font-sys);
    font-size: 12px;
    color: var(--dx-text2);
    opacity: 0.85;
}
.chart-content.rubber-mode { cursor: crosshair; }
.chart-content .rubber-box {
    position: absolute; z-index: 25; pointer-events: none;
    border: 1px dashed #2196f3;
    background: rgba(33,150,243,0.12);
}

/* Curseurs de l'application : C1 #0078D7, C2 #DC322F, trait de 1,5 px, sans halo */
#appPage .chart-content .track-line { width: 9px !important; background: transparent !important; opacity: 1 !important; filter: none !important; }
#appPage .chart-content .track-line::after { content: ''; position: absolute; left: 3.75px; top: 0; bottom: 0; width: 1.5px; background: #0078d7; }
#appPage .chart-content .track-line-1::after { background: #dc322f; }

/* ── Legende de l'application (repliable) ─────────────────────────────── */
#appPage .chart-legend.desk-legend {
    width: 180px;
    padding: 0;
    display: flex;
    background: var(--bg2);
    border-left: 1px solid var(--border);
    backdrop-filter: none;
    overflow: hidden;
    transition: width 0.15s ease;
}
#appPage .chart-legend.desk-legend.collapsed { width: 16px; }
#appPage .chart-legend.desk-legend.collapsed .dl-main { display: none; }
#appPage .desk-legend .dl-toggle {
    flex: 0 0 16px; width: 16px; height: auto;
    display: flex; align-items: center; justify-content: center;
    padding: 0; margin: 0; border: 0; border-radius: 0;
    background: transparent; color: var(--dx-primary); cursor: pointer;
    box-shadow: none; transform: none;
}
#appPage .desk-legend .dl-toggle:hover { background: var(--bg-hover); }
#appPage .desk-legend .dl-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#appPage .desk-legend .dl-header {
    padding: 5px 6px 5px 4px;
    font-family: var(--font-sys); font-size: 11px; font-weight: 600;
    color: var(--dx-legend-title);
    border-bottom: 1px solid var(--border);
}
#appPage .desk-legend .dl-body { flex: 1; overflow-y: auto; padding: 6px 8px 6px 4px; }
#appPage .desk-legend .dl-row {
    display: grid;
    grid-template-columns: 14px 14px minmax(0, 1fr) 14px 16px 44px;
    align-items: center;
    height: 16px; margin: 1px 0;
    font-family: var(--font-sys); font-size: 10px; color: var(--dx-text);
}
#appPage .desk-legend .dl-row.off { opacity: 0.4; }
#appPage .desk-legend .dl-vis { width: 11px; height: 11px; margin: 0; cursor: pointer; }
#appPage .desk-legend .dl-line { width: 10px; height: 2px; margin: 0 2px; }
#appPage .desk-legend .dl-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 1.6.6 : nom de voie coupe, suffixe « (filtered) (∫) » / « #2 » toujours visible */
#appPage .desk-legend .dl-name.dl-split { display: flex; min-width: 0; }
#appPage .desk-legend .dl-base { overflow: hidden; text-overflow: ellipsis; min-width: 1.5em; }
#appPage .desk-legend .dl-suffix { flex-shrink: 0; white-space: pre; }
#appPage .desk-legend .dl-filter { display: flex; justify-content: center; }
#appPage .desk-legend .dl-axis {
    width: 14px; height: 11px; padding: 0; margin: 0;
    border: 0; border-radius: 2px;
    font: 700 7px/11px var(--font-sys); color: #ffffff; text-align: center;
    cursor: pointer; box-shadow: none; transform: none;
}
#appPage .desk-legend .dl-axis:hover { filter: brightness(1.15); transform: none; }
#appPage .desk-legend .dl-value {
    text-align: right; white-space: nowrap; overflow: hidden;
    font-family: Consolas, 'JetBrains Mono', monospace; font-size: 9px; color: var(--dx-text2);
}
#appPage .desk-legend .dl-empty { padding: 8px 2px 4px; font-family: var(--font-sys); font-size: 11px; line-height: 1.4; font-style: italic; color: var(--dx-text2); }
#appPage .desk-legend .dl-axes { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border); }
#appPage .desk-legend .dl-axes:first-child { margin-top: 2px; }
#appPage .desk-legend .dl-axes-title { font-family: var(--font-sys); font-size: 8px; color: var(--dx-text2); margin-bottom: 3px; }
#appPage .desk-legend .dl-pills { display: flex; gap: 2px; }
#appPage .desk-legend .dl-pill {
    display: inline-block; padding: 0 3px; border-radius: 2px;
    font: 600 7px/11px var(--font-sys); color: #ffffff;
}

/* Chart Settings flottant : on le tire par son en-tete */
@media (min-width: 641px) {
    .filter-panel .fp-header { cursor: move; touch-action: none; }
    .filter-panel.fp-dragging { user-select: none; opacity: 0.96; }
}

/* Telephone : cibles un peu plus grandes, legende plus etroite */
@media (max-width: 640px) {
    #appPage .chart-window .chart-titlebar { height: 34px; }
    #appPage .chart-window .titlebar-btn { width: 30px; height: 30px; }
    #appPage .chart-window .chart-footer { height: 32px; }
    #appPage .chart-window .footer-btn.tb-btn { width: 26px; height: 26px; min-width: 26px; }
    #appPage .chart-window .tb-sep { margin: 6px 3px; }
    #appPage .chart-legend.desk-legend { width: 132px; }
}

/* Les themes animent TOUT (« .theme-x * { transition: all 0.3s } ») : la fenetre Settings tiree a la
   souris et le pouce de la barre de defilement doivent suivre le pointeur sans retard. */
.theme-light .filter-panel, .theme-dark .filter-panel,
.theme-light .tc-scroll, .theme-dark .tc-scroll,
.theme-light .tc-scroll-thumb, .theme-dark .tc-scroll-thumb,
.theme-light .rubber-box, .theme-dark .rubber-box { transition: none; }

/* Fenetre etroite : les boutons de la barre de titre restent visibles (la pastille puis le titre
   cedent la place), la barre d'outils de gauche defile, Reprendre / Pause restent a droite. */
#appPage .chart-window .chart-titlebar-btns { flex-shrink: 0; }
#appPage .chart-window .chart-status { flex-shrink: 20; min-width: 0; overflow: hidden; text-overflow: clip; }
#appPage .chart-window .chart-title { flex-shrink: 1; min-width: 0; }
#appPage .chart-window .chart-titlebar-fill { flex-shrink: 100; }
#appPage .chart-window .chart-footer-left { flex: 1 1 auto; min-width: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
#appPage .chart-window .chart-footer-left::-webkit-scrollbar { display: none; }
#appPage .chart-window .chart-footer-center { flex: 0 0 auto; }
#appPage .chart-window .chart-footer-right { flex-shrink: 0; }

/* 1.6.1 : blocs « Cursor 1 », « Cursor 2 » et « Δ Differences » de la legende (ChartWindowView.xaml) */
:root { --dx-cur-bg: #151c2b; --dx-cur1: #3b82f6; --dx-cur2: #fbbf24; }
:root.theme-light { --dx-cur-bg: #ffffff; --dx-cur1: #1976d2; --dx-cur2: #f57c00; }
#appPage .desk-legend .dl-cursors:not(:empty) { margin-top: 8px; }
#appPage .desk-legend .dl-cur {
    background: var(--dx-cur-bg);
    border: 1px solid var(--dx-cur1);
    border-radius: 3px;
    padding: 4px;
    margin: 0 0 4px;
    font-family: var(--font-sys);
    color: var(--dx-text);
}
#appPage .desk-legend .dl-cur2 { border-color: var(--dx-cur2); }
#appPage .desk-legend .dl-delta { border-color: #fbbf24; }               /* DeltaBorderColor */
:root.theme-light #appPage .desk-legend .dl-delta { border-color: #f57c00; background: #fff8e7; }   /* DeltaBgColor */
#appPage .desk-legend .dl-cur-head { display: flex; align-items: center; gap: 4px; font-size: 9.5px; font-weight: 600; }
#appPage .desk-legend .dl-cur-sw { width: 8px; height: 8px; border-radius: 2px; background: var(--dx-primary); }
#appPage .desk-legend .dl-cur2 .dl-cur-sw { background: #dc322f; }
#appPage .desk-legend .dl-delta-sym { font-size: 12px; line-height: 10px; }
#appPage .desk-legend .dl-cur-x,
#appPage .desk-legend .dl-cur-v { display: flex; justify-content: space-between; gap: 6px; font-size: 9px; line-height: 13px; margin-top: 2px; }
#appPage .desk-legend .dl-cur-v { font-size: 8.5px; margin-top: 0; }
#appPage .desk-legend .dl-cur-v span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dx-text2); }
#appPage .desk-legend .dl-cur-x span:last-child,
#appPage .desk-legend .dl-cur-v span:last-child { font-family: Consolas, 'JetBrains Mono', monospace; white-space: nowrap; }

/* 1.6.1 : information du display au centre de l'en-tete (HeaderInfoText : Power Meter) */
#appPage .chart-window .chart-titlebar-fill { display: flex; justify-content: center; overflow: hidden; }
#appPage .chart-header-info {
    font-family: var(--font-sys); font-size: 11.5px; color: var(--dx-text);
    white-space: pre; overflow: hidden; text-overflow: ellipsis; min-width: 0; pointer-events: none;
}
#appPage .chart-window .pm-header-main { display: none; }

/* Trend Table de l'application : valeurs en Consolas, « [unite] » apres le nom, Φ en couleur secondaire */
#appPage .desk-table { font-family: var(--font-sys); font-size: 11px; }
#appPage .desk-table th { height: 24px; font-weight: 600; font-size: 11px; color: var(--dx-text2); text-align: left; white-space: nowrap; }
#appPage .desk-table td { height: 20px; padding: 0 8px; white-space: nowrap; }
#appPage .desk-table td.dt-v { font-family: Consolas, 'JetBrains Mono', monospace; color: var(--dx-text); }
#appPage .desk-table .dt-phase { color: var(--dx-text2) !important; }
#appPage .desk-table .dt-ch { min-width: 110px; }
#appPage .desk-table .dt-unit { font-size: 10px; color: var(--dx-text2); }

/* Trend & Alarm Monitoring : unite a cote de la valeur, mention en pied */
#appPage .dash-card-unit { margin-left: 4px; font-size: 11px; color: var(--dx-text2); font-family: var(--font-sys); }
#appPage .dash-foot { padding: 6px 4px 2px; font-family: var(--font-sys); font-size: 9px; font-style: italic; color: var(--dx-text2); }
.chart-content .tc-plot.tc-plot-full { bottom: 0; }
#appPage .chart-window .tb-digits { width: auto; min-width: 34px; padding: 0 4px; font: 700 9px/1 var(--font-sys); color: var(--dx-ink); }

/* ── 1.6.2 : en mode clair, en-tête et barre d'outils des graphes accordés au reste du site
   (barre du haut et menu blancs, filets gris) au lieu du bleu-gris ; la fenêtre se détache du fond
   gris de la page par son filet et son ombre. Le thème sombre ne change pas. ─────────────── */
:root.theme-light #appPage .chart-window { border-color: #dfe3e8; box-shadow: 0 1px 2px rgba(16,24,40,0.06), 0 4px 16px rgba(16,24,40,0.07); }
:root.theme-light #appPage .chart-window .chart-titlebar { background: #ffffff; border-bottom: 1px solid #e6e9ee; }
:root.theme-light #appPage .chart-window .chart-footer { background: #f8f9fb; border-top: 1px solid #e6e9ee; }
:root.theme-light #appPage .chart-window .chart-title { color: #1f2937; }
:root.theme-light #appPage .chart-window .titlebar-btn { color: #6b7280; }
:root.theme-light #appPage .chart-window .titlebar-btn:hover { background: #f1f3f6; color: #111827; }

/* 1.6.4 : badges Y1..Y4 (légende et clé « Y AXES ») — texte centré horizontalement ET verticalement */
#appPage .desk-legend .dl-axis,
#appPage .desk-legend .dl-pill {
    display: inline-flex; align-items: center; justify-content: center;
    box-sizing: border-box; min-width: 16px; height: 12px; padding: 0 3px;
    line-height: 1; text-align: center; vertical-align: middle;
}
