/* =============================================================
   Custom Select — padrão único do projeto
   Customizable Select (appearance: base-select)
   Progressive enhancement — fallback para select nativo.
   Ref: https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Forms/Customizable_select
   ============================================================= */

/* --- Base: alinhamento vertical + seta padrão Bootstrap --- */
select.jedi-custom-select.form-select {
  display: block;
  width: 100%;
  line-height: 1.5;
  padding-top: 0;
  padding-bottom: 0;
  /* Mantém a seta padrão do .form-select (Bootstrap) */
  background-image: var(--bs-form-select-bg-img);
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px 12px;
  padding-right: 2.25rem;
}

/* --- Customizable Select (Chrome 134+, Edge 134+) --- */
@supports (appearance: base-select) {
  select.jedi-custom-select.form-select,
  select.jedi-custom-select.form-select::picker(select) {
    appearance: base-select !important;
  }

  select.jedi-custom-select.form-select {
    display: inline-flex;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    padding-top: 0;
    padding-bottom: 0;
    padding-right: 2.25rem;
    line-height: 1.5;
    /* Seta padrão Bootstrap — oculta a seta nativa do base-select */
    background-image: var(--bs-form-select-bg-img) !important;
    background-repeat: no-repeat !important;
    background-position: right 0.75rem center !important;
    background-size: 16px 12px !important;
    background-color: var(--color-surface, #fff);
    border: 1px solid color-mix(in srgb, var(--color-border, #dee2e6) 88%, #adb5bd 12%);
    color: var(--color-text, #092d41);
    font-weight: 500;
    transition:
      background-color 0.25s ease,
      border-color 0.25s ease,
      box-shadow 0.25s ease;
  }

  select.jedi-custom-select.form-select:hover {
    background-color: color-mix(in srgb, var(--color-primary-soft, #e6eef2) 28%, white 72%);
    background-image: var(--bs-form-select-bg-img) !important;
  }

  select.jedi-custom-select.form-select:focus,
  select.jedi-custom-select.form-select:focus-visible {
    outline: none;
    border-color: var(--color-primary, #1a3c4c);
    box-shadow: 0 0 0 0.25rem rgba(27, 38, 59, 0.15);
    background-color: var(--color-surface, #fff);
    background-image: var(--bs-form-select-bg-img) !important;
  }

  /* Botão interno (valor selecionado) */
  select.jedi-custom-select.form-select > button {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    align-self: stretch;
    width: 100%;
    min-width: 0;
    min-height: 100%;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    font: inherit;
    font-weight: inherit;
    color: inherit;
    line-height: inherit;
    text-align: left;
    cursor: pointer;
  }

  select.jedi-custom-select.form-select selectedcontent {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 100%;
    line-height: 1.5;
  }

  select.jedi-custom-select.form-select selectedcontent .select-option-label {
    line-height: 1.5;
  }

  /* Usa seta Bootstrap — oculta ::picker-icon do base-select */
  select.jedi-custom-select.form-select::picker-icon {
    display: none;
  }

  /* Dropdown */
  select.jedi-custom-select.form-select::picker(select) {
    border: none;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(27, 38, 59, 0.14);
    opacity: 0;
    transition: all 0.3s allow-discrete;
    top: calc(anchor(bottom) + 4px);
    min-width: anchor-size(width);
  }

  select.jedi-custom-select.form-select:open::picker(select) {
    opacity: 1;
  }

  @starting-style {
    select.jedi-custom-select.form-select:open::picker(select) {
      opacity: 0;
    }
  }

  /* Opções */
  select.jedi-custom-select.form-select option {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
    border: none;
    border-bottom: 1px solid color-mix(in srgb, var(--color-border, #dee2e6) 55%, transparent 45%);
    background: var(--color-surface, #fff);
    padding: 0.65rem 1rem;
    color: var(--color-text, #092d41);
    font-weight: 500;
    transition: background-color 0.2s ease, color 0.2s ease;
  }

  select.jedi-custom-select.form-select option:first-of-type {
    border-radius: 10px 10px 0 0;
  }

  select.jedi-custom-select.form-select option:last-of-type {
    border-radius: 0 0 10px 10px;
    border-bottom: none;
  }

  select.jedi-custom-select.form-select option:nth-of-type(odd) {
    background: color-mix(in srgb, var(--color-primary-soft, #e6eef2) 18%, white 82%);
  }

  select.jedi-custom-select.form-select option:hover,
  select.jedi-custom-select.form-select option:focus {
    background: color-mix(in srgb, var(--color-primary, #1a3c4c) 12%, white 88%);
    color: var(--color-primary, #1a3c4c);
  }

  select.jedi-custom-select.form-select option:checked {
    font-weight: 600;
    color: var(--color-primary, #1a3c4c);
    background: color-mix(in srgb, var(--color-primary-soft, #e6eef2) 55%, white 45%);
  }

  select.jedi-custom-select.form-select option .select-option-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    flex-shrink: 0;
    font-size: 0.9rem;
    color: var(--color-text-muted, #64748b);
  }

  select.jedi-custom-select.form-select option .select-option-icon--active {
    color: #2e7d32;
    font-size: 0.45rem;
  }

  select.jedi-custom-select.form-select option .select-option-icon--inactive {
    color: #6c757d;
    font-size: 0.45rem;
  }

  select.jedi-custom-select.form-select option .select-option-icon--warning {
    color: #b45309;
    font-size: 0.75rem;
  }

  select.jedi-custom-select.form-select option .select-option-icon--draft {
    color: var(--color-text-muted, #64748b);
    font-size: 0.75rem;
  }

  select.jedi-custom-select.form-select selectedcontent .select-option-icon {
    display: none;
  }

  select.jedi-custom-select.form-select option::checkmark {
    order: 1;
    margin-left: auto;
    color: var(--color-primary, #1a3c4c);
    content: "\2713";
    font-size: 0.85rem;
  }
}

/* Alturas comuns dos filtros — centralização vertical consistente */
select.jedi-custom-select.form-select.h-12,
select.jedi-custom-select.form-select.filter-select-input {
  min-height: 3rem;
  height: 3rem;
}

@supports (appearance: base-select) {
  select.jedi-custom-select.form-select.h-12 > button,
  select.jedi-custom-select.form-select.filter-select-input > button {
    min-height: 3rem;
  }
}
