/* ── POWER METER (1.4.0) ─────────────────────────────────────────
   Le display Power Meter de DaqExpert : memes blocs, memes couleurs de phase
   (A = texte, B = #D9483B, C = #2F7BE8), memes pastilles OK / A verifier. */

.pm-root {
    --pm-phase-a: var(--text0);
    --pm-ok-bg: rgba(46, 157, 87, 0.20);
    --pm-ok-fg: #1E8A47;
    --pm-warn-bg: rgba(224, 123, 26, 0.20);
    --pm-warn-fg: #B35A0B;
    --pm-na-bg: rgba(128, 136, 144, 0.10);
    --pm-card-bg: var(--bg1);
    --pm-tile-veil: rgba(59, 130, 246, 0.05);
    position: relative;
    overflow: hidden;
}
:root:not(.theme-light) .pm-root {
    /* Contraste sur fond sombre : memes teintes, un ton plus clair. */
    --pm-ok-fg: #3FBF6E;
    --pm-warn-fg: #E8913A;
    --pm-card-bg: var(--bg2);
}

.pm-scroll {
    position: absolute; inset: 0;
    overflow: auto;
    padding: 8px 10px;
    font-family: var(--font-ui);
    color: var(--text0);
    --pm-tile-cols: 5;
    --pm-side-cols: 2;
}

.pm-card {
    background: var(--pm-card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 14px;
    margin: 4px;
    min-width: 0;
}
.pm-section-title { font-size: 13px; font-weight: 600; color: var(--text0); margin-bottom: 8px; }
.pm-note { font-size: 11px; color: var(--text1); margin-top: 6px; }
.pm-center { text-align: center; }
.pm-na { font-size: 12px; color: var(--text2); text-align: center; margin: 18px 0; }

/* En-tete : connexion, TP, TC ; etat, fenetre, source */
.pm-header { margin: 2px 4px 6px; display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; justify-content: space-between; }
.pm-header-main { font-size: 12px; font-weight: 600; color: var(--text0); }
.pm-header-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 11px; color: var(--text1); }
.pm-state { display: inline-flex; align-items: center; gap: 6px; }
.pm-state-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 6px var(--green); }
.pm-state-wait .pm-state-dot { background: var(--text2); box-shadow: none; }

/* Cinq grandes valeurs */
.pm-tiles { display: grid; grid-template-columns: repeat(var(--pm-tile-cols), minmax(0, 1fr)); }
.pm-tile { padding: 10px 14px; background-image: linear-gradient(var(--pm-tile-veil), var(--pm-tile-veil)); }
.pm-tile-label { font-size: 12px; color: var(--text1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pm-tile-value { margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pm-num { font-family: var(--font-mono); font-size: 24px; font-weight: 600; color: var(--text0); letter-spacing: -0.02em; }
.pm-unit { font-size: 13px; color: var(--text1); }
.pm-tile-note { font-size: 11px; color: var(--text1); min-height: 14px; }

/* Tableaux (par phase, elements) */
.pm-table { width: 100%; border-collapse: collapse; font-size: 12px; table-layout: auto; }
.pm-table th, .pm-table td { padding: 5px 0 5px 10px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
.pm-table th { font-weight: 600; color: var(--text0); }
.pm-table th.pm-col-label { font-weight: 400; color: var(--text1); }
.pm-table .pm-col-label { text-align: left; padding-left: 0; white-space: normal; color: var(--text0); width: 99%; }
.pm-table td { font-family: var(--font-mono); font-size: 11.5px; }
.pm-table td.pm-col-label { font-family: var(--font-ui); font-size: 12px; }
.pm-table th:not(.pm-col-label), .pm-table td:not(.pm-col-label) { min-width: 78px; }
.pm-table .pm-total { font-weight: 600; }
/* Le theme clair stylise tous les th/td de la page (fond, 12 px de marge) : le tableau du display garde les siens. */
.theme-light .pm-table th, .theme-light .pm-table td { background: transparent; padding: 5px 0 5px 10px; border-bottom: 1px solid var(--border); }
.theme-light .pm-table th { text-align: right; color: var(--text0); }
.theme-light .pm-table td { color: var(--text0); }
.theme-light .pm-table .pm-col-label { text-align: left; padding-left: 0; }
.theme-light .pm-table th.pm-col-label { color: var(--text1); }
.theme-light .pm-table tr:hover { background: transparent; }
.pm-table .pm-calc { font-style: italic; }
.pm-ph-a { color: var(--pm-phase-a) !important; }
.pm-ph-b { color: #D9483B !important; }
.pm-ph-c { color: #2F7BE8 !important; }

/* Diagramme vectoriel + verifications de cablage : cote a cote des 600 px */
.pm-side { display: grid; grid-template-columns: repeat(var(--pm-side-cols), minmax(0, 1fr)); }
.pm-phasor-wrap { display: flex; justify-content: center; }
.pm-phasor { width: 100%; max-width: 260px; height: auto; display: block; overflow: visible; }
.pm-phasor .pm-grid { fill: none; stroke: var(--border); }
:root:not(.theme-light) .pm-phasor .pm-grid { stroke: rgba(255, 255, 255, 0.16); }
.theme-light .pm-phasor .pm-grid { stroke: rgba(0, 0, 0, 0.18); }
.pm-phasor text { font-family: 'Segoe UI', var(--font-ui), sans-serif; }

.pm-check { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.pm-check-label { flex: 1 1 auto; min-width: 0; color: var(--text1); }
.pm-check-value { color: var(--text0); text-align: right; font-family: var(--font-mono); font-size: 11.5px; }
.pm-check-limit { color: var(--text2); font-family: var(--font-ui); font-size: 10.5px; }
.pm-pill { min-width: 64px; text-align: center; border-radius: 9px; padding: 1px 8px; font-size: 11px; font-weight: 600;
           background: var(--pm-na-bg); color: var(--text1); }
.pm-pill-ok { background: var(--pm-ok-bg); color: var(--pm-ok-fg); }
.pm-pill-warn { background: var(--pm-warn-bg); color: var(--pm-warn-fg); }
.pm-tile-note.pm-pf-lag, .pm-tile-note.pm-pf-lead, .pm-tile-note.pm-pf-unity { color: var(--text1); }

/* Messages d'etat */
.pm-empty { display: flex; align-items: center; justify-content: center; min-height: 100%; padding: 16px; }
.pm-banner { border-radius: 6px; padding: 10px 14px; font-size: 12.5px; line-height: 1.45; border: 1px solid var(--border); margin: 4px; }
.pm-empty .pm-banner { max-width: 520px; text-align: center; font-size: 13px; }
.pm-banner-info { background: var(--bg2); color: var(--text1); }
.pm-banner-warn { background: var(--pm-warn-bg); color: var(--pm-warn-fg); border-color: rgba(224, 123, 26, 0.35); font-weight: 600; }

/* Hors licence : l'apercu grise derriere le cadenas (convention des outils verrouilles de DaqExpert) */
/* L'apercu ne defile pas : le cadenas reste au centre de ce qui est visible. */
.pm-locked { position: relative; height: 100%; overflow: hidden; }
.pm-locked-content { opacity: 0.35; filter: grayscale(1) blur(0.6px); pointer-events: none; user-select: none; }
.pm-lock-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; }
.pm-lock-card { display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 360px; text-align: center;
                background: var(--bg1); border: 1px solid var(--border); border-radius: 8px; padding: 16px 20px;
                box-shadow: var(--shadow); color: var(--text0); font-size: 13px; font-weight: 600; }
.pm-lock-card svg { color: var(--text1); }

/* Fenetre etroite (telephone) */
@media (max-width: 480px) {
    .pm-scroll { padding: 6px; }
    .pm-card { padding: 8px 10px; margin: 3px; }
    .pm-num { font-size: 20px; }
    .pm-table th:not(.pm-col-label), .pm-table td:not(.pm-col-label) { min-width: 0; padding-left: 6px; }
    .pm-header { flex-direction: column; }
    .pm-check-value { white-space: nowrap; }
    .pm-check-limit { display: block; }
}
