:host {
  display: inline-block;
}

:host.app-button-host--full-width {
  display: block;
  width: 100%;
}

.app-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs, 0.25rem);
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius-md, 6px);
  font-family: inherit;
  font-weight: var(--font-weight-semibold, 600);
  line-height: 1;
  cursor: pointer;
  transition: background-color var(--transition-fast, 120ms ease),
    border-color var(--transition-fast, 120ms ease),
    box-shadow var(--transition-fast, 120ms ease),
    opacity var(--transition-fast, 120ms ease);

  &:focus-visible {
    outline: 2px solid var(--primary-color, #2f6e5d);
    outline-offset: 2px;
  }

  &:disabled {
    cursor: not-allowed;
    opacity: 0.6;
  }
}

.app-button--sm {
  height: 32px;
  padding: 0 var(--space-sm, 0.5rem);
  font-size: var(--font-size-sm, 0.8125rem);
}

.app-button--md {
  height: 40px;
  padding: 0 var(--space-md, 1rem);
  font-size: var(--font-size-md, 0.9375rem);
}

.app-button--lg {
  height: 48px;
  padding: 0 var(--space-lg, 1.5rem);
  font-size: var(--font-size-lg, 1rem);
}

.app-button--primary {
  background: var(--primary-color, #2f6e5d);
  border-color: var(--primary-color, #2f6e5d);
  color: var(--bg-primary, #fff);

  &:hover:not(:disabled) {
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.08));
  }
}

.app-button--secondary {
  background: var(--bg-secondary, #f4f4f5);
  border-color: var(--border-color, #e4e4e7);
  color: var(--text-primary, #1f322d);

  &:hover:not(:disabled) {
    border-color: var(--primary-color, #2f6e5d);
  }
}

.app-button--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-primary, #1f322d);

  &:hover:not(:disabled) {
    background: var(--bg-secondary, #f4f4f5);
  }
}

.app-button--danger {
  background: var(--error-color, #c0392b);
  border-color: var(--error-color, #c0392b);
  color: var(--bg-primary, #fff);

  &:hover:not(:disabled) {
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.08));
  }
}

.app-button__spinner {
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: app-button-spin 0.6s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .app-button {
    transition: none;
  }

  .app-button__spinner {
    animation-duration: 1.2s;
  }
}

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