/* Select2: que nunca se pase del contenedor */
.select2-container,
.select2-container--bootstrap-5 {
  max-width: 100% !important;
  width: 100% !important;
}

/* El control (caja) debe verse como un form-select */
.select2-container .select2-selection.s2-bs {
  /* estilos de Bootstrap 5 para inputs */
  border: 1px solid var(--bs-border-color, #ced4da);
  border-radius: .375rem; /* .form-select border-radius */
  min-height: calc(2.25rem + 2px); /* altura aprox de .form-select */
  display: flex;
  align-items: center;
  padding: .375rem .75rem;
  box-shadow: none;
}

/* Placeholder / texto */
.select2-container .select2-selection.s2-bs .select2-selection__rendered {
  padding: 0;          /* ya damos el padding al contenedor */
  line-height: normal; /* alineación vertical correcta */
  color: inherit;
  width: 100%;
}

/* Flecha a la derecha como el select */
.select2-container .select2-selection.s2-bs .select2-selection__arrow {
  height: 100%;
  right: .5rem;
}

/* Focus ring como Bootstrap */
.select2-container--focus .select2-selection.s2-bs,
.select2-container .select2-selection.s2-bs:focus {
  border-color: #86b7fe;
  outline: 0;
  box-shadow: 0 0 0 .25rem rgba(13,110,253,.25);
}

/* Tamaño pequeño opcional (si necesitas .form-select-sm) */
.form-select-sm + .select2-container .select2-selection.s2-bs {
  min-height: calc(1.8125rem + 2px);
  padding: .25rem .5rem;
  border-radius: .25rem;
}

/* Dropdown: que no se desborde y respete el padre */
.select2-dropdown.s2-dropdown {
  max-width: 100%;
  width: auto;             /* que se ajuste al contenido pero sin pasar el padre */
}

/* --- Fix: que el botón de limpiar (×) no empuje el texto hacia abajo --- */
.select2-container .select2-selection.s2-bs {
  position: relative;                /* para posicionar el clear y la flecha */
}

/* Texto en una sola línea con ellipsis */
.select2-container .select2-selection--single .select2-selection__rendered {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  padding-right: 3.25rem;            /* espacio para clear (×) + flecha */
}

/* Botón de limpiar (×) posicionado sin afectar el flujo */
.select2-container .select2-selection--single .select2-selection__clear {
  position: absolute;
  right: 2rem;                       /* antes de la flecha */
  top: 50%;
  transform: translateY(-50%);
  margin-right: 0;
  line-height: 1;
  font-size: 1rem;                   /* ajusta si lo ves muy grande/pequeño */
  opacity: .7;
}
.select2-container .select2-selection--single .select2-selection__clear:hover {
  opacity: 1;
}

/* Flecha del select2 a la derecha, centrada */
.select2-container .select2-selection--single .select2-selection__arrow {
  right: .5rem;
  top: 50%;
  transform: translateY(-50%);
}

/* Si usas tamaño pequeño (form-select-sm) */
.form-select-sm + .select2-container .select2-selection--single .select2-selection__rendered {
  padding-right: 2.75rem;
}
.form-select-sm + .select2-container .select2-selection--single .select2-selection__clear {
  right: 1.75rem;
}
