/* Push Recharts legends to the right and a bit lower while keeping wrapping stable. */
.recharts-wrapper .recharts-legend-wrapper {
  width: 100% !important;
  max-width: calc(100% - 2rem) !important;
  left: 0 !important;
  right: 0 !important;
  bottom: -0.15rem !important;
}

.recharts-wrapper .recharts-default-legend {
  display: flex !important;
  flex-wrap: wrap !important;
  justify-content: flex-end !important;
  align-items: center !important;
  gap: 0.35rem 1rem !important;
  width: 100% !important;
  padding: 0.15rem 0 0 !important;
  margin: 0 auto !important;
  line-height: 1.15 !important;
  white-space: normal !important;
  text-align: right !important;
}

.recharts-wrapper .recharts-default-legend .recharts-legend-item {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 0.35rem !important;
  margin-right: 0 !important;
  max-width: 14rem !important;
  white-space: normal !important;
  vertical-align: top !important;
}

.recharts-wrapper .recharts-default-legend .recharts-legend-item-text {
  display: inline-block !important;
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  text-align: right !important;
  line-height: 1.15 !important;
}

.recharts-wrapper .recharts-default-legend .recharts-surface {
  flex: 0 0 auto !important;
}

/* Ne garder visibles que Active et Suspended dans le dropdown */
body:has(a[aria-current="page"][href="/prompts"]):has(
    [data-testid="connectors-status-filter"][aria-expanded="true"]
  )
  [data-radix-popper-content-wrapper]
  [role="listbox"][data-state="open"]
  [data-radix-select-viewport]
  > [role="option"]:not(:nth-child(1)):not(:nth-child(2)):not(:nth-child(3)) {
  display: none !important;
}

/* Optionnel : éviter une zone scrollable inutile */
body:has(a[aria-current="page"][href="/prompts"])
  [data-radix-popper-content-wrapper]
  [role="listbox"][data-state="open"]
  [data-radix-select-viewport] {
  height: auto !important;
  overflow-y: hidden !important;
}

/* Ne garder visibles que All et les 3 derniers qui dans le dropdown */

body:has(a[aria-current="page"][href="/items"])
  [data-radix-popper-content-wrapper]
  [role="listbox"][data-state="open"]
  [data-radix-select-viewport]
  > [role="option"]:not(:first-child):not(:nth-child(2)):not(
    :nth-last-child(-n + 6)
  ) {
  display: none !important;
}
body:has(a[aria-current="page"][href="/items"])
  [data-radix-popper-content-wrapper]
  [role="listbox"][data-state="open"]
  [data-radix-select-viewport] {
  height: auto !important;
  overflow-y: hidden !important;
}

/* Page /prompts : cacher le bloc Description dans la modal */
body:has(a[aria-current="page"][href="/prompts"])
  div:has(> label[for="source-description"]) {
  display: none !important;
}

/* Page /prompts : masquer l'action Sync sur les cartes de prompts */
body:has(a[aria-current="page"][href="/prompts"])
  button:has(svg.lucide-refresh-cw) {
  display: none !important;
}
