/**
 * BAJ Design System - Button Components
 * Standardized button system with strict brand compliance
 * 
 * @package baj-theme
 * @version 2.0.0
 */

/* =============================================================================
   BAJ Button System - Design System Standardization
   ========================================================================== */

/* Button Base - Core styling for all buttons */
.baj-button {
  /* Layout */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px; /* Accessibility: touch target minimum */
  padding: 12px 24px;
  
  /* Typography - Brand Poppins */
  font-family: 'Poppins', sans-serif;
  font-weight: 500; /* Brand: Medium weight for buttons */
  font-size: 16px;
  line-height: 1.5;
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: -0.01em;
  
  /* Border & Shape */
  border: 2px solid transparent;
  border-radius: 6px; /* Updated from variable radius */
  
  /* Interaction */
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  -webkit-appearance: none;
  
  /* Focus Management - WCAG Compliance */
  &:focus,
  &:focus-visible {
    outline: 2px solid #2B7D79; /* Darker brand focus */
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(43, 125, 121, 0.2);
    text-decoration: none;
  }
  
  /* Loading State Base */
  &.baj-button--loading {
    position: relative;
    color: transparent;
    pointer-events: none;
    
    &::after {
      content: '';
      position: absolute;
      width: 20px;
      height: 20px;
      border: 2px solid transparent;
      border-top: 2px solid currentColor;
      border-radius: 50%;
      animation: baj-button-spin 1s linear infinite;
    }
  }
}

/* Button Variants - Brand Colors Only */

/* Primary Button - Main brand color */
.baj-button--primary {
  background-color: #3AA6A1; /* Brand: Primary Teal */
  color: white;
  border-color: #3AA6A1;
  
  &:hover:not(:disabled):not(.baj-button--loading) {
    background-color: #2B7D79; /* Darker teal on hover */
    border-color: #2B7D79;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(43, 125, 121, 0.3);
    color: white;
    text-decoration: none;
  }
  
  &:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(43, 125, 121, 0.4);
  }
  
  &.baj-button--loading::after {
    border-top-color: white;
  }
}

/* Secondary Button - Outlined style */
.baj-button--secondary {
  background-color: transparent;
  color: #3AA6A1; /* Brand: Primary on transparent */
  border-color: #3AA6A1;
  
  &:hover:not(:disabled):not(.baj-button--loading) {
    background-color: #3AA6A1;
    color: white;
    text-decoration: none;
  }
  
  &.baj-button--loading::after {
    border-top-color: #3AA6A1;
  }
}

/* Accent Button - Coral for alerts/urgency */
.baj-button--accent {
  background-color: #E07A5F; /* Brand: Coral Accent */
  color: white;
  border-color: #E07A5F;
  
  &:hover:not(:disabled):not(.baj-button--loading) {
    background-color: #C5654A; /* Darker coral */
    border-color: #C5654A;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(197, 101, 74, 0.3);
    color: white;
    text-decoration: none;
  }
  
  &.baj-button--loading::after {
    border-top-color: white;
  }
}

/* Success Button - Using secondary brand color */
.baj-button--success {
  background-color: #A3BFA8; /* Brand: Secondary Sage */
  color: white;
  border-color: #A3BFA8;
  
  &:hover:not(:disabled):not(.baj-button--loading) {
    background-color: #8DA894; /* Darker sage */
    border-color: #8DA894;
    color: white;
    text-decoration: none;
  }
  
  &.baj-button--loading::after {
    border-top-color: white;
  }
}

/* Button Sizes - Brand Spacing Scale */

.baj-button--small {
  min-height: 36px;
  padding: 8px 16px; /* Brand: 8px spacing */
  font-size: 14px;
}

.baj-button--large {
  min-height: 56px;
  padding: 16px 32px; /* Brand: 16px and 32px spacing */
  font-size: 18px;
}

/* Disabled State */
.baj-button:disabled,
.baj-button--disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
  
  &:hover {
    transform: none !important;
    box-shadow: none !important;
  }
}

/* Icon Buttons */
.baj-button--icon-only {
  width: 48px;
  min-width: 48px;
  padding: 12px;
  justify-content: center;
  
  &.baj-button--small {
    width: 36px;
    min-width: 36px;
    padding: 8px;
  }
  
  &.baj-button--large {
    width: 56px;
    min-width: 56px;
    padding: 16px;
  }
}

/* Button with Icon */
.baj-button--with-icon {
  gap: 8px; /* Brand: 8px spacing */
  
  .baj-button__icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
  }
  
  &.baj-button--small .baj-button__icon {
    width: 16px;
    height: 16px;
  }
  
  &.baj-button--large .baj-button__icon {
    width: 24px;
    height: 24px;
  }
}

/* Button Animations */
@keyframes baj-button-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Legacy Button Compatibility - Override existing styles */
.button.baj-button,
button.baj-button,
input[type="button"].baj-button,
input[type="reset"].baj-button,
input[type="submit"].baj-button {
  /* Override existing button styles */
  border-radius: 6px !important;
  font-weight: 500 !important;
  font-family: 'Poppins', sans-serif !important;
}

/* Button Group - For related actions */
.baj-button-group {
  display: inline-flex;
  gap: 12px; /* Brand: 12px spacing */
  
  &.baj-button-group--attached {
    gap: 0;
    
    .baj-button {
      border-radius: 0;
      border-right-width: 1px;
      
      &:first-child {
        border-radius: 6px 0 0 6px;
        border-right-width: 2px;
      }
      
      &:last-child {
        border-radius: 0 6px 6px 0;
      }
      
      &:only-child {
        border-radius: 6px;
      }
    }
  }
}

/* Responsive Behavior */
@media (max-width: 768px) {
  .baj-button {
    min-height: 44px; /* Slightly smaller on mobile but still accessible */
    font-size: 15px;
  }
  
  .baj-button--small {
    min-height: 40px;
    font-size: 13px;
  }
  
  .baj-button--large {
    min-height: 50px;
    font-size: 17px;
  }
  
  .baj-button-group {
    flex-direction: column;
    width: 100%;
    
    .baj-button {
      width: 100%;
    }
    
    &.baj-button-group--attached {
      .baj-button {
        border-radius: 0;
        border-bottom-width: 1px;
        
        &:first-child {
          border-radius: 6px 6px 0 0;
          border-bottom-width: 2px;
        }
        
        &:last-child {
          border-radius: 0 0 6px 6px;
        }
      }
    }
  }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  .baj-button {
    border-width: 3px;
  }
  
  .baj-button:focus,
  .baj-button:focus-visible {
    outline-width: 3px;
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .baj-button {
    transition: none;
  }
  
  .baj-button:hover:not(:disabled) {
    transform: none;
  }
  
  .baj-button--loading::after {
    animation: none;
  }
}