/*!
 * Chosen - Bootstrap 5 Theme (Integración perfecta)
 */

/* @group Base */
.chosen-container {
  position: relative;
  margin-top: 0.5rem;
  display: inline-block;
  vertical-align: middle;
  width: 100%;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
}

.chosen-container * {
  -webkit-box-sizing: border-box;
          box-sizing: border-box;
}

.chosen-container .chosen-drop {
  position: absolute;
  top: 100%;
  z-index: 1050;
  width: 100%;
  border: var(--bs-border-width) solid var(--bs-border-color);
  border-top: 0;
  background-color: var(--bs-body-bg);
  border-radius: 0 0 var(--bs-border-radius) var(--bs-border-radius);
  -webkit-box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
          box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  clip: rect(0, 0, 0, 0);
  -webkit-clip-path: inset(100% 100%);
          clip-path: inset(100% 100%);
}

.chosen-container.chosen-with-drop .chosen-drop {
  clip: auto;
  -webkit-clip-path: none;
          clip-path: none;
}

.chosen-container a {
  cursor: pointer;
  text-decoration: none;
}

/* @end */

/* @group Single Chosen - Mismos estilos que form-control */
.chosen-container-single .chosen-single {
  position: relative;
  display: block;
  width: 100%;
  padding: 0.375rem 0.75rem;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--bs-body-color);
  background-color: var(--bs-body-bg);
  background-clip: padding-box;
  border: var(--bs-border-width) solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}

/* Hover effect */
.chosen-container-single .chosen-single:hover {
  border-color: var(--bs-border-color);
}

/* Span interno */
.chosen-container-single .chosen-single span {
  display: block;
  overflow: hidden;
  margin-right: 26px;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.5;
}

/* Deseleccionar */
.chosen-container-single .chosen-single-with-deselect span {
  margin-right: 38px;
}

/* Botón de limpiar (X) */
.chosen-container-single .chosen-single abbr {
  position: absolute;
  top: 50%;
  right: 26px;
  display: block;
  width: 16px;
  height: 16px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%236c757d'%3E%3Cpath d='M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z'/%3E%3C/svg%3E") no-repeat center;
  background-size: contain;
  font-size: 1px;
  -webkit-transform: translateY(-50%);
          transform: translateY(-50%);
  cursor: pointer;
  opacity: 0.5;
}

.chosen-container-single .chosen-single abbr:hover {
  opacity: 1;
}

/* Flecha desplegable */
.chosen-container-single .chosen-single div {
  position: absolute;
  top: 0;
  right: 0;
  display: block;
  width: 30px;
  height: 100%;
}

.chosen-container-single .chosen-single div b {
  display: block;
  width: 100%;
  height: 100%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%236c757d'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") no-repeat center;
  background-size: 20px;
  transition: transform .15s ease-in-out;
}

/* Caja de búsqueda */
.chosen-container-single .chosen-search {
  position: relative;
  z-index: 1010;
  margin: 0;
  padding: 0.5rem;
  white-space: nowrap;
}

.chosen-container-single .chosen-search input[type="text"] {
  display: block;
  width: 100%;
  padding: 0.375rem 0.75rem;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--bs-body-color);
  background-color: var(--bs-body-bg);
  background-clip: padding-box;
  border: var(--bs-border-width) solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}

.chosen-container-single .chosen-search input[type="text"]:focus {
  border-color: #86b7fe;
  outline: 0;
  -webkit-box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
          box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Dropdown */
.chosen-container-single .chosen-drop {
  margin-top: -1px;
  border-radius: 0 0 var(--bs-border-radius) var(--bs-border-radius);
}

/* Estado FOCUS - Igual que form-control:focus */
.chosen-container-active .chosen-single {
  border-color: #86b7fe;
  outline: 0;
  -webkit-box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
          box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.chosen-container-active.chosen-with-drop .chosen-single {
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
}

.chosen-container-active.chosen-with-drop .chosen-single div b {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%236c757d'%3E%3Cpath d='M7 14l5-5 5 5z'/%3E%3C/svg%3E") no-repeat center;
  background-size: 20px;
}

/* @end */

/* @group Results */
.chosen-container .chosen-results {
  color: var(--bs-body-color);
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
  margin: 0;
  padding: 0.5rem 0;
  max-height: 240px;
  -webkit-overflow-scrolling: touch;
}

.chosen-container .chosen-results li {
  display: none;
  margin: 0;
  padding: 0.5rem 1rem;
  list-style: none;
  font-size: 1rem;
  line-height: 1.5;
  word-wrap: break-word;
  cursor: pointer;
}

.chosen-container .chosen-results li.active-result {
  display: list-item;
}

.chosen-container .chosen-results li.disabled-result {
  display: list-item;
  color: var(--bs-secondary-color);
  background-color: var(--bs-secondary-bg);
  cursor: not-allowed;
  opacity: 0.65;
}

.chosen-container .chosen-results li.highlighted {
  background-color: #0d6efd;
  background-image: none;
  color: #fff;
}

.chosen-container .chosen-results li.no-results {
  color: var(--bs-secondary-color);
  display: list-item;
  background-color: var(--bs-secondary-bg);
  padding: 0.5rem 1rem;
  font-style: italic;
}

.chosen-container .chosen-results li.group-result {
  display: list-item;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  color: var(--bs-secondary-color);
  cursor: default;
  padding: 0.5rem 1rem 0.25rem;
  letter-spacing: 0.5px;
}

.chosen-container .chosen-results li.group-option {
  padding-left: 2rem;
}

.chosen-container .chosen-results li em {
  font-style: normal;
  text-decoration: underline;
  font-weight: 600;
  background-color: rgba(13, 110, 253, 0.1);
}

/* @end */

/* @group Estado Deshabilitado */
.chosen-disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.chosen-disabled .chosen-single {
  cursor: not-allowed;
  background-color: var(--bs-secondary-bg);
}

.chosen-disabled .chosen-choices .search-choice .search-choice-close {
  cursor: not-allowed;
}

/* @end */

/* @group Validación de Bootstrap */
.chosen-container.is-invalid .chosen-single,
.was-validated .chosen-container:invalid .chosen-single {
  border-color: #dc3545;
  padding-right: calc(1.5em + 0.75rem);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23dc3545'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z'/%3E%3C/svg%3E") no-repeat right 0.75rem center/calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.chosen-container.is-invalid .chosen-single:focus,
.was-validated .chosen-container:invalid .chosen-single:focus {
  border-color: #dc3545;
  -webkit-box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25);
          box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25);
}

.chosen-container.is-valid .chosen-single,
.was-validated .chosen-container:valid .chosen-single {
  border-color: #198754;
  padding-right: calc(1.5em + 0.75rem);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23198754'%3E%3Cpath d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z'/%3E%3C/svg%3E") no-repeat right 0.75rem center/calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.chosen-container.is-valid .chosen-single:focus,
.was-validated .chosen-container:valid .chosen-single:focus {
  border-color: #198754;
  -webkit-box-shadow: 0 0 0 0.25rem rgba(25, 135, 84, 0.25);
          box-shadow: 0 0 0 0.25rem rgba(25, 135, 84, 0.25);
}

/* @end */

/* @group Multi Chosen (opcional) */
.chosen-container-multi .chosen-choices {
  position: relative;
  overflow: hidden;
  margin: 0;
  padding: 0.375rem 0.75rem;
  width: 100%;
  min-height: calc(1.5em + 0.75rem + 2px);
  border: var(--bs-border-width) solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  background-color: var(--bs-body-bg);
  cursor: text;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.chosen-container-multi .chosen-choices li {
  float: left;
  list-style: none;
}

.chosen-container-multi .chosen-choices li.search-field {
  margin: 0;
  padding: 0;
  white-space: nowrap;
  flex: 1;
}

.chosen-container-multi .chosen-choices li.search-field input[type="text"] {
  margin: 0;
  padding: 0;
  height: auto;
  outline: 0;
  border: 0 !important;
  background: transparent !important;
  -webkit-box-shadow: none;
          box-shadow: none;
  color: var(--bs-body-color);
  font-size: 1rem;
  font-family: inherit;
  line-height: 1.5;
  width: 100%;
}

.chosen-container-multi .chosen-choices li.search-choice {
  position: relative;
  margin: 0;
  padding: 0.25rem 1.5rem 0.25rem 0.5rem;
  border: var(--bs-border-width) solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  background-color: var(--bs-secondary-bg);
  color: var(--bs-body-color);
  font-size: 0.875rem;
  line-height: 1.4;
  cursor: default;
  display: inline-flex;
  align-items: center;
}

.chosen-container-multi .chosen-choices li.search-choice .search-choice-close {
  position: absolute;
  top: 50%;
  right: 0.25rem;
  display: block;
  width: 16px;
  height: 16px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%236c757d'%3E%3Cpath d='M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z'/%3E%3C/svg%3E") no-repeat center;
  background-size: contain;
  font-size: 1px;
  -webkit-transform: translateY(-50%);
          transform: translateY(-50%);
  cursor: pointer;
  opacity: 0.5;
}

.chosen-container-multi .chosen-choices li.search-choice .search-choice-close:hover {
  opacity: 1;
}

.chosen-container-multi .chosen-drop .result-selected {
  display: none;
}

/* @end */

/* @group Responsive */
@media (max-width: 768px) {
  .chosen-container .chosen-drop {
    position: fixed;
    top: auto;
    left: 0 !important;
    right: 0 !important;
    bottom: 0;
    width: 100%;
    max-height: 60vh;
    border-radius: var(--bs-border-radius) var(--bs-border-radius) 0 0;
    -webkit-box-shadow: 0 -0.125rem 0.5rem rgba(0, 0, 0, 0.15);
            box-shadow: 0 -0.125rem 0.5rem rgba(0, 0, 0, 0.15));
  }
  
  .chosen-container .chosen-results {
    max-height: 50vh;
  }
  
  .chosen-container-single .chosen-search input[type="text"] {
    font-size: 16px; /* Evita zoom en iOS */
  }
}

/* @end */