/*
 * 晟昱和 3D打印 - 布局系统
 * Layout Framework
 */

/* =========================
   1. 容器系统
   ========================= */
.container {
  width: 100%;
  max-width: var(--container-xl);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-6);
  padding-right: var(--space-6);
}

.container-sm { max-width: var(--container-sm); }
.container-md { max-width: var(--container-md); }
.container-lg { max-width: var(--container-lg); }
.container-xl { max-width: var(--container-xl); }
.container-2xl { max-width: var(--container-2xl); }

@media (max-width: 640px) {
  .container {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }
}

/* =========================
   2. 区域与间距
   ========================= */
.section {
  padding-top: var(--space-24);
  padding-bottom: var(--space-24);
  position: relative;
}

.section-sm {
  padding-top: var(--space-16);
  padding-bottom: var(--space-16);
}

.section-lg {
  padding-top: var(--space-24);
  padding-bottom: var(--space-24);
}

.section-alt {
  background-color: var(--bg-secondary);
}

.section-divider {
  border-top: 1px solid var(--border-color);
}

/* =========================
   3. 网格系统
   ========================= */
.grid {
  display: grid;
  gap: var(--space-6);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }

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

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

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

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

/* 侧边栏布局 */
.layout-sidebar {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--space-10);
}

.layout-sidebar-reverse {
  grid-template-columns: 320px 1fr;
}

/* =========================
   4. Flexbox 工具类
   ========================= */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-wrap { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }
.flex-1 { flex: 1 1 0%; }
.flex-auto { flex: 1 1 auto; }
.flex-none { flex: none; }

.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.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; }

.gap-x-2 { column-gap: var(--space-2); }
.gap-x-4 { column-gap: var(--space-4); }
.gap-x-6 { column-gap: var(--space-6); }
.gap-y-2 { row-gap: var(--space-2); }
.gap-y-4 { row-gap: var(--space-4); }
.gap-y-6 { row-gap: var(--space-6); }

/* =========================
   5. 响应式断点
   ========================= */
@media (max-width: 1024px) {
  .lg\:grid-2 { grid-template-columns: repeat(2, 1fr); }
  .lg\:grid-1 { grid-template-columns: 1fr; }
  .lg\:flex-col { flex-direction: column; }
  .lg\:hidden { display: none; }
  .lg\:text-center { text-align: center; }

  .layout-sidebar,
  .layout-sidebar-reverse {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .section { padding-top: var(--space-16); padding-bottom: var(--space-16); }
  .section-lg { padding-top: var(--space-20); padding-bottom: var(--space-20); }

  .md\:grid-2 { grid-template-columns: repeat(2, 1fr); }
  .md\:grid-1 { grid-template-columns: 1fr; }
  .md\:flex-col { flex-direction: column; }
  .md\:hidden { display: none; }
  .md\:text-center { text-align: center; }

  .grid-2,
  .grid-3,
  .grid-4,
  .grid-5,
  .grid-6 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .sm\:grid-1 { grid-template-columns: 1fr; }
  .sm\:flex-col { flex-direction: column; }
  .sm\:hidden { display: none; }
  .sm\:text-center { text-align: center; }

  .grid-auto,
  .grid-auto-sm,
  .grid-auto-lg {
    grid-template-columns: 1fr;
  }
}

/* =========================
   6. 显示工具类
   ========================= */
.block { display: block; }
.inline-block { display: inline-block; }
.hidden { display: none; }

@media (min-width: 769px) {
  .mobile-only { display: none !important; }
}

@media (max-width: 768px) {
  .desktop-only { display: none !important; }
}

/* =========================
   7. 定位与层级
   ========================= */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }

.inset-0 { inset: 0; }
.top-0 { top: 0; }
.bottom-0 { bottom: 0; }
.left-0 { left: 0; }
.right-0 { right: 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; }

/* =========================
   8. 其他布局工具
   ========================= */
.w-full { width: 100%; }
.h-full { height: 100%; }
.min-h-screen { min-height: 100vh; }
.min-h-full { min-height: 100%; }

.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-x-auto { overflow-x: auto; }

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

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

/* 内容居中 */
.center-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
