/* ========================================
   BUTTON SYSTEM - Clean Code Architecture
   ======================================== */

/* ========================================
   1. BASE BUTTON STYLES
   ======================================== */

.btn {
  /* Layout */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  
  /* Spacing - Default (Medium) */
  padding: 12px 24px;
  
  /* Typography */
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  
  /* Visual */
  border: none;
  border-radius: 12px;
  cursor: pointer;
  
  /* Animation */
  transition: all 0.3s ease;
  
  /* Default Theme (Primary) */
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #ffffff !important;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn:active {
  transform: translateY(0);
}

/* Ensure text color inheritance for nested elements */
.btn span,
.btn svg {
  color: inherit;
  flex-shrink: 0;
}

/* ========================================
   2. BUTTON VARIANTS (Themes)
   ======================================== */

/* Primary (Default - already defined above) */
.btn--primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #ffffff !important;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn--primary:hover {
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* Secondary */
.btn--secondary {
  background: #ffffff;
  color: #667eea !important;
  border: 2px solid #667eea;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.1);
}

.btn--secondary:hover {
  background: #667eea;
  color: #ffffff !important;
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
}

/* Success */
.btn--success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff !important;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.btn--success:hover {
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

/* Danger */
.btn--danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #ffffff !important;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.btn--danger:hover {
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

/* Outline */
.btn--outline {
  background: transparent;
  color: #2c3e50 !important;
  border: 2px solid #e1e8ed;
  box-shadow: none;
}

.btn--outline:hover {
  background: #f8f9fa;
  border-color: #667eea;
  color: #667eea !important;
}

/* ========================================
   3. BUTTON SIZES
   ======================================== */

.btn--xs {
  padding: 8px 16px;
  font-size: 0.85rem;
  border-radius: 8px;
}

.btn--sm {
  padding: 10px 20px;
  font-size: 0.9rem;
  border-radius: 10px;
}

.btn--md {
  padding: 12px 24px;
  font-size: 1rem;
  border-radius: 12px;
}

.btn--lg {
  padding: 16px 32px;
  font-size: 1.1rem;
  border-radius: 14px;
}

.btn--xl {
  padding: 20px 40px;
  font-size: 1.2rem;
  border-radius: 16px;
}

/* ========================================
   4. BUTTON LAYOUT MODIFIERS
   ======================================== */

.btn--block {
  width: 100%;
  display: flex;
}

.btn--auto {
  width: auto;
  display: inline-flex;
}

.btn--icon-only {
  padding: 12px;
  width: 48px;
  height: 48px;
}

.btn--icon-only.btn--sm {
  padding: 8px;
  width: 36px;
  height: 36px;
}

.btn--icon-only.btn--lg {
  padding: 16px;
  width: 56px;
  height: 56px;
}

/* ========================================
   5. BUTTON STATES
   ======================================== */

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

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

.btn--loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  border-top-color: transparent;
  animation: btn-spin 0.6s linear infinite;
}

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

/* Focus (Accessibility) */
.btn:focus-visible {
  outline: 3px solid rgba(102, 126, 234, 0.5);
  outline-offset: 2px;
}

.btn--secondary:focus-visible {
  outline-color: rgba(102, 126, 234, 0.5);
}

.btn--success:focus-visible {
  outline-color: rgba(16, 185, 129, 0.5);
}

.btn--danger:focus-visible {
  outline-color: rgba(239, 68, 68, 0.5);
}

.btn--outline:focus-visible {
  outline-color: rgba(102, 126, 234, 0.5);
}

/* ========================================
   6. BUTTON GROUPS
   ======================================== */

.btn-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

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

.btn-group--center {
  justify-content: center;
}

.btn-group--right {
  justify-content: flex-end;
}

.btn-group--space-between {
  justify-content: space-between;
}

/* ========================================
   7. CONTEXT-SPECIFIC OVERRIDES
   ======================================== */

/* Product Cards */
.product-card__footer .btn {
  min-width: 100px;
  flex-shrink: 0;
}

/* Modals */
.product-modal .btn,
.product-modal a.btn,
.product-modal button.btn {
  color: #ffffff !important;
}

.product-modal__footer .btn {
  min-width: 200px;
}

/* Calendar */
.calendar-footer .btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

/* ========================================
   8. RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 640px) {
  .btn {
    padding: 10px 20px;
    font-size: 0.95rem;
  }
  
  .btn--lg {
    padding: 14px 28px;
    font-size: 1.05rem;
  }
  
  .btn--xl {
    padding: 16px 32px;
    font-size: 1.1rem;
  }
  
  .btn-group {
    gap: 8px;
  }
  
  .product-modal__footer .btn {
    min-width: 100%;
  }
}

/* ========================================
   9. UTILITY CLASSES
   ======================================== */

/* Remove default link styling for button links */
a.btn {
  text-decoration: none;
}

a.btn:visited {
  color: inherit;
}

/* Ensure proper stacking */
.btn {
  position: relative;
  z-index: 1;
}
