/*
 * BSCountryPicker — estilos del selector de países buscable.
 * Todas las clases usan el prefijo bs-cp- (ver CLAUDE.md: nada de clases
 * genéricas que puedan colisionar con el resto del sitio).
 * Usa exclusivamente variables del sitio (bs-base.css), no colores literales.
 */

.bs-cp {
  position: relative;
  width: 100%;
  max-width: 100%;
  font-family: Lexend, Roboto, Arial, sans-serif;
}

.bs-cp-field {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.bs-cp-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 34px 10px 14px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--bs-text-0);
  background: var(--bs-surface-0);
  border: 1px solid var(--bs-border);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.bs-cp-input::placeholder {
  color: var(--bs-text-2);
}

.bs-cp-input:focus {
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--bs-primary) 25%, transparent);
}

.bs-cp-input[aria-expanded="true"] {
  border-radius: 10px 10px 0 0;
}

.bs-cp-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--bs-text-2);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0;
  transition: color 0.2s ease, background 0.2s ease;
}

.bs-cp-clear:hover {
  color: var(--bs-text-0);
  background: var(--soft-tone);
}

.bs-cp-clear:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
}

/* Desplegable ------------------------------------------------------- */

.bs-cp-listbox {
  position: absolute;
  z-index: 40;
  top: 100%;
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  max-height: 17.5rem; /* ~8 opciones visibles + scroll */
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bs-surface-0);
  border: 1px solid var(--bs-primary);
  border-top: none;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 14px 32px -12px rgba(0, 0, 0, 0.45);
}

.bs-cp-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  color: var(--bs-text-0);
  font-size: 0.92rem;
  scroll-margin: 4px;
}

.bs-cp-option--active,
.bs-cp-option:hover {
  background: var(--soft-tone);
}

.bs-cp-option[aria-selected="true"] {
  color: var(--bs-primary);
}

.bs-cp-flag {
  flex: 0 0 auto;
  font-size: 1.15em;
  line-height: 1;
  min-width: 1.4em;
  text-align: center;
}

.bs-cp-option-name {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Sin resultados: la lista queda vacía (sin fila especial); el propio
   vacío ya comunica "no matches" en un combobox estándar. */

/* Badge de 2 letras cuando el sistema no dibuja banderas emoji -------- */

.bs-cp--noflag .bs-cp-flag--badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.9em;
  padding: 1px 5px;
  font-size: 0.68rem;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--bs-btn-primary-fg, var(--bs-surface-0));
  background: var(--bs-primary);
  border-radius: 999px;
  line-height: 1.6;
}

/* Modo degradado (countries.json no cargó): input simple de 2 letras -- */

.bs-cp--degraded .bs-cp-input {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: 'JetBrains Mono', monospace;
  text-align: center;
  max-width: 6rem;
}

/* Responsive: el desplegable no debe salirse de la pantalla ----------- */

@media (max-width: 480px) {
  .bs-cp-listbox {
    max-height: 60vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bs-cp-input,
  .bs-cp-clear {
    transition: none;
  }
}
