/* =====================================================================
   Barre de commande FiaVia (Ctrl+K)
   =====================================================================
   Autonome : aucune dépendance à Bootstrap au-delà des icônes Remix.
   Les couleurs passent par des variables pour que le thème sombre ne
   soit qu'une redéclaration, jamais une duplication de règles.
   ===================================================================== */

.fv-cmd {
  --fv-bg:        #ffffff;
  --fv-bg-soft:   #f6f7fb;
  --fv-border:    #e6e8f0;
  --fv-text:      #22293c;
  --fv-muted:     #7a839b;
  --fv-accent:    #6366f1;
  --fv-accent-bg: rgba(99, 102, 241, .10);
  --fv-shadow:    0 24px 70px rgba(15, 23, 42, .28);
  --fv-radius:    16px;

  position: fixed;
  inset: 0;
  z-index: 1090; /* au-dessus des dropdowns Bootstrap (1000) et du menu (1080) */
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 8vh 16px 16px;
}

.fv-cmd[hidden] { display: none; }

/* Thème sombre — mêmes deux sélecteurs que le reste du panel. */
html.dark-style .fv-cmd,
html[data-style='dark'] .fv-cmd {
  --fv-bg:        #2b2c40;
  --fv-bg-soft:   #333452;
  --fv-border:    #44465f;
  --fv-text:      #dfdfec;
  --fv-muted:     #a3a4cc;
  --fv-accent:    #8b8fff;
  --fv-accent-bg: rgba(139, 143, 255, .16);
  --fv-shadow:    0 24px 70px rgba(0, 0, 0, .55);
}

.fv-cmd-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(3px);
}

.fv-cmd-dialog {
  position: relative;
  width: 100%;
  max-width: 720px;
  max-height: 78vh;
  display: flex;
  flex-direction: column;
  background: var(--fv-bg);
  color: var(--fv-text);
  border: 1px solid var(--fv-border);
  border-radius: var(--fv-radius);
  box-shadow: var(--fv-shadow);
  overflow: hidden;
  animation: fv-cmd-in .14s ease-out;
}

@keyframes fv-cmd-in {
  from { opacity: 0; transform: translateY(-8px) scale(.985); }
  to   { opacity: 1; transform: none; }
}

/* Le mouvement d'entrée est décoratif : on le supprime pour qui a demandé
   moins d'animations, la modale s'affiche alors instantanément. */
@media (prefers-reduced-motion: reduce) {
  .fv-cmd-dialog { animation: none; }
}

/* ── Champ de saisie ──────────────────────────────────────────────── */

.fv-cmd-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--fv-border);
  flex: 0 0 auto;
}

.fv-cmd-head-icon {
  font-size: 20px;
  color: var(--fv-muted);
  flex: 0 0 auto;
}

.fv-cmd-input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--fv-text);
  font-size: 15.5px;
  line-height: 1.4;
  padding: 2px 0;
}

.fv-cmd-input::placeholder { color: var(--fv-muted); }

.fv-cmd-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--fv-border);
  border-top-color: var(--fv-accent);
  border-radius: 50%;
  animation: fv-cmd-spin .6s linear infinite;
  flex: 0 0 auto;
}

@keyframes fv-cmd-spin { to { transform: rotate(360deg); } }

.fv-cmd-esc {
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 6px;
  border: 1px solid var(--fv-border);
  background: var(--fv-bg-soft);
  color: var(--fv-muted);
  cursor: pointer;
  flex: 0 0 auto;
}

/* ── Pastilles « ce que j'ai compris » ────────────────────────────── */

.fv-cmd-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--fv-border);
  background: var(--fv-bg-soft);
  flex: 0 0 auto;
}

.fv-cmd-chip {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.fv-cmd-chip.t-danger    { background: rgba(255, 62, 29, .12);  color: #d63016; border-color: rgba(255, 62, 29, .22); }
.fv-cmd-chip.t-warning   { background: rgba(255, 171, 0, .14);  color: #b87400; border-color: rgba(255, 171, 0, .26); }
.fv-cmd-chip.t-success   { background: rgba(40, 199, 111, .13); color: #1a9459; border-color: rgba(40, 199, 111, .24); }
.fv-cmd-chip.t-info      { background: rgba(0, 186, 217, .13);  color: #0090a8; border-color: rgba(0, 186, 217, .24); }
.fv-cmd-chip.t-primary   { background: var(--fv-accent-bg);     color: var(--fv-accent); border-color: var(--fv-accent-bg); }
.fv-cmd-chip.t-secondary { background: var(--fv-bg);            color: var(--fv-muted);  border-color: var(--fv-border); }

html.dark-style .fv-cmd-chip.t-danger,
html[data-style='dark'] .fv-cmd-chip.t-danger  { color: #ff8b76; }
html.dark-style .fv-cmd-chip.t-warning,
html[data-style='dark'] .fv-cmd-chip.t-warning { color: #ffc659; }
html.dark-style .fv-cmd-chip.t-success,
html[data-style='dark'] .fv-cmd-chip.t-success { color: #6fdda4; }
html.dark-style .fv-cmd-chip.t-info,
html[data-style='dark'] .fv-cmd-chip.t-info    { color: #5fd8ec; }

/* ── Corps défilant ───────────────────────────────────────────────── */

.fv-cmd-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px 0 10px;
}

.fv-cmd-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 18px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--fv-muted);
}

.fv-cmd-section-more {
  font-size: 11px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--fv-accent);
  text-decoration: none;
  white-space: nowrap;
}

.fv-cmd-section-more:hover { text-decoration: underline; }

/* ── Une ligne de résultat ────────────────────────────────────────── */

.fv-cmd-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 18px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  border-left: 2px solid transparent;
}

.fv-cmd-item:hover,
.fv-cmd-item.is-active {
  background: var(--fv-accent-bg);
  border-left-color: var(--fv-accent);
}

.fv-cmd-avatar {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
}

.fv-cmd-avatar.is-icon {
  background: var(--fv-bg-soft);
  color: var(--fv-muted);
  font-size: 16px;
}

.fv-cmd-item-main {
  flex: 1 1 auto;
  min-width: 0;
}

.fv-cmd-item-title {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fv-cmd-item-sub {
  font-size: 11.5px;
  color: var(--fv-muted);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fv-cmd-item-right {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.fv-cmd-item-meta {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--fv-muted);
  white-space: nowrap;
}

.fv-cmd-badge {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.fv-cmd-badge.t-danger    { background: rgba(255, 62, 29, .14);  color: #d63016; }
.fv-cmd-badge.t-warning   { background: rgba(255, 171, 0, .16);  color: #b87400; }
.fv-cmd-badge.t-success   { background: rgba(40, 199, 111, .15); color: #1a9459; }
.fv-cmd-badge.t-info      { background: rgba(0, 186, 217, .15);  color: #0090a8; }
.fv-cmd-badge.t-primary   { background: var(--fv-accent-bg);     color: var(--fv-accent); }
.fv-cmd-badge.t-secondary { background: var(--fv-bg-soft);       color: var(--fv-muted); }

html.dark-style .fv-cmd-badge.t-danger,
html[data-style='dark'] .fv-cmd-badge.t-danger  { color: #ff8b76; }
html.dark-style .fv-cmd-badge.t-warning,
html[data-style='dark'] .fv-cmd-badge.t-warning { color: #ffc659; }
html.dark-style .fv-cmd-badge.t-success,
html[data-style='dark'] .fv-cmd-badge.t-success { color: #6fdda4; }
html.dark-style .fv-cmd-badge.t-info,
html[data-style='dark'] .fv-cmd-badge.t-info    { color: #5fd8ec; }

/* ── Carte de réponse ─────────────────────────────────────────────── */

.fv-cmd-answer {
  margin: 12px 14px 4px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--fv-border);
  background: linear-gradient(135deg, var(--fv-accent-bg), transparent 70%), var(--fv-bg-soft);
}

.fv-cmd-answer-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.fv-cmd-answer-icon {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  color: #fff;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
}

.fv-cmd-answer-icon.t-danger  { background: linear-gradient(135deg, #ff5b3e, #d63016); }
.fv-cmd-answer-icon.t-warning { background: linear-gradient(135deg, #ffc247, #e08700); }
.fv-cmd-answer-icon.t-success { background: linear-gradient(135deg, #43d391, #1a9459); }
.fv-cmd-answer-icon.t-info    { background: linear-gradient(135deg, #4fd3e8, #0090a8); }

.fv-cmd-answer-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.fv-cmd-answer-sub {
  font-size: 12px;
  color: var(--fv-muted);
  margin-top: 2px;
}

.fv-cmd-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.fv-cmd-stat {
  flex: 1 1 128px;
  min-width: 118px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--fv-bg);
  border: 1px solid var(--fv-border);
}

.fv-cmd-stat-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--fv-muted);
  font-weight: 700;
}

.fv-cmd-stat-value {
  font-size: 14px;
  font-weight: 700;
  margin-top: 2px;
  line-height: 1.25;
}

.fv-cmd-stat-hint {
  font-size: 10.5px;
  color: var(--fv-muted);
  margin-top: 1px;
}

.fv-cmd-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.fv-cmd-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  color: var(--fv-text);
  background: var(--fv-bg);
  border: 1px solid var(--fv-border);
  cursor: pointer;
}

.fv-cmd-action:hover,
.fv-cmd-action.is-active {
  border-color: var(--fv-accent);
  color: var(--fv-accent);
  background: var(--fv-accent-bg);
}

/* ── Raccourcis de l'écran d'accueil ──────────────────────────────── */

.fv-cmd-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 4px 18px 8px;
}

.fv-cmd-shortcut {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  color: var(--fv-text);
  background: var(--fv-bg-soft);
  border: 1px solid var(--fv-border);
  cursor: pointer;
}

.fv-cmd-shortcut:hover,
.fv-cmd-shortcut.is-active {
  border-color: var(--fv-accent);
  background: var(--fv-accent-bg);
}

.fv-cmd-shortcut-count {
  font-size: 11px;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--fv-bg);
  border: 1px solid var(--fv-border);
}

.fv-cmd-shortcut.t-danger  .fv-cmd-shortcut-count { color: #d63016; }
.fv-cmd-shortcut.t-warning .fv-cmd-shortcut-count { color: #b87400; }
.fv-cmd-shortcut.t-info    .fv-cmd-shortcut-count { color: #0090a8; }

html.dark-style .fv-cmd-shortcut.t-danger .fv-cmd-shortcut-count,
html[data-style='dark'] .fv-cmd-shortcut.t-danger .fv-cmd-shortcut-count  { color: #ff8b76; }
html.dark-style .fv-cmd-shortcut.t-warning .fv-cmd-shortcut-count,
html[data-style='dark'] .fv-cmd-shortcut.t-warning .fv-cmd-shortcut-count { color: #ffc659; }
html.dark-style .fv-cmd-shortcut.t-info .fv-cmd-shortcut-count,
html[data-style='dark'] .fv-cmd-shortcut.t-info .fv-cmd-shortcut-count    { color: #5fd8ec; }

/* ── États ────────────────────────────────────────────────────────── */

.fv-cmd-empty {
  padding: 34px 20px;
  text-align: center;
  color: var(--fv-muted);
}

.fv-cmd-empty-icon {
  font-size: 30px;
  opacity: .5;
  display: block;
  margin-bottom: 8px;
}

.fv-cmd-empty-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--fv-text);
}

.fv-cmd-empty-sub {
  font-size: 12px;
  margin-top: 4px;
}

.fv-cmd-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 12px;
}

.fv-cmd-example {
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px dashed var(--fv-border);
  background: transparent;
  color: var(--fv-muted);
  cursor: pointer;
}

.fv-cmd-example:hover {
  border-style: solid;
  border-color: var(--fv-accent);
  color: var(--fv-accent);
}

/* ── Pied ─────────────────────────────────────────────────────────── */

.fv-cmd-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 18px;
  border-top: 1px solid var(--fv-border);
  background: var(--fv-bg-soft);
  font-size: 11px;
  color: var(--fv-muted);
}

.fv-cmd-foot kbd {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--fv-border);
  background: var(--fv-bg);
  color: var(--fv-muted);
  margin-right: 3px;
}

.fv-cmd-took { margin-left: auto; }

/* ── Déclencheur dans la navbar ───────────────────────────────────── */

/* Le déclencheur imite un champ de saisie plutôt que d'être du texte nu :
   c'est ce qui fait comprendre, sans le lire, qu'on peut y chercher quelque
   chose. Il n'en est pas un pour autant — la saisie a lieu dans la modale, et
   un vrai <input> ici obligerait à gérer deux champs concurrents.

   Les variables sont redéclarées localement : celles de `.fv-cmd` sont
   scopées à la modale, or le déclencheur vit dans la navbar, en dehors. */

.fv-cmd-trigger {
  --fvt-bg:        #f6f7fb;
  --fvt-bg-hover:  #ffffff;
  --fvt-border:    #e3e6f0;
  --fvt-border-hi: #c7cbe0;
  --fvt-text:      #7a839b;
  --fvt-icon:      #9aa2b8;
  --fvt-accent:    #6366f1;
  --fvt-kbd-bg:    #ffffff;
  /* Plus soutenu que --fvt-text : le raccourci est écrit en 10,5 px, et le
     gris du libellé n'y atteindrait pas 4,5:1 sur fond blanc. */
  --fvt-kbd-text:  #5b6479;

  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: clamp(210px, 24vw, 360px);
  padding: 7px 8px 7px 12px;
  border: 1px solid var(--fvt-border);
  border-radius: 10px;
  background: var(--fvt-bg);
  color: var(--fvt-text);
  text-decoration: none;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}

html.dark-style .fv-cmd-trigger,
html[data-style='dark'] .fv-cmd-trigger {
  --fvt-bg:        #2f3050;
  --fvt-bg-hover:  #383a5c;
  --fvt-border:    #44465f;
  --fvt-border-hi: #5b5d7d;
  --fvt-text:      #a3a4cc;
  --fvt-icon:      #8f90bd;
  --fvt-accent:    #8b8fff;
  --fvt-kbd-bg:    #24253d;
  --fvt-kbd-text:  #c4c5e8;
}

.fv-cmd-trigger:hover {
  background: var(--fvt-bg-hover);
  border-color: var(--fvt-border-hi);
  box-shadow: 0 2px 10px rgba(15, 23, 42, .06);
  color: var(--fvt-text);
}

.fv-cmd-trigger:focus-visible {
  outline: 0;
  border-color: var(--fvt-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--fvt-accent) 22%, transparent);
}

.fv-cmd-trigger-icon {
  flex: 0 0 auto;
  font-size: 17px;
  color: var(--fvt-icon);
  transition: color .15s ease;
}

.fv-cmd-trigger:hover .fv-cmd-trigger-icon { color: var(--fvt-accent); }

.fv-cmd-trigger-label {
  flex: 1 1 auto;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fv-cmd-trigger-keys {
  flex: 0 0 auto;
  display: flex;
  gap: 3px;
}

/* Le sélecteur descend volontairement depuis `.fv-cmd-trigger` : le thème
   déclare `kbd { color: var(--bs-body-bg); background-color: var(--bs-body-color) }`,
   soit un pavé SOMBRE à texte clair. Une simple classe suffirait à le battre,
   mais ce raccourci vit dans la navbar, au milieu de règles du thème qui
   peuvent gagner en spécificité à la prochaine mise à jour. Deux niveaux
   coûtent zéro et referment la question.

   Chaque propriété héritée du thème est reprise explicitement — fond, couleur,
   police, ombre : n'en redéfinir qu'une partie est précisément ce qui avait
   produit un texte gris sur fond noir. */
.fv-cmd-trigger .fv-cmd-trigger-kbd {
  background-color: var(--fvt-kbd-bg);
  color: var(--fvt-kbd-text);
  border: 1px solid var(--fvt-border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 5px;
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.5;
  box-shadow: none;
}

/* Navbar serrée : le champ se replie sur son icône. Garder les 360 px
   écraserait la cloche des alertes et le sélecteur de langue. */
@media (max-width: 991.98px) {
  .fv-cmd-trigger {
    width: auto;
    padding: 8px;
    border-radius: 50%;
  }
  .fv-cmd-trigger-label,
  .fv-cmd-trigger-keys { display: none; }
}

@media (max-width: 767.98px) {
  .fv-cmd { padding: 0; }
  .fv-cmd-dialog { max-width: none; max-height: 100vh; height: 100%; border-radius: 0; border: 0; }
  .fv-cmd-stat { flex-basis: 100%; }
}
