/* ============================================================================
   UTILITY CLASSES
   Atomic utility classes for consistent spacing, typography, and layout
   ============================================================================ */

/* Spacing Utilities */
.p-0 { padding: 0; }
.p-1 { padding: 4px; }
.p-2 { padding: 8px; }
.p-3 { padding: 12px; }
.p-4 { padding: 16px; }
.p-5 { padding: 20px; }
.p-6 { padding: 24px; }
.p-8 { padding: 32px; }

.px-2 { padding-left: 8px; padding-right: 8px; }
.px-3 { padding-left: 12px; padding-right: 12px; }
.px-4 { padding-left: 16px; padding-right: 16px; }
.px-6 { padding-left: 24px; padding-right: 24px; }

.py-1 { padding-top: 4px; padding-bottom: 4px; }
.py-2 { padding-top: 8px; padding-bottom: 8px; }
.py-3 { padding-top: 12px; padding-bottom: 12px; }
.py-4 { padding-top: 16px; padding-bottom: 16px; }

.m-0 { margin: 0; }
.m-2 { margin: 8px; }
.m-4 { margin: 16px; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mt-8 { margin-top: 32px; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mb-8 { margin-bottom: 32px; }

.ml-2 { margin-left: 8px; }
.mr-2 { margin-right: 8px; }

/* Spacing between children */
.space-y-2 > * + * { margin-top: 8px; }
.space-y-3 > * + * { margin-top: 12px; }
.space-y-4 > * + * { margin-top: 16px; }
.space-y-6 > * + * { margin-top: 24px; }

.space-x-2 > * + * { margin-left: 8px; }
.space-x-3 > * + * { margin-left: 12px; }
.space-x-4 > * + * { margin-left: 16px; }

/* Typography Utilities */
.text-xs { font-size: 12px; line-height: 1.5; }
.text-sm { font-size: 13px; line-height: 1.5; }
.text-base { font-size: 14px; line-height: 1.5; }
.text-lg { font-size: 16px; line-height: 1.5; }
.text-xl { font-size: 18px; line-height: 1.4; }
.text-2xl { font-size: 20px; line-height: 1.4; }
.text-3xl { font-size: 24px; line-height: 1.3; }
.text-4xl { font-size: 32px; line-height: 1.2; }

.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

.uppercase { text-transform: uppercase; }
.lowercase { text-transform: lowercase; }
.capitalize { text-transform: capitalize; }
.normal-case { text-transform: none; }

.tracking-tight { letter-spacing: -0.03em; }
.tracking-normal { letter-spacing: 0; }
.tracking-wide { letter-spacing: 0.025em; }

.leading-none { line-height: 1; }
.leading-tight { line-height: 1.2; }
.leading-normal { line-height: 1.5; }
.leading-relaxed { line-height: 1.8; }

/* Color Utilities */
.text-foreground { color: hsl(var(--foreground)); }
.text-muted { color: hsl(var(--muted-foreground)); }
.text-primary { color: hsl(var(--primary)); }
.text-destructive { color: hsl(var(--destructive)); }
.text-success { color: hsl(142 76% 36%); }

.bg-background { background: hsl(var(--background)); }
.bg-card { background: hsl(var(--card)); }
.bg-muted { background: hsl(var(--muted)); }
.bg-primary { background: hsl(var(--primary)); }
.bg-destructive { background: hsl(var(--destructive)); }

/* Border Utilities */
.border { border: 1px solid hsl(var(--border)); }
.border-2 { border: 2px solid hsl(var(--border)); }
.border-t { border-top: 1px solid hsl(var(--border)); }
.border-b { border-bottom: 1px solid hsl(var(--border)); }
.border-l { border-left: 1px solid hsl(var(--border)); }
.border-r { border-right: 1px solid hsl(var(--border)); }
.border-none { border: none; }

.border-muted { border-color: hsl(var(--border) / 0.5); }
.border-primary { border-color: hsl(var(--primary)); }
.border-destructive { border-color: hsl(var(--destructive)); }

/* Border Radius Utilities */
.rounded-none { border-radius: 0; }
.rounded-sm { border-radius: var(--radius-sm); }
.rounded { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: 9999px; }

/* Shadow Utilities */
.shadow-none { box-shadow: none; }
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

/* Display Utilities */
.block { display: block; }
.inline-block { display: inline-block; }
.inline { display: inline; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }
.hidden { display: none; }

/* Flexbox Utilities */
.flex-row { flex-direction: row; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }

.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.items-baseline { align-items: baseline; }
.items-stretch { align-items: stretch; }

.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }
.justify-evenly { justify-content: space-evenly; }

.flex-1 { flex: 1 1 0%; }
.flex-auto { flex: 1 1 auto; }
.flex-initial { flex: 0 1 auto; }
.flex-none { flex: none; }

.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.gap-8 { gap: 32px; }

/* Width & Height Utilities */
.w-full { width: 100%; }
.w-auto { width: auto; }
.w-fit { width: fit-content; }
.max-w-full { max-width: 100%; }
.min-w-0 { min-width: 0; }

.h-full { height: 100%; }
.h-screen { height: 100vh; }
.h-auto { height: auto; }
.h-4 { height: 16px; }
.h-5 { height: 20px; }
.h-6 { height: 24px; }
.h-8 { height: 32px; }

/* Position Utilities */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }
.static { position: static; }

.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.top-0 { top: 0; }
.right-0 { right: 0; }
.bottom-0 { bottom: 0; }
.left-0 { left: 0; }

/* Overflow Utilities */
.overflow-auto { overflow: auto; }
.overflow-hidden { overflow: hidden; }
.overflow-visible { overflow: visible; }
.overflow-scroll { overflow: scroll; }
.overflow-x-auto { overflow-x: auto; overflow-y: visible; }
.overflow-y-auto { overflow-x: visible; overflow-y: auto; }

/* Cursor Utilities */
.cursor-pointer { cursor: pointer; }
.cursor-not-allowed { cursor: not-allowed; }
.cursor-default { cursor: default; }

/* Transition Utilities */
.transition { transition: all 0.15s ease; }
.transition-colors { transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease; }
.transition-opacity { transition: opacity 0.15s ease; }
.transition-transform { transition: transform 0.15s ease; }
.transition-none { transition: none; }

/* Opacity Utilities */
.opacity-0 { opacity: 0; }
.opacity-50 { opacity: 0.5; }
.opacity-75 { opacity: 0.75; }
.opacity-100 { opacity: 1; }

/* Z-Index Utilities */
.z-0 { z-index: 0; }
.z-10 { z-index: 10; }
.z-20 { z-index: 20; }
.z-30 { z-index: 30; }
.z-40 { z-index: 40; }
.z-50 { z-index: 50; }

/* ============================================================================
   COMPONENT CLASSES
   Reusable component patterns
   ============================================================================ */

/* Card Component */
.card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.card-sm {
  padding: 16px;
}

.card-lg {
  padding: 32px;
}

.card-header {
  margin: -24px -24px 24px -24px;
  padding: 20px 24px;
  border-bottom: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.card-footer {
  margin: 24px -24px -24px -24px;
  padding: 16px 24px;
  border-top: 1px solid hsl(var(--border));
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.card-title {
  font-size: 18px;
  font-weight: 600;
  color: hsl(var(--foreground));
  margin: 0;
}

/* Badge Component */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 9999px;
  transition: all 0.15s ease;
}

.badge-default {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}

.badge-primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.badge-destructive {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}

.badge-outline {
  background: transparent;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
}

.badge-success {
  background: hsl(142 76% 36% / 0.15);
  color: hsl(142 76% 36%);
}

/* Divider */
.divider {
  height: 1px;
  background: hsl(var(--border));
  margin: 16px 0;
}

.divider-lg {
  margin: 24px 0;
}

/* Loading States */
.skeleton {
  background: hsl(var(--muted));
  border-radius: var(--radius-sm);
  position: relative;
  overflow: hidden;
}

.skeleton::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: linear-gradient(90deg, transparent, hsl(var(--muted-foreground) / 0.1), transparent);
  animation: skeleton-shimmer 2s infinite;
}

@keyframes skeleton-shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Container */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.container-sm {
  max-width: 768px;
}

.container-lg {
  max-width: 1400px;
}

/* Page Layout */
.page-container {
  min-height: 100vh;
  padding: 40px 24px;
}

.page-header {
  margin-bottom: 32px;
}

.page-title {
  font-size: 32px;
  font-weight: 700;
  color: hsl(var(--foreground));
  letter-spacing: -0.03em;
  margin: 0 0 8px 0;
}

.page-subtitle {
  font-size: 16px;
  color: hsl(var(--muted-foreground));
  margin: 0;
}

/* Section */
.section {
  margin-bottom: 48px;
}

.section-title {
  font-size: 20px;
  font-weight: 600;
  color: hsl(var(--foreground));
  margin: 0 0 16px 0;
}

.section-description {
  font-size: 14px;
  color: hsl(var(--muted-foreground));
  margin: 0 0 24px 0;
}

/* Table Utilities */
.table-container {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table-responsive {
  overflow-x: auto;
}

/* Form Layout */
.form-row {
  display: flex;
  gap: 16px;
  align-items: flex-end;
}

.form-col {
  flex: 1;
  min-width: 0;
}

/* Modal Backdrop */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: hsl(var(--foreground) / 0.5);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}

/* Icon Size Utilities */
.icon-xs { width: 12px; height: 12px; }
.icon-sm { width: 16px; height: 16px; }
.icon-md { width: 20px; height: 20px; }
.icon-lg { width: 24px; height: 24px; }
.icon-xl { width: 32px; height: 32px; }

/* Additional Spacing Utilities */
.p-10 { padding: 40px; }
.p-12 { padding: 48px; }

.mx-auto { margin-left: auto; margin-right: auto; }
.my-0 { margin-top: 0; margin-bottom: 0; }
.my-3 { margin-top: 12px; margin-bottom: 12px; }

/* Width & Max-Width Utilities */
.max-w-xs { max-width: 20rem; }  /* 320px */
.max-w-sm { max-width: 24rem; }  /* 384px */
.max-w-md { max-width: 28rem; }  /* 448px */
.max-w-lg { max-width: 32rem; }  /* 512px */
.max-w-xl { max-width: 36rem; }  /* 576px */
.max-w-2xl { max-width: 42rem; } /* 672px */

/* Animation Utilities */
.animate-spin {
  animation: spin 0.8s linear infinite;
}

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

/* Box Shadow Utilities */
.shadow-2xl { box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); }

/* Additional Border Utilities */
.border-t-0 { border-top-width: 0; }
.border-t-foreground { border-top-color: hsl(var(--foreground)); }

/* Background Utilities */
.bg-error-light { background: #fef2f2; }
.bg-border { background: hsl(var(--border)); }
.border-destructive { border-color: #fecaca; }
.bg-destructive\/10 { background: hsl(var(--destructive) / 0.1); }
.border-destructive\/30 { border-color: hsl(var(--destructive) / 0.3); }

/* Text Color Utilities */
.text-error { color: #991b1b; }

/* Component Classes */
.info-card {
  padding: 16px;
  background: hsl(var(--muted));
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  margin-bottom: 16px;
}

.info-card-title {
  margin: 0 0 4px 0;
  font-size: 14px;
  font-weight: 600;
  color: hsl(var(--foreground));
}

/* Additional utilities */
.text-xs { font-size: 11px; }
.font-mono { font-family: monospace; }
.font-inherit { font-family: inherit; }
.bg-transparent { background: transparent; }
.border-none { border: none; }
.-mt-px { margin-top: -1px; }
.py-1 { padding-top: 4px; padding-bottom: 4px; }
.px-1 { padding-left: 4px; padding-right: 4px; }
.py-1\.5 { padding-top: 6px; padding-bottom: 6px; }
.px-1\.5 { padding-left: 6px; padding-right: 6px; }
.w-15 { width: 60px; }
.w-20 { width: 80px; }
.w-75 { width: 300px; }

/* Flex alignment utilities */
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }

/* Grid utilities */
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-cols-custom { grid-template-columns: 100px 120px 1fr auto; }

/* Responsive Utilities */
@media (max-width: 640px) {
  .sm\:hidden { display: none; }
  .sm\:block { display: block; }
  .sm\:flex { display: flex; }
  .sm\:flex-col { flex-direction: column; }
  .sm\:gap-2 { gap: 8px; }
  .sm\:p-4 { padding: 16px; }
  .sm\:text-sm { font-size: 13px; }
}

@media (min-width: 641px) {
  .md\:flex { display: flex; }
  .md\:grid { display: grid; }
  .md\:hidden { display: none; }
  .md\:flex-row { flex-direction: row; }
  .md\:gap-4 { gap: 16px; }
  .md\:p-6 { padding: 24px; }
}