/* Palette de recherche ⌘K, créée dans <body> par static/js/components/command_palette.js.
   Le déclencheur du header (.app-cmdk-trigger) et les touches (.app-kbd) sont dans theme.css. */

html.cmdk-open,
html.cmdk-open body {
  overflow: hidden;
}

.cmdk-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1090;
  background: var(--app-overlay-backdrop);
}

.cmdk {
  position: fixed;
  z-index: 1091;
  top: 88px;
  left: 50%;
  display: flex;
  flex-direction: column;
  width: min(680px, calc(100vw - 24px));
  max-height: calc(100vh - 112px);
  max-height: calc(100dvh - 112px);
  overflow: hidden;
  border: 1px solid var(--app-control-border);
  border-radius: var(--app-radius-card);
  background: var(--app-card-bg-strong);
  color: var(--app-title-color);
  box-shadow: var(--app-float-shadow);
  transform: translateX(-50%);
}

.cmdk-input-row {
  display: flex;
  flex: none;
  align-items: center;
  gap: 12px;
  height: 58px;
  padding: 0 16px;
  border-bottom: 1px solid var(--app-separator);
  color: var(--app-muted-color);
}

.cmdk-input-row > i {
  font-size: 1.2rem;
  line-height: 1;
}

.cmdk-input {
  flex-grow: 1;
  min-width: 0;
  height: 40px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--app-title-color);
  font: inherit;
  font-size: var(--app-fs-lg);
}

.cmdk-input::placeholder {
  color: var(--app-muted-color);
}

.cmdk-esc {
  cursor: pointer;
}

/* Catégories */
/* Les catégories (.app-chip) sur une ligne, qui défile de côté si elles ne tiennent pas. */
.cmdk-chips {
  display: flex;
  flex: none;
  gap: 4px;
  padding: 10px 16px;
  overflow-x: auto;
  border-bottom: 1px solid var(--app-separator);
  scrollbar-width: none;
}

/* Résultats */
.cmdk-results {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 6px 8px 8px;
  overflow-y: auto;
}

.cmdk-group-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 10px 4px;
}

.cmdk-group-head span:last-child:not(:first-child) {
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.cmdk-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--app-radius);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.cmdk-item:hover,
.cmdk-item:focus-visible {
  text-decoration: none;
  outline: 0;
}

.cmdk-item.is-active {
  background: var(--app-primary-tint);
}

/* Un contact : ses initiales dans la puce, plus petites que les icônes. */
.cmdk-icon-initiales {
  font-size: var(--app-fs-xs);
  font-weight: 700;
}

.cmdk-title,
.cmdk-sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cmdk-sub {
  color: var(--app-muted-color);
  font-size: var(--app-fs-sm);
}

.cmdk-typo {
  flex: none;
}

/* Le numéro d'un client ou d'un contact, lisible sans ouvrir sa fiche ; l'icône le copie. */
.cmdk-tel {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 4px;
  color: var(--app-body-color);
  font-size: var(--app-fs-base);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cmdk-copy {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--app-radius-xs);
  color: var(--app-muted-color);
  font-size: var(--app-fs-sm);
  cursor: copy;
}

.cmdk-copy:hover {
  background: var(--app-control-hover);
  color: var(--app-title-color);
}

.cmdk-tel.is-copie {
  gap: 6px;
  height: 26px;
  padding: 0 8px;
  border-radius: var(--app-radius-sm);
  background: var(--app-success-bg);
  color: var(--app-success-text);
  font-size: var(--app-fs-sm);
  font-weight: 600;
}

.cmdk-open-hint {
  display: none;
  flex: none;
  align-items: center;
  gap: 6px;
  color: var(--app-muted-color);
  font-size: var(--app-fs-xs);
  white-space: nowrap;
}

.cmdk-item.is-active .cmdk-open-hint {
  display: flex;
}

.cmdk-more {
  display: block;
  padding: 4px 10px 6px 54px;
  color: var(--app-primary);
  font-size: var(--app-fs-sm);
  font-weight: 600;
}

span.cmdk-more {
  color: var(--app-muted-color);
  font-weight: 500;
}

.cmdk-approx {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 2px 2px;
  padding: 8px 12px;
  border-radius: var(--app-radius);
  background: var(--app-accent-bg);
  color: var(--app-accent-text);
  font-size: var(--app-fs-sm);
}

.cmdk-empty {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 28px 16px;
  color: var(--app-muted-strong);
  font-size: var(--app-fs-base);
  text-align: center;
}

.cmdk-empty strong {
  color: var(--app-title-color);
  font-weight: 600;
}

.cmdk-tip {
  margin: 8px 2px 2px;
}

.cmdk-approx > i {
  flex: none;
  margin-top: 1px;
}

/* Pied : rappel des touches */
.cmdk-footer {
  display: flex;
  flex: none;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  border-top: 1px solid var(--app-separator);
  background: var(--app-surface-soft);
  color: var(--app-muted-color);
  font-size: var(--app-fs-xs);
}

.cmdk-footer > span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.cmdk-footer-text {
  margin-left: 2px;
}

.cmdk-footer-right {
  margin-left: auto;
}

@media (max-width: 767.98px) {
  .cmdk {
    top: 12px;
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
  }

  .cmdk-footer,
  .cmdk-open-hint {
    display: none;
  }

  .cmdk-item.is-active .cmdk-open-hint {
    display: none;
  }
}
