/* ============================================================================
 * DESIGN SYSTEM AUAS — BOTONES
 * ----------------------------------------------------------------------------
 * Bootstrap 5.3.2 ya resuelve el 95% de los casos. Este archivo SOLO:
 *   1. Normaliza los tamaños para que coincidan con los tokens
 *   2. Añade el estado de foco accesible
 *   3. Cubre los dos patrones propios del producto (FAB, acciones de tabla)
 *
 * No redefinir colores de botón: usar las clases de Bootstrap.
 * ========================================================================= */

/* ==========================================================================
   1. CONSISTENCIA DE ALTURA
   Los tokens declaran --ui-control-height*; Bootstrap usa rem.
   Se alinean ambos para que input, select y botón midan lo mismo.
   ========================================================================= */
.btn {
  --bs-btn-padding-y: 0.375rem;
  --bs-btn-padding-x: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  font-weight: var(--ui-font-weight-semibold);
  border-radius: var(--ui-radius-xs);
  transition: var(--ui-transition-theme);
}

.btn-sm {
  --bs-btn-padding-y: 0.25rem;
  --bs-btn-padding-x: 0.5rem;
}

.btn-lg {
  --bs-btn-padding-y: 0.5rem;
  --bs-btn-padding-x: 1rem;
}

/* ==========================================================================
   2. FOCO ACCESIBLE
   El template no define un anillo de foco consistente. Este es el valor
   real del producto: 0 0 0 0.2rem rgba(4,169,245,.25)
   ========================================================================= */
.btn:focus-visible,
.btn-primary:focus-visible,
.btn-outline-primary:focus-visible {
  box-shadow: var(--ui-shadow-focus);
  border-color: var(--ui-primary);
  outline: 0;
}

.btn:focus:not(:focus-visible) {
  box-shadow: none;
}

/* ==========================================================================
   3. ICONOS DENTRO DEL BOTÓN
   `gap` ya gestiona el espacio: no usar margin en el <i>.
   ========================================================================= */
.btn > i,
.btn > .feather,
.btn > svg {
  flex-shrink: 0;
  width: 1em;
  height: 1em;
}

/* Estado deshabilitado con icono: atenuar el icono también */
.btn:disabled > i,
.btn.disabled > i {
  opacity: 0.65;
}

/* ==========================================================================
   4. ESTADO DE CARGA
   Patrón ya usado en risk_assesment/polls_modal.js:84
   ========================================================================= */
.btn.is-loading {
  pointer-events: none;
  opacity: 0.75;
}

.btn.is-loading > .spinner-border {
  width: 1em;
  height: 1em;
  border-width: 0.15em;
}

/* ==========================================================================
   5. FAB — floating button (patrón propio de Datta able)
   Preservado: es el patrón de "agregar registro" en todos los listados.
   Definido en {COMPANY}/css/style-custom.css:14
   ========================================================================= */
.floating-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-weight: var(--ui-font-weight-semibold);
  color: var(--ui-text-inverse);
  background: var(--ui-primary);
  border: 0;
  border-radius: var(--ui-radius-pill);
  box-shadow: var(--ui-shadow-dropdown);
  transition: var(--ui-transition-theme);
}

.floating-button:hover,
.floating-button:focus-visible {
  background: var(--ui-primary-hover);
  box-shadow: var(--ui-shadow-focus);
}

.floating-button:active {
  background: var(--ui-primary-active);
}

/* ==========================================================================
   6. BOTONES EN CELDAS DE TABLA
   Altura fija para que las filas no se descriptorquen.
   ========================================================================= */
.table td .btn,
.table th .btn {
  min-width: 2rem;
}

/* ==========================================================================
   7. BOTONES SOLO-ICONO
   Proporción cuadrada para alinear columnas de acciones.
   ========================================================================= */
.btn-square {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--ui-control-height-sm);
  height: var(--ui-control-height-sm);
  padding: 0;
}

/* ==========================================================================
   8. GRUPO DE BOTONES
   ========================================================================= */
.btn-group > .btn:not(:first-child) {
  margin-left: -1px;
}

.btn-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ui-space-2);
}
