/**
 * SVGaze - Button Components
 *
 * All button styles and variants used throughout the application.
 */

/* === Base Button === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);

  padding: var(--button-padding-y) var(--button-padding-x);
  border: none;
  border-radius: var(--radius-md);

  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  text-align: center;
  text-decoration: none;
  white-space: nowrap;

  cursor: pointer;
  user-select: none;
  transition: all var(--transition-fast);

  /* Primary variant (default) */
  background: var(--primary);
  color: #ffffff;
}

.btn svg {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

.btn:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

/* === Button Variants === */

/* Ghost Button - Outline style */
.btn.ghost {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn.ghost:hover:not(:disabled) {
  background: var(--primary-light);
  border-color: var(--primary-hover);
  color: var(--primary-hover);
}

/* Secondary Button */
.btn.secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn.secondary:hover:not(:disabled) {
  background: var(--bg);
  border-color: var(--border-hover);
}

/* Success Button */
.btn.success {
  background: var(--success);
  color: #ffffff;
}

.btn.success:hover:not(:disabled) {
  background: #15803d;
}

/* Danger Button */
.btn.danger {
  background: var(--error);
  color: #ffffff;
}

.btn.danger:hover:not(:disabled) {
  background: #b91c1c;
}

/* === Small Buttons === */
.small-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);

  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);

  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-tight);
  white-space: nowrap;

  background: var(--card);
  color: var(--text-primary);

  cursor: pointer;
  user-select: none;
  transition: all var(--transition-fast);
}

.small-btn:hover:not(:disabled) {
  background: var(--bg);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.small-btn:active:not(:disabled) {
  transform: translateY(0);
}

.small-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.small-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Small Button Variants */
.small-btn.primary {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.small-btn.primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.small-btn.edit {
  background: rgba(59, 130, 246, 0.05);
  border-color: rgba(59, 130, 246, 0.2);
}

.small-btn.edit:hover:not(:disabled) {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.4);
}

.small-btn.success {
  background: var(--success);
  color: #ffffff;
  border-color: var(--success);
}

.small-btn.success:hover:not(:disabled) {
  background: #15803d;
  border-color: #15803d;
}

.small-btn.ghost {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-normal);
}

.small-btn.ghost:hover:not(:disabled) {
  background: transparent;
  color: var(--primary);
  text-decoration: none;
}

/* === Icon Buttons === */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);

  background: var(--card);
  color: var(--text-secondary);

  cursor: pointer;
  transition: all var(--transition-fast);
}

.icon-btn:hover:not(:disabled) {
  background: var(--bg);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.icon-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.icon-btn.primary {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.icon-btn.primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

/* === Button States === */

/* Favorited state for star button */
.favorited {
  color: var(--favorite-color) !important;
}

.small-btn.favorited {
  background: var(--warning-light);
  border-color: var(--favorite-color);
}

/* Loading state */
.btn.loading,
.small-btn.loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.btn.loading::after,
.small-btn.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  margin-left: -8px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* === Button Groups === */
.button-group {
  display: inline-flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.button-group .btn,
.button-group .small-btn {
  flex-shrink: 0;
}

/* === Responsive === */
@media (max-width: 640px) {
  .btn {
    padding: 6px 10px;
    font-size: var(--font-size-sm);
  }

  .small-btn {
    padding: 4px 6px;
    font-size: var(--font-size-xs);
  }
}
