/**
 * BYD Shares and Stocks - Layout Utilities
 * 
 * Container, grid system, flexbox utilities, and spacing helpers.
 * All sections use max-width: 1200px.
 */

/* ============================================
   1. CONTAINER
   ============================================ */
.container {
  width: 100%;
  max-width: var(--container-max-width);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--container-padding);
  padding-right: var(--container-padding);
}

/* Smaller container for narrow content */
.container-sm {
  max-width: 800px;
}

/* Larger container for hero sections */
.container-lg {
  max-width: 1400px;
}

/* Full width container */
.container-fluid {
  max-width: 100%;
}

@media (max-width: 768px) {
  .container {
    padding-left: var(--container-padding-sm);
    padding-right: var(--container-padding-sm);
  }
}

/* ============================================
   2. SECTIONS
   ============================================ */
.section {
  padding-top: var(--section-py);
  padding-bottom: var(--section-py);
}

.section-sm {
  padding-top: var(--section-py-sm);
  padding-bottom: var(--section-py-sm);
}

/* Section with background color */
.section-alt {
  background-color: var(--color-bg-secondary);
}

/* Section header (title + description) */
.section-header {
  text-align: center;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: var(--space-12);
}

.section-header .section-label {
  margin-bottom: var(--space-4);
}

.section-header .section-title {
  margin-bottom: var(--space-4);
  color: var(--color-text-primary);
}

.section-header .section-description {
  font-size: var(--text-body-lg);
  color: var(--color-text-secondary);
  margin-bottom: 0;
}

/* Section footer (CTA area) */
.section-footer {
  text-align: center;
  margin-top: var(--space-12);
}

@media (max-width: 768px) {
  .section {
    padding-top: var(--section-py-sm);
    padding-bottom: var(--section-py-sm);
  }
  
  .section-header {
    margin-bottom: var(--space-8);
  }
  
  .section-footer {
    margin-top: var(--space-8);
  }
}

/* ============================================
   3. CSS GRID
   ============================================ */
.grid {
  display: grid;
  gap: var(--grid-gap);
}

/* Column definitions */
.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid-cols-5 { grid-template-columns: repeat(5, 1fr); }
.grid-cols-6 { grid-template-columns: repeat(6, 1fr); }

/* Auto-fit grid (responsive by default) */
.grid-auto-fit {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.grid-auto-fill {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* Column span */
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }
.col-span-4 { grid-column: span 4; }
.col-span-full { grid-column: 1 / -1; }

/* Row span */
.row-span-2 { grid-row: span 2; }
.row-span-3 { grid-row: span 3; }

/* Gap variations */
.gap-0 { gap: 0; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }
.gap-10 { gap: var(--space-10); }
.gap-12 { gap: var(--space-12); }

/* Responsive grid */
@media (max-width: 1024px) {
  .grid-cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .grid-cols-5,
  .grid-cols-6 {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .grid {
    gap: var(--grid-gap-sm);
  }
  
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4,
  .grid-cols-5,
  .grid-cols-6 {
    grid-template-columns: 1fr;
  }
  
  .col-span-2,
  .col-span-3,
  .col-span-4 {
    grid-column: span 1;
  }
}

/* ============================================
   4. FLEXBOX
   ============================================ */
.flex {
  display: flex;
}

.inline-flex {
  display: inline-flex;
}

/* Direction */
.flex-row { flex-direction: row; }
.flex-col { flex-direction: column; }
.flex-row-reverse { flex-direction: row-reverse; }
.flex-col-reverse { flex-direction: column-reverse; }

/* Wrap */
.flex-wrap { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }

/* Justify content */
.justify-start { justify-content: flex-start; }
.justify-end { justify-content: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }
.justify-evenly { justify-content: space-evenly; }

/* Align items */
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.items-center { align-items: center; }
.items-baseline { align-items: baseline; }
.items-stretch { align-items: stretch; }

/* Align self */
.self-start { align-self: flex-start; }
.self-end { align-self: flex-end; }
.self-center { align-self: center; }
.self-stretch { align-self: stretch; }

/* Flex grow/shrink */
.flex-1 { flex: 1 1 0%; }
.flex-auto { flex: 1 1 auto; }
.flex-initial { flex: 0 1 auto; }
.flex-none { flex: none; }

.grow { flex-grow: 1; }
.grow-0 { flex-grow: 0; }
.shrink { flex-shrink: 1; }
.shrink-0 { flex-shrink: 0; }

/* ============================================
   5. SPACING UTILITIES
   ============================================ */
/* Margin */
.m-0 { margin: 0; }
.m-auto { margin: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }

.mt-0 { margin-top: 0; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mt-10 { margin-top: var(--space-10); }
.mt-12 { margin-top: var(--space-12); }
.mt-16 { margin-top: var(--space-16); }

.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.mb-10 { margin-bottom: var(--space-10); }
.mb-12 { margin-bottom: var(--space-12); }
.mb-16 { margin-bottom: var(--space-16); }

.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }

/* Padding */
.p-0 { padding: 0; }
.p-2 { padding: var(--space-2); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }

.py-4 { padding-top: var(--space-4); padding-bottom: var(--space-4); }
.py-6 { padding-top: var(--space-6); padding-bottom: var(--space-6); }
.py-8 { padding-top: var(--space-8); padding-bottom: var(--space-8); }
.py-12 { padding-top: var(--space-12); padding-bottom: var(--space-12); }
.py-16 { padding-top: var(--space-16); padding-bottom: var(--space-16); }

.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.px-6 { padding-left: var(--space-6); padding-right: var(--space-6); }
.px-8 { padding-left: var(--space-8); padding-right: var(--space-8); }

/* ============================================
   6. WIDTH & HEIGHT
   ============================================ */
.w-full { width: 100%; }
.w-auto { width: auto; }
.w-screen { width: 100vw; }

.h-full { height: 100%; }
.h-auto { height: auto; }
.h-screen { height: 100vh; }

.min-h-screen { min-height: 100vh; }

.max-w-full { max-width: 100%; }
.max-w-screen { max-width: 100vw; }

/* ============================================
   7. POSITIONING
   ============================================ */
.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; }

/* ============================================
   8. TWO-COLUMN LAYOUTS
   ============================================ */
/* Equal split */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-12);
  align-items: center;
}

/* Content left, larger right */
.two-col-content {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: var(--space-12);
  align-items: center;
}

/* Larger left, content right */
.two-col-content-reverse {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: var(--space-12);
  align-items: center;
}

@media (max-width: 768px) {
  .two-col,
  .two-col-content,
  .two-col-content-reverse {
    grid-template-columns: 1fr;
    gap: var(--space-8);
  }
}

/* ============================================
   9. ASPECT RATIOS
   ============================================ */
.aspect-square { aspect-ratio: 1 / 1; }
.aspect-video { aspect-ratio: 16 / 9; }
.aspect-4-3 { aspect-ratio: 4 / 3; }

/* ============================================
   10. OVERFLOW
   ============================================ */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }
.overflow-visible { overflow: visible; }

/* ============================================
   11. Z-INDEX
   ============================================ */
.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; }

/* ============================================
   12. RESPONSIVE DISPLAY
   ============================================ */
.block { display: block; }
.inline-block { display: inline-block; }
.inline { display: inline; }

/* Hide on mobile */
@media (max-width: 768px) {
  .hide-mobile {
    display: none !important;
  }
}

/* Show only on mobile */
@media (min-width: 769px) {
  .show-mobile {
    display: none !important;
  }
}

/* Hide on tablet and below */
@media (max-width: 1024px) {
  .hide-tablet {
    display: none !important;
  }
}

/* ============================================
   13. CTA SECTIONS
   ============================================ */
.cta-section {
  background: var(--color-bg-primary);
}

.cta-card {
  max-width: var(--container-max-width);
  margin: 0 auto;
  padding: var(--space-16) var(--space-12);
  background: var(--gradient-hero);
  border-radius: var(--radius-2xl);
  text-align: center;
}

.cta-content {
  max-width: 600px;
  margin: 0 auto;
}

.cta-title {
  font-size: var(--text-h2);
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-4);
}

.cta-description {
  font-size: var(--text-body-lg);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-8);
}

.cta-actions {
  display: flex;
  justify-content: center;
  gap: var(--space-6);
  flex-wrap: wrap;
}

@media (max-width: 768px) {
  .cta-card {
    padding: var(--space-10) var(--space-6);
    border-radius: var(--radius-xl);
  }
}

@media (max-width: 480px) {
  .cta-actions {
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
  }
  
  .cta-actions .btn {
    width: 100%;
  }
}

