/* Button Component - Enhanced Hierarchy */

/* Base Button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: 0.75rem 1.5rem;
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  line-height: 1;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  border: 2px solid transparent;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  user-select: none;
  position: relative;
  overflow: hidden;
}

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

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

/* Primary Button - Highest priority CTA */
.btn-primary {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(139, 92, 246, 0.3);
}

/* Secondary Button - Less emphasis */
.btn-secondary {
  background: transparent;
  color: var(--color-text-dark);
  border-color: var(--color-border-light);
}

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

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

/* Transparent variants for dark backgrounds */
.navigation-transparent .btn-secondary {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border-color: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(10px);
}

.navigation-transparent .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.6);
}

.navigation-transparent .btn-primary {
  background: white;
  color: var(--color-primary);
  border-color: white;
}

.navigation-transparent .btn-primary:hover {
  background: rgba(255, 255, 255, 0.95);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Tertiary Button - Minimal emphasis */
.btn-tertiary {
  background: transparent;
  color: var(--color-primary);
  border-color: transparent;
  padding: 0.5rem 1rem;
}

.btn-tertiary:hover:not(:disabled) {
  background: var(--color-primary-alpha);
  color: var(--color-primary-dark);
}

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

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

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

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
  border-color: #dc2626;
}

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

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

/* Button Sizes */
.btn-small,
.btn-sm {
  padding: 0.5rem 1rem;
  font-size: var(--font-size-sm);
}

.btn-large,
.btn-lg {
  padding: 1rem 2rem;
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
}

/* Block Button */
.btn-block {
  display: flex;
  width: 100%;
}

/* Icon Buttons */
.btn-icon {
  padding: 0.75rem;
  aspect-ratio: 1;
}

.btn-icon.btn-small {
  padding: 0.5rem;
}

.btn-icon.btn-large {
  padding: 1rem;
}

/* Button with icon */
.btn svg {
  width: 1.25rem;
  height: 1.25rem;
}

.btn-small svg,
.btn-sm svg {
  width: 1rem;
  height: 1rem;
}

.btn-large svg,
.btn-lg svg {
  width: 1.5rem;
  height: 1.5rem;
}

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

.btn-loading::after {
  content: '';
  position: absolute;
  width: 1rem;
  height: 1rem;
  top: 50%;
  left: 50%;
  margin-left: -0.5rem;
  margin-top: -0.5rem;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: button-spin 0.6s linear infinite;
}

.btn-secondary.btn-loading::after {
  border-color: rgba(0, 0, 0, 0.2);
  border-top-color: var(--color-primary);
}

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

/* Button Groups */
.btn-group {
  display: inline-flex;
  gap: var(--spacing-sm);
}

.btn-group .btn {
  margin: 0;
}

.btn-group-vertical {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

/* Responsive Button Behavior */
@media (max-width: 768px) {
  .btn {
    padding: 0.875rem 1.5rem;
    font-size: var(--font-size-base);
  }
  
  .btn-large,
  .btn-lg {
    padding: 1rem 1.75rem;
    font-size: var(--font-size-lg);
  }
  
  .btn-small,
  .btn-sm {
    padding: 0.625rem 1rem;
    font-size: var(--font-size-sm);
  }
  
  /* Stack button groups on mobile */
  .btn-group {
    flex-direction: column;
    width: 100%;
  }
  
  .btn-group .btn {
    width: 100%;
  }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  .btn {
    border-width: 3px;
  }
  
  .btn-primary {
    border-color: var(--color-primary-dark);
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .btn {
    transition: none;
  }
  
  .btn:hover {
    transform: none;
  }
}
