/* ============================================================
   search.css — palette de recherche transverse

   Etape P1.13, lot 2, 27/09/2026.
   Cadrage : docs/cadrage_recherche_globale.md

   POURQUOI UNE PALETTE ET NON UN CHAMP DANS L'EN-TETE. La premiere ligne de
   l'en-tete porte deja le titre, le fil d'audit a cinq etapes, trois boutons de
   session et cinq utilitaires ; elle passe a la ligne des 1200 px. Un champ de
   saisie permanent y aurait pris la place du fil d'audit. Le declencheur est
   donc un bouton sobre, et la saisie s'ouvre au centre de l'ecran.

   PAS DE LISERE : le resultat survole ou selectionne au clavier se signale par
   un fond, la couleur du texte et la graisse, jamais par un trait colore.
   ============================================================ */

/* ── Le declencheur, dans les utilitaires d'en-tete ───────── */
.ap-recherche-declencheur {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 8px;
    background: #f8fafc;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: background .12s, color .12s;
}
.ap-recherche-declencheur:hover { background: #f1f5f9; color: #0f172a; }
.ap-recherche-declencheur svg { width: 15px; height: 15px; }
.ap-recherche-declencheur kbd {
    font-family: inherit;
    font-size: 10.5px;
    font-weight: 700;
    line-height: 1;
    padding: 3px 5px;
    border-radius: 5px;
    background: #e2e8f0;
    color: #64748b;
}
/* Sous 1000 px, l'icone seule : l'en-tete est deja a l'etroit. */
@media (max-width: 1000px) {
    .ap-recherche-declencheur .ap-recherche-declencheur-libelle,
    .ap-recherche-declencheur kbd { display: none; }
    .ap-recherche-declencheur { padding: 0 9px; }
}

/* ── La palette ───────────────────────────────────────────── */
.ap-recherche[hidden] { display: none; }
.ap-recherche {
    position: fixed;
    inset: 0;
    z-index: 3000;   /* au-dessus des modales de l'application (1000-2000) */
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 84px 16px 16px;
}
.ap-recherche-voile {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .45);
}
.ap-recherche-boite {
    position: relative;
    width: 100%;
    max-width: 660px;
    max-height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .28);
    overflow: hidden;
}

/* ── La saisie ────────────────────────────────────────────── */
.ap-recherche-saisie {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
}
.ap-recherche-saisie > svg,
.ap-recherche-saisie > i { width: 18px; height: 18px; color: #94a3b8; flex-shrink: 0; }
.ap-recherche-saisie input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    font-family: inherit;
    font-size: 15px;
    color: #0f172a;
}
.ap-recherche-saisie input::placeholder { color: #94a3b8; }
/* La croix native du type=search doublerait notre bouton de fermeture. */
.ap-recherche-saisie input::-webkit-search-cancel-button { display: none; }

.ap-recherche-etat {
    font-size: 11px;
    color: #94a3b8;
    white-space: nowrap;
    flex-shrink: 0;
}
.ap-recherche-fermer {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    flex-shrink: 0;
}
.ap-recherche-fermer:hover { background: #f1f5f9; color: #475569; }
.ap-recherche-fermer svg { width: 15px; height: 15px; }

/* ── Les resultats ────────────────────────────────────────── */
.ap-recherche-resultats {
    overflow-y: auto;
    padding: 6px 0 8px;
    flex: 1;
}

.ap-recherche-famille {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 12px 16px 5px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    color: #94a3b8;
}
.ap-recherche-famille svg { width: 13px; height: 13px; }
.ap-recherche-famille-compte {
    margin-left: auto;
    text-transform: none;
    letter-spacing: 0;
    font-size: 11px;
    font-weight: 600;
}
.ap-recherche-tout {
    margin-left: 8px;
    padding: 2px 7px;
    border: 0;
    border-radius: 6px;
    background: #eff6ff;
    font-family: inherit;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .2px;
    text-transform: none;
    color: #2563eb;
    cursor: pointer;
}
.ap-recherche-tout:hover { background: #dbeafe; }

.ap-recherche-item {
    display: flex;
    align-items: baseline;
    gap: 10px;
    width: calc(100% - 16px);
    margin: 0 8px;
    padding: 8px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}
/* Survol et selection au clavier : meme signalement, aucun bord accentue. */
.ap-recherche-item:hover,
.ap-recherche-item.ap-actif {
    background: #eff6ff;
}
.ap-recherche-item:focus { outline: 0; }
.ap-recherche-item:focus-visible {
    outline: 2px solid var(--ap-primary, #2563eb);
    outline-offset: -2px;
}

.ap-recherche-ref {
    flex-shrink: 0;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    font-variant-numeric: tabular-nums;
}
.ap-recherche-item.ap-actif .ap-recherche-ref,
.ap-recherche-item:hover .ap-recherche-ref { color: #2563eb; }

.ap-recherche-texte { min-width: 0; flex: 1; }

/* display: block indispensable. Ce sont des <span>, donc en ligne par defaut,
   et « overflow: hidden » comme « text-overflow: ellipsis » n'ont AUCUN effet
   sur un element en ligne : le titre et l'extrait se suivaient sur une meme
   ligne et debordaient a droite de la palette, avec une barre de defilement
   horizontale a la cle. Constate a la recette du 27/09/2026. */
.ap-recherche-titre,
.ap-recherche-extrait { display: block; }

.ap-recherche-titre {
    font-size: 13px;
    font-weight: 500;
    color: #0f172a;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ap-recherche-item.ap-actif .ap-recherche-titre,
.ap-recherche-item:hover .ap-recherche-titre { font-weight: 600; }
.ap-recherche-extrait {
    margin-top: 2px;
    font-size: 11.5px;
    color: #64748b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Le terme trouve, mis en evidence sans couleur d'etat. */
.ap-recherche-titre mark,
.ap-recherche-extrait mark {
    background: #fef3c7;
    color: inherit;
    font-weight: 700;
    padding: 0 1px;
    border-radius: 2px;
}

/* ── Messages ─────────────────────────────────────────────── */
.ap-recherche-message {
    padding: 26px 20px;
    text-align: center;
    font-size: 13px;
    color: #64748b;
}
.ap-recherche-message-aide {
    margin-top: 6px;
    font-size: 11.5px;
    color: #94a3b8;
}

/* ── Pied ─────────────────────────────────────────────────── */
.ap-recherche-pied {
    padding: 8px 16px;
    border-top: 1px solid #f1f5f9;
    font-size: 11px;
    color: #94a3b8;
    flex-shrink: 0;
}

@media (max-width: 640px) {
    .ap-recherche { padding: 12px; align-items: stretch; }
    .ap-recherche-boite { max-height: 100%; }
}
