/* 
  Layout System
  Defines comprehensive layout patterns using CSS Grid and Flexbox
  for consistent, responsive layouts across the application
*/

.admin-layout {
  display: grid;
  grid-template-areas: "header header" "sidebar main";
  grid-template-columns: 350px 1fr;
  grid-template-rows: auto 1fr;
  block-size: 100dvh;
  overflow: auto;  
  background-color: var(--clr-surface-a0);
  

  @media (width >= 48rem) {
    --sidebar-border-width: var(--border);
    --sidebar-padding: var(--space-2);
    --sidebar-width: 350px;
  }
}

#main {
  display: flex;
  flex-direction: column;
  grid-area: main;
  gap: var(--space-4);
  padding: var(--space-6);
  padding-top: 0;
  overflow-y: auto;
}

/* ========== CONTAINER SYSTEM ========== */
/* Base container - centered with max-width */
.container {
  width: 100%;
  padding-inline: var(--space-6);
  margin-inline: auto;
  max-width: 1400px;
}

/* Container size variants */
.container-sm {
  max-width: 640px;
}

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

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

.container-xl {
  max-width: 1280px;
}

.container-fluid {
  max-width: none;
}

/* Container with padding variants */
.container-padded {
  padding: var(--space-6);
}

/* ========== GRID SYSTEM ========== */
/* Base grid */
.grid {
  display: grid;
  gap: var(--space-4);
}

/* Predefined column layouts */
.grid-2col {
  grid-template-columns: repeat(2, 1fr);
}

.grid-3col {
  grid-template-columns: repeat(3, 1fr);
}

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

.grid-5col {
  grid-template-columns: repeat(5, 1fr);
}

.grid-6col {
  grid-template-columns: repeat(6, 1fr);
}

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

/* Auto-responsive grid - automatically adjusts columns based on container width */
.grid-auto-sm {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.grid-auto-md {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.grid-auto-lg {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

/* Column and row spanning utilities */
.col-span-2 {
  grid-column: span 2;
}

.col-span-3 {
  grid-column: span 3;
}

.col-span-4 {
  grid-column: span 4;
}

.col-span-6 {
  grid-column: span 6;
}

.col-span-12 {
  grid-column: span 12;
}

.row-span-2 {
  grid-row: span 2;
}

.row-span-3 {
  grid-row: span 3;
}

/* ========== COMMON LAYOUT PATTERNS ========== */
/* Sidebar layout - for admin pages with navigation */
.layout-sidebar {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: var(--space-6);
}

/* Dashboard layout with sidebar and main content */
.layout-dashboard {
  display: grid;
  grid-template-columns: 250px 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
  grid-template-areas: 
    "sidebar header"
    "sidebar main";
}

.dashboard-sidebar {
  grid-area: sidebar;
}

.dashboard-header {
  grid-area: header;
}

.dashboard-main {
  grid-area: main;
  padding: var(--space-6);
}

/* Two-column layout with configurable ratio */
.layout-split-even {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
}

.layout-split-1-2 {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: var(--space-6);
}

.layout-split-2-1 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-6);
}

.layout-split-1-3 {
  display: grid;
  grid-template-columns: 1fr 3fr;
  gap: var(--space-6);
}

.layout-split-3-1 {
  display: grid;
  grid-template-columns: 3fr 1fr;
  gap: var(--space-6);
}

/* Card grid layouts */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-4);
}

/* ========== FLEXBOX LAYOUTS ========== */
/* Basic flex container */
.flex {
  display: flex;
}

.flex-inline {
  display: inline-flex;
}

/* Direction variants */
.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 variants */
.flex-wrap {
  flex-wrap: wrap;
}

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

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

/* Grow and shrink utility classes */
.flex-1 {
  flex: 1 1 0%;
}

.flex-auto {
  flex: 1 1 auto;
}

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

.flex-none {
  flex: none;
}

.flex-grow {
  flex-grow: 1;
}

.flex-grow-0 {
  flex-grow: 0;
}

.flex-shrink {
  flex-shrink: 1;
}

.flex-shrink-0 {
  flex-shrink: 0;
}

/* Alignment utilities */
.items-start {
  align-items: flex-start;
}

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

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

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

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

.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;
}

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

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

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

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

.content-around {
  align-content: space-around;
}

.content-stretch {
  align-content: stretch;
}

/* Individual item alignment */
.self-start {
  align-self: flex-start;
}

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

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

.self-stretch {
  align-self: stretch;
}

/* Spacing utilities */
.gap-0 {
  gap: 0;
}

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

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

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

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

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

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

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

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

/* Directional gap (column/row) */
.gap-x-4 {
  column-gap: var(--space-4);
}

.gap-y-4 {
  row-gap: var(--space-4);
}

/* ========== PAGE COMPONENT LAYOUTS ========== */
/* Page layout with header, content, footer structure */
.page-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-block-end: var(--space-6);
}

.page-title {
  font-size: var(--text-2xl);
  font-weight: var(--font-semibold);
  color: var(--clr-primary-a20);
  margin: 0;
}

.page-actions {
  display: flex;
  gap: var(--space-2);
}

.page-content {
  flex: 1;
}

.page-footer {
  margin-block-start: auto;
  padding: var(--space-4) 0;
}

/* Common section layouts */
.section {
  margin-block: var(--space-8);
}

.section-header {
  margin-block-end: var(--space-4);
}

/* Stack layout (vertical spacing between elements) */
.stack {
  display: flex;
  flex-direction: column;
}

.stack > * + * {
  margin-block-start: var(--space-4);
}

/* Cluster layout (for tags, buttons, etc. in a flex-wrap) */
.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* ========== RESPONSIVE PATTERNS ========== */
/* Breakpoint helpers are defined here, with logical direction
   support for international layouts */

/* Small screens and down */
@media (max-width: 640px) {
  .sm\:grid-1col {
    grid-template-columns: 1fr;
  }
  
  .sm\:flex-col {
    flex-direction: column;
  }
  
  .layout-sidebar,
  .layout-split-even,
  .layout-split-1-2,
  .layout-split-2-1,
  .layout-split-1-3,
  .layout-split-3-1 {
    grid-template-columns: 1fr;
  }
  
  .layout-dashboard {
    grid-template-areas: 
      "header"
      "sidebar"
      "main";
    grid-template-columns: 1fr;
  }
  
  .container {
    padding-inline: var(--space-3);
  }
}

/* Medium screens and down */
@media (max-width: 768px) {
  .md\:grid-2col {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .md\:flex-col {
    flex-direction: column;
  }
}

/* Large screens and down */
@media (max-width: 1024px) {
  .lg\:grid-3col {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ========== SPECIALTY COMPONENTS ========== */
/* Tab container for stat type selection */
.tab-container {
  display: flex;
  gap: var(--space-1);
  margin-block-end: var(--space-4);
  border-bottom: 1px solid var(--clr-surface-a20);
  overflow-x: auto;
}

.tab-item {
  padding: var(--space-2) var(--space-4);
  border-bottom: 2px solid transparent;
  font-weight: var(--font-medium);
  color: var(--clr-surface-a50);
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
}

.tab-item:hover {
  color: var(--clr-primary-a0);
}

.tab-item.active {
  color: var(--clr-primary-a0);
  border-bottom-color: var(--clr-primary-a0);
}

/* Data tables layout */
.data-table-container {
  width: 100%;
  overflow-x: auto;
}


