/**
 * 万核基因 - Layout CSS
 * 基础重置 + 布局系统 + 响应式
 * 版本: 1.0.0
 * 更新: 2026-01-25
 */

/* ==================== Reset 基础重置 ==================== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    font-size: var(--text-lg);
    line-height: var(--leading-normal);
    color: var(--c9);
    background: var(--bg-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: inherit;
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--b);
}

img {
    max-width: 100%;
    height: auto;
    vertical-align: middle;
    border-style: none;
}

button,
input,
select,
textarea {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

button {
    cursor: pointer;
    border: none;
    background: transparent;
}

ul, ol {
    list-style: none;
}

table {
    border-collapse: collapse;
    border-spacing: 0;
}

/* ==================== 容器 ==================== */
.wrap {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 10px;
}

.wrap-narrow {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 10px;
}

.wrap-wide {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 10px;
}

/* ==================== 主布局 ==================== */
.main {
    padding: var(--gap-md) 0;
}

/* 两栏布局：主内容 + 右侧栏 */
.layout-2col {
    display: flex;
    gap: var(--gap-lg);
    align-items: flex-start;
}

.layout-2col .main-content {
    flex: 1;
    min-width: 0;
}

.layout-2col .main-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
}

/* 三栏布局：左侧栏 + 主内容 + 右侧栏 */
.layout-3col {
    display: flex;
    gap: var(--gap-md);
    align-items: flex-start;
}

.layout-3col .col-left {
    width: var(--sidebar-narrow);
    flex-shrink: 0;
}

.layout-3col .col-main {
    flex: 1;
    min-width: 0;
}

.layout-3col .col-right {
    width: var(--sidebar-width);
    flex-shrink: 0;
}

/* 兼容旧类名 */
.main-c { flex: 1; min-width: 0; }
.main-r { width: var(--sidebar-width); flex-shrink: 0; }
.col-l { width: var(--sidebar-narrow); flex-shrink: 0; }
.col-m { flex: 1; min-width: 0; }
.col-r { width: var(--sidebar-width); flex-shrink: 0; }

/* 行布局 */
.row {
    display: flex;
    gap: var(--gap-md);
    margin-bottom: var(--gap-md);
}

.row:last-child {
    margin-bottom: 0;
}

/* ==================== 弹性布局工具 ==================== */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.flex-none { flex: none; }
.flex-shrink-0 { flex-shrink: 0; }

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

.gap-xs { gap: var(--gap-xs); }
.gap-sm { gap: var(--gap-sm); }
.gap-md { gap: var(--gap-md); }
.gap-lg { gap: var(--gap-lg); }
.gap-xl { gap: var(--gap-xl); }

/* ==================== 网格布局工具 ==================== */
.grid { display: grid; }
.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); }

/* ==================== 间距工具 ==================== */
.m-0 { margin: 0; }
.mt-sm { margin-top: var(--gap-sm); }
.mt-md { margin-top: var(--gap-md); }
.mt-lg { margin-top: var(--gap-lg); }
.mb-sm { margin-bottom: var(--gap-sm); }
.mb-md { margin-bottom: var(--gap-md); }
.mb-lg { margin-bottom: var(--gap-lg); }
.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }

.p-0 { padding: 0; }
.p-sm { padding: var(--gap-sm); }
.p-md { padding: var(--gap-md); }
.p-lg { padding: var(--gap-lg); }
.px-md { padding-left: var(--gap-md); padding-right: var(--gap-md); }
.py-md { padding-top: var(--gap-md); padding-bottom: var(--gap-md); }

/* ==================== 文本工具 ==================== */
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-md { font-size: var(--text-md); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }
.text-3xl { font-size: var(--text-3xl); }

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

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

.text-primary { color: var(--b); }
.text-success { color: var(--g); }
.text-warning { color: var(--y); }
.text-danger { color: var(--r); }
.text-muted { color: var(--c5); }

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ==================== 显示隐藏 ==================== */
.hidden { display: none !important; }
.invisible { visibility: hidden; }
.visible { visibility: visible; }

/* ==================== 位置 ==================== */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }

/* ==================== 宽高 ==================== */
.w-full { width: 100%; }
.h-full { height: 100%; }
.min-w-0 { min-width: 0; }
.min-h-0 { min-height: 0; }

/* ==================== 圆角 ==================== */
.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }

/* ==================== 阴影 ==================== */
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

/* ==================== 背景 ==================== */
.bg-white { background: var(--white); }
.bg-body { background: var(--bg-body); }
.bg-primary { background: var(--b); }
.bg-primary-light { background: var(--bb); }

/* ==================== 边框 ==================== */
.border { border: 1px solid var(--c2); }
.border-t { border-top: 1px solid var(--c2); }
.border-b { border-bottom: 1px solid var(--c2); }
.border-l { border-left: 1px solid var(--c2); }
.border-r { border-right: 1px solid var(--c2); }
.border-dashed { border-style: dashed; }
.border-primary { border-color: var(--b); }

/* ==================== 响应式断点 ==================== */
/* 
 * xs: 0 - 480px (手机竖屏)
 * sm: 481px - 768px (手机横屏/小平板)
 * md: 769px - 992px (平板)
 * lg: 993px - 1200px (小桌面)
 * xl: 1201px+ (大桌面)
 */

/* 平板及以下隐藏侧边栏 */
@media (max-width: 992px) {
    .layout-2col .main-sidebar,
    .layout-3col .col-right,
    .main-r {
        width: 240px;
    }
    
    .layout-3col .col-left,
    .col-l {
        width: 160px;
    }
}

/* 手机端 */
@media (max-width: 768px) {
    html {
        font-size: 13px;
    }
    
    .wrap {
        padding: 0 12px;
    }
    
    .layout-2col,
    .layout-3col,
    .row {
        flex-direction: column;
        gap: var(--gap-md);
    }
    
    .layout-2col .main-sidebar,
    .layout-3col .col-left,
    .layout-3col .col-right,
    .main-r,
    .col-l,
    .col-r {
        width: 100%;
    }
    
    .grid-cols-4,
    .grid-cols-5 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .grid-cols-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* 手机端隐藏 */
    .hide-mobile {
        display: none !important;
    }
}

/* 仅桌面端显示 */
@media (min-width: 769px) {
    .hide-desktop {
        display: none !important;
    }
}

/* 小手机 */
@media (max-width: 480px) {
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4,
    .grid-cols-5 {
        grid-template-columns: 1fr;
    }
}

/* ==================== 打印样式 ==================== */
@media print {
    .no-print,
    .float-tools,
    .header,
    .topbar,
    footer {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
    }
}
