/* ========================================
   Native Dropdown
======================================== */

.ui-dropdown,
.form-field select.ui-dropdown {
  appearance: none;

  width: 100%;
  min-height: 52px;
  padding: 0 44px 0 16px;

  color: var(--color-text);

  background-color: #fff;
  background-image:
    linear-gradient(45deg, transparent 50%, #4b5563 50%),
    linear-gradient(135deg, #4b5563 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 13px) 50%;
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;

  border: 1px solid #e5e7eb;
  border-radius: 14px;

  cursor: pointer;
  font: inherit;
  outline: none;

  transition: var(--transition);
}

.ui-dropdown--sm,
.form-field select.ui-dropdown--sm {
  min-height: 48px;
  padding-left: 14px;
}

.ui-dropdown:hover,
.form-field select.ui-dropdown:hover {
  border-color: #9ca3af;
}

.ui-dropdown:focus,
.ui-dropdown:focus-visible,
.form-field select.ui-dropdown:focus,
.form-field select.ui-dropdown:focus-visible {
  border-color: var(--color-primary);

  box-shadow: 0 0 0 4px rgba(14, 141, 219, 0.12);
}

.ui-dropdown:disabled,
.form-field select.ui-dropdown:disabled {
  color: #9ca3af;

  background-color: #f8fafc;

  cursor: not-allowed;
}

.ui-dropdown.is-invalid,
.ui-dropdown--error,
.form-field.has-error .ui-dropdown {
  border-color: #dc2626;
}

select.ui-dropdown[multiple] {
  height: auto;
  min-height: 150px;
  padding: 12px 16px;

  background-image: none;

  cursor: default;
}


/* ========================================
   Custom Select
======================================== */

.custom-select {
  position: relative;

  width: 100%;
}

.custom-select__native {
  position: absolute;

  width: 1px;
  height: 1px;

  overflow: hidden;

  opacity: 0;

  pointer-events: none;
}


/* ========================================
   Custom Select Trigger
======================================== */

.custom-select__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;

  width: 100%;
  min-height: 50px;
  padding: 0 14px;

  color: #111827;

  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 14px;

  cursor: pointer;

  font: inherit;
  font-size: 14px;
  text-align: left;

  outline: none;

  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.custom-select__trigger [data-select-value] {
  min-width: 0;

  overflow: hidden;

  white-space: nowrap;
  text-overflow: ellipsis;
}

.custom-select__trigger:hover {
  border-color: #9ca3af;
}

.custom-select__trigger:disabled,
.custom-select.is-disabled .custom-select__trigger {
  color: #9ca3af;

  background: #f8fafc;

  cursor: not-allowed;
}

.custom-select__trigger:focus,
.custom-select__trigger:focus-visible,
.custom-select.is-open .custom-select__trigger {
  border-color: var(--color-primary);

  box-shadow: 0 0 0 4px rgba(14, 141, 219, 0.12);
}


/* ========================================
   Custom Select Arrow
======================================== */

.custom-select__arrow {
  flex: 0 0 auto;

  width: 8px;
  height: 8px;
  margin-top: -4px;
  margin-right: 3px;

  border-right: 2px solid #4b5563;
  border-bottom: 2px solid #4b5563;

  transform: rotate(45deg);

  transition: transform 0.2s ease;
}

.custom-select.is-open .custom-select__arrow {
  margin-top: 4px;

  transform: rotate(225deg);
}


/* ========================================
   Custom Select Dropdown
======================================== */

.custom-select__dropdown {
  position: absolute;
  z-index: 1000;
  top: calc(100% + 6px);
  right: 0;
  left: 0;

  display: none;

  overflow: hidden;

  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);

  box-shadow: var(--shadow);
}

.custom-select.is-open .custom-select__dropdown {
  display: block;
}


/* ========================================
   Custom Select Options
======================================== */

.custom-select__options {
  max-height: 260px;
  padding: 8px;

  overflow-x: hidden;
  overflow-y: auto;
}

.custom-select__option {
  display: block;

  width: 100%;
  padding: 10px 20px;

  color: #111827;

  background: transparent;
  border: 0;

  cursor: pointer;

  font: inherit;
  font-size: 14px;
  text-align: left;

  outline: 0;
}

.custom-select__option[hidden] {
  display: none;
}

.custom-select__option:hover,
.custom-select__option:focus-visible {
  background: #f3f4f6;
}

.custom-select__option.is-selected {
  background: #f3f4f6;

  font-weight: 500;
}

.custom-select__option:disabled {
  color: #9ca3af;

  cursor: not-allowed;
}


/* ========================================
   Custom Select Search
======================================== */

.custom-select__search {
  padding: 8px;

  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.custom-select__search input {
  width: 100%;
  height: 42px;
  padding: 0 12px;

  color: var(--color-text);

  border: 1px solid var(--color-border);
  border-radius: 10px;

  font: inherit;
  font-size: 14px;

  outline: none;

  transition: var(--transition);
}

.custom-select__search input::placeholder {
  color: var(--color-text-light);
}

.custom-select__search input:focus {
  border-color: var(--color-primary);

  box-shadow: 0 0 0 3px rgba(14, 141, 219, 0.12);
}


/* ========================================
   Filter Select
======================================== */

.custom-select--filter .custom-select__dropdown {
  right: auto;
  left: 0;

  width: max-content;
  min-width: max(100%, 180px);
  max-width: 260px;
}

.custom-select--filter .custom-select__options {
  max-height: 260px;
  padding: 8px;

  overflow-x: hidden;
  overflow-y: auto;
}

.custom-select--filter .custom-select__option {
  width: 100%;
  min-width: max-content;
  padding: 10px 14px;

  border-radius: 10px;

  white-space: nowrap;
}

.custom-select--filter .custom-select__option:hover,
.custom-select--filter .custom-select__option:focus-visible,
.custom-select--filter .custom-select__option.is-selected {
  color: var(--color-primary);

  background: #f1f5f9;
}


/* ========================================
   Status Select
======================================== */

.custom-select--status {
  width: 100%;
  min-width: 0;
}

.custom-select--status .custom-select__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;

  width: 100%;
  height: 48px;
  min-height: 48px;
  padding: 0 12px;

  color: #64748b;

  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;

  cursor: pointer;
}

.custom-select--status .custom-select__trigger:hover {
  border-color: #9ca3af;
}

.custom-select--status .custom-select__trigger:focus,
.custom-select--status .custom-select__trigger:focus-visible,
.custom-select--status.is-open .custom-select__trigger {
  border-color: var(--color-primary);

  box-shadow: 0 0 0 4px rgba(14, 141, 219, 0.12);
}

.custom-select--status .custom-select__arrow {
  flex: 0 0 auto;

  width: 8px;
  height: 8px;
}

.custom-select--status .custom-select__dropdown {
  right: 0;
  left: auto;

  width: 100%;
  min-width: 100%;

  border-radius: 14px;
}

.custom-select--status .custom-select__options {
  max-height: 260px;
  padding: 8px;

  overflow-x: hidden;
  overflow-y: auto;
}

.custom-select--status .custom-select__option {
  width: 100%;
  padding: 10px 14px;

  color: #111827;

  background: transparent;
  border: 0;
  border-radius: 10px;

  font-size: 14px;
  font-weight: 400;

  white-space: nowrap;
}

.custom-select--status .custom-select__option:hover,
.custom-select--status .custom-select__option:focus-visible,
.custom-select--status .custom-select__option.is-selected {
  color: var(--color-primary);

  background: #f1f5f9;
}


/* ========================================
   Error State
======================================== */

.form-field.has-error .custom-select__trigger,
.custom-select--error .custom-select__trigger {
  border-color: #dc2626;
}


/* ========================================
   Inline Status Form Layout
======================================== */

.inline-status-form > button[type="submit"] {
  flex: 0 0 auto;

  padding: 0;

  white-space: nowrap;
}


/* ========================================
   Responsive
======================================== */

@media (max-width: 640px) {
  .inline-status-form .custom-select {
    flex-basis: auto;

    width: 100%;
  }
}