/**
 * ThinSky Button Component System
 *
 * Features:
 * - Loading state with spinner
 * - Icon support (left/right)
 * - Multiple variants (primary, secondary, ghost, danger)
 * - Full accessibility support
 * - Dark mode compatible
 */

/* =============================================================================
   BASE BUTTON STYLES
   ============================================================================= */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.5;
  text-decoration: none;
  border-radius: 9999px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.4);
}

.btn:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* =============================================================================
   BUTTON VARIANTS
   ============================================================================= */

/* Primary Variant - Blue solid background */
.btn-primary {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 4px 14px 0 rgba(37, 99, 235, 0.39);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px 0 rgba(37, 99, 235, 0.5);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 10px 0 rgba(37, 99, 235, 0.3);
}

/* Dark mode primary */
.dark .btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  box-shadow: 0 4px 14px 0 rgba(59, 130, 246, 0.3);
}

.dark .btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  box-shadow: 0 6px 20px 0 rgba(59, 130, 246, 0.4);
}

/* Secondary Variant - Transparent with border */
.btn-secondary {
  background-color: transparent;
  color: #2563eb;
  border-color: #2563eb;
}

.btn-secondary:hover:not(:disabled) {
  background-color: #2563eb;
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 4px 14px 0 rgba(37, 99, 235, 0.3);
}

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

/* Dark mode secondary */
.dark .btn-secondary {
  color: #93c5fd;
  border-color: #93c5fd;
}

.dark .btn-secondary:hover:not(:disabled) {
  background-color: #93c5fd;
  color: #1e3a8a;
  border-color: #93c5fd;
}

/* Ghost Variant - Transparent with hover effect only */
.btn-ghost {
  background-color: transparent;
  color: #374151;
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background-color: rgba(59, 130, 246, 0.1);
  color: #2563eb;
}

.btn-ghost:active:not(:disabled) {
  background-color: rgba(59, 130, 246, 0.2);
}

/* Dark mode ghost */
.dark .btn-ghost {
  color: #d1d5db;
}

.dark .btn-ghost:hover:not(:disabled) {
  background-color: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}

/* Danger Variant - Red for destructive actions */
.btn-danger {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 4px 14px 0 rgba(220, 38, 38, 0.39);
}

.btn-danger:hover:not(:disabled) {
  background: linear-gradient(135deg, #b91c1c 0%, #991b1b 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px 0 rgba(220, 38, 38, 0.5);
}

/* =============================================================================
   BUTTON SIZES
   ============================================================================= */

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  gap: 0.375rem;
}

.btn-lg {
  padding: 1rem 2rem;
  font-size: 1.125rem;
  gap: 0.625rem;
}

.btn-xl {
  padding: 1.25rem 2.5rem;
  font-size: 1.25rem;
  gap: 0.75rem;
}

/* =============================================================================
   ICON SUPPORT
   ============================================================================= */

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.25em;
  height: 1.25em;
}

.btn-icon svg {
  width: 100%;
  height: 100%;
}

.btn-icon-left {
  margin-right: 0.25rem;
}

.btn-icon-right {
  margin-left: 0.25rem;
}

/* Icon-only button (square) */
.btn-icon-only {
  padding: 0.75rem;
  border-radius: 50%;
}

.btn-icon-only.btn-sm {
  padding: 0.5rem;
}

.btn-icon-only.btn-lg {
  padding: 1rem;
}

/* =============================================================================
   LOADING STATE
   ============================================================================= */

.btn-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-loading .btn-content {
  visibility: hidden;
  opacity: 0;
}

.btn-loading .btn-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Spinner Animation */
.btn-spinner {
  display: none;
  width: 1.25em;
  height: 1.25em;
}

.btn-loading .btn-spinner {
  display: block;
}

.btn-spinner svg {
  width: 100%;
  height: 100%;
  animation: btn-spin 1s linear infinite;
}

@keyframes btn-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* =============================================================================
   DISABLED STATE
   ============================================================================= */

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
  transform: none !important;
  box-shadow: none !important;
}

/* =============================================================================
   ACCESSIBILITY
   ============================================================================= */

/* High contrast mode support */
@media (prefers-contrast: high) {
  .btn {
    border-width: 3px;
  }

  .btn-primary,
  .btn-danger {
    border-color: currentColor;
  }
}

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

  .btn:hover {
    transform: none;
  }

  .btn-spinner svg {
    animation: none;
  }
}

/* Screen reader only text */
.btn .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus visible for keyboard navigation */
.btn:focus:not(:focus-visible) {
  box-shadow: none;
}

/* =============================================================================
   SPECIAL VARIANTS - SERVICE SPECIFIC
   ============================================================================= */

/* Purple for Penetration Testing */
.btn-purple {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  color: #ffffff;
  box-shadow: 0 4px 14px 0 rgba(124, 58, 237, 0.39);
}

.btn-purple:hover:not(:disabled) {
  background: linear-gradient(135deg, #6d28d9 0%, #5b21b6 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px 0 rgba(124, 58, 237, 0.5);
}

/* Teal for Phishing Training */
.btn-teal {
  background: linear-gradient(135deg, #14b8a6 0%, #0d9488 100%);
  color: #ffffff;
  box-shadow: 0 4px 14px 0 rgba(20, 184, 166, 0.39);
}

.btn-teal:hover:not(:disabled) {
  background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px 0 rgba(20, 184, 166, 0.5);
}

/* Green for OpenVAS */
.btn-green {
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  color: #ffffff;
  box-shadow: 0 4px 14px 0 rgba(34, 197, 94, 0.39);
}

.btn-green:hover:not(:disabled) {
  background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px 0 rgba(34, 197, 94, 0.5);
}

/* Orange for Velociraptor */
.btn-orange {
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  color: #ffffff;
  box-shadow: 0 4px 14px 0 rgba(249, 115, 22, 0.39);
}

.btn-orange:hover:not(:disabled) {
  background: linear-gradient(135deg, #ea580c 0%, #c2410c 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px 0 rgba(249, 115, 22, 0.5);
}

/* Cyan for SonarQube */
.btn-cyan {
  background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
  color: #ffffff;
  box-shadow: 0 4px 14px 0 rgba(6, 182, 212, 0.39);
}

.btn-cyan:hover:not(:disabled) {
  background: linear-gradient(135deg, #0891b2 0%, #0e7490 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px 0 rgba(6, 182, 212, 0.5);
}

/* =============================================================================
   BUTTON GROUP
   ============================================================================= */

.btn-group {
  display: inline-flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-group-vertical {
  flex-direction: column;
  align-items: stretch;
}

/* =============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================= */

@media (max-width: 640px) {
  .btn {
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
  }

  .btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
  }

  .btn-xl {
    padding: 1rem 2rem;
    font-size: 1.125rem;
  }

  .btn-group {
    width: 100%;
  }

  .btn-group .btn {
    flex: 1;
    min-width: 0;
  }
}
