/* ============================================================
   Zen UI Controls - Socle visuel commun
   ============================================================ */

:root {
    --zen-ctrl-height: 30px;
    --zen-ctrl-font-size: 13px;
    --zen-ctrl-font-family: "Segoe UI", Arial, sans-serif;
    --zen-ctrl-radius: 4px;
    --zen-ctrl-padding-x: 10px;
    --zen-ctrl-border-color: var(--zen-theme-border-strong, #b8c2cc);
    --zen-ctrl-focus-border-color: var(--zen-theme-focus, #0F6CB7);
    --zen-ctrl-bg: var(--zen-theme-surface, #ffffff);
    --zen-ctrl-color: var(--zen-theme-text, #1f2937);
    --zen-ctrl-disabled-bg: var(--zen-theme-disabled-bg, #f3f4f6);
    --zen-ctrl-disabled-color: var(--zen-theme-disabled-text, #6b7280);
    --zen-ctrl-placeholder-color: var(--zen-theme-placeholder, #9ca3af);
    /* Caret commun aux contrôles ouvrant un choix. */
    --zen-ctrl-caret-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2356616f' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    --zen-ctrl-caret-size: 10px 6px;
    --zen-ctrl-caret-slot-width: 30px;

    /* Langage visuel commun des choix multiples (MultiSelect + filtres ZenGrid). */
    --zen-choice-chip-bg: var(--zen-theme-surface-muted, #e8eef7);
    --zen-choice-chip-color: var(--zen-theme-text, #334155);
    --zen-choice-chip-radius: 3px;
    --zen-choice-accent-color: var(--zen-theme-action, var(--zen-ctrl-focus-border-color));
}

/*
 * Socle partagé par les composants qui représentent plusieurs choix.
 * Le contrôle métier et les filtres de grille utilisent les mêmes puces
 * et les mêmes cases à cocher : aucune vue ne redéfinit leur aspect.
 */
.zen-choice-chips {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.zen-choice-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    min-width: 0;
    max-width: 100%;
    padding: 2px 6px;
    border: 0;
    border-radius: var(--zen-choice-chip-radius);
    background: var(--zen-choice-chip-bg);
    color: var(--zen-choice-chip-color);
    font: inherit;
    line-height: 1.2;
    white-space: nowrap;
}

.zen-choice-chip > .zen-choice-chip__label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.zen-choice-checkbox {
    width: 14px;
    height: 14px;
    flex: 0 0 14px;
    margin: 0;
    accent-color: var(--zen-choice-accent-color);
}

.zen-choice-option {
    display: flex;
    align-items: center;
    gap: 8px;
}

/*
 * Même langage visuel pour DropDown / MultiSelect / ColorPicker.
 * Les contrôles custom utilisent cette classe ; le select natif reprend
 * exactement la même image via myDropDown.css.
 */
.zen-ctrl-caret {
    display: inline-flex;
    flex: 0 0 var(--zen-ctrl-caret-slot-width);
    width: var(--zen-ctrl-caret-slot-width);
    min-width: var(--zen-ctrl-caret-slot-width);
    height: 100%;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    background-image: var(--zen-ctrl-caret-image);
    background-repeat: no-repeat;
    background-position: right var(--zen-ctrl-padding-x) center;
    background-size: var(--zen-ctrl-caret-size);
}

/* Compatibilité avec un ancien DOM qui contiendrait encore l'icône FA. */
.zen-ctrl-caret > i {
    display: none;
}

/*
 * myMultiSelectDropDown : le caret fait partie du contrôle lui-même.
 * Le layout ne doit dépendre ni d'une grille, ni d'un TemplateRow,
 * ni d'un CSS historique du module qui l'héberge.
 */
mymultiselectdropdown {
    display: block;
    width: 100%;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box;
}

.myMultiSelectDropDown {
    position: relative;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    color: var(--zen-theme-text, #1f2937);
    font-family: var(--zen-ctrl-font-family);
    font-size: var(--zen-ctrl-font-size);
}

.myMultiSelectDropDown > .msd-display {
    display: flex;
    align-items: center;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    height: var(--zen-ctrl-height);
    min-height: var(--zen-ctrl-height);
    padding: 0 0 0 var(--zen-ctrl-padding-x);
    border-top: none !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: 1px solid var(--zen-ctrl-border-color) !important;
    border-radius: 0 !important;
    background: transparent !important;
}

.myMultiSelectDropDown.readonly > .msd-display,
.myMultiSelectDropDown.is-readonly > .msd-display {
    border-bottom-color: transparent !important;
    background: transparent !important;
    cursor: default;
}

/* Même signal de focus/ouverture que myDropDown. */
.myMultiSelectDropDown:not(.readonly):not(.is-readonly):focus-within > .msd-display,
.myMultiSelectDropDown:not(.readonly):not(.is-readonly).is-open > .msd-display {
    border-bottom-color: var(--zen-ctrl-focus-border-color) !important;
}

.myMultiSelectDropDown .msd-chips {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1 1 auto;
    min-width: 0;
    margin: 0 !important;
    padding: 0 !important;
}

/*
 * Les puces peuvent recevoir des styles historiques du host applicatif.
 * Leur marge externe ne doit jamais décaler l'axe du MultiSelect :
 * seul le padding du contrôle définit l'alignement avec myDropDown.
 */
.myMultiSelectDropDown .msd-chip {
    margin: 0 !important;
}

.myMultiSelectDropDown .msd-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    cursor: pointer;
}

.myMultiSelectDropDown .msd-item {
    min-height: 30px;
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
}

.myMultiSelectDropDown .msd-item:hover,
.myMultiSelectDropDown .msd-item:focus-within {
    background: var(--zen-theme-hover-bg, #f1f5f9);
}

.myMultiSelectDropDown .msd-caret {
    display: inline-flex;
    flex: 0 0 var(--zen-ctrl-caret-slot-width);
    width: var(--zen-ctrl-caret-slot-width);
    min-width: var(--zen-ctrl-caret-slot-width);
    height: var(--zen-ctrl-height);
    min-height: var(--zen-ctrl-height);
    align-self: center;
}

/*
 * Mode lecture = représentation de valeur :
 * le caret disparaît et ne réserve plus de place dans le flux.
 * On le garde dans le DOM pour ne pas changer la structure du contrôle
 * lors des bascules READ/EDIT.
 */
.myMultiSelectDropDown.readonly .msd-caret,
.myMultiSelectDropDown.is-readonly .msd-caret {
    position: absolute;
    right: 0;
    top: 0;
    visibility: hidden;
    pointer-events: none;
}


/* Base visuelle pour les contrôles standards */
.MyButton,
.mySplitButton button,
.myColorPicker {
    box-sizing: border-box;
    height: var(--zen-ctrl-height);
    min-height: var(--zen-ctrl-height);
    font-size: var(--zen-ctrl-font-size);
    font-family: var(--zen-ctrl-font-family);
    line-height: normal;
}
.zr-filter-group {
    margin-bottom: 10px;
}

.zr-filter-group-title {
    font-weight: 600;
    font-size: 13px;
    color: #0d4f86;
    margin-bottom: 6px;
    padding: 3px 8px;
    border-left: 3px solid #0d4f86;
    border-bottom: 1px solid var(--zen-theme-border, #dcdcdc);
    background: #eef4fb;
}

.zr-filter-group-body {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 8px 18px;
    align-items: center;
    /* important : pas de hauteur artificielle */
    min-height: 0;
    height: auto;
    padding: 0;
    margin: 0;
}

.zr-filter-line {
    display: grid;
    grid-template-columns: 80px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    min-width: 0;
    min-height: 28px;
    height: auto;
    margin: 0;
    padding: 0;
}

    .zr-filter-line .lbFiltre {
        font-size: 12px;
        font-weight: 600;
        margin: 0;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        overflow-wrap: break-word;
        line-height: 1.15;
    }

    .zr-filter-line input,
    .zr-filter-line select,
    .zr-filter-line .txtFiltre,
    .zr-filter-line .cbFiltre {
        width: 100%;
        min-width: 0;
        height: 26px;
        box-sizing: border-box;
    }

    .zr-filter-line button {
        width: 22px;
        height: 22px;
        min-width: 22px;
        padding: 0;
        justify-self: center;
    }

.zr-criteres {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.zr-popup {
    padding-bottom: 10px;
}

.zr-filter-group {
    margin: 0 0 6px 0 !important;
    padding: 0 !important;
    height: auto !important;
    min-height: 0 !important;
}

.zr-filter-group-title {
    height: 22px !important;
    min-height: 0 !important;
    line-height: 18px !important;
    margin: 0 0 4px 0 !important;
    padding: 2px 8px !important;
    box-sizing: border-box;
}

.zr-filter-group-body {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 6px 18px !important;
    align-items: center !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    grid-auto-rows: min-content !important;
}

.zr-filter-line {
    display: grid !important;
    grid-template-columns: 80px minmax(0, 1fr);
    align-items: start !important;
    gap: 8px !important;
    height: auto !important;
    min-height: 28px !important;
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box;
}

    .zr-filter-line .lbFiltre {
        min-width: 0 !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 4px 0 0 0 !important;
        white-space: normal !important;
        overflow-wrap: break-word !important;
        line-height: 1.15 !important;
        align-self: start !important;
    }

    .zr-filter-line input,
    .zr-filter-line select,
    .zr-filter-line .txtFiltre,
    .zr-filter-line .cbFiltre {
        height: 24px !important;
        min-height: 0 !important;
        margin: 0 !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        box-sizing: border-box;
    }

    .zr-filter-line button {
        width: 22px !important;
        height: 22px !important;
        min-width: 22px !important;
        min-height: 22px !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* R3H6 — cosmetic only: local reset lives inside the raw filter control. */
    .zr-filter-line .zr-filter-control {
        position: relative;
        width: 100%;
        min-width: 0;
        align-self: start;
    }

    .zr-filter-line .zr-filter-control .txtFiltre,
    .zr-filter-line .zr-filter-control .cbFiltre {
        width: 100%;
        min-width: 0;
    }

    /* Text clear sits at the far right, like the compact filter editor. */
    .zr-filter-line .zr-filter-control .txtFiltre {
        padding-right: 26px !important;
    }

    /* Select/date keep their native arrow/calendar at the far right. */
    .zr-filter-line .zr-filter-control .cbFiltre,
    .zr-filter-line .zr-filter-control .txtFiltre[type="date"],
    .zr-filter-line .zr-filter-control .txtFiltre[type="datetime-local"] {
        padding-right: 46px !important;
    }

    .zr-filter-line .zr-filter-clear {
        position: absolute;
        top: 50%;
        right: 4px;
        z-index: 2;
        transform: translateY(-50%);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 18px !important;
        height: 18px !important;
        min-width: 18px !important;
        min-height: 18px !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        border-radius: 4px;
        background: transparent !important;
        color: var(--zen-theme-action, #0F6CB7);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        cursor: pointer;
        box-shadow: none !important;
    }

    .zr-filter-line .zr-filter-clear.is-active {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .zr-filter-line .zr-filter-control:has(.cbFiltre) .zr-filter-clear,
    .zr-filter-line .zr-filter-control:has(.txtFiltre[type="date"]) .zr-filter-clear,
    .zr-filter-line .zr-filter-control:has(.txtFiltre[type="datetime-local"]) .zr-filter-clear {
        right: 24px;
    }

    .zr-filter-line .zr-filter-clear:hover,
    .zr-filter-line .zr-filter-clear:focus-visible {
        background: var(--zen-theme-surface-subtle, #eef4fb) !important;
        outline: none;
    }

    .zr-filter-line .zr-filter-clear i {
        font-size: 10px;
        pointer-events: none;
    }

/* requiered decorator */
/* RequiredDecorator */
decorator.zen-decorator,
decorator.field {
    display: block;
   /* width: 100%;*/
    min-width: 0;
    box-sizing: border-box;
    position: relative;
}

decorator.is-required {
    padding-right: 22px;
}

    decorator.is-required > .zen-decorator-required-icon {
        position: absolute;
        right: 4px;
        top: 50%;
        transform: translateY(-50%);
        width: 14px;
        height: 14px;
        border-radius: 50%;
        background: var(--zen-theme-danger, #e53935);
        color: white;
        font-size: 10px;
        font-weight: bold;
        line-height: 14px;
        text-align: center;
        z-index: 5;
        pointer-events: auto;
        cursor: help;
    }

decorator mydropdown {
    display: block;
    width: 100%;
    min-width: 0;
}

decorator .myDropdown {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 28px;
}

/* Un contrôle dans un décorateur visuel doit laisser le décorateur piloter le rendu */
.zen-decorator.myCellOK *,
.zen-decorator.myCellNOK *,
.zen-decorator.myCellWarning *,
.zen-decorator.myCellError * {
    color: inherit !important;
    -webkit-text-fill-color: currentColor !important;
}

.zen-decorator.myCellOK input,
.zen-decorator.myCellNOK input,
.zen-decorator.myCellWarning input,
.zen-decorator.myCellError input,
.zen-decorator.myCellOK .myNumericBox,
.zen-decorator.myCellNOK .myNumericBox,
.zen-decorator.myCellWarning .myNumericBox,
.zen-decorator.myCellError .myNumericBox,
.zen-decorator.myCellOK .myNumericBox-wrap,
.zen-decorator.myCellNOK .myNumericBox-wrap,
.zen-decorator.myCellWarning .myNumericBox-wrap,
.zen-decorator.myCellError .myNumericBox-wrap {
    background: transparent !important;
    color: inherit !important;
    -webkit-text-fill-color: currentColor !important;
    border-color: transparent !important;
    box-shadow: none !important;
}
.zen-decorator.myCellOK input:disabled,
.zen-decorator.myCellNOK input:disabled,
.zen-decorator.myCellWarning input:disabled,
.zen-decorator.myCellError input:disabled {
    opacity: 1 !important;
}

/* Décorateur visuel générique
   Le host porte le fond/couleur ; les contrôles enfants doivent
   laisser ce rendu visible et hériter du contraste du décorateur. */
.zen-decorator.zen-decorator-visual * {
    color: inherit !important;
    -webkit-text-fill-color: currentColor !important;
}

.zen-decorator.zen-decorator-visual input,
.zen-decorator.zen-decorator-visual textarea,
.zen-decorator.zen-decorator-visual select,
.zen-decorator.zen-decorator-visual .myNumericBox,
.zen-decorator.zen-decorator-visual .myNumericBox-wrap {
    background: transparent !important;
    color: inherit !important;
    -webkit-text-fill-color: currentColor !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

.zen-decorator.zen-decorator-visual input:disabled,
.zen-decorator.zen-decorator-visual textarea:disabled,
.zen-decorator.zen-decorator-visual select:disabled {
    opacity: 1 !important;
}
/* ============================================================
   ZenSplit — primitive de layout à deux panneaux
   horizontal = gauche / droite
   vertical   = haut / bas

   Le layout est une grid CSS à trois pistes : Pane1 / séparateur / Pane2.
   Cela permet d'animer aussi bien le premier que le second panneau sans
   transformer le contenu métier ni lui imposer une largeur artificielle.
   ============================================================ */
zensplit.zen-split,
.zen-split {
    --zen-split-second-size: 35%;
    --zen-split-handle-size: 8px;
    display: grid;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    box-sizing: border-box;
}

zensplit.zen-split[data-orientation="horizontal"],
.zen-split[data-orientation="horizontal"] {
    grid-template-columns: minmax(0, 1fr) var(--zen-split-handle-size) minmax(0, var(--zen-split-second-size));
    grid-template-rows: minmax(0, 1fr);
}

zensplit.zen-split[data-orientation="vertical"],
.zen-split[data-orientation="vertical"] {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) var(--zen-split-handle-size) minmax(0, var(--zen-split-second-size));
}

.zen-split > .zen-split__pane {
    display: flex;
    min-width: 0;
    min-height: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

/* Le rangement est une convention du composant, pas une animation applicative.
   L'interpolation des pistes est pilotée par ZenSplit avec Web Animations : les
   valeurs de départ et d'arrivée sont mesurées en pixels, ce qui garantit un
   mouvement réel même lorsque le layout normal mélange fr/minmax/px. */
.zen-split.is-animated {
    /* classe d'état/documentation ; animation pilotée côté composant */
}

.zen-split > .zen-split__splitter {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    background: transparent;
    z-index: 4;
    touch-action: none;
    user-select: none;
    outline: none;
}

.zen-split[data-orientation="horizontal"] > .zen-split__splitter {
    cursor: col-resize;
}

.zen-split[data-orientation="vertical"] > .zen-split__splitter {
    cursor: row-resize;
}

.zen-split > .zen-split__splitter::before {
    content: "";
    position: absolute;
    background: rgba(100, 116, 139, 0.34);
    transition: background-color 120ms ease, box-shadow 120ms ease;
}

.zen-split[data-orientation="horizontal"] > .zen-split__splitter::before {
    width: 1px;
    height: 100%;
}

.zen-split[data-orientation="vertical"] > .zen-split__splitter::before {
    width: 100%;
    height: 1px;
}

.zen-split > .zen-split__splitter:hover::before,
.zen-split.is-resizing > .zen-split__splitter::before,
.zen-split > .zen-split__splitter:focus-visible::before {
    background: var(--zen-ctrl-focus-border-color, #2563eb);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--zen-ctrl-focus-border-color, #2563eb) 18%, transparent);
}

.zen-split__handle {
    position: absolute;
    inset: 0;
}

.zen-split__collapse {
    position: relative;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 28px;
    padding: 0;
    border: 1px solid rgba(100, 116, 139, 0.32);
    border-radius: 5px;
    background: var(--zen-theme-surface, #fff);
    color: var(--zen-theme-text-muted, #475569);
    font-size: 10px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.zen-split[data-orientation="vertical"] .zen-split__collapse {
    width: 28px;
    height: 18px;
}

.zen-split__collapse:hover,
.zen-split__collapse:focus-visible {
    color: var(--zen-ctrl-focus-border-color, #2563eb);
    border-color: var(--zen-ctrl-focus-border-color, #2563eb);
    outline: none;
}

.zen-split[data-orientation="horizontal"].is-first-collapsed {
    grid-template-columns: 0px var(--zen-split-handle-size) minmax(0, 1fr);
}

.zen-split[data-orientation="horizontal"].is-second-collapsed {
    grid-template-columns: minmax(0, 1fr) var(--zen-split-handle-size) 0px;
}

.zen-split[data-orientation="vertical"].is-first-collapsed {
    grid-template-rows: 0px var(--zen-split-handle-size) minmax(0, 1fr);
}

.zen-split[data-orientation="vertical"].is-second-collapsed {
    grid-template-rows: minmax(0, 1fr) var(--zen-split-handle-size) 0px;
}

/* prefers-reduced-motion est respecté côté ZenSplit avant de lancer
   l'animation Web Animations. */

body.zen-split-resizing,
body.zen-split-resizing * {
    cursor: inherit !important;
    user-select: none !important;
}


/* ============================================================
   Placeholder / EmptyText — contrat visuel commun
   ============================================================ */

/*
 * Un texte synthétique (aide de saisie ou état vide) ne doit jamais
 * pouvoir être confondu avec une vraie donnée métier.
 *
 * READ : les contrôles appliquent .is-placeholder lorsqu'ils rendent
 *        EmptyText (ou le fallback Placeholder historique).
 * EDIT : les inputs natifs utilisent ::placeholder.
 */
.is-placeholder,
.msd-placeholder {
    color: var(--zen-ctrl-placeholder-color) !important;
    font-style: italic;
}

input.myTextBox::placeholder,
textarea.myTextBoxArea::placeholder,
input.myPassword::placeholder,
input.myPhone::placeholder,
input.myNumericBox-input::placeholder,
input.myDateTime::placeholder,
input.myTime::placeholder,
.myMultiSelectDropDown .msd-search::placeholder {
    color: var(--zen-ctrl-placeholder-color);
    font-style: italic;
    opacity: 1;
}

/* Le placeholder d'un DropDown est une vraie option __NULL__.
   Le contrôle pose .is-placeholder sur le select tant qu'elle est active. */
select.myDropDown.is-placeholder,
select.myDropdown.is-placeholder {
    color: var(--zen-ctrl-placeholder-color);
    font-style: italic;
}
