/* ── FILTRES DU SPECTATEUR (1.5.0) / CHART SETTINGS (1.5.9) ─────────────────────────────────
   Panneau « Chart Settings - Filtering & Display » (js/filterPanel.js) et badge « Filtré : ... ».
   Contenu de la boite de DaqExpert, style du live : couleurs du theme (variables --bg* / --text*,
   redefinies par le theme clair), coins arrondis, boutons du dialogue d'alarme. Le panneau vit
   dans <body> : a cote du graphe sur grand ecran, feuille plein ecran en bas de page sous 640 px
   (cibles tactiles de 40 px, champs a 16 px pour eviter le zoom iOS). */

.filter-panel {
    position: fixed;
    z-index: 3000;
    width: 480px;
    max-width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
    display: flex;
    flex-direction: column;
    background: var(--bg1);
    color: var(--text0);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-card, 10px);
    box-shadow: 0 18px 48px rgba(0,0,0,0.55), 0 0 0 1px rgba(0,0,0,0.15);
    font-family: var(--font-sys);
    font-size: 12px;
    overflow: hidden;
}

/* En-tete : roue dentee + « Chart Settings - Filtering & Display » */
.filter-panel .fp-header {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 10px 9px 14px;
    background: var(--bg2);   /* 1.6.8 : meme fond que le panneau LEGEND (l'en-tete bleute des graphes ne s'applique pas ici) */
    border-bottom: 1px solid var(--border);
}
.filter-panel .fp-header-icon { display: flex; color: var(--accent); }
.filter-panel .fp-header-title {
    flex: 1; min-width: 0;
    font-size: 13px; font-weight: 600; color: var(--text0);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.filter-panel .fp-close {
    width: 28px; height: 28px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    padding: 0; border: 0; border-radius: 7px;
    background: transparent; color: var(--text1); cursor: pointer;
}
.filter-panel .fp-close:hover { background: rgba(255,59,92,0.18); color: var(--red); }

.filter-panel .fp-body { padding: 12px 14px 6px; overflow-y: auto; flex: 1; min-height: 0; }

/* Groupes (GroupBox de l'application) */
.filter-panel .fp-group {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 12px 10px;
    margin: 0 0 12px;
    min-width: 0;
    background: rgba(255,255,255,0.015);
}
.filter-panel .fp-group legend {
    padding: 0 6px; margin-left: -4px;
    color: var(--accent);
    font-size: 10.5px; font-weight: 700;
    letter-spacing: 0.06em; text-transform: uppercase;
}
.filter-panel .fp-off .fp-grid label { opacity: 0.45; }

/* Filtering Settings : Name / Type / Order a gauche, Cutoff / Low / High a droite */
.filter-panel .fp-grid {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 7px 10px;
    align-items: center;
    margin: 6px 0 2px;
}
.filter-panel .fp-grid label { color: var(--text1); white-space: nowrap; }
.filter-panel .fp-grid label:nth-of-type(even) { padding-left: 6px; }

.filter-panel .fp-body select,
.filter-panel .fp-body .fp-grid input.fp-num {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text0);
    font-family: var(--font-sys);
    font-size: 12px;
    height: 28px;
    padding: 2px 8px;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    transition: border-color var(--transition);
}
.filter-panel .fp-body .fp-grid input.fp-num { font-family: var(--font-mono); }
.filter-panel select:hover:not(:disabled),
.filter-panel .fp-num:hover:not(:disabled) { border-color: var(--border-accent); }
.filter-panel select:focus,
.filter-panel input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-halo); }
.filter-panel select:disabled,
.filter-panel input:disabled { opacity: 0.45; cursor: not-allowed; }

.filter-panel .fp-check,
.filter-panel .fp-radio {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 0;
    cursor: pointer;
    color: var(--text0);
}
.filter-panel .fp-body input[type="checkbox"],
.filter-panel .fp-body input[type="radio"] { width: 15px; height: 15px; accent-color: var(--accent); margin: 0; flex-shrink: 0; cursor: pointer; }

/* Filter All Channels : « Apply to all: [ ] » + bouton [■ Color] */
.filter-panel .fp-allrow { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding-top: 2px; }
.filter-panel .fp-allgrp.fp-off .fp-check { opacity: 0.55; }
.filter-panel .fp-colorbtn {
    position: relative;
    display: inline-flex; align-items: center; gap: 7px;
    height: 28px; padding: 0 12px 0 8px;
    border: 1px solid var(--border); border-radius: 6px;
    background: var(--bg2); color: var(--text0);
    cursor: pointer;
    transition: border-color var(--transition);
}
.filter-panel .fp-colorbtn:hover { border-color: var(--border-accent); }
.filter-panel .fp-colorbtn.fp-disabled { opacity: 0.45; cursor: not-allowed; }
.filter-panel .fp-swatch {
    display: inline-block; width: 18px; height: 14px; flex-shrink: 0;
    border-radius: 3px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25), 0 0 0 1px rgba(0,0,0,0.35);
}
/* le vrai <input type="color"> est sous l'echantillon, invisible : le clic ouvre le selecteur */
.filter-panel input[type="color"] {
    position: absolute; inset: 0; width: 100%; height: 100%;
    opacity: 0; border: 0; padding: 0; cursor: pointer;
}
.filter-panel input[type="color"]:disabled { cursor: not-allowed; }

/* Local Settings : Filter | Channel | Y-Axis | Integration Type | Color */
.filter-panel .fp-table-wrap { overflow-x: auto; margin: 4px -4px 0; padding: 0 4px; }
.filter-panel .fp-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.filter-panel .fp-table th {
    text-align: left; font-weight: 600; font-size: 11px; color: var(--text1);
    padding: 6px 6px; white-space: nowrap;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
}
.filter-panel .fp-table th:first-child { border-top-left-radius: 6px; }
.filter-panel .fp-table th:last-child { border-top-right-radius: 6px; }
.filter-panel .fp-table td { padding: 4px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.filter-panel .fp-table tbody tr:nth-child(even) td { background: rgba(255,255,255,0.02); }
.filter-panel .fp-table tbody tr:hover td { background: var(--bg-selected); }
.filter-panel .fp-body .fp-table select { height: 26px; padding: 1px 6px; font-size: 11.5px; }
.filter-panel .fp-col-f { width: 44px; text-align: center !important; }
.filter-panel .fp-col-c { width: 48px; text-align: center !important; }
.filter-panel .fp-table td:nth-child(3) { min-width: 62px; }
.filter-panel .fp-table td:nth-child(4) { min-width: 104px; }
.filter-panel .fp-ch label { display: flex; align-items: center; gap: 7px; cursor: pointer; min-width: 0; }
.filter-panel .fp-ch span { font-family: var(--font-mono); font-size: 11.5px; word-break: break-all; }
.filter-panel .fp-hidden-ch .fp-ch span { color: var(--text2); }
/* 1.6.6 : lignes de Local Settings — liste « Channel » par ligne ; ligne « None » estompee */
.filter-panel .fp-slots .fp-ch { min-width: 150px; }
.filter-panel .fp-body .fp-slots select.fp-slotch { width: 100%; font-family: var(--font-mono); }
.filter-panel .fp-slots .fp-hidden-ch .fp-slotch { color: var(--text2); }
.filter-panel .fp-slots .fp-hidden-ch td:not(.fp-ch) { opacity: 0.6; }
.filter-panel .fp-toggle-all {
    background: none; border: 0; padding: 0; margin: 0;
    font: inherit; color: inherit; cursor: pointer;
}
.filter-panel .fp-toggle-all:hover:not(:disabled) { color: var(--accent); text-decoration: underline; }
.filter-panel .fp-toggle-all:disabled { cursor: default; opacity: 0.6; }
.filter-panel .fp-colorcell {
    position: relative; display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 24px; border-radius: 5px; cursor: pointer;
    border: 1px solid var(--border); background: var(--bg2);
}
.filter-panel .fp-colorcell:hover { border-color: var(--border-accent); }

.filter-panel .fp-hint { margin: 4px 0 8px; color: var(--text2); line-height: 1.45; font-size: 11.5px; }
.filter-panel .fp-operator { margin: 0 0 4px 23px; }
.filter-panel .fp-notice {
    margin: 0 0 10px; padding: 7px 10px; border-radius: 6px;
    background: rgba(255,214,0,0.10); color: var(--yellow); line-height: 1.4;
}
/* Billet 270 : avis d'arete enregistree abaissee a l'ouverture (FilterLoweredNotice), meme aspect que fp-notice. */
.filter-panel .fp-lowered {
    margin: 0 0 10px; padding: 7px 10px; border-radius: 6px;
    background: rgba(255,214,0,0.10); color: var(--yellow); line-height: 1.4;
}
.filter-panel .fp-error {
    margin: 0 0 10px; padding: 7px 10px; border-radius: 6px;
    background: rgba(255,59,92,0.12); color: var(--red); line-height: 1.4;
    white-space: pre-line;   /* billet 270 : message sur plusieurs lignes, comme l'application */
}
.filter-panel .fp-about { margin: 0 0 8px; }
.filter-panel .fp-about summary {
    cursor: pointer; color: var(--text1); font-size: 11.5px; padding: 2px 0 6px;
    list-style-position: inside;
}
.filter-panel .fp-about summary:hover { color: var(--accent); }
.filter-panel .fp-about .fp-hint { padding-left: 10px; border-left: 2px solid var(--border-accent); }

/* Boutons Cancel / Apply : ceux du dialogue d'alarme (widgets.css), un peu plus grands */
.filter-panel .fp-footer {
    display: flex; justify-content: flex-end; gap: 8px;
    padding: 10px 14px;
    background: var(--bg2);   /* 1.6.8 : meme fond que le panneau LEGEND (l'en-tete bleute des graphes ne s'applique pas ici) */
    border-top: 1px solid var(--border);
}
.filter-panel .fp-footer button {
    height: 30px; min-width: 86px; padding: 0 16px; border-radius: 7px;
    font-family: var(--font-sys); font-size: 12px; font-weight: 600;
    letter-spacing: 0.02em; cursor: pointer;
    transition: opacity var(--transition), border-color var(--transition), color var(--transition);
}
.filter-panel .fp-footer .fp-cancel { background: var(--bg3); border: 1px solid var(--border); color: var(--text1); }
.filter-panel .fp-footer .fp-cancel:hover { color: var(--text0); border-color: var(--border-accent); }
.filter-panel .fp-footer .fp-apply { background: var(--accent); border: 1px solid var(--accent); color: var(--bg0); }
.filter-panel .fp-footer .fp-apply:hover { opacity: 0.88; }

/* Bouton Settings de la barre de titre : « actif » quand un filtre ou une operation tourne */
#appPage .titlebar-btn.chart-settings-btn.active { color: var(--accent); background: rgba(0,229,255,0.12); }
#appPage .titlebar-btn.chart-settings-btn.active:hover { background: rgba(0,229,255,0.2); }

/* Badge « Filtré : passe-bas 100 Hz, ordre 4 » en haut a gauche du trace. */
.filter-badge {
    position: absolute;
    top: 4px; left: 50px;
    max-width: calc(100% - 60px);
    z-index: 5;
    padding: 2px 8px;
    border-radius: 3px;
    background: rgba(0,229,255,0.14);
    border: 1px solid rgba(0,229,255,0.45);
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 10px;
    line-height: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: auto;
}
.filter-badge-warn { background: rgba(255,214,0,0.12); border-color: rgba(255,214,0,0.5); color: var(--yellow); }
.filter-badge-raw  { background: rgba(160,174,192,0.12); border-color: rgba(160,174,192,0.4); color: var(--text1); }


.filter-open-btn { cursor: pointer; }

/* Theme clair : les variables --bg* / --text* sont deja celles du theme ; quelques nuances */
.theme-light .filter-panel {
    border-color: rgba(15,40,70,0.16);
    box-shadow: 0 18px 48px rgba(15,40,70,0.18), 0 2px 6px rgba(15,40,70,0.08);
}
.theme-light .filter-panel .fp-group { background: rgba(15,40,70,0.015); border-color: rgba(15,40,70,0.12); }
.theme-light .filter-panel .fp-group legend { color: #0b7fa8; }
.theme-light .filter-panel .fp-body select,
.theme-light .filter-panel .fp-body .fp-grid input.fp-num,
.theme-light .filter-panel .fp-colorbtn,
.theme-light .filter-panel .fp-colorcell { background: #ffffff; border-color: rgba(15,40,70,0.18); }
.theme-light .filter-panel .fp-table th { background: #eef2f7; }
.theme-light .filter-panel .fp-table tbody tr:nth-child(even) td { background: rgba(15,40,70,0.025); }
.theme-light .filter-panel .fp-table tbody tr:hover td { background: rgba(0,153,204,0.07); }
.theme-light .filter-panel .fp-swatch { box-shadow: inset 0 0 0 1px rgba(0,0,0,0.15); }
.theme-light .filter-panel .fp-footer .fp-cancel { background: #ffffff; border-color: rgba(15,40,70,0.18); }
.theme-light .filter-panel .fp-footer .fp-apply { color: #ffffff; }
.theme-light .filter-badge { color: #007f99; background: rgba(0,180,216,0.10); border-color: rgba(0,180,216,0.45); }
.theme-light .filter-badge-warn { color: #8a6d00; }
.theme-light .filter-panel .fp-notice, .theme-light .filter-panel .fp-lowered { color: #8a6d00; }
.theme-light #appPage .titlebar-btn.chart-settings-btn.active,
:root.theme-light #appPage .titlebar-btn.chart-settings-btn.active { color: #0b7fa8; background: rgba(0,153,204,0.12); }

/* ── Telephone : feuille plein ecran en bas, cibles tactiles ─────────────────────────── */
@media (max-width: 640px) {
    .filter-panel {
        left: 0 !important; right: 0; bottom: 0; top: auto !important;
        width: 100%; max-width: 100%;
        max-height: 88vh;
        border-radius: 14px 14px 0 0;
        font-size: 13px;
    }
    .filter-panel .fp-body { padding: 12px 12px 6px; }
    .filter-panel select,
    .filter-panel .fp-num { height: 40px; font-size: 16px; }
    .filter-panel .fp-body .fp-table select { height: 38px; font-size: 15px; }
    /* Name / Type / Order puis Cutoff / Low / High : deux colonnes (libelle, champ) */
    .filter-panel .fp-grid { grid-template-columns: minmax(92px, auto) minmax(0, 1fr); gap: 8px 12px; }
    .filter-panel .fp-grid label:nth-of-type(even) { padding-left: 0; }
    /* ordre de la boite : Name, Type, Order puis Cutoff, Low, High (la grille large les met cote a cote) */
    .filter-panel .fp-grid > :nth-child(5), .filter-panel .fp-grid > :nth-child(6) { order: 1; }
    .filter-panel .fp-grid > :nth-child(9), .filter-panel .fp-grid > :nth-child(10) { order: 2; }
    .filter-panel .fp-grid > :nth-child(3), .filter-panel .fp-grid > :nth-child(4) { order: 3; }
    .filter-panel .fp-grid > :nth-child(7), .filter-panel .fp-grid > :nth-child(8) { order: 4; }
    .filter-panel .fp-grid > :nth-child(11), .filter-panel .fp-grid > :nth-child(12) { order: 5; }
    .filter-panel .fp-check,
    .filter-panel .fp-radio { min-height: 40px; }
    .filter-panel .fp-body input[type="checkbox"],
    .filter-panel .fp-body input[type="radio"] { width: 22px; height: 22px; }
    .filter-panel .fp-colorbtn { height: 40px; }
    .filter-panel .fp-colorcell { width: 40px; height: 34px; }
    /* la grille des voies defile DANS le panneau, jamais la page */
    .filter-panel .fp-table { min-width: 470px; }
    .filter-panel .fp-table.fp-slots { min-width: 520px; }
    .filter-panel .fp-slots .fp-ch { min-width: 170px; }
    .filter-panel .fp-table td { padding: 6px; }
    .filter-panel .fp-footer { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
    .filter-panel .fp-footer button { height: 44px; flex: 1; font-size: 14px; }
    .filter-panel .fp-close { width: 40px; height: 40px; }
    .filter-badge { left: 4px; max-width: calc(100% - 8px); white-space: normal; }
}

/* 1.6.1 : « Filter All Channels » + « Update Rate » (Trend) sur une ligne, pastilles de l'application */
.filter-panel .fp-row2 { display: flex; gap: 10px; align-items: stretch; }
.filter-panel .fp-row2 > .fp-group { flex: 0 1 auto; min-width: 0; }
.filter-panel .fp-row2 > .fp-calc { flex: 1 1 auto; }
.filter-panel .fp-pills { display: flex; flex-wrap: wrap; gap: 4px; padding-top: 2px; }
.filter-panel .fp-pill { position: relative; cursor: pointer; }
.filter-panel .fp-pill input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.filter-panel .fp-pill span {
    display: inline-block; padding: 3px 8px; border-radius: 3px;
    font-size: 10.5px; font-weight: 600; white-space: nowrap;
    border: 1px solid var(--border); background: var(--bg2); color: var(--text1);
}
.filter-panel .fp-pill input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--bg0); }
.filter-panel .fp-pill input:focus-visible + span { box-shadow: 0 0 0 3px var(--focus-halo); }
@media (max-width: 640px) { .filter-panel .fp-row2 { flex-direction: column; gap: 0; } }

/* 1.6.1 : boite « FFT Settings » (FFTChartSettingsView.xaml) — groupes en colonnes */
.filter-panel.fft-panel { width: 560px; }
.filter-panel .fp-cols { display: grid; gap: 8px; }
.filter-panel .fp-cols-21 { grid-template-columns: 2fr 1fr; }
.filter-panel .fp-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.filter-panel .fp-cols > .fp-group { margin-bottom: 10px; min-width: 0; }
.filter-panel .fp-trig > .fp-cols > .fp-group,
.filter-panel .fp-trig > .fp-modes { margin-bottom: 6px; }
.filter-panel .fp-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.filter-panel .fp-body .fp-inline input.fp-num {
    width: 56px; height: 26px; padding: 2px 6px; box-sizing: border-box;
    background: var(--bg2); border: 1px solid var(--border); border-radius: 6px;
    color: var(--text0); font-family: var(--font-mono); font-size: 12px;
}
.theme-light .filter-panel .fp-body .fp-inline input.fp-num { background: #ffffff; border-color: rgba(15,40,70,0.18); }
.filter-panel .fp-body .fp-inline input.fp-num:disabled { opacity: 0.45; }
.filter-panel .fp-zc { display: inline-flex; align-items: center; gap: 6px; }
.filter-panel .fp-body .fp-zc input.fp-cyc { width: 44px; height: 24px; padding: 1px 4px; }
.filter-panel .fp-dis { opacity: 0.5; }
.filter-panel .fp-swatches { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; }
.filter-panel .fp-swatches .fp-prev { width: 30px; height: 18px; margin-right: 4px; }
.filter-panel .fp-sw { position: relative; cursor: pointer; }
.filter-panel .fp-sw input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.filter-panel .fp-sw span { display: block; width: 16px; height: 16px; border-radius: 3px; border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.25); }
.filter-panel .fp-sw input:checked + span { border-color: var(--accent); }
.filter-panel .fp-sw input:focus-visible + span { box-shadow: 0 0 0 3px var(--focus-halo); }
@media (max-width: 640px) {
    .filter-panel.fft-panel { width: 100%; }
    .filter-panel .fp-cols-3, .filter-panel .fp-cols-21 { grid-template-columns: 1fr; gap: 0; }
    .filter-panel .fp-sw span { width: 24px; height: 24px; }
}
/* 1.6.1 : boite « Orbit Settings » (OrbitChartSettingsView.xaml) */
.filter-panel.orbit-panel { width: 520px; }
.filter-panel .fp-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.filter-panel .fp-cols-2 select { width: 100%; }
.filter-panel .fp-cols-2 .fp-inline { flex-wrap: nowrap; }
.filter-panel .fp-cols-2 .fp-inline select { flex: 1; min-width: 0; }
.filter-panel .fp-swatches .fp-prev-l { width: 40px; height: 20px; }
.filter-panel .fp-sw-l span { width: 22px; height: 22px; }
.filter-panel .fp-dis-label { color: var(--text1); margin-right: 4px; }
@media (max-width: 640px) {
    .filter-panel.orbit-panel { width: 100%; }
    .filter-panel .fp-cols-2 { grid-template-columns: 1fr; gap: 0; }
}
/* 1.6.1 : boite « Dashboard Settings - Signal Selection » */
.filter-panel.dash-panel { width: 440px; }
.filter-panel .fp-dash-bar { margin: 4px 0 8px; }
.filter-panel .fp-btn {
    height: 26px; padding: 0 10px; border-radius: 6px; cursor: pointer;
    font-family: var(--font-sys); font-size: 11.5px; font-weight: 600;
    border: 1px solid var(--border); background: var(--bg2); color: var(--text0);
}
.filter-panel .fp-btn:hover { border-color: var(--border-accent); }
.filter-panel .fp-dash-rate { color: var(--text1); }
.filter-panel .fp-dash-list { max-height: 250px; min-height: 120px; overflow-y: auto; }
@media (max-width: 640px) { .filter-panel.dash-panel { width: 100%; } }
