/* Les contrôles natifs conservent les liaisons Blazor et la navigation au clavier. */
:root {
  --select-accent: #315d4f;
  --select-ink: #263d34;
  --select-border: #d5e1d9;
  --select-tint: #edf5ef;
}

:where(.portal-theme-discovery, .portal-theme-organizer, .org-shell, .organizer-space-switcher) {
  --select-accent: #1f6fd6;
  --select-ink: #254363;
  --select-border: #d6e5f5;
  --select-tint: #ebf5ff;
}

:where(.portal-theme-provider, .provider-dashboard-frame, .provider-listing-editor) {
  --select-accent: #327245;
  --select-ink: #2c4938;
  --select-border: #d5e3d7;
  --select-tint: #edf6ef;
}

:where(.portal-theme-public) {
  --select-accent: #6547da;
  --select-ink: #463763;
  --select-border: #e2daf3;
  --select-tint: #f3efff;
}

:where(.portal-theme-julia) {
  --select-accent: #bc326b;
  --select-ink: #67354c;
  --select-border: #f0d7e3;
  --select-tint: #fff0f7;
}

html body select:not([multiple]):not([data-native-select]):is(:not([size]), [size="1"]) {
  appearance: none;
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
  min-height: 40px;
  padding: 10px 40px 10px 14px;
  border: 1px solid var(--select-border);
  border-radius: 12px;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' viewBox='0 0 24 24'%3E%3Cpath d='m7 10 5 5 5-5' stroke='%2365756d' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  background-size: 16px;
  color: var(--select-ink);
  font-family: inherit;
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

html body select:not([multiple]):not([data-native-select]):hover:not(:disabled) {
  border-color: var(--select-accent);
  background-color: var(--select-tint);
}

html body select:not([multiple]):not([data-native-select]):focus-visible {
  outline: 2px solid var(--select-accent);
  outline-offset: 3px;
  border-color: var(--select-accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--select-accent) 12%, transparent);
}

html body select:not([multiple]):not([data-native-select]):disabled {
  background-color: #f3f5f4;
  color: #7a8680;
  opacity: 0.7;
  cursor: not-allowed;
}

html body select:not([multiple]):not([data-native-select]):is(.invalid, [aria-invalid="true"], :user-invalid) {
  border-color: #bd4453;
}

/* Les champs accolés à un bouton gardent leur silhouette commune. */
html body .org-space-selector select:not([multiple]):not([data-native-select]),
html body .editor-add-chip select:not([multiple]):not([data-native-select]) {
  border-start-end-radius: 0;
  border-end-end-radius: 0;
}

html body #organizer-preparation .org-task-options select {
  padding-inline-end: 40px;
}

/* Le menu s'affiche dans la couche supérieure, sans être coupé par les cartes. */
@supports (appearance: base-select) and selector(select::picker(select)) {
  html body select:not([multiple]):not([data-native-select]):is(:not([size]), [size="1"]),
  html body select:not([multiple]):not([data-native-select]):is(:not([size]), [size="1"])::picker(select) {
    appearance: base-select;
  }

  html body select:not([multiple]):not([data-native-select]):is(:not([size]), [size="1"]) {
    align-items: center;
    gap: 12px;
    padding-inline-end: 14px;
    background-image: none;
  }

  html body #organizer-preparation .org-task-options select {
    padding-inline-end: 14px;
  }

  html body select:not([multiple]):not([data-native-select])::picker-icon {
    display: block;
    align-self: center;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin-block: 0;
    margin-inline-start: auto;
    color: var(--select-accent);
    background-color: currentColor;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
    content: "";
    transition: rotate 160ms ease;
  }

  html body select:not([multiple]):not([data-native-select]):open {
    border-color: var(--select-accent);
    background-color: #fff;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--select-accent) 12%, transparent);
  }

  html body select:not([multiple]):not([data-native-select]):open::picker-icon {
    rotate: 180deg;
  }

  html body select:not([multiple]):not([data-native-select])::picker(select) {
    box-sizing: border-box;
    inline-size: max-content;
    min-inline-size: anchor-size(width);
    max-inline-size: calc(100vw - 24px);
    position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline;
    max-block-size: min(24rem, 60dvh);
    margin-block: 8px;
    padding: 6px;
    border: 1px solid var(--select-border);
    border-radius: 16px;
    background: #fff;
    color: var(--select-ink);
    box-shadow: 0 16px 48px #1d352324, 0 3px 10px #1d35230a;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--select-border) transparent;
    font-family: inherit;
    font-size: 14px;
    text-align: start;
  }

  html body select:not([multiple]):not([data-native-select]) option {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 36px;
    margin: 2px 0;
    padding: 7px 10px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: #fff;
    color: var(--select-ink);
    font-size: 13px;
    font-weight: 400;
    line-height: 1.5;
    white-space: normal;
    overflow-wrap: anywhere;
    cursor: pointer;
  }

  html body select:not([multiple]):not([data-native-select]) option:is(:hover, :focus-visible):not(:disabled) {
    outline: none;
    border-color: var(--select-border);
    background: var(--select-tint);
  }

  html body select:not([multiple]):not([data-native-select]) option:checked {
    background: var(--select-tint);
    color: var(--select-accent);
    font-weight: 600;
  }

  html body select:not([multiple]):not([data-native-select]) option::checkmark {
    order: 1;
    margin-inline-start: auto;
    color: var(--select-accent);
    font-size: 14px;
    content: "✓";
  }

  html body select:not([multiple]):not([data-native-select]) option:disabled {
    color: #8a938e;
    cursor: not-allowed;
  }

  html body select:not([multiple]):not([data-native-select]) optgroup {
    padding: 6px;
    color: #6b7b73;
    font-size: 12px;
    font-weight: 600;
  }
}

@media (max-width: 700px) {
  html body select:not([multiple]):not([data-native-select]):is(:not([size]), [size="1"]) {
    min-height: 44px;
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html body select:not([data-native-select]),
  html body select:not([data-native-select])::picker-icon {
    transition: none;
  }
}

@media (forced-colors: active) {
  html body select:not([multiple]):not([data-native-select]):is(:not([size]), [size="1"]) {
    border-color: ButtonText;
  }

  html body select:not([multiple]):not([data-native-select]):focus-visible {
    outline-color: Highlight;
  }
}
