/* style.css - 主样式表 */
/* 包老师数学思维网站 */
/* 基于421-2版设计系统规范 */

/* ============================================================ */
/* 1. CSS变量与重置 */
/* ============================================================ */

:root {
    /* 颜色系统 */
    --color-primary: #3498db;
    --color-primary-hover: #2980b9;
    --color-primary-light: #ebf5fb;
    --color-success: #2ecc71;
    --color-success-hover: #27ae60;
    --color-warning: #f39c12;
    --color-warning-hover: #e67e22;
    --color-error: #e74c3c;
    --color-error-hover: #c0392b;
    --color-info: #3498db;
    
    /* 文字颜色 */
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-muted: #999999;
    --text-white: #ffffff;
    
    /* 背景颜色 */
    --bg-body: #f8f9fa;
    --bg-white: #ffffff;
    --bg-light: #f0f2f5;
    --bg-dark: #2c3e50;
    
    /* 边框颜色 */
    --border-color: #dee2e6;
    --border-light: #e9ecef;
    
    /* 字体 */
    --font-family: 'Microsoft YaHei', 'PingFang SC', 'Helvetica Neue', sans-serif;
    --font-mono: 'Courier New', Consolas, monospace;
    
    /* 字号 */
    --font-size-xs: 12px;
    --font-size-sm: 14px;
    --font-size-base: 16px;
    --font-size-lg: 18px;
    --font-size-xl: 24px;
    --font-size-xxl: 36px;
    
    /* 行高 */
    --line-height-tight: 1.2;
    --line-height-base: 1.5;
    --line-height-loose: 1.6;
    
    /* 字重 */
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    
    /* 间距（8px基准） */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-xxl: 48px;
    
    /* 圆角 */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --radius-round: 50%;
    
    /* 阴影 */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
    --shadow-xl: 0 8px 32px rgba(0,0,0,0.2);
    
    /* 过渡 */
    --transition-fast: 0.15s ease;
    --transition-base: 0.3s ease;
    --transition-slow: 0.5s ease;
    
    /* 布局 */
    --container-max-width: 1200px;
    --header-height: 64px;
    --sidebar-width: 260px;
}

/* ============================================================ */
/* 2. Reset */
/* ============================================================ */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: var(--font-size-base);
    line-height: var(--line-height-base);
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    color: var(--text-primary);
    background-color: var(--bg-body);
    min-height: 100vh;
    line-height: var(--line-height-base);
}

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

a:hover {
    color: var(--color-primary-hover);
    text-decoration: underline;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

ul, ol {
    list-style: none;
}

/* ============================================================ */
/* 3. 排版 */
/* ============================================================ */

h1, h2, h3, h4, h5, h6 {
    line-height: var(--line-height-tight);
    color: var(--text-primary);
    margin-bottom: var(--spacing-md);
}

h1 { font-size: var(--font-size-xxl); font-weight: var(--font-weight-bold); }
h2 { font-size: var(--font-size-xl); font-weight: var(--font-weight-semibold); }
h3 { font-size: var(--font-size-lg); font-weight: var(--font-weight-medium); }

p {
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
    line-height: var(--line-height-loose);
}

/* ============================================================ */
/* 4. 布局 */
/* ============================================================ */

.container {
    width: 100%;
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

.page-wrapper {
    min-height: calc(100vh - var(--header-height));
    padding-top: var(--spacing-xl);
    padding-bottom: var(--spacing-xxl);
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.grid {
    display: grid;
    gap: var(--spacing-lg);
}

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

/* ============================================================ */
/* 5. Header导航 */
/* ============================================================ */

.header {
    background: var(--bg-white);
    box-shadow: var(--shadow-sm);
    height: var(--header-height);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    color: var(--color-primary);
    text-decoration: none;
}

.logo:hover {
    text-decoration: none;
    color: var(--color-primary-hover);
}

.logo img {
    height: 40px;
    width: auto;
}

/* 导航菜单 */
.nav {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
}

.nav a {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.nav a:hover {
    color: var(--color-primary);
    background: var(--color-primary-light);
    text-decoration: none;
}

.nav a.active {
    color: var(--color-primary);
    font-weight: var(--font-weight-medium);
}

/* 用户信息 */
.user-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-round);
    background: var(--color-primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-sm);
    color: var(--color-primary);
}

/* ============================================================ */
/* 6. Footer */
/* ============================================================ */

.footer {
    background: var(--bg-dark);
    color: var(--text-white);
    padding: var(--spacing-xl) 0;
    margin-top: auto;
}

.footer-inner {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 var(--spacing-md);
    text-align: center;
}

.footer p {
    color: rgba(255,255,255,0.7);
    font-size: var(--font-size-sm);
    margin-bottom: var(--spacing-sm);
}

/* ============================================================ */
/* 7. 页面内容区 */
/* ============================================================ */

.page-header {
    padding: var(--spacing-xl) 0;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: var(--spacing-xl);
}

.page-title {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    margin-bottom: var(--spacing-sm);
}

.page-description {
    color: var(--text-secondary);
    font-size: var(--font-size-base);
}

/* ============================================================ */
/* 8. 通用状态 */
/* ============================================================ */

/* 加载状态 */
.loading {
    position: relative;
    opacity: 0.7;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid var(--border-light);
    border-top: 3px solid var(--color-primary);
    border-radius: var(--radius-round);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: var(--spacing-xxl) var(--spacing-md);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: var(--spacing-md);
}

.empty-title {
    font-size: var(--font-size-lg);
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}

.empty-description {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
}

/* 错误状态 */
.error-state {
    text-align: center;
    padding: var(--spacing-xxl) var(--spacing-md);
    background: #fff5f5;
    border-radius: var(--radius-lg);
    border: 1px solid #fed7d7;
}

.error-icon {
    font-size: 48px;
    margin-bottom: var(--spacing-md);
}

.error-title {
    font-size: var(--font-size-lg);
    color: var(--color-error);
    margin-bottom: var(--spacing-sm);
}

.error-description {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
}

.error-actions {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: center;
}

/* ============================================================ */
/* 9. 动画 */
/* ============================================================ */

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(20px); }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

/* ============================================================ */
/* 10. 无障碍访问 */
/* ============================================================ */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* ============================================================ */
/* 11. 通知容器 */
/* ============================================================ */

#notification-container {
    position: fixed;
    top: var(--spacing-md);
    right: var(--spacing-md);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.notification {
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--radius-md);
    color: var(--text-white);
    font-size: var(--font-size-sm);
    box-shadow: var(--shadow-md);
    animation: fadeIn 0.3s ease;
    max-width: 360px;
}
