/* ════════════════════════════════════════════════════════════════════════════════
   BUTTON SYSTEM - Complete Button Component Library
   All variants, sizes, states, and interactive elements
════════════════════════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────────────────────
   BASE BUTTON STYLES
   ───────────────────────────────────────────────────────────────────────────── */

button,
.btn,
.button {
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─────────────────────────────────────────────────────────────────────────────
   PRIMARY BUTTON (Call-to-Action)
   ───────────────────────────────────────────────────────────────────────────── */

/* Opt-in only: do not style every <button> (breaks nav, games, sidebar). */
.btn,
.btn-primary,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-2);
  padding: 11px 20px;
  border-radius: var(--radius-lg);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  border: none;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--primary-400), var(--primary-600));
  color: #fff;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35);
  transition: all var(--duration-150) var(--ease-out);
}

.btn:hover,
.btn-primary:hover,
.button:hover {
  filter: brightness(1.08);
  box-shadow: 0 12px 32px rgba(99, 102, 241, 0.45);
  transform: translateY(-2px);
}

.btn:active,
.btn-primary:active,
.button:active {
  transform: scale(0.96);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

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

.btn:disabled,
.btn-primary:disabled,
.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ─────────────────────────────────────────────────────────────────────────────
   SECONDARY BUTTON
   ───────────────────────────────────────────────────────────────────────────── */

.btn-secondary {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary-400);
  border: 1.5px solid rgba(129, 140, 248, 0.35);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
}

.btn-secondary:hover {
  background: rgba(99, 102, 241, 0.25);
  border-color: rgba(129, 140, 248, 0.55);
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.2);
  transform: translateY(-2px);
}

.btn-secondary:active {
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}

/* ─────────────────────────────────────────────────────────────────────────────
   OUTLINED / GHOST BUTTON
   ───────────────────────────────────────────────────────────────────────────── */

.btn-ghost,
.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1.5px solid var(--border-hover);
  box-shadow: none;
}

.btn-ghost:hover,
.btn-outline:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transform: translateY(-2px);
}

.btn-ghost:active,
.btn-outline:active {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* ─────────────────────────────────────────────────────────────────────────────
   DANGER / DESTRUCTIVE BUTTON
   ───────────────────────────────────────────────────────────────────────────── */

.btn-danger,
.btn-delete {
  background: linear-gradient(135deg, var(--danger-500), var(--danger-600));
  color: #fff;
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.35);
}

.btn-danger:hover,
.btn-delete:hover {
  filter: brightness(1.08);
  box-shadow: 0 12px 32px rgba(239, 68, 68, 0.45);
  transform: translateY(-2px);
}

.btn-danger:active,
.btn-delete:active {
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
}

/* ─────────────────────────────────────────────────────────────────────────────
   SUCCESS / POSITIVE BUTTON
   ───────────────────────────────────────────────────────────────────────────── */

.btn-success {
  background: linear-gradient(135deg, var(--success-500), var(--success-600));
  color: #fff;
  box-shadow: 0 8px 24px rgba(34, 197, 94, 0.35);
}

.btn-success:hover {
  filter: brightness(1.08);
  box-shadow: 0 12px 32px rgba(34, 197, 94, 0.45);
  transform: translateY(-2px);
}

.btn-success:active {
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.25);
}

/* ─────────────────────────────────────────────────────────────────────────────
   WARNING / CAUTION BUTTON
   ───────────────────────────────────────────────────────────────────────────── */

.btn-warning {
  background: linear-gradient(135deg, var(--warning-500), var(--warning-600));
  color: #000;
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.35);
  font-weight: var(--font-weight-extrabold);
}

.btn-warning:hover {
  filter: brightness(1.08);
  box-shadow: 0 12px 32px rgba(245, 158, 11, 0.45);
  transform: translateY(-2px);
}

.btn-warning:active {
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}

/* ─────────────────────────────────────────────────────────────────────────────
   INFO / ACCENT BUTTON
   ───────────────────────────────────────────────────────────────────────────── */

.btn-info {
  background: linear-gradient(135deg, var(--info-500), var(--info-600));
  color: #fff;
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.35);
}

.btn-info:hover {
  filter: brightness(1.08);
  box-shadow: 0 12px 32px rgba(59, 130, 246, 0.45);
  transform: translateY(-2px);
}

.btn-info:active {
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

/* ─────────────────────────────────────────────────────────────────────────────
   GOLD / PREMIUM BUTTON (Casino Special)
   ───────────────────────────────────────────────────────────────────────────── */

.btn-gold,
.btn-premium {
  background: linear-gradient(135deg, #fbbf24, #f59e0b, #d97706);
  color: #000;
  box-shadow: 0 10px 30px rgba(245, 158, 11, 0.45);
  font-weight: var(--font-weight-black);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-gold:hover,
.btn-premium:hover {
  filter: brightness(1.12) drop-shadow(0 0 8px rgba(245, 158, 11, 0.6));
  box-shadow: 0 14px 40px rgba(245, 158, 11, 0.55);
  transform: translateY(-3px);
}

.btn-gold:active,
.btn-premium:active {
  box-shadow: 0 6px 16px rgba(245, 158, 11, 0.35);
  transform: scale(0.96);
}

/* ─────────────────────────────────────────────────────────────────────────────
   BUTTON SIZES
   ───────────────────────────────────────────────────────────────────────────── */

.btn-xs {
  padding: 4px 8px;
  font-size: var(--font-size-xs);
  height: 28px;
  min-width: 28px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: var(--font-size-xs);
  height: 32px;
  min-width: 32px;
}

.btn-md {
  padding: 11px 20px;
  font-size: var(--font-size-sm);
  height: 40px;
}

.btn-lg {
  padding: 14px 28px;
  font-size: var(--font-size-base);
  height: 48px;
}

.btn-xl {
  padding: 18px 36px;
  font-size: var(--font-size-lg);
  height: 56px;
  gap: var(--spacing-3);
}

/* ─────────────────────────────────────────────────────────────────────────────
   BUTTON WIDTHS
   ───────────────────────────────────────────────────────────────────────────── */

.btn-full {
  width: 100%;
}

.btn-half {
  width: calc(50% - var(--spacing-1));
}

.btn-block {
  display: flex;
  width: 100%;
  margin: var(--spacing-2) 0;
}

/* ─────────────────────────────────────────────────────────────────────────────
   BUTTON GROUPS
   ───────────────────────────────────────────────────────────────────────────── */

.btn-group {
  display: inline-flex;
  gap: var(--spacing-1);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-alt);
  padding: 2px;
  border: 1px solid var(--border-hover);
}

.btn-group .btn,
.btn-group .button {
  margin: 0;
  border-radius: 0;
  box-shadow: none;
  border: none;
  flex: 1;
}

.btn-group .btn:first-child,
.btn-group .button:first-child {
  border-top-left-radius: var(--radius-lg);
  border-bottom-left-radius: var(--radius-lg);
}

.btn-group .btn:last-child,
.btn-group .button:last-child {
  border-top-right-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}

/* ─────────────────────────────────────────────────────────────────────────────
   BUTTON STATES
   ───────────────────────────────────────────────────────────────────────────── */

/* Loading State */
.btn.loading {
  pointer-events: none;
  opacity: 0.7;
}

.btn.loading::after {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin var(--duration-1000) linear infinite;
  margin-left: var(--spacing-1);
}

/* Disabled State */
.btn[disabled],
.btn.disabled,
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Active/Selected State */
.btn.active {
  filter: brightness(0.95);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Error State */
.btn.error {
  background: linear-gradient(135deg, var(--danger-500), var(--danger-600));
}

/* ─────────────────────────────────────────────────────────────────────────────
   ICON BUTTONS
   ───────────────────────────────────────────────────────────────────────────── */

.btn-icon {
  width: 40px;
  height: 40px;
  min-width: 40px;
  padding: 0;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary-400);
  border: 1px solid rgba(129, 140, 248, 0.35);
}

.btn-icon:hover {
  background: rgba(99, 102, 241, 0.25);
  border-color: rgba(129, 140, 248, 0.5);
}

.btn-icon.btn-icon-lg {
  width: 48px;
  height: 48px;
  min-width: 48px;
  font-size: 1.25rem;
}

.btn-icon.btn-icon-sm {
  width: 32px;
  height: 32px;
  min-width: 32px;
  font-size: 0.875rem;
}

.btn-icon.btn-icon-lg {
  border-radius: var(--radius-lg);
}

/* ─────────────────────────────────────────────────────────────────────────────
   TEXT BUTTONS (Minimal)
   ───────────────────────────────────────────────────────────────────────────── */

.btn-text {
  background: transparent;
  color: var(--primary-400);
  border: none;
  box-shadow: none;
  padding: 6px 12px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.btn-text:hover {
  color: var(--primary-300);
  text-decoration-thickness: 2px;
  transform: translateY(0);
}

.btn-text:active {
  opacity: 0.8;
}

/* ─────────────────────────────────────────────────────────────────────────────
   BUTTON GROUPS / SEGMENTED CONTROLS
   ───────────────────────────────────────────────────────────────────────────── */

.btn-toggle-group {
  display: inline-flex;
  gap: 0;
  background: var(--bg-alt);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg);
  padding: 3px;
}

.btn-toggle-group .btn,
.btn-toggle-group button {
  margin: 0;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  box-shadow: none;
  padding: 8px 16px;
  flex: 1;
  text-align: center;
}

.btn-toggle-group .btn.active,
.btn-toggle-group button.active {
  background: var(--bg3);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* ─────────────────────────────────────────────────────────────────────────────
   RESPONSIVE BUTTON ADJUSTMENTS
   ───────────────────────────────────────────────────────────────────────────── */

@media (max-width: 639px) {
  .btn,
  .button,
  .btn-md {
    padding: 12px 18px;
    font-size: var(--font-size-sm);
    min-height: 44px;
  }

  .btn-lg {
    padding: 14px 24px;
    min-height: 48px;
  }

  .btn-group {
    width: 100%;
  }

  .btn-half {
    width: calc(50% - 4px);
  }
}

/* ─────────────────────────────────────────────────────────────────────────────
   BUTTON WITH BADGE / NOTIFICATION
   ───────────────────────────────────────────────────────────────────────────── */

.btn-with-badge {
  position: relative;
}

.btn-with-badge .badge {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  background: var(--danger-500);
  color: white;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg);
}

/* ─────────────────────────────────────────────────────────────────────────────
   BUTTON ANIMATIONS
   ───────────────────────────────────────────────────────────────────────────── */

@keyframes buttonPulse {
  0% {
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35);
  }
  50% {
    box-shadow: 0 12px 32px rgba(99, 102, 241, 0.55);
  }
  100% {
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35);
  }
}

.btn.pulse {
  animation: buttonPulse 2s ease-in-out infinite;
}

@keyframes buttonRipple {
  0% {
    box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.7);
  }
  100% {
    box-shadow: 0 0 0 10px rgba(99, 102, 241, 0);
  }
}

.btn.ripple:active {
  animation: buttonRipple 0.6s ease-out;
}

/* ─────────────────────────────────────────────────────────────────────────────
   ACCESSIBILITY
   ───────────────────────────────────────────────────────────────────────────── */

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

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

  .btn:hover {
    transform: none;
  }

  .btn.pulse {
    animation: none;
  }
}

/* ─────────────────────────────────────────────────────────────────────────────
   PRINT STYLES
   ───────────────────────────────────────────────────────────────────────────── */

@media print {
  .btn,
  button {
    border: 1px solid #000;
    background: white;
    color: black;
    box-shadow: none;
  }
}
