/* ========================================================================== 
   HooshAmoozan custom select - consistent RTL dropdown for public/admin UI
   Native <select> remains the form value source; this layer only replaces UI.
   ========================================================================== */

.hoosh-select {
  --hs-bg: var(--admin-elevated, var(--bg-elevated, #171b25));
  --hs-bg-hover: var(--admin-surface-hover, var(--bg-tertiary, #1c2230));
  --hs-menu-bg: var(--admin-surface, var(--bg-surface, #111620));
  --hs-border: var(--admin-border, var(--border, #2a3140));
  --hs-border-hover: var(--admin-border-hover, var(--border-hover, #3a4558));
  --hs-text: var(--admin-text, var(--text-primary, #eef2f7));
  --hs-muted: var(--admin-text-muted, var(--text-secondary, #9aa4b2));
  --hs-accent: var(--admin-primary, var(--accent, #3b82f6));
  --hs-accent-text: var(--admin-primary-text, var(--accent-text, #60a5fa));
  --hs-accent-soft: var(--admin-primary-muted, var(--accent-muted, rgba(59,130,246,.12)));
  --hs-radius: var(--radius-sm, 9px);
  --hs-select-width: 100%;

  position: relative;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  display: block;
  direction: rtl;
  text-align: right;
}

.hoosh-select.has-inline-width {
  width: var(--hoosh-select-width);
  max-width: 100%;
  display: inline-block;
  vertical-align: middle;
}

.hoosh-select.has-inline-width[style*="--hoosh-select-width: auto"] {
  min-width: 150px;
}

.hoosh-select-native {
  position: absolute !important;
  inline-size: 1px !important;
  block-size: 1px !important;
  inset-inline-start: 0 !important;
  inset-block-start: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
  overflow: hidden !important;
  clip-path: inset(50%) !important;
}

.hoosh-select-trigger {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 12px 9px 10px;
  border: 1px solid var(--hs-border);
  border-radius: var(--hs-radius);
  background: var(--hs-bg);
  color: var(--hs-text);
  font: inherit;
  font-size: .88rem;
  font-weight: 600;
  line-height: 1.55;
  text-align: right;
  cursor: pointer;
  outline: none;
  transition: border-color .16s ease, background-color .16s ease, color .16s ease;
}

.hoosh-select-trigger:hover {
  border-color: var(--hs-border-hover);
  background: var(--hs-bg-hover);
}

.hoosh-select-trigger:focus-visible,
.hoosh-select.is-open .hoosh-select-trigger {
  border-color: var(--hs-accent);
  outline: 2px solid color-mix(in srgb, var(--hs-accent) 34%, transparent);
  outline-offset: 1px;
}

.hoosh-select.is-disabled .hoosh-select-trigger,
.hoosh-select-trigger:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.hoosh-select-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: rtl;
  text-align: right;
}

.hoosh-select-icon {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 22px;
  color: var(--hs-muted);
  transition: transform .18s ease, color .18s ease;
}

.hoosh-select.is-open .hoosh-select-icon {
  transform: rotate(180deg);
  color: var(--hs-accent-text);
}

/* The menu is portalled out of its field; inside native dialogs it stays in the dialog/top-layer context. */
.hoosh-select-menu {
  --hs-bg: var(--admin-elevated, var(--bg-elevated, #171b25));
  --hs-bg-hover: var(--admin-surface-hover, var(--bg-tertiary, #1c2230));
  --hs-menu-bg: var(--admin-surface, var(--bg-surface, #111620));
  --hs-border: var(--admin-border, var(--border, #2a3140));
  --hs-text: var(--admin-text, var(--text-primary, #eef2f7));
  --hs-muted: var(--admin-text-muted, var(--text-secondary, #9aa4b2));
  --hs-accent: var(--admin-primary, var(--accent, #3b82f6));
  --hs-accent-text: var(--admin-primary-text, var(--accent-text, #60a5fa));
  --hs-accent-soft: var(--admin-primary-muted, var(--accent-muted, rgba(59,130,246,.12)));
  --hs-radius: var(--radius-sm, 9px);
  --hs-scroll-thumb: var(--admin-scroll-thumb, rgba(148,163,184,.55));
  --hs-scroll-track: var(--admin-scroll-track, rgba(255,255,255,.035));

  position: fixed;
  z-index: 10050;
  display: none;
  direction: rtl;
  text-align: right;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
  border: 1px solid var(--hs-border);
  border-radius: calc(var(--hs-radius) + 2px);
  background:
    linear-gradient(180deg, rgba(255,255,255,.045), transparent 46px),
    var(--hs-menu-bg);
  color: var(--hs-text);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  scrollbar-width: thin;
  scrollbar-color: var(--hs-scroll-thumb) var(--hs-scroll-track);
  outline: none;
}

.hoosh-select-menu.is-open {
  display: block;
  animation: hooshSelectOpen .13s ease-out;
}

.hoosh-select-menu:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--hs-accent) 42%, transparent);
  outline-offset: 2px;
}

.hoosh-select-menu::-webkit-scrollbar {
  width: 8px;
}

.hoosh-select-menu::-webkit-scrollbar-track {
  background: var(--hs-scroll-track);
  border-radius: 999px;
}

.hoosh-select-menu::-webkit-scrollbar-thumb {
  background: var(--hs-scroll-thumb);
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 999px;
}

.hoosh-select-option {
  position: relative;
  min-height: 40px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22px;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border-radius: 7px;
  color: var(--hs-text);
  font-size: .86rem;
  font-weight: 550;
  line-height: 1.55;
  cursor: pointer;
  user-select: none;
  white-space: normal;
  overflow-wrap: anywhere;
  transition: background-color .12s ease, color .12s ease;
}

.hoosh-select-option::after {
  content: '';
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--hs-accent-text);
  font-size: .85rem;
  font-weight: 900;
}

.hoosh-select-option.is-selected::after {
  content: '✓';
}

.hoosh-select-option.is-active,
.hoosh-select-option:hover {
  background: var(--hs-accent-soft);
  color: var(--hs-accent-text);
}

.hoosh-select-option.is-selected {
  font-weight: 800;
}

.hoosh-select-option.is-disabled {
  opacity: .42;
  cursor: not-allowed;
  background: transparent;
  color: var(--hs-muted);
}

@keyframes hooshSelectOpen {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .hoosh-select-trigger,
  .hoosh-select-icon,
  .hoosh-select-option,
  .hoosh-select-menu.is-open {
    transition: none;
    animation: none;
  }
}

@media (max-width: 640px) {
  .hoosh-select,
  .hoosh-select.has-inline-width {
    width: 100%;
    max-width: 100%;
  }

  .hoosh-select-trigger {
    min-height: 46px;
    padding: 10px 12px;
    font-size: .92rem;
  }

  .hoosh-select-option {
    min-height: 44px;
    padding: 9px 11px;
    font-size: .9rem;
  }
}

.hoosh-select.is-invalid .hoosh-select-trigger {
  border-color: #ef4444;
}

/* v35 - match dropdown scrollbar to the site scrollbar language */
.hoosh-select-menu{scrollbar-width:thin;scrollbar-color:#465064 transparent}
.hoosh-select-menu::-webkit-scrollbar{width:7px;height:7px}
.hoosh-select-menu::-webkit-scrollbar-track{background:transparent}
.hoosh-select-menu::-webkit-scrollbar-thumb{border:2px solid transparent;border-radius:999px;background:#465064;background-clip:padding-box}
.hoosh-select-menu::-webkit-scrollbar-thumb:hover{background:#64748b;background-clip:padding-box}
.hoosh-select-menu::-webkit-scrollbar-button{display:none;width:0;height:0}

/* v42 — selects inside native <dialog> stay in the same top-layer context. */
.hoosh-select-menu[popover] {
  margin: 0;
  inset: auto;
}
.hoosh-select-menu[popover]:popover-open { display: block; }
.ha-admin-dialog .hoosh-select-menu { z-index: 2147483200; }
