/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: 12px var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  transition:
    background var(--transition),
    color var(--transition);
  white-space: nowrap;
}

/* Primario: dark, para fondos claros */
.btn-primary {
  background: var(--interactive-secondary);
  color: var(--text-on-dark);
}
.btn-primary:hover {
  background: var(--interactive-secondary-hover);
  color: var(--text-on-dark);
}

/* Acento: para usar sobre header/hero oscuro */
.btn-accent {
  background: var(--interactive-primary);
  color: var(--text-on-accent);
}
.btn-accent:hover {
  background: var(--interactive-primary-hover);
  color: var(--text-on-accent);
}
.btn-accent:active {
  background: var(--interactive-primary-active);
  color: var(--text-on-accent);
}

/* Modificador píldora */
.btn--pill {
  border-radius: var(--radius-full);
}

/* Outline: transparente con borde blanco — para usar sobre fondos oscuros */
.btn-outline {
  background: transparent;
  color: var(--neutral-0);
  border: 1px solid var(--neutral-0);
}
.btn-outline:hover {
  background: rgba(255, 255, 255, 0.1);
}
.btn-outline:active {
  background: rgba(255, 255, 255, 0.18);
}

/* Outline dark: transparente con borde oscuro — para usar sobre fondos claros */
.btn-outline--dark {
  background: transparent;
  color: var(--text-on-light);
  border: 1px solid var(--text-on-light);
}
.btn-outline--dark:hover {
  background: rgba(0, 0, 0, 0.06);
}
.btn-outline--dark:active {
  background: rgba(0, 0, 0, 0.12);
}

/* Brand rojo: para CTAs de alta jerarquía sobre fondos oscuros */
.btn-brand {
  background: var(--color-primary);
  color: var(--neutral-0);
}
.btn-brand:hover {
  background: var(--color-error);
  color: var(--neutral-0);
}
.btn-brand:active {
  background: #9b1111;
  color: var(--neutral-0);
}

.btn-ghost {
  background: transparent;
  color: var(--text-on-light);
  border: 1px solid var(--border-default);
}
.btn-ghost:hover {
  background: var(--neutral-50);
}

/* ── Search bar (sobre header oscuro) ── */
.search-bar {
  display: flex;
  flex: 1;
  max-width: 560px;
}

.search-bar input {
  flex: 1;
  padding: 10px var(--space-2);
  background: var(--surface-dark-1);
  border: 1px solid var(--surface-dark-2);
  border-right: none;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  font-size: var(--text-md);
  color: var(--text-on-dark);
  outline: none;
  transition: border-color var(--transition);
}
.search-bar input::placeholder {
  color: var(--text-on-dark-muted);
}
.search-bar input:focus {
  border-color: var(--border-focus);
}

.search-bar button {
  padding: 10px var(--space-3);
  background: var(--interactive-primary);
  color: var(--text-on-accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  transition: background var(--transition);
}
.search-bar button:hover {
  background: var(--interactive-primary-hover);
}
.search-bar button:active {
  background: var(--interactive-primary-active);
}

/* ── Product card ── */
.product-card {
  background: var(--surface-light-1);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  transition:
    box-shadow var(--transition),
    transform var(--transition);
}
.product-card:hover {
  box-shadow: var(--shadow-md);
}

.product-card__code {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-on-light-muted);
}

.product-card__name {
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
  color: var(--text-on-light);
}

.product-card__brand {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-accent-safe);
}

.product-card__aplicacion {
  font-size: var(--text-xs);
  color: var(--text-on-light-secondary);
  margin-top: auto;
  line-height: var(--leading-normal);
}

.product-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-1);
  padding-top: var(--space-1);
  border-top: 1px solid var(--border-default);
}

/* ── Badge ── */
.badge {
  display: inline-block;
  padding: var(--space-0-5) var(--space-1);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}
.badge-stock {
  background: #e8f5e9;
  color: var(--color-success);
}
.badge-nostock {
  background: #ffebee;
  color: var(--color-error);
}

/* ── Filter group ── */
.filter-group {
  margin-bottom: var(--space-2);
}

.filter-group__title {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--text-on-light-muted);
  margin-bottom: var(--space-1);
}

.filter-option {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-0-5) 0;
  font-size: var(--text-sm);
  color: var(--text-on-light-secondary);
  cursor: pointer;
}
.filter-option input {
  cursor: pointer;
  accent-color: var(--interactive-secondary);
}

/* ── Results info ── */
.results-info {
  font-size: var(--text-sm);
  color: var(--text-on-light-muted);
  margin-bottom: var(--space-2);
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: var(--space-10) var(--space-2);
  color: var(--text-on-light-secondary);
}
.empty-state h3 {
  margin-bottom: var(--space-1);
  color: var(--text-on-light);
}

/* ── Loader ── */
.loader {
  display: flex;
  justify-content: center;
  padding: var(--space-8);
}
.loader::after {
  content: "";
  width: 32px;
  height: 32px;
  border: 3px solid var(--neutral-200);
  border-top-color: var(--color-accent-safe);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── WhatsApp Widget ── */
.chat-widget {
  position: fixed;
  bottom: var(--space-4);
  right: var(--space-4);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
}

.chat-widget__popup {
  width: 320px;
  background: var(--neutral-100);
  border-radius: 16px;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(12px) scale(0.96);
  transition:
    transform var(--duration-slow) var(--ease-spring),
    opacity var(--duration-slow) var(--ease-default),
    visibility 0s var(--duration-slow);
}

.chat-widget__popup.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  transition:
    transform var(--duration-slow) var(--ease-spring),
    opacity var(--duration-slow) var(--ease-default),
    visibility 0s 0s;
}

.chat-widget__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  background: var(--surface-dark-1);
  color: var(--text-on-dark);
}

.chat-widget__title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.chat-widget__close {
  background: transparent;
  color: var(--text-on-dark);
  font-size: 20px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  opacity: 0.65;
  transition: opacity var(--transition);
}
.chat-widget__close:hover {
  opacity: 1;
}

.chat-widget__body {
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.chat-widget__bubble {
  background: var(--surface-light-1);
  border-radius: var(--radius-xl);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-md);
  color: var(--text-on-light);
  line-height: var(--leading-relaxed);
}

.chat-widget__bubble p + p {
  margin-top: var(--space-1);
}

.chat-widget__input-row {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.chat-widget__input {
  flex: 1;
  padding: 10px var(--space-2);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  background: var(--surface-light-1);
  font-size: var(--text-sm);
  color: var(--text-on-light);
  outline: none;
  transition: border-color var(--transition);
}
.chat-widget__input::placeholder {
  color: var(--text-on-light-muted);
}
.chat-widget__input:focus {
  border-color: var(--interactive-whatsapp);
}

.chat-widget__send {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  background: var(--interactive-whatsapp);
  color: var(--neutral-0);
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background var(--transition),
    transform var(--transition);
}
.chat-widget__send:hover {
  background: #1ebe5d;
}
.chat-widget__send:active {
  transform: scale(0.93);
}

.chat-widget__trigger {
  width: 60px;
  height: 60px;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  background: var(--interactive-whatsapp);
  color: var(--neutral-0);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transition:
    transform var(--transition),
    box-shadow var(--transition);
}
.chat-widget__trigger:hover {
  transform: scale(1.06);
}
.chat-widget__trigger:active {
  transform: scale(0.94);
}

@media (max-width: 480px) {
  .chat-widget {
    bottom: var(--space-3);
    right: var(--space-3);
  }
  .chat-widget__popup {
    width: calc(100vw - 48px);
  }
}

/* ── Form feedback ── */
.form-feedback {
  padding: var(--space-1-5) var(--space-2);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  margin-bottom: var(--space-3);
}

.form-feedback--ok {
  color: #fff;
  background: var(--color-success);
}

.form-feedback--error {
  color: #fff;
  background: var(--color-error);
}
