/**
 * Utility Classes
 * Layout, spacing, and responsive utilities for the universal design system
 */

/*
 * Legacy copies of Tailwind classes (same meaning as Tailwind's). Mobile review
 * slice 8b moved them into a cascade layer BELOW Tailwind's `utilities` layer
 * (tailwind.css, loaded first, fixes the order: properties, theme, base,
 * components, utilities). Unlayered, they beat Tailwind outright, so responsive
 * / state variants (sm:flex-nowrap, md:grid-cols-12, hover:shadow-lg,
 * focus:ring-*, border-{color}, duration-*) silently did nothing. Where
 * Tailwind compiles the class it now wins; where it doesn't, these still apply.
 *
 * Border colour: Tailwind's .border / .border-t set width + style only; the
 * layered legacy .border / .border-t below still supply the faint grey colour
 * (components layer), and authored border-{color} utilities now override it.
 *
 * Kept UNLAYERED below on purpose (different meaning or element-selector risk):
 * .text-secondary (grey here, crimson in Tailwind), .bg-tertiary (grey vs cyan),
 * .rounded (0.5rem vs 0.25rem), .text-sm / .text-xs, and every custom class
 * (.d-flex, .mb-md, .gap-md, …) that has no Tailwind twin.
 */
@layer components {
  .max-w-7xl {
    max-width: 80rem;
  }

  .mx-auto {
    margin-left: auto;
    margin-right: auto;
  }

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

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

  .flex-wrap {
    flex-wrap: wrap;
  }

  .flex-1 {
    flex: 1;
  }

  .grid-cols-4 {
    grid-template-columns: repeat(4, 1fr);
  }

  .w-8 {
    width: 2rem;
  }

  .h-8 {
    height: 2rem;
  }

  .border {
    border: 1px solid var(--border-color, #e5e7eb);
  }

  .border-t {
    border-top: var(--component-border);
  }

  .border-gray-200 {
    border-color: #e5e7eb;
  }

  .rounded-lg {
    border-radius: 0.5rem;
  }

  .rounded-full {
    border-radius: var(--radius-full);
  }

  .shadow-sm {
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  }

  .shadow-md {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  }

  .hover\:shadow-md:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  }

  .transition {
    transition-property: all;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
  }

  .transition-shadow {
    transition-property: box-shadow;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
  }

  @media (min-width: 768px) {
    .md\:grid-cols-2 {
      grid-template-columns: repeat(2, 1fr);
    }
  }

  @media (min-width: 1024px) {
    .lg\:grid-cols-3 {
      grid-template-columns: repeat(3, 1fr);
    }

    .lg\:grid-cols-4 {
      grid-template-columns: repeat(4, 1fr);
    }

    .lg\:grid-cols-12 {
      grid-template-columns: repeat(12, minmax(0, 1fr));
    }

    .lg\:col-span-1 {
      grid-column: span 1 / span 1;
    }

    .lg\:col-span-3 {
      grid-column: span 3 / span 3;
    }

    .lg\:col-span-4 {
      grid-column: span 4 / span 4;
    }

  }

  @media (min-width: 1280px) {
    .xl\:grid-cols-4 {
      grid-template-columns: repeat(4, 1fr);
    }
  }
}

/* Layout utilities */
.app-container {
  width: 100%;
  max-width: var(--container-xl);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

/* Flexbox utilities */
.d-flex {
  display: flex;
}

.d-grid {
  display: grid;
}

.align-center {
  align-items: center;
}

.align-start {
  align-items: flex-start;
}

.align-end {
  align-items: flex-end;
}

.gap-xs {
  gap: var(--space-xs);
}

.gap-sm {
  gap: var(--space-sm);
}

.gap-md {
  gap: var(--space-md);
}

.gap-lg {
  gap: var(--space-lg);
}

.gap-xl {
  gap: var(--space-xl);
}

/* Grid utilities */

/* Spacing utilities */
.p-sm {
  padding: var(--space-sm);
}

.p-md {
  padding: var(--space-md);
}

.p-lg {
  padding: var(--space-lg);
}

.px-lg {
  padding-left: var(--space-lg);
  padding-right: var(--space-lg);
}

.py-xl {
  padding-top: var(--space-xl);
  padding-bottom: var(--space-xl);
}

.px-xs {
  padding-left: var(--space-xs);
  padding-right: var(--space-xs);
}

.pt-md {
  padding-top: var(--space-md);
}

/* Space-between utilities */
.space-y-sm > * + * {
  margin-top: var(--space-sm);
}

.space-y-md > * + * {
  margin-top: var(--space-md);
}

.space-y-lg > * + * {
  margin-top: var(--space-lg);
}

.mb-xs {
  margin-bottom: var(--space-xs);
}

.mb-sm {
  margin-bottom: var(--space-sm);
}

.mb-md {
  margin-bottom: var(--space-md);
}

.mb-lg {
  margin-bottom: var(--space-lg);
}

.mb-xl {
  margin-bottom: var(--space-xl);
}

.mb-2xl {
  margin-bottom: var(--space-2xl);
}

.mt-xs {
  margin-top: var(--space-xs);
}

.mt-sm {
  margin-top: var(--space-sm);
}

.mt-md {
  margin-top: var(--space-md);
}

.mt-lg {
  margin-top: var(--space-lg);
}

.mt-xl {
  margin-top: var(--space-xl);
}

.mt-2xl {
  margin-top: var(--space-2xl);
}

/* Width utilities */

/* Border utilities */

.rounded {
  border-radius: var(--component-radius);
}

/* Shadow utilities */

/* Transition utilities */

/* Background utilities */
.bg-tertiary {
  background-color: var(--bg-tertiary);
}

/* Text utilities */
.text-sm {
  font-size: var(--text-sm);
}

.text-xs {
  font-size: var(--text-xs);
}

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

/* Responsive utilities — only lg:col-span-5 has no Tailwind twin (the rest
   moved into @layer components above). */
@media (min-width: 1024px) {
  .lg\:col-span-5 {
    grid-column: span 5 / span 5;
  }
}
