/* ==========================================================================
   SuperAdmin CustomSelect Component
   ========================================================================== */

.sa-custom-select {
  position: relative;
  width: 100%;
  min-width: 0;
}

.sa-custom-select__trigger {
  width: 100%;
  min-width: 0;
  height: 38px;
  min-height: 38px;
  padding: 0 1rem;
  background: var(--sa-input-bg);
  border: 1px solid var(--sa-border);
  border-radius: 0.625rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  box-sizing: border-box;
  outline: none;
  user-select: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

/* Size Variants: sm (34px), md (38px), lg (44px) */
.sa-custom-select__trigger--sm {
  height: 34px;
  min-height: 34px;
  padding: 0 0.75rem;
  font-size: 0.8125rem;
  border-radius: 0.5rem;
}

.sa-custom-select__trigger--md {
  height: 38px;
  min-height: 38px;
  padding: 0 1rem;
  font-size: 0.875rem;
  border-radius: 0.625rem;
}

.sa-custom-select__trigger--lg {
  height: 44px;
  min-height: 44px;
  padding: 0 1rem;
  font-size: 0.9375rem;
  border-radius: 0.75rem;
}

.sa-custom-select__trigger:hover {
  border-color: var(--sa-border-hover);
  background: var(--sa-hover-bg);
}

.sa-custom-select__trigger:focus,
.sa-custom-select__trigger.triggerOpen {
  background: var(--sa-input-bg);
  border-color: var(--sa-primary);
  box-shadow: 0 0 0 3px var(--sa-primary-ring);
}

.sa-custom-select__value {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--sa-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 0.5rem;
  min-width: 0;
}

.sa-custom-select__value-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--sa-primary);
  flex-shrink: 0;
}

.sa-custom-select__value-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sa-custom-select__chevron {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sa-text-secondary);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), color 0.2s ease;
  flex-shrink: 0;
}

.sa-custom-select__trigger:hover .sa-custom-select__chevron {
  color: var(--sa-text);
}

.sa-custom-select__trigger.triggerOpen .sa-custom-select__chevron {
  transform: rotate(180deg);
  color: var(--sa-primary);
}

/* Dropdown Menu Popup */
.sa-custom-select__menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--sa-surface-raised);
  border: 1px solid var(--sa-border-hover);
  border-radius: 0.75rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.08);
  z-index: 100;
  overflow: hidden;
  display: none;
  animation: saCustomSelectSlideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.sa-custom-select__menu.open {
  display: block;
}

/* Dropup when near bottom of viewport or modal */
.sa-custom-select__menu.sa-custom-select__menu--up {
  top: auto;
  bottom: calc(100% + 6px);
  animation: saCustomSelectSlideInUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

@keyframes saCustomSelectSlideInUp {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sa-custom-select__options {
  padding: 0.375rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 220px;
  overflow-y: auto;
}

.sa-custom-select__option {
  padding: 0.625rem 0.875rem;
  min-height: 38px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--sa-text);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.sa-custom-select__option-left {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
  overflow: hidden;
}

.sa-custom-select__option-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--sa-text-secondary);
  flex-shrink: 0;
  transition: color 0.15s ease;
}

.sa-custom-select__option-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sa-custom-select__option:hover .sa-custom-select__option-icon,
.sa-custom-select__option.selected .sa-custom-select__option-icon {
  color: var(--sa-primary);
}

.sa-custom-select__option:hover {
  background: var(--sa-hover-bg);
  color: var(--sa-primary);
}

.sa-custom-select__option.selected {
  background: var(--sa-primary-bg);
  color: var(--sa-primary);
  font-weight: 600;
}

.sa-custom-select__option.selected:hover {
  background: var(--sa-hover-bg);
  color: var(--sa-primary);
}

.sa-custom-select__check {
  display: flex;
  align-items: center;
  color: var(--sa-primary-icon);
  flex-shrink: 0;
  margin-left: 0.5rem;
}

/* ==========================================================================
   Mobile Responsive
   ========================================================================== */

@media (max-width: 768px) {
  .sa-custom-select__trigger {
    height: 44px;
    min-height: 44px;
    padding: 0 0.875rem;
  }

  .sa-custom-select__menu {
    top: calc(100% + 4px);
    max-height: 240px;
  }

  .sa-custom-select__option {
    padding: 0.75rem 0.875rem;
    min-height: 44px;
  }
}

/* ==========================================================================
   Dark Theme Overrides
   ========================================================================== */

[data-theme='dark'] .sa-custom-select__trigger {
  background: #172238;
  border-color: #334155;
  color: #f8fafc;
}

[data-theme='dark'] .sa-custom-select__trigger:hover {
  background: #202d47;
  border-color: #475569;
}

[data-theme='dark'] .sa-custom-select__trigger:focus,
[data-theme='dark'] .sa-custom-select__trigger.triggerOpen {
  background: #172238;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.22);
}

[data-theme='dark'] .sa-custom-select__menu {
  background: #1e293b;
  border-color: #475569;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
}

[data-theme='dark'] .sa-custom-select__option:hover {
  background: #273549;
  color: #60a5fa;
}

[data-theme='dark'] .sa-custom-select__option.selected {
  background: rgba(59, 130, 246, 0.18);
  color: #60a5fa;
}

[data-theme='dark'] .sa-custom-select__option.selected:hover {
  background: rgba(59, 130, 246, 0.26);
  color: #93c5fd;
}

