/*
 * Lot 18 — productivity: command palette (Ctrl+K), keyboard shortcuts (help, sequence hint), exports page, menus
 * showing their keys. Tokens only (tokens.css); light and dark follow automatically.
 */

/* ---------- Command palette ---------- */
.yb-palette.mud-dialog {
  max-width: 680px;
  margin-top: 10vh;
  overflow: hidden;
  border: 1px solid var(--yb-border);
  border-radius: var(--yb-radius-lg);
  background: var(--yb-surface-raised);
  box-shadow: var(--yb-shadow-lg);
}

.yb-palette .yb-search-dialog__content.mud-dialog-content {
  display: flex;
  flex-direction: column;
  padding: 0;
}

.yb-palette__field {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--yb-space-3);
  height: 60px;
  padding: 0 var(--yb-space-3) 0 var(--yb-space-5);
  border-bottom: 1px solid var(--yb-border);
}

.yb-palette__search-icon.mud-icon-root {
  flex: none;
  color: var(--yb-primary);
  font-size: 22px;
}

.yb-palette__input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: none;
  color: var(--yb-text);
  font: inherit;
  font-size: 1.0625rem;
  letter-spacing: -0.005em;
  outline: none;
}

.yb-palette__input::placeholder {
  color: var(--yb-text-muted);
}

/* Searching: a thin petrol line under the field instead of a spinner. */
.yb-palette__busy {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  overflow: hidden;
}

.yb-palette__busy::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 30%;
  background: var(--yb-primary);
  animation: yb-palette-busy 900ms var(--yb-ease) infinite;
}

@keyframes yb-palette-busy {
  from { transform: translateX(-100%); }
  to { transform: translateX(340%); }
}

@media (prefers-reduced-motion: reduce) {
  .yb-palette__busy::after {
    width: 100%;
    animation: none;
    opacity: 0.5;
  }
}

.yb-palette__close {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  border: 0;
  border-radius: var(--yb-radius-sm);
  background: none;
  color: var(--yb-text-muted);
  cursor: pointer;
}

.yb-palette__close:hover {
  background: var(--yb-hover);
}

.yb-palette__close:focus-visible {
  outline: 2px solid var(--yb-focus);
  outline-offset: 2px;
}

.yb-palette__results {
  max-height: min(540px, 64vh);
  padding: var(--yb-space-2) var(--yb-space-2) var(--yb-space-3);
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding: var(--yb-space-8) 0 var(--yb-space-2);
}

.yb-palette__group + .yb-palette__group {
  margin-top: var(--yb-space-2);
}

.yb-palette__group-title {
  margin: 0;
  padding: var(--yb-space-2) var(--yb-space-3) var(--yb-space-1);
  color: var(--yb-text-muted);
  font-size: var(--yb-text-caption);
  font-weight: var(--yb-weight-medium);
  line-height: var(--yb-leading-caption);
}

.yb-palette__option {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--yb-space-3);
  min-height: 48px;
  padding: var(--yb-space-1) var(--yb-space-3);
  border-radius: var(--yb-radius-sm);
  color: var(--yb-text);
  cursor: pointer;
}

.yb-palette__option.is-active {
  background: var(--yb-selected);
}

/* The active option carries a petrol edge: visible without relying on the tint alone. */
.yb-palette__option.is-active::before {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 0;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--yb-primary);
}

.yb-palette__icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--yb-bg-sunken);
  color: var(--yb-text-muted);
}

.yb-palette__icon .mud-icon-root {
  font-size: 18px;
}

/* Actions are what the palette is for: saffron, the "à faire" colour of the design system. */
.yb-palette__icon--actions {
  background: var(--yb-accent-soft);
  color: var(--yb-on-accent-soft);
}

.yb-palette__icon--invoices,
.yb-palette__icon--quotes {
  background: var(--yb-primary-soft);
  color: var(--yb-on-primary-soft);
}

.yb-palette__text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.yb-palette__title,
.yb-palette__meta {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.yb-palette__title {
  font-weight: var(--yb-weight-medium);
}

.yb-palette__meta {
  color: var(--yb-text-muted);
  font-size: var(--yb-text-caption);
  line-height: var(--yb-leading-caption);
}

.yb-palette__aside {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: var(--yb-space-2);
}

.yb-palette__amount {
  min-width: 6.5em;
  text-align: right;
}

.yb-palette__keys {
  opacity: 0.85;
}

.yb-palette__enter {
  visibility: hidden;
}

.yb-palette__option.is-active .yb-palette__enter {
  visibility: visible;
  border-color: var(--yb-primary);
  color: var(--yb-primary);
}

.yb-palette__empty {
  padding: var(--yb-space-8) var(--yb-space-6);
  text-align: center;
}

.yb-palette__empty-title {
  margin: 0 0 var(--yb-space-1);
  font-weight: var(--yb-weight-strong);
  overflow-wrap: anywhere;
}

.yb-palette__empty-text {
  max-width: 44ch;
  margin: 0 auto;
  color: var(--yb-text-muted);
}

.yb-palette__footer {
  display: flex;
  align-items: center;
  gap: var(--yb-space-5);
  min-height: 40px;
  padding: 0 var(--yb-space-5);
  border-top: 1px solid var(--yb-border);
  background: var(--yb-bg-sunken);
  color: var(--yb-text-muted);
  font-size: var(--yb-text-caption);
}

.yb-palette__footer > span,
.yb-palette__help {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.yb-palette__help {
  margin-left: auto;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.yb-palette__help:hover {
  color: var(--yb-text);
}

@media (max-width: 599px) {
  .mud-dialog-container:has(.yb-palette) {
    padding: 0;
  }

  .yb-palette.mud-dialog {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .yb-palette .yb-search-dialog__content.mud-dialog-content {
    height: 100%;
  }

  .yb-palette__field {
    height: 56px;
    padding-left: var(--yb-space-4);
  }

  .yb-palette__results {
    flex: 1;
    max-height: none;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .yb-palette__option {
    min-height: 52px;
  }

  .yb-palette__keys,
  .yb-palette__enter {
    display: none;
  }

  .yb-palette__amount {
    min-width: 0;
  }

  .yb-palette__aside .yb-status {
    display: none;
  }
}

/* ---------- Sequence hint ("G" … then F) ---------- */
.yb-sequence-hint {
  position: fixed;
  bottom: var(--yb-space-6);
  left: 50%;
  z-index: 1500;
  display: flex;
  align-items: center;
  gap: var(--yb-space-4);
  max-width: calc(100vw - 2 * var(--yb-space-4));
  padding: var(--yb-space-2) var(--yb-space-4);
  border-radius: var(--yb-radius-md);
  background: var(--yb-brand-surface);
  color: var(--yb-on-brand);
  box-shadow: var(--yb-shadow-lg);
  font-size: var(--yb-text-caption);
  transform: translateX(-50%);
  animation: yb-hint-in var(--yb-duration-fast) var(--yb-ease);
}

@keyframes yb-hint-in {
  from { opacity: 0; transform: translate(-50%, 6px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .yb-sequence-hint {
    animation: none;
  }
}

.yb-sequence-hint kbd {
  border-color: rgb(255 255 255 / 0.28);
  background: rgb(255 255 255 / 0.08);
  color: var(--yb-on-brand);
}

.yb-sequence-hint__lead {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: var(--yb-space-2);
  margin: 0;
  font-weight: var(--yb-weight-strong);
}

.yb-sequence-hint__lead kbd {
  border-color: var(--yb-accent);
  background: var(--yb-accent);
  color: var(--yb-on-accent);
}

.yb-sequence-hint__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--yb-space-1) var(--yb-space-4);
  margin: 0;
  padding: 0 0 0 var(--yb-space-4);
  border-left: 1px solid rgb(255 255 255 / 0.18);
  list-style: none;
}

.yb-sequence-hint__list li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--yb-on-brand-muted);
}

/* ---------- Keyboard shortcuts help ---------- */
.yb-help-dialog .mud-dialog-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.yb-help-dialog__lead {
  color: var(--yb-text-muted);
  font-size: var(--yb-text-body);
  font-weight: var(--yb-weight-regular);
}

.yb-help {
  columns: 2 300px;
  column-gap: var(--yb-space-8);
}

.yb-help__group {
  break-inside: avoid;
  margin-bottom: var(--yb-space-6);
}

.yb-help__title {
  margin: 0 0 var(--yb-space-2);
  font-size: var(--yb-text-title-3);
  font-weight: var(--yb-weight-title-3);
  line-height: var(--yb-leading-title-3);
}

.yb-help__list {
  margin: 0;
}

.yb-help__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--yb-space-4);
  min-height: 36px;
  border-bottom: 1px solid var(--yb-border);
}

.yb-help__row:last-child {
  border-bottom: 0;
}

.yb-help__row dt {
  color: var(--yb-text);
}

.yb-help__row dd {
  flex: none;
  margin: 0;
}

.yb-shortcut__then,
.yb-shortcut__or {
  align-self: center;
  margin: 0 2px;
  color: var(--yb-text-muted);
  font-size: var(--yb-text-caption);
}

/* Keys in menus (Nouveau ▾): pushed to the right, quiet. */
.yb-menu-shortcut__keys kbd {
  min-width: 18px;
  height: 18px;
  font-size: 0.6875rem;
}

/* ---------- Exports page ---------- */
.yb-exports {
  display: flex;
  flex-direction: column;
  gap: var(--yb-space-6);
  max-width: 1080px;
}

.yb-exports__heading {
  margin: 0;
  font-size: var(--yb-text-title-2);
  font-weight: var(--yb-weight-title-2);
  line-height: var(--yb-leading-title-2);
  letter-spacing: var(--yb-tracking-title-2);
}

.yb-exports__period {
  border: 1px solid var(--yb-border);
  border-radius: var(--yb-radius-md);
  background: var(--yb-surface);
}

.yb-exports__period-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--yb-space-3) var(--yb-space-4);
  padding: var(--yb-space-4) var(--yb-space-5);
  border-bottom: 1px solid var(--yb-border);
}

.yb-exports__picker .yb-period__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.yb-export-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.yb-export-row {
  display: grid;
  /* D496: the count column has a bounded width; its text wraps instead of crushing the title and its description. */
  grid-template-columns: 40px minmax(0, 1fr) minmax(12rem, 20rem) 11rem;
  align-items: center;
  gap: var(--yb-space-4);
  padding: var(--yb-space-4) var(--yb-space-5);
}

.yb-export-row + .yb-export-row {
  border-top: 1px solid var(--yb-border);
}

.yb-export-row__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--yb-radius-sm);
  background: var(--yb-primary-soft);
  color: var(--yb-on-primary-soft);
}

.yb-export-row__title {
  margin: 0;
  font-size: var(--yb-text-title-3);
  font-weight: var(--yb-weight-title-3);
  line-height: var(--yb-leading-title-3);
}

.yb-export-row__desc {
  margin: 2px 0 0;
  color: var(--yb-text-muted);
  font-size: var(--yb-text-caption);
  line-height: var(--yb-leading-caption);
}

.yb-export-row__count {
  margin: 0;
  color: var(--yb-text);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* « montant TVA comprise, sans les factures annulées » under the count, in grey. */
.yb-export-row__note {
  display: block;
  color: var(--yb-text-muted);
  font-size: var(--yb-text-caption);
  line-height: var(--yb-leading-caption);
}

.yb-export-row__actions {
  display: flex;
  justify-content: flex-start;
  gap: var(--yb-space-2);
}

.yb-exports__error {
  display: flex;
  align-items: center;
  gap: var(--yb-space-2);
  margin: 0;
  padding: var(--yb-space-3) var(--yb-space-5);
  border-top: 1px solid var(--yb-border);
  color: var(--yb-error);
}

/* The fiduciary package: a folder with a saffron tab and its packing list. */
.yb-fiduciary {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: var(--yb-space-6) var(--yb-space-8);
  padding: var(--yb-space-6);
  border: 1px solid var(--yb-border);
  border-top: 4px solid var(--yb-accent);
  border-radius: var(--yb-radius-md);
  background: var(--yb-surface);
}

.yb-fiduciary__intro {
  display: flex;
  align-items: flex-start;
  gap: var(--yb-space-4);
}

.yb-fiduciary__icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--yb-radius-sm);
  background: var(--yb-accent-soft);
  color: var(--yb-on-accent-soft);
}

.yb-fiduciary__lead {
  max-width: 40ch;
  margin: var(--yb-space-1) 0 0;
  color: var(--yb-text-muted);
}

.yb-fiduciary__none {
  margin: 0;
  color: var(--yb-text-muted);
}

.yb-fiduciary__body {
  display: flex;
  flex-direction: column;
  gap: var(--yb-space-4);
  min-width: 0;
}

.yb-fiduciary__choose {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--yb-space-3);
}

.yb-fiduciary__label {
  font-weight: var(--yb-weight-medium);
}

.yb-fiduciary__select {
  min-width: 16rem;
}

.yb-fiduciary__select select {
  height: 40px;
  font-size: var(--yb-text-body);
}

/* Packing list: label, dotted leader, value. */

/* The sentence and its link wrap beside the icon (a phone), never under it. */

.yb-fiduciary__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--yb-space-3) var(--yb-space-4);
}

.yb-fiduciary__hint {
  color: var(--yb-text-muted);
  font-size: var(--yb-text-caption);
}

@media (max-width: 1023px) {
  .yb-fiduciary {
    grid-template-columns: minmax(0, 1fr);
  }

  .yb-export-row {
    grid-template-columns: 40px minmax(0, 1fr) auto;
  }

  .yb-export-row__count {
    grid-column: 2;
    text-align: left;
  }

  .yb-export-row__actions {
    grid-column: 3;
    grid-row: 1 / span 2;
  }
}

@media (max-width: 599px) {
  .yb-exports__period-head,
  .yb-export-row {
    padding-right: var(--yb-space-4);
    padding-left: var(--yb-space-4);
  }

  .yb-export-row {
    grid-template-columns: 40px minmax(0, 1fr);
    gap: var(--yb-space-2) var(--yb-space-3);
  }

  .yb-export-row__count {
    grid-column: 2;
  }

  .yb-export-row__actions {
    grid-column: 2;
    grid-row: auto;
    justify-content: flex-start;
  }

  .yb-fiduciary {
    padding: var(--yb-space-4);
  }

  .yb-fiduciary__select {
    width: 100%;
    min-width: 0;
  }
}

/* Lot 28b (D268): the movements of the bank of the fiduciary package, in one line. */

/* Audit UX, page 19: « CSV » reads as something to click (a link beside « Excel »); the way to « Fin d'année » fills a phone line. */
.yb-exports__csv.mud-button-root {
  color: var(--yb-link, var(--yb-primary));
  text-decoration: underline;
  text-underline-offset: 3px;
}

@media (max-width: 767.98px) {
  .yb-fiduciary__actions .mud-button-root {
    flex: 1 1 auto;
  }
}
