/* ========================================
   ATOMS - Phase 2 Atomic Design System
   ======================================== */

/* ===== BUTTONS ===== */
/* Base button styles with explicit dimensions to prevent CLS */
.btn {
  /* Explicit dimensions to prevent layout shift */
  min-height: 44px; /* Touch-friendly minimum */
  min-width: 120px;
  
  /* Typography */
  font-family: var(--font-primary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-tight);
  
  /* Spacing */
  padding: var(--space-3) var(--space-6);
  
  /* Visual */
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-primary);
  
  /* Layout */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  
  /* Transitions */
  transition: all var(--transition-fast);
  
  /* Prevent text selection */
  user-select: none;
  
  /* Focus management */
  outline: none;
}

/* Button size variants */
.btn-sm {
  min-height: 36px;
  min-width: 100px;
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-xs);
}

.btn-lg {
  min-height: 52px;
  min-width: 140px;
  padding: var(--space-4) var(--space-8);
  font-size: var(--font-size-base);
}

.btn-xl {
  min-height: 60px;
  min-width: 160px;
  padding: var(--space-5) var(--space-10);
  font-size: var(--font-size-lg);
}

/* Button color variants */
.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: var(--color-white);
  border-color: var(--color-primary);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--color-primary-dark), var(--color-primary));
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  color: var(--color-white);
}

.btn-primary:focus {
  box-shadow: 0 0 0 0.2rem rgba(0, 102, 204, 0.25);
}

.btn-outline-primary {
  background: transparent;
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.btn-outline-primary:hover {
  background: var(--color-primary);
  color: var(--color-white);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-outline-primary:focus {
  box-shadow: 0 0 0 0.2rem rgba(0, 102, 204, 0.25);
}

.btn-secondary {
  background: var(--color-gray-100);
  color: var(--text-primary);
  border-color: var(--color-gray-300);
}

.btn-secondary:hover {
  background: var(--color-gray-200);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* ===== FORM INPUTS ===== */
/* Base input styles with explicit dimensions */
.form-control {
  /* Explicit dimensions to prevent CLS */
  min-height: 44px;
  width: 100%;
  
  /* Typography */
  font-family: var(--font-primary);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-normal);
  
  /* Spacing */
  padding: var(--space-3) var(--space-4);
  
  /* Visual */
  border: 1px solid var(--color-gray-300);
  border-radius: var(--radius-md);
  background: var(--color-white);
  color: var(--text-primary);
  
  /* Layout */
  display: block;
  
  /* Transitions */
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  
  /* Focus management */
  outline: none;
}

.form-control:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 0.2rem rgba(0, 102, 204, 0.25);
}

.form-control::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

/* Input size variants */
.form-control-sm {
  min-height: 36px;
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-sm);
}

.form-control-lg {
  min-height: 52px;
  padding: var(--space-4) var(--space-5);
  font-size: var(--font-size-lg);
}

/* Input states */
.form-control.is-invalid {
  border-color: var(--color-danger);
}

.form-control.is-valid {
  border-color: var(--color-success);
}

/* ===== LABELS ===== */
.form-label {
  /* Typography */
  font-family: var(--font-primary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  
  /* Layout */
  display: block;
  margin-bottom: var(--space-2);
  
  /* Spacing */
  line-height: var(--line-height-tight);
}

/* ===== ICONS ===== */
/* Base icon styles with explicit dimensions */
.icon {
  /* Explicit dimensions to prevent CLS */
  width: 1em;
  height: 1em;
  
  /* Layout */
  display: inline-block;
  vertical-align: middle;
  
  /* Visual */
  fill: currentColor;
  stroke: currentColor;
  
  /* Transitions */
  transition: all var(--transition-fast);
}

/* Icon size variants */
.icon-xs {
  width: 0.75em;
  height: 0.75em;
  font-size: var(--font-size-xs);
}

.icon-sm {
  width: 0.875em;
  height: 0.875em;
  font-size: var(--font-size-sm);
}

.icon-lg {
  width: 1.25em;
  height: 1.25em;
  font-size: var(--font-size-lg);
}

.icon-xl {
  width: 1.5em;
  height: 1.5em;
  font-size: var(--font-size-xl);
}

.icon-2xl {
  width: 2em;
  height: 2em;
  font-size: var(--font-size-2xl);
}

/* Icon color variants */
.icon-primary {
  color: var(--color-primary);
}

.icon-secondary {
  color: var(--color-secondary);
}

.icon-success {
  color: var(--color-success);
}

.icon-warning {
  color: var(--color-warning);
}

.icon-danger {
  color: var(--color-danger);
}

.icon-muted {
  color: var(--text-muted);
}

/* ===== BADGES ===== */
/* Base badge styles with explicit dimensions */
.badge {
  /* Explicit dimensions to prevent CLS */
  min-height: 20px;
  min-width: 20px;
  
  /* Typography */
  font-family: var(--font-primary);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  line-height: 1;
  
  /* Spacing */
  padding: var(--space-1) var(--space-2);
  
  /* Visual */
  border-radius: var(--radius-full);
  background: var(--color-gray-500);
  color: var(--color-white);
  
  /* Layout */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
  
  /* Transitions */
  transition: all var(--transition-fast);
}

/* Badge size variants */
.badge-sm {
  min-height: 16px;
  min-width: 16px;
  padding: var(--space-1);
  font-size: 0.625rem;
}

.badge-lg {
  min-height: 24px;
  min-width: 24px;
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-sm);
}

/* Badge color variants */
.badge-primary {
  background: var(--color-primary);
  color: var(--color-white);
}

.badge-secondary {
  background: var(--color-secondary);
  color: var(--color-white);
}

.badge-success {
  background: var(--color-success);
  color: var(--color-white);
}

.badge-warning {
  background: var(--color-warning);
  color: var(--color-white);
}

.badge-danger {
  background: var(--color-danger);
  color: var(--color-white);
}

/* ===== AVATARS ===== */
/* Base avatar styles with explicit dimensions */
.avatar {
  /* Explicit dimensions to prevent CLS */
  width: 40px;
  height: 40px;
  
  /* Visual */
  border-radius: var(--radius-full);
  background: var(--color-gray-200);
  color: var(--text-muted);
  
  /* Layout */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  
  /* Typography */
  font-family: var(--font-primary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  line-height: 1;
  
  /* Transitions */
  transition: all var(--transition-fast);
}

/* Avatar size variants */
.avatar-xs {
  width: 24px;
  height: 24px;
  font-size: var(--font-size-xs);
}

.avatar-sm {
  width: 32px;
  height: 32px;
  font-size: var(--font-size-xs);
}

.avatar-lg {
  width: 48px;
  height: 48px;
  font-size: var(--font-size-base);
}

.avatar-xl {
  width: 64px;
  height: 64px;
  font-size: var(--font-size-lg);
}

.avatar-2xl {
  width: 80px;
  height: 80px;
  font-size: var(--font-size-xl);
}

/* ===== LOADING SPINNERS ===== */
/* Base spinner styles with explicit dimensions */
.spinner {
  /* Explicit dimensions to prevent CLS */
  width: 20px;
  height: 20px;
  
  /* Visual */
  border: 2px solid var(--color-gray-300);
  border-top: 2px solid var(--color-primary);
  border-radius: var(--radius-full);
  
  /* Animation */
  animation: spin 1s linear infinite;
  
  /* Layout */
  display: inline-block;
}

/* Spinner size variants */
.spinner-sm {
  width: 16px;
  height: 16px;
  border-width: 1px;
}

.spinner-lg {
  width: 24px;
  height: 24px;
  border-width: 3px;
}

.spinner-xl {
  width: 32px;
  height: 32px;
  border-width: 4px;
}

/* ===== DIVIDERS ===== */
/* Base divider styles with explicit dimensions */
.divider {
  /* Explicit dimensions to prevent CLS */
  height: 1px;
  width: 100%;
  
  /* Visual */
  background: var(--color-gray-200);
  border: none;
  
  /* Layout */
  display: block;
  margin: var(--space-4) 0;
}

/* Divider variants */
.divider-vertical {
  width: 1px;
  height: 100%;
  margin: 0 var(--space-4);
}

.divider-thick {
  height: 2px;
}

.divider-dashed {
  background: none;
  border-top: 1px dashed var(--color-gray-300);
}

/* ===== RESPONSIVE ATOM ADJUSTMENTS ===== */
/* Mobile-first responsive adjustments for atoms */

/* Button responsive adjustments */
@media (max-width: 767.98px) {
  .btn {
    min-height: 48px; /* Larger touch targets on mobile */
    min-width: 140px;
    padding: var(--space-3) var(--space-6);
  }
  
  .btn-sm {
    min-height: 40px;
    min-width: 120px;
  }
  
  .btn-lg {
    min-height: 56px;
    min-width: 160px;
  }
}

/* Form control responsive adjustments */
@media (max-width: 767.98px) {
  .form-control {
    min-height: 48px; /* Larger touch targets on mobile */
    font-size: 16px; /* Prevent zoom on iOS */
  }
}

/* Icon responsive adjustments */
@media (max-width: 767.98px) {
  .icon {
    font-size: 1.2em; /* Slightly larger icons on mobile */
  }
}

/* ===== ACCESSIBILITY ENHANCEMENTS ===== */
/* High contrast mode support */
@media (prefers-contrast: high) {
  .btn {
    border-width: 2px;
  }
  
  .form-control {
    border-width: 2px;
  }
  
  .btn-primary {
    background: var(--color-primary);
    border-color: var(--color-primary);
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .btn,
  .form-control,
  .icon,
  .badge,
  .avatar {
    transition: none;
  }
  
  .spinner {
    animation: none;
  }
}

/* Focus indicators for keyboard navigation */
.btn:focus-visible,
.form-control:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ===== ANIMATIONS ===== */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Animation utility classes */
.animate-fade-in {
  animation: fadeIn 0.3s ease-out;
}

.animate-slide-in {
  animation: slideIn 0.3s ease-out;
}
