/* Component: Buttons - Unified Modern Premium Design
   All buttons share the same base styling with consistent spacing, shadows, and interactions.
   Variants only differ in color scheme, not in structure or behavior. */

:root {
  /* Button tokens - unified for all variants */
  --btn-radius: 0.75rem;
  --btn-padding-y: 0.75rem;
  --btn-padding-x: 1.5rem;
  --btn-font-size: 0.95rem;
  --btn-font-weight: 600;
  --btn-line-height: 1.5;
  --btn-transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Primary gradient colors - softer */
  --btn-primary-from: #818cf8;
  --btn-primary-to: #a78bfa;
  --btn-primary-hover-from: #6366f1;
  --btn-primary-hover-to: #8b5cf6;
  
  /* Unified shadow system - dezenter */
  --btn-shadow-rest: 0 2px 8px rgba(129, 140, 248, 0.1), 0 1px 3px rgba(0, 0, 0, 0.06);
  --btn-shadow-hover: 0 8px 24px rgba(129, 140, 248, 0.15), 0 4px 12px rgba(0, 0, 0, 0.08);
  --btn-shadow-active: 0 1px 3px rgba(129, 140, 248, 0.1), 0 0 0 0 rgba(0, 0, 0, 0);
}

/* Base button - unified design for all variants */
.btn, a.btn {
  /* Layout & Spacing */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: var(--btn-padding-y) var(--btn-padding-x);
  
  /* Typography */
  font-size: var(--btn-font-size);
  font-weight: var(--btn-font-weight);
  line-height: var(--btn-line-height);
  text-decoration: none;
  white-space: nowrap;
  
  /* Visual */
  border-radius: var(--btn-radius);
  border: none;
  background: transparent;
  color: inherit;
  
  /* Interaction */
  cursor: pointer;
  user-select: none;
  vertical-align: middle;
  transition: var(--btn-transition);
  
  /* Positioning */
  position: relative;
  overflow: hidden;
  
  /* Initial state */
  box-shadow: var(--btn-shadow-rest);
  transform: translateY(0) scale(1);
}

/* Unified hover state - applies to all buttons */
.btn:hover:not(:disabled):not([aria-disabled="true"]) {
  transform: translateY(-2px) scale(1.02);
  box-shadow: var(--btn-shadow-hover);
}

/* Unified active state */
.btn:active:not(:disabled):not([aria-disabled="true"]) {
  transform: translateY(0) scale(0.98);
  box-shadow: var(--btn-shadow-active);
}

/* Unified focus state */
.btn:focus {
  outline: none;
  box-shadow: var(--btn-shadow-hover), 0 0 0 3px rgba(129, 140, 248, 0.15);
}

/* === BUTTON VARIANTS === */
/* All variants share the same structure, only colors differ */

/* Primary - Gradient button (default style) */
.btn-primary {
  background: transparent !important;
  color: white;
  position: relative;
  z-index: 1;
}

/* Base Gradient */
.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--btn-primary-from) 0%, var(--btn-primary-to) 100%);
  z-index: -1;
  transition: opacity 0.3s ease;
  border-radius: inherit;
}

/* Hover Gradient */
.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--btn-primary-hover-from) 0%, var(--btn-primary-hover-to) 100%);
  opacity: 0;
  z-index: -1;
  transition: opacity 0.3s ease;
  border-radius: inherit;
}

.btn-primary:hover::after {
  opacity: 1;
}

/* Vibrant CTA - Extra prominent */
.btn-vibrant {
  background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  color: white !important;
  padding: 1rem 2.5rem;
  font-size: 1.1rem;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 10px 25px rgba(99, 102, 241, 0.4);
  animation: pulse-light 3s infinite;
}

.btn-vibrant:hover {
  background: linear-gradient(135deg, #4f46e5 0%, #9333ea 100%);
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 15px 35px rgba(99, 102, 241, 0.5);
  animation: none;
}

@keyframes pulse-light {
  0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.6); }
  70% { box-shadow: 0 0 0 15px rgba(99, 102, 241, 0); }
  100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

/* Secondary - Neutral gradient */
.btn-secondary {
  background: transparent !important;
  color: white;
  position: relative;
  z-index: 1;
}

/* Base Gradient */
.btn-secondary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #64748b 0%, #475569 100%);
  z-index: -1;
  transition: opacity 0.3s ease;
  border-radius: inherit;
}

/* Hover Gradient */
.btn-secondary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #475569 0%, #334155 100%);
  opacity: 0;
  z-index: -1;
  transition: opacity 0.3s ease;
  border-radius: inherit;
}

.btn-secondary:hover::after {
  opacity: 1;
}

/* Outline - Same structure, transparent background with gradient border */
.btn-outline {
  background: transparent;
  border: 2px solid transparent;
  background-image: 
    linear-gradient(white, white),
    linear-gradient(135deg, var(--btn-primary-from) 0%, var(--btn-primary-to) 100%);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  color: var(--btn-primary-from);
  box-shadow: none;
}

.btn-outline:hover {
  background-image: 
    linear-gradient(135deg, rgba(129, 140, 248, 0.04) 0%, rgba(167, 139, 250, 0.04) 100%),
    linear-gradient(135deg, var(--btn-primary-hover-from) 0%, var(--btn-primary-hover-to) 100%);
  color: var(--btn-primary-hover-from);
}

.btn-outline.btn-primary {
  color: var(--btn-primary-from);
}

/* Ghost - Minimal, transparent with subtle hover */
.btn-ghost {
  background: transparent;
  color: var(--btn-primary-from);
  box-shadow: none;
}

.btn-ghost:hover {
  background: rgba(129, 140, 248, 0.06);
  box-shadow: none;
}

/* Muted - Soft gray gradient */
.btn-muted {
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  color: #475569;
}

.btn-muted::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 0;
}

.btn-muted:hover::before {
  opacity: 1;
}

.btn-muted > * {
  position: relative;
  z-index: 1;
}

/* Link - Text-only button */
.btn-link {
  background: transparent;
  color: var(--btn-primary-from);
  box-shadow: none;
  text-decoration: underline;
  padding: 0.25rem 0.5rem;
}

.btn-link:hover {
  color: var(--btn-primary-hover-from);
  text-decoration: none;
  box-shadow: none;
  transform: none;
}

/* === SIZE VARIANTS === */
/* Unified sizing - maintains proportions across all variants */

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  border-radius: calc(var(--btn-radius) - 0.125rem);
}

.btn-lg {
  padding: 1rem 2rem;
  font-size: 1.125rem;
  border-radius: calc(var(--btn-radius) + 0.125rem);
}

.btn-block, .btn-full {
  display: flex;
  width: 100%;
}

/* Icon-only button - perfect square */
.btn-icon {
  padding: 0.75rem;
  width: 3rem;
  height: 3rem;
  aspect-ratio: 1;
}

.btn-icon.btn-sm {
  padding: 0.5rem;
  width: 2.25rem;
  height: 2.25rem;
}

.btn-icon.btn-lg {
  padding: 1rem;
  width: 3.75rem;
  height: 3.75rem;
}

.btn-icon svg, .btn-icon i {
  pointer-events: none;
}

/* === SHAPE VARIANTS === */
.btn-pill {
  border-radius: 999px;
}

.btn-square {
  border-radius: 0.375rem;
}

/* === STATES === */

/* Disabled / aria-disabled - unified across all variants */
.btn:disabled,
.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
  pointer-events: none;
}

.btn:disabled::before,
.btn[disabled]::before,
.btn[aria-disabled="true"]::before {
  display: none;
}

/* Loading state - unified spinner animation */
.btn.loading {
  pointer-events: none;
  position: relative;
}

.btn.loading .btn-text {
  opacity: 0;
}

.btn.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 1.25rem;
  height: 1.25rem;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
}

/* Loading spinner colors for different variants */
.btn-outline.loading::after,
.btn-ghost.loading::after,
.btn-link.loading::after,
.btn-muted.loading::after {
  border-color: rgba(129, 140, 248, 0.15);
  border-top-color: var(--btn-primary-from);
}

@keyframes btn-spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* === ACCESSIBILITY === */

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .btn {
    transition: none;
  }
  .btn.loading::after {
    animation: none;
    opacity: 0.5;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .btn {
    border: 2px solid currentColor;
  }
}
