/* =========================[ FEX SELECT - BASE ]========================= */
.fex-select {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  font-size: var(--font-size-small);
  font-family: var(--font-primary);
  width: 100%;
}

.fex-select-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--field-border);
  border-radius: var(--field-radius);
  background: var(--field-bg);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  min-height: var(--field-height);
  box-sizing: border-box;
  box-shadow: none;
}

.fex-select-wrapper:hover {
  border-color: var(--field-border-hover);
  box-shadow: none;
}

.fex-select-content {
  padding: 0 12px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  color: var(--color-text);
  font-weight: 500;
  min-width: 0; /* important to avoid overflow with flex + ellipsis */
}

.fex-select-icon {
  width: 36px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-left: none;
  background: transparent;
  color: var(--color-gray);
}

.fex-select-search-toggle {
  display: none;
  width: 36px;
  height: 100%;
  border: none;
  border-left: 1px solid var(--color-surface-border);
  background: transparent;
  color: var(--color-gray);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  outline: none;
  box-shadow: none;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.fex-select-search-toggle .material-symbols-outlined,
.fex-select-search-toggle:hover .material-symbols-outlined {
  font-size: 16px;
  margin-right: 0px;
}

.fex-select-search-toggle:hover,
.fex-select-search-toggle:focus,
.fex-select-search-toggle:focus-visible,
.fex-select-search-toggle:active {
  width: 36px;
  height: 100%;
  padding: 0;
  border: none;
  border-left: 1px solid var(--color-surface-border);
  background: rgba(37, 99, 235, 0.06);
  color: var(--color-blue-primary);
  outline: none;
  box-shadow: none;
}

.fex-select-icon .material-symbols-outlined {
  font-size: 18px;
  transition: transform 0.2s ease;
}

.fex-select.open .fex-select-icon .material-symbols-outlined {
  transform: rotate(180deg);
}

.fex-select-options {
  position: fixed;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  list-style: none;
  margin: 0;
  padding: 6px 0;
  border-radius: 8px;
  background: var(--white);
  max-height: 240px;
  overflow-y: auto;
  box-shadow: 0 5px 5px -3px rgba(15, 23, 42, 0.12), 0 8px 10px 1px rgba(15, 23, 42, 0.08), 0 3px 14px 2px rgba(15, 23, 42, 0.07);
  z-index: 10001;
}

.fex-select.open .fex-select-options {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.fex-select-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  background-color: #ffffff;
  color: var(--color-dark);
  font-weight: 400;
}

.fex-select-option:hover {
  background-color: #f1f5f9;
  color: var(--color-dark);
}

.fex-select-option.selected {
  background: rgba(37, 99, 235, 0.08);
  color: var(--color-blue-primary);
  font-weight: 600;
}

.fex-select-option-label {
  flex: 1;
  min-width: 0;
}

.fex-select-option-check {
  display: none;
  align-items: center;
  justify-content: center;
  width: 24px;
  min-width: 24px;
  color: var(--color-blue-primary);
}

.fex-select-option-check .material-symbols-outlined {
  font-size: 18px;
  margin-right: 0;
}

.fex-select-option.selected .fex-select-option-check {
  display: flex;
}

/* =========================[ ESTADOS ]========================= */
.fex-select.disabled {
  opacity: 1;
}

.fex-select.disabled .fex-select-wrapper {
  background: #f8fafc;
  cursor: default;
  box-shadow: none;
}

.fex-select.disabled .fex-select-content {
  color: var(--color-text);
  cursor: default;
}

.fex-select.disabled .fex-select-icon,
.fex-select.disabled .fex-select-search-toggle {
  background: #f8fafc;
  color: var(--color-gray);
  cursor: default;
}

.fex-select.disabled .fex-select-search-toggle {
  pointer-events: none;
}


/* =========================[ COMPACT MODE (Flatpickr) ]========================= */
.fex-select-compact .fex-select-wrapper,
.fex-select--compact .fex-select-wrapper {
  height: 28px;
  padding: 0;
  min-height: unset;
  box-shadow: none; /* compactos não precisam parecer cards */
}

.fex-select-compact .fex-select-content,
.fex-select--compact .fex-select-content {
  padding: 2px 8px;
  font-weight: 600;
  font-size: var(--font-size-small);
}

.fex-select--compact .fex-select-search-toggle {
  display: none;
}

/* =========================[ SELEÇÃO DE TEXTO NO INPUT ]========================= */
.fex-select-content::selection {
  background: transparent;
  color: var(--color-text);
}

.fex-select-content::-moz-selection {
  background: transparent;
  color: var(--color-text);
}

/* =========================[ CARD STATE QUANDO ABERTO ]========================= */
.fex-select.open .fex-select-wrapper {
  background: var(--field-bg-focus);
  border-color: var(--field-focus);
  box-shadow: inset 0 0 0 1px var(--field-focus);
  z-index: 2100;
  position: relative;
}

/* =========================[ REMOVER BORDA NATIVA DO FOCUS ]========================= */
.fex-select-content:focus,
.fex-select-wrapper:focus,
.fex-select-option:focus {
  outline: none;
  box-shadow: none;
}


.fex-select-wrapper:focus {
  outline: none;
  border-color: var(--field-focus);
  box-shadow: inset 0 0 0 1px var(--field-focus);
}

.fex-select-option.highlighted {
  background-color: #f1f5f9;
  color: var(--color-blue-primary);
}

.fex-select.input-error .fex-select-wrapper {
    border: 1px solid var(--color-error, #e11d48) !important;
    box-shadow: 0 0 4px rgba(225, 29, 72, 0.5);
}

/* =========================[ FEX SELECT - MEDIA (ICON / IMG) ]========================= */

/* Default: media hidden to avoid affecting normal selects */
.fex-select-media {
  display: none;
}

.fex-select-option-media {
  display: none;
}

.fex-select-option-label {
  display: block;
  flex: 1;
  min-width: 0;
}

/* Only enable media layout when iconField/imgField is configured */
.fex-select[data-icon-field]:not([data-icon-field=""]) .fex-select-media,
.fex-select[data-img-field]:not([data-img-field=""]) .fex-select-media {
  width: 34px;
  min-width: 34px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  color: var(--color-gray);
}

.fex-select[data-icon-field]:not([data-icon-field=""]) .fex-select-media i,
.fex-select[data-img-field]:not([data-img-field=""]) .fex-select-media i {
  font-size: 14px;
}

.fex-select[data-icon-field]:not([data-icon-field=""]) .fex-select-media img,
.fex-select[data-img-field]:not([data-img-field=""]) .fex-select-media img {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  object-fit: cover;
}

/* Options layout only when media is enabled */
.fex-select[data-icon-field]:not([data-icon-field=""]) .fex-select-option,
.fex-select[data-img-field]:not([data-img-field=""]) .fex-select-option {
  display: flex;
  align-items: center;
  gap: 10px;
}

.fex-select[data-icon-field]:not([data-icon-field=""]) .fex-select-option-media,
.fex-select[data-img-field]:not([data-img-field=""]) .fex-select-option-media {
  width: 22px;
  min-width: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-gray);
}

.fex-select[data-icon-field]:not([data-icon-field=""]) .fex-select-option-media i,
.fex-select[data-img-field]:not([data-img-field=""]) .fex-select-option-media i {
  font-size: 14px;
}

.fex-select[data-icon-field]:not([data-icon-field=""]) .fex-select-option-media img,
.fex-select[data-img-field]:not([data-img-field=""]) .fex-select-option-media img {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  object-fit: cover;
}

/* Keep label ellipsis only in media mode */
.fex-select[data-icon-field]:not([data-icon-field=""]) .fex-select-option-label,
.fex-select[data-img-field]:not([data-img-field=""]) .fex-select-option-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =========================[ MOBILE ]========================= */
@media (max-width: 768px) {

  .rows-per-page {
    width: 100%;
  }

  .rows-per-page .fex-select {
    max-width: 100%;
  }

  .rows-per-page .fex-select-wrapper {
    width: 100%;
  }

  .fex-select-search-toggle {
    display: flex;
  }

  .fex-select-search-toggle i {
    margin-right: 0px;
  }

  .fex-select-content {
    padding-right: 8px;
  }
}

/* =========================[ FEX SELECT - ON DARK ]=========================
   Variation for a FexSelect over a colored background (e.g. the gradient header of a mobile screen): translucent pill
   with white text. Wrap the tag: <div class="fex-select-on-dark"><FexSelect name="..." /></div>. The options list keeps
   the default look. */
.fex-select-on-dark .fex-select-wrapper {
  min-height: 36px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  box-shadow: none;
}

.fex-select-on-dark .fex-select-wrapper:hover {
  background: rgba(255, 255, 255, 0.26);
  box-shadow: none;
}

.fex-select-on-dark .fex-select-content {
  padding: 0 4px 0 14px;
  color: #fff;
  font-weight: 700;
}

.fex-select-on-dark .fex-select-icon {
  width: 34px;
  color: #fff;
}

.fex-select-on-dark .fex-select-icon .material-symbols-outlined,
.fex-select-on-dark .fex-select-search-toggle .material-symbols-outlined {
  color: inherit;
}

.fex-select-on-dark .fex-select-search-toggle {
  border-left: 0;
  color: rgba(255, 255, 255, 0.8);
}
