/* ─────────────────────────────────────────────────────────
   SELECT PERSONALIZADO  (App.Select — js/components/select.js)

   Sigue el lenguaje visual del proyecto: sin líneas de borde,
   campos rellenos en slate-100, radios de 0.75rem y el primario
   rgb(37 99 235). El panel se monta en <body> con position:fixed
   para no quedar recortado por .table-wrap ni por los modales.
   ───────────────────────────────────────────────────────── */

.vselect {
  position: relative;
  width: 100%;
}

/* El <select> real sigue en el DOM: mantiene name/value y el envío
   del formulario. Se oculta sin display:none para no romper la
   validación nativa del navegador. */
.vselect__native {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
  opacity: 0;
}

/* ─── Campo principal ───────────────────────────────────── */
.vselect__control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.625rem 0.75rem 0.625rem 0.875rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
  color: rgb(15 23 42);
  background-color: rgb(241 245 249);
  border: none;
  border-radius: 0.75rem;
  cursor: pointer;
  transition: background-color 0.15s, box-shadow 0.15s;
}

.vselect__control:hover:not(:disabled) {
  background-color: rgb(226 232 240);
}

.vselect__control:focus-visible,
.vselect.is-open .vselect__control {
  outline: none;
  background-color: white;
  box-shadow: 0 0 0 4px rgb(59 130 246 / 0.2);
}

.vselect__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vselect__label.is-placeholder {
  color: rgb(148 163 184);
  font-weight: 400;
}

/* ─── Botones de la derecha ─────────────────────────────── */
.vselect__clear,
.vselect__arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: rgb(100 116 139);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.vselect__clear {
  width: 1.125rem;
  height: 1.125rem;
  border-radius: 9999px;
  color: rgb(148 163 184);
  transition: background-color 0.15s, color 0.15s;
}

.vselect__clear:hover {
  background-color: rgb(226 232 240);
  color: rgb(51 65 85);
}

.vselect__arrow {
  transition: transform 0.18s ease;
}

.vselect.is-open .vselect__arrow {
  transform: rotate(180deg);
}

.vselect__icon {
  width: 1.0625rem;
  height: 1.0625rem;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.vselect__clear .vselect__icon {
  width: 0.75rem;
  height: 0.75rem;
}

/* ─── Estados ───────────────────────────────────────────── */
.vselect.is-disabled .vselect__control {
  background-color: rgb(248 250 252);
  color: rgb(148 163 184);
  cursor: not-allowed;
}

.vselect.is-disabled .vselect__label.is-placeholder {
  color: rgb(203 213 225);
}

.vselect.is-loading .vselect__control {
  cursor: progress;
}

.vselect__spinner {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid rgb(203 213 225);
  border-top-color: rgb(37 99 235);
  animation: vselect-spin 0.7s linear infinite;
}

@keyframes vselect-spin {
  to { transform: rotate(360deg); }
}

/* ─── Panel desplegable ─────────────────────────────────── */
.vselect__panel {
  position: fixed;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  max-height: 17rem;
  padding: 0.375rem;
  background: white;
  border-radius: 0.875rem;
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.06), 0 16px 40px -12px rgb(15 23 42 / 0.28);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.13s ease, transform 0.13s ease;
  overflow: hidden;
}

.vselect__panel.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Abierto hacia arriba: la animación entra desde abajo */
.vselect__panel.is-up {
  transform: translateY(4px);
}

.vselect__panel.is-up.is-visible {
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .vselect__panel,
  .vselect__arrow {
    transition: none;
  }
}

/* ─── Buscador ──────────────────────────────────────────── */
.vselect__search-wrap {
  position: relative;
  flex-shrink: 0;
  margin-bottom: 0.25rem;
}

.vselect__search {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2rem;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  color: rgb(15 23 42);
  background-color: rgb(241 245 249);
  border: none;
  border-radius: 0.625rem;
}

.vselect__search::placeholder {
  color: rgb(148 163 184);
  font-weight: 400;
}

.vselect__search:focus {
  outline: none;
  background-color: white;
  box-shadow: 0 0 0 3px rgb(59 130 246 / 0.18);
}

.vselect__search-icon {
  position: absolute;
  left: 0.625rem;
  top: 50%;
  transform: translateY(-50%);
  width: 0.875rem;
  height: 0.875rem;
  color: rgb(148 163 184);
  pointer-events: none;
}

/* ─── Lista de opciones ─────────────────────────────────── */
.vselect__list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  list-style: none;
  overscroll-behavior: contain;
}

.vselect__list::-webkit-scrollbar {
  width: 8px;
}

.vselect__list::-webkit-scrollbar-thumb {
  background-color: rgb(203 213 225);
  border-radius: 9999px;
}

.vselect__group {
  padding: 0.5rem 0.625rem 0.25rem;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgb(148 163 184);
}

.vselect__option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.625rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: rgb(30 41 59);
  border-radius: 0.625rem;
  cursor: pointer;
  transition: background-color 0.1s;
}

.vselect__option-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vselect__option.is-active {
  background-color: rgb(241 245 249);
}

.vselect__option.is-selected {
  color: rgb(37 99 235);
  font-weight: 700;
}

.vselect__option.is-selected.is-active {
  background-color: rgb(239 246 255);
}

.vselect__option.is-disabled {
  color: rgb(203 213 225);
  cursor: not-allowed;
}

.vselect__check {
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  color: rgb(37 99 235);
  opacity: 0;
}

.vselect__option.is-selected .vselect__check {
  opacity: 1;
}

.vselect__empty {
  padding: 1.5rem 0.75rem;
  text-align: center;
  font-size: 0.8125rem;
  color: rgb(148 163 184);
}

.vselect__loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.5rem 0.75rem;
  font-size: 0.8125rem;
  color: rgb(100 116 139);
}

/* ─── Variante compacta (tablas de ítems) ───────────────── */
.vselect--inline .vselect__control {
  padding: 0.25rem 0.375rem 0.25rem 0.5rem;
  font-size: 0.8125rem;
  background: transparent;
  border-radius: 0.375rem;
}

.vselect--inline .vselect__control:hover:not(:disabled) {
  background-color: rgb(241 245 249);
}

/* ─── Responsive: en móvil el panel ocupa el ancho útil ─── */
@media (max-width: 480px) {
  .vselect__panel {
    max-height: 60vh;
  }

  .vselect__option {
    padding: 0.625rem;
    font-size: 0.875rem;
  }
}
