/* —— Native <select> polish (all app selects except auth) —— */
select:not(.phr-auth-select) {
  appearance: none;
  -webkit-appearance: none;
  color-scheme: inherit;
  min-height: 2.5rem;
  border-radius: 0.75rem;
  border: 1px solid hsl(var(--border) / 0.9);
  background-color: hsl(var(--card));
  background-image:
    linear-gradient(180deg, hsl(var(--foreground) / 0.03), transparent 55%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.25'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat, no-repeat;
  background-position: 0 0, right 0.7rem center;
  background-size: auto, 1rem;
  color: hsl(var(--foreground));
  padding: 0.45rem 2.35rem 0.45rem 0.85rem;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  box-shadow:
    0 1px 0 hsl(var(--foreground) / 0.04) inset,
    0 1px 2px hsl(0 0% 0% / 0.04);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background-color 0.15s ease;
  cursor: pointer;
}

html.dark select:not(.phr-auth-select),
html:not(.light) select:not(.phr-auth-select) {
  border-color: hsl(0 0% 100% / 0.12);
  background-color: hsl(var(--card));
  background-image:
    linear-gradient(180deg, hsl(0 0% 100% / 0.06), transparent 55%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2.25'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat, no-repeat;
  background-position: 0 0, right 0.7rem center;
  background-size: auto, 1rem;
  box-shadow:
    0 1px 0 hsl(0 0% 100% / 0.05) inset,
    0 6px 16px hsl(0 0% 0% / 0.18);
  color-scheme: dark;
}

select:not(.phr-auth-select):hover:not(:disabled) {
  border-color: hsl(var(--foreground) / 0.28);
}

html.dark select:not(.phr-auth-select):hover:not(:disabled),
html:not(.light) select:not(.phr-auth-select):hover:not(:disabled) {
  border-color: hsl(0 0% 100% / 0.28);
}

select:not(.phr-auth-select):focus,
select:not(.phr-auth-select):focus-visible {
  outline: none;
  border-color: hsl(var(--ring) / 0.65);
  box-shadow:
    0 0 0 3px hsl(var(--ring) / 0.18),
    0 1px 0 hsl(var(--foreground) / 0.04) inset;
}

select:not(.phr-auth-select):disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

select:not(.phr-auth-select) option {
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  font-weight: 500;
}

/* Legacy helper class — keep in sync with native polish */
.ww-select {
  appearance: none;
  -webkit-appearance: none;
  background-color: hsl(var(--card));
  color: hsl(var(--foreground));
  border-radius: 0.75rem;
  padding-right: 2.35rem;
}

/* —— Custom Select component —— */
.ww-select-field {
  /* Prefer Tailwind width utilities from ClassName. Do not force width:100% here —
     this stylesheet loads after app.css and was overriding sm:w-[180px], pushing
     sibling create buttons off-screen (body overflow-x:hidden). */
  position: relative;
  max-width: 100%;
}

.ww-select-field.w-full {
  width: 100%;
}

.ww-select-trigger {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  border-radius: 0.75rem;
  border: 1px solid hsl(var(--border) / 0.9);
  background:
    linear-gradient(180deg, hsl(var(--foreground) / 0.03), transparent 55%),
    hsl(var(--card));
  color: hsl(var(--foreground));
  box-shadow:
    0 1px 0 hsl(var(--foreground) / 0.04) inset,
    0 1px 2px hsl(0 0% 0% / 0.04);
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    box-shadow 0.15s ease;
}

html.dark .ww-select-trigger,
html:not(.light) .ww-select-trigger {
  border-color: hsl(0 0% 100% / 0.12);
  background:
    linear-gradient(180deg, hsl(0 0% 100% / 0.06), hsl(0 0% 100% / 0.02)),
    hsl(var(--card));
  box-shadow:
    0 1px 0 hsl(0 0% 100% / 0.05) inset,
    0 6px 16px hsl(0 0% 0% / 0.18);
}

.ww-select-trigger.is-md {
  min-height: 2.5rem;
  padding: 0.45rem 0.55rem 0.45rem 0.85rem;
  font-size: 0.875rem;
}

.ww-select-trigger.is-sm {
  min-height: 2.25rem;
  padding: 0.35rem 0.45rem 0.35rem 0.75rem;
  font-size: 0.8125rem;
}

.ww-select-trigger:hover:not(:disabled) {
  border-color: hsl(var(--foreground) / 0.28);
}

html.dark .ww-select-trigger:hover:not(:disabled),
html:not(.light) .ww-select-trigger:hover:not(:disabled) {
  border-color: hsl(0 0% 100% / 0.28);
}

.ww-select-field.is-open .ww-select-trigger {
  border-color: hsl(var(--ring) / 0.65);
  box-shadow:
    0 0 0 3px hsl(var(--ring) / 0.18),
    0 1px 0 hsl(var(--foreground) / 0.04) inset;
}

.ww-select-trigger:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.ww-select-value {
  min-width: 0;
  flex: 1;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  overflow: hidden;
  text-align: left;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.ww-select-value-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ww-select-value.is-placeholder {
  font-weight: 500;
  color: hsl(var(--muted-foreground));
}

.ww-select-avatar {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 9999px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--muted));
  object-fit: cover;
  flex-shrink: 0;
}

.ww-select-avatar.is-sm {
  width: 1.5rem;
  height: 1.5rem;
}

.ww-select-avatar.is-initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: hsl(var(--muted-foreground));
  line-height: 1;
}

.ww-select-chevron {
  display: inline-flex;
  width: 1.6rem;
  height: 1.6rem;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  border: 1px solid hsl(var(--border) / 0.8);
  background: hsl(var(--muted) / 0.45);
  color: hsl(var(--muted-foreground));
  transition: transform 0.2s ease, background 0.15s ease, color 0.15s ease;
}

html.dark .ww-select-chevron,
html:not(.light) .ww-select-chevron {
  border-color: hsl(0 0% 100% / 0.1);
  background: hsl(0 0% 100% / 0.05);
}

.ww-select-chevron svg {
  width: 0.85rem;
  height: 0.85rem;
}

.ww-select-field.is-open .ww-select-chevron {
  transform: rotate(180deg);
  color: hsl(var(--foreground));
}

.ww-select-clear {
  display: inline-flex;
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 0.45rem;
  color: hsl(var(--muted-foreground));
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.ww-select-clear:hover {
  color: hsl(var(--foreground));
  background: hsl(var(--muted) / 0.6);
}

.ww-select-scrim {
  position: fixed;
  inset: 0;
  z-index: 250;
}

/* Inside dialogs, keep the dismiss layer below action buttons (z-index 300). */
.ww-dialog-scroll .ww-select-scrim {
  z-index: 40;
}

.ww-dialog-scroll .ww-select-menu,
.ww-dialog-scroll .ww-select-menu.is-fixed {
  z-index: 50;
}

.ww-select-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.4rem);
  z-index: 260;
  overflow: hidden;
  border-radius: 0.9rem;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--popover));
  color: hsl(var(--popover-foreground));
  box-shadow:
    0 0 0 1px hsl(var(--foreground) / 0.04) inset,
    0 18px 40px hsl(0 0% 0% / 0.18),
    0 6px 14px hsl(0 0% 0% / 0.1);
  animation: ww-select-in 0.16s cubic-bezier(0.22, 1, 0.36, 1);
}

.ww-select-menu.is-fixed {
  position: fixed;
  right: auto;
}

html.dark .ww-select-menu,
html:not(.light) .ww-select-menu {
  border-color: hsl(0 0% 100% / 0.14);
  background:
    linear-gradient(180deg, hsl(0 0% 100% / 0.07), transparent 40%),
    hsl(0 0% 12% / 0.97);
  box-shadow:
    0 0 0 1px hsl(0 0% 100% / 0.04) inset,
    0 24px 48px hsl(0 0% 0% / 0.55);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.ww-select-menu-inner {
  max-height: min(16rem, 50vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.35rem;
  -webkit-overflow-scrolling: touch;
}

.ww-select-empty {
  margin: 0;
  padding: 1.25rem 0.75rem;
  text-align: center;
  font-size: 0.85rem;
  color: hsl(var(--muted-foreground));
}

.ww-select-option {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.12rem;
  padding: 0.6rem 0.7rem;
  border: none;
  border-radius: 0.65rem;
  background: transparent;
  color: hsl(var(--foreground));
  font: inherit;
  font-size: 0.875rem;
  font-weight: 550;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.ww-select-option:last-child {
  margin-bottom: 0;
}

.ww-select-option span,
.ww-select-option-label {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ww-select-option.is-selected .ww-select-avatar.is-initials {
  background: hsl(var(--primary-foreground) / 0.18);
  color: inherit;
  border-color: transparent;
}

html.dark .ww-select-option.is-selected .ww-select-avatar.is-initials,
html:not(.light) .ww-select-option.is-selected .ww-select-avatar.is-initials {
  background: hsl(0 0% 0% / 0.08);
  color: inherit;
}

.ww-select-option:hover,
.ww-select-option:focus-visible {
  background: hsl(var(--muted) / 0.7);
  outline: none;
}

html.dark .ww-select-option:hover,
html.dark .ww-select-option:focus-visible,
html:not(.light) .ww-select-option:hover,
html:not(.light) .ww-select-option:focus-visible {
  background: hsl(0 0% 100% / 0.08);
}

.ww-select-option.is-selected {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  box-shadow: 0 4px 12px hsl(var(--primary) / 0.25);
}

html.dark .ww-select-option.is-selected,
html:not(.light) .ww-select-option.is-selected {
  background: #fff;
  color: #0a0a0a;
  box-shadow: 0 6px 16px hsl(0 0% 0% / 0.25);
}

.ww-select-check {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  opacity: 0.9;
}

@keyframes ww-select-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Compact filter row helpers */
.ww-select-field.ww-select-inline {
  width: auto;
  min-width: 9.5rem;
}
