/*
  BolsaHoy — Componentes compartidos, construidos exclusivamente sobre
  var(--bh-*) de tokens.css. Adopción progresiva: las páginas migradas
  pueden usar estas clases en vez de sus equivalentes locales, no es
  obligatorio migrar todo de golpe.
*/

.bh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--bh-line);
  border-radius: var(--bh-radius-sm);
  background: var(--bh-bg-elevated);
  color: var(--bh-ink);
  font-family: var(--bh-font-sans);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.bh-btn:hover {
  border-color: var(--bh-blue);
}

.bh-btn-primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--bh-blue), var(--bh-blue-2));
  color: var(--bh-white);
}

.bh-btn-primary:hover {
  box-shadow: var(--bh-shadow-glow);
}

.bh-btn-danger {
  border-color: rgba(240, 68, 56, 0.4);
  color: var(--bh-red);
  background: transparent;
}

.bh-card {
  border: 1px solid var(--bh-line);
  border-radius: var(--bh-radius);
  background: var(--bh-panel);
  box-shadow: var(--bh-shadow);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.bh-card:hover {
  border-color: rgba(31, 128, 255, 0.35);
  box-shadow: var(--bh-shadow-glow);
}

.bh-input {
  width: 100%;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--bh-line);
  border-radius: var(--bh-radius-sm);
  background: var(--bh-bg-elevated);
  color: var(--bh-ink);
  font-family: var(--bh-font-sans);
  font-size: 14px;
}

.bh-input:focus {
  outline: none;
  border-color: var(--bh-blue);
}

.bh-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  font-family: var(--bh-font-mono);
}

.bh-badge-up {
  color: var(--bh-up);
  background: rgba(0, 196, 140, 0.14);
}

.bh-badge-down {
  color: var(--bh-down);
  background: rgba(240, 68, 56, 0.14);
}

.bh-mono {
  font-family: var(--bh-font-mono);
  font-variant-numeric: tabular-nums;
}

.bh-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: rgba(2, 4, 10, 0.72);
  backdrop-filter: blur(14px);
}

.bh-modal {
  width: min(560px, calc(100% - 32px));
  max-height: calc(100vh - 64px);
  overflow: auto;
  border: 1px solid var(--bh-line);
  border-radius: var(--bh-radius-lg);
  background: var(--bh-panel);
  box-shadow: var(--bh-shadow);
}

/* Toggle de tema — icono se muestra según data-theme sin JS adicional */
.bh-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--bh-line);
  border-radius: 999px;
  background: var(--bh-bg-elevated);
  color: var(--bh-ink);
  cursor: pointer;
}

.bh-theme-toggle .bh-icon,
[data-theme-toggle] .bh-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
}

[data-theme-toggle] .icon-moon {
  display: none;
}

[data-theme="dark"] [data-theme-toggle] .icon-sun {
  display: none;
}

[data-theme="dark"] [data-theme-toggle] .icon-moon {
  display: inline-block;
}

[data-theme="dark"] .bh-theme-toggle .icon-moon {
  display: inline-block;
}

/* Foco accesible consistente — visible solo en navegación por teclado */
:focus-visible {
  outline: 2px solid var(--bh-blue);
  outline-offset: 2px;
  border-radius: var(--bh-radius-sm);
}

/* Skeleton de carga reutilizable — reemplaza "Cargando..." por un shimmer */
.bh-skeleton {
  position: relative;
  overflow: hidden;
  background: var(--bh-panel-2);
  border-radius: var(--bh-radius-sm);
  color: transparent !important;
}

.bh-skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
  animation: bh-shimmer 1.6s ease-in-out infinite;
}

[data-theme="light"] .bh-skeleton::after {
  background: linear-gradient(90deg, transparent, rgba(8, 9, 11, 0.06), transparent);
}

@keyframes bh-shimmer {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

@media (prefers-reduced-motion: no-preference) {
  .bh-btn,
  .bh-card {
    transition-duration: 0.18s;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bh-btn,
  .bh-card {
    transition: none;
  }
  .bh-skeleton::after {
    animation: none;
  }
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
