/**
 * 全局样式文件 - 统一设计系统
 * 版本: 2.0
 * 最后更新: 2025-10-19
 */

/* ================================
   CSS 变量 - 设计系统
   ================================ */
:root {
    /* 主色调 - 紫色渐变 */
    --primary-start: #667eea;
    --primary-end: #764ba2;
    --primary-gradient: linear-gradient(135deg, var(--primary-start) 0%, var(--primary-end) 100%);

    /* 辅助颜色 */
    --secondary-start: #4f58c4;
    --secondary-end: #7a6eea;
    --secondary-gradient: linear-gradient(135deg, var(--secondary-start) 0%, var(--secondary-end) 100%);

    /* 背景颜色 */
    --bg-light: #f5f7fa;
    --bg-white: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.95);
    --bg-overlay: rgba(255, 255, 255, 0.2);

    /* 文字颜色 */
    --text-primary: #2c3e50;
    --text-secondary: #5c6278;
    --text-light: #8c92a4;
    --text-white: #ffffff;

    /* 边框和阴影 */
    --border-color: #e0e0e0;
    --border-focus: var(--primary-start);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 15px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.15);
    --shadow-xl: 0 18px 45px rgba(55, 64, 155, 0.18);

    /* 圆角 */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* 间距 */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* 字体大小 */
    --text-xs: 12px;
    --text-sm: 14px;
    --text-base: 16px;
    --text-lg: 18px;
    --text-xl: 20px;
    --text-2xl: 24px;
    --text-3xl: 30px;
    --text-4xl: 36px;

    /* 过渡动画 */
    --transition-fast: 0.15s ease;
    --transition-base: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* ================================
   全局重置
   ================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-light);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ================================
   通用布局组件
   ================================ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

.container-sm {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

.container-lg {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

/* ================================
   卡片组件
   ================================ */
.card {
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-base);
}

.card:hover {
    box-shadow: var(--shadow-xl);
    transform: translateY(-2px);
}

.card-header {
    margin-bottom: var(--space-lg);
}

.card-title {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.card-subtitle {
    font-size: var(--text-base);
    color: var(--text-secondary);
}

/* ================================
   按钮组件
   ================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 12px 24px;
    font-size: var(--text-base);
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 按钮尺寸 */
.btn-sm {
    padding: 8px 16px;
    font-size: var(--text-sm);
}

.btn-lg {
    padding: 16px 32px;
    font-size: var(--text-lg);
    height: 54px;
}

.btn-block {
    width: 100%;
}

/* 按钮类型 */
.btn-primary {
    background: var(--primary-gradient);
    color: var(--text-white);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: var(--bg-white);
    color: var(--primary-start);
    border: 2px solid var(--primary-start);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--primary-start);
    color: var(--text-white);
}

.btn-outline {
    background: transparent;
    color: var(--text-white);
    border: 2px solid var(--text-white);
}

.btn-outline:hover:not(:disabled) {
    background: var(--text-white);
    color: var(--primary-start);
}

.btn-ghost {
    background: var(--bg-overlay);
    color: var(--text-white);
}

.btn-ghost:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.3);
}

/* ================================
   表单组件
   ================================ */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.form-help {
    display: block;
    font-size: var(--text-sm);
    color: var(--text-light);
    margin-bottom: var(--space-sm);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 14px 16px;
    font-size: var(--text-base);
    font-family: inherit;
    color: var(--text-primary);
    background-color: var(--bg-white);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
    background-color: var(--bg-light);
    cursor: not-allowed;
    opacity: 0.6;
}

/* ================================
   网格布局
   ================================ */
.grid {
    display: grid;
    gap: var(--space-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);
}

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

/* ================================
   Flex 布局
   ================================ */
.flex {
    display: flex;
}

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

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

.flex-col {
    display: flex;
    flex-direction: column;
}

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

/* ================================
   通用工具类
   ================================ */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-muted { color: var(--text-secondary); }
.text-light { color: var(--text-light); }
.text-white { color: var(--text-white); }

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-normal { font-weight: 400; }

.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }

/* ================================
   加载动画
   ================================ */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ================================
   渐变背景
   ================================ */
.bg-gradient-primary {
    background: var(--primary-gradient);
}

.bg-gradient-secondary {
    background: var(--secondary-gradient);
}

.bg-light {
    background-color: var(--bg-light);
}

.bg-white {
    background-color: var(--bg-white);
}

/* ================================
   响应式设计
   ================================ */
@media (max-width: 1024px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    :root {
        --space-xl: 24px;
        --space-2xl: 32px;
        --text-3xl: 24px;
        --text-4xl: 30px;
    }

    .container,
    .container-sm,
    .container-lg {
        padding: 0 var(--space-md);
    }

    .card {
        padding: var(--space-lg);
    }

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

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

/* ================================
   滚动条样式
   ================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-light);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* ================================
   选择文本样式
   ================================ */
::selection {
    background-color: var(--primary-start);
    color: var(--text-white);
}

::-moz-selection {
    background-color: var(--primary-start);
    color: var(--text-white);
}

/* ================================
   打印样式
   ================================ */
@media print {
    body {
        background: white;
    }

    .card {
        box-shadow: none;
        border: 1px solid var(--border-color);
    }

    .btn {
        display: none;
    }
}
