/* Search dialog + floating button (same file in demat_desktop and demat_mobile; markup html/layouts/demat/recherche.php). */

/* --- Floating button (desktop) --------------------------------------------------------------- */

.recherche-fab {
  position: fixed;
  right: 16px;
  bottom: calc(16px + var(--recherche-decalage, 0px));
  z-index: 1000; /* = .demat-outils, under the cookie bar (99999); recherche.js lifts it above the bar */
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 2px solid var(--blanc-ecume);
  border-radius: 50%;
  color: var(--blanc-ecume);
  background: var(--noir-goemon);
  box-shadow: 0 4px 14px rgba(0, 30, 38, 0.35);
  cursor: pointer;
  transition: transform 0.15s, background 0.15s, opacity 0.2s;
}
.recherche-fab:hover { background: var(--bleu-glaz); transform: scale(1.06); }
.recherche-fab:focus-visible { outline: 3px solid var(--bleu-glaz); outline-offset: 3px; }
body:has(dialog[open]) .recherche-fab,
.recherche-fab.est-masque { opacity: 0; visibility: hidden; pointer-events: none; }

/* --- Dialog ----------------------------------------------------------------------------------- */

.recherche-dialogue {
  width: min(760px, calc(100% - 32px));
  height: min(86vh, 820px);
  max-height: none;
  margin: 7vh auto auto;
  padding: 0;
  border: 0;
  border-radius: var(--rayon);
  background: var(--blanc-ecume);
  color: var(--hermine);
  box-shadow: 0 28px 70px rgba(0, 10, 14, 0.45);
  overflow: hidden;
}
.recherche-dialogue[open] { display: flex; flex-direction: column; animation: rd-entree 160ms ease-out; }
.recherche-dialogue::backdrop { background: rgba(0, 30, 38, 0.62); backdrop-filter: blur(3px); }
@keyframes rd-entree { from { opacity: 0; transform: translateY(10px); } }

.rd-entete { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem 0.5rem; }
.rd-titre { margin: 0; font-size: 1.3rem; }
.rd-fermer {
  width: 44px; height: 44px; margin-right: -0.5rem; border: 0; border-radius: 50%;
  background: none; color: var(--hermine); font-size: 1.9rem; line-height: 1; cursor: pointer;
}
.rd-fermer:hover { background: var(--sable); }

.rd-form { position: relative; margin: 0 1.25rem; }
.rd-loupe { position: absolute; left: 0.9rem; top: 50%; transform: translateY(-50%); color: var(--granit); display: flex; }
.rd-q {
  width: 100%; min-height: 52px; padding: 0.7rem 1rem 0.7rem 2.9rem;
  border: 2px solid var(--noir-goemon); border-radius: 999px; background: #fff; color: var(--hermine);
  font: inherit; font-size: 1.08rem; /* >= 16px: no iOS zoom */
}
.rd-q:focus { outline: none; border-color: var(--bleu-glaz); box-shadow: 0 0 0 3px rgba(14, 125, 140, 0.25); }
.est-en-cours .rd-loupe { color: var(--bleu-glaz); animation: rd-pulse 0.8s ease-in-out infinite alternate; }
@keyframes rd-pulse { to { opacity: 0.35; } }

.rd-filtres { display: grid; gap: 0.55rem; padding: 0.8rem 1.25rem 0.75rem; border-bottom: 1px solid var(--ligne); }
.rd-puces, .rd-champ { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }
.rd-puces .rd-puce { font-size: 0.88rem; }
.rd-ligne { display: flex; flex-wrap: wrap; gap: 0.55rem 1.5rem; }
.rd-champ[hidden] { display: none; }
.rd-libelle { font-size: 0.82rem; font-weight: 700; color: var(--granit); margin-right: 0.15rem; }
.rd-puce {
  min-height: 36px; padding: 0.3rem 0.75rem; border: 1px solid var(--ligne); border-radius: 999px;
  background: #fff; color: var(--hermine); font: inherit; font-size: 0.9rem; cursor: pointer;
}
.rd-puce--petite { min-height: 32px; padding: 0.2rem 0.7rem; font-size: 0.84rem; }
.rd-puce:hover { border-color: var(--bleu-glaz); }
.rd-puce[aria-pressed="true"] { background: var(--noir-goemon); border-color: var(--noir-goemon); color: var(--blanc-ecume); }
.rd-puce[hidden] { display: none; }
.rd-dept {
  min-height: 32px; padding: 0.2rem 1.8rem 0.2rem 0.6rem; border: 1px solid var(--ligne); border-radius: 999px;
  background-color: #fff; color: var(--hermine); font: inherit; font-size: 0.84rem;
}

.recherche-dialogue :focus-visible { outline: 3px solid var(--bleu-glaz); outline-offset: 2px; }

/* Results + empty state: the only scrolling part */
.rd-corps { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0.4rem 1.25rem 1rem; }
.rd-groupe { padding: 0.6rem 0 0.4rem; border-bottom: 1px solid var(--ligne); }
.rd-groupe:last-child { border-bottom: 0; }
.rd-groupe-titre {
  display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.25rem;
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--granit);
}
.rd-compte { padding: 0 0.45rem; border-radius: 999px; background: var(--sable); color: var(--hermine); letter-spacing: 0; }
.rd-option {
  display: block; padding: 0.5rem 0.65rem; margin: 0 -0.65rem; border-radius: 8px;
  color: var(--hermine); text-decoration: none; scroll-margin: 0.5rem;
}
.rd-option:hover, .rd-option.est-actif { background: rgba(14, 125, 140, 0.1); }
.rd-option.est-actif { box-shadow: inset 3px 0 0 var(--bleu-glaz); }
.rd-option-titre { display: block; font-weight: 600; }
.rd-option-titre mark { padding: 0; background: rgba(14, 125, 140, 0.18); color: inherit; }
.rd-option-meta { display: block; margin-top: 0.1rem; font-size: 0.84rem; color: var(--granit); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rd-voir { font-size: 0.88rem; font-weight: 700; color: var(--bleu-glaz); }
.rd-vide { margin: 1.5rem 0; color: var(--granit); }

.rd-accueil-titre { display: flex; align-items: center; justify-content: space-between; margin: 0.9rem 0 0.5rem; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--granit); }
.rd-accueil-titre h3 { margin: 0; font: inherit; }
.rd-effacer { border: 0; background: none; color: var(--bleu-glaz); font: inherit; text-transform: none; letter-spacing: 0; cursor: pointer; text-decoration: underline; min-height: 32px; }
.rd-suggestions { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 0; padding: 0; list-style: none; }
.rd-suggestion {
  min-height: 36px; padding: 0.35rem 0.85rem; border: 1px dashed rgba(0, 30, 38, 0.3); border-radius: 999px;
  background: transparent; color: var(--hermine); font: inherit; font-size: 0.9rem; cursor: pointer;
}
.rd-suggestion:hover { border-style: solid; border-color: var(--bleu-glaz); }
.rd-suggestion--recente::before { content: "↺ "; color: var(--granit); }

.rd-astuce { margin: 0; padding: 0.6rem 1.25rem; border-top: 1px solid var(--ligne); font-size: 0.8rem; color: var(--granit); }
.rd-astuce kbd { font-family: var(--police-donnees); font-size: 0.75rem; padding: 0 0.3em; border: 1px solid var(--ligne); border-radius: 4px; background: #fff; color: var(--hermine); }

/* Phones: full screen, chips scroll sideways, no keyboard hints */
@media (max-width: 700px) {
  .recherche-dialogue { width: 100%; max-width: none; height: 100%; margin: 0; border-radius: 0; padding-top: env(safe-area-inset-top, 0px); }
  .rd-entete, .rd-filtres, .rd-corps { padding-left: 1rem; padding-right: 1rem; }
  .rd-form { margin: 0 1rem; }
  .rd-puces, .rd-champ { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -1rem; padding: 0 1rem; }
  .rd-ligne { display: grid; gap: 0.55rem; }
  .rd-puce, .rd-libelle, .rd-dept { flex: none; }
  .rd-astuce { display: none; }
  .rd-corps { padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); }
}

@media (prefers-reduced-motion: reduce) {
  .recherche-fab { transition: none; }
  .recherche-fab:hover { transform: none; }
  .recherche-dialogue[open], .est-en-cours .rd-loupe { animation: none; }
}

@media print { .recherche-fab, .recherche-dialogue { display: none !important; } }
