:root {
    /* 颜色系统 */
    --primary-color: #667eea;
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-color: #764ba2;
    --accent-color: #ff6b6b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --text-color: #1f2937;
    --text-light: #6b7280;
    --background-color: #f3f4f6;
    --card-background: #ffffff;
    --border-color: #e5e7eb;

    /* 阴影 */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    /* 圆角 */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;

    /* 字体 */
    --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
}

/* 动画定义 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translate3d(0, 20px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden; /* 防止移动端横向滚动 */
}

/* 页面进入动画 - 应用于主要容器 */
.container, .auth-container, .dashboard-container, main {
    animation: fadeInUp 0.5s ease-out forwards;
}

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

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

/* 布局容器 */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* 通用 Header */
.header {
    background: var(--card-background);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid var(--border-color);
    width: 100%;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 4rem;
    padding: 0 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: none;
    white-space: nowrap;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* 按钮样式 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all 0.2s;
    cursor: pointer;
    border: none;
    font-size: 0.875rem;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(102, 126, 234, 0.4);
    color: white;
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: white;
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--background-color);
    border-color: var(--text-light);
}

.btn-danger {
    background: #fee2e2;
    color: var(--danger-color);
}

.btn-danger:hover {
    background: #fecaca;
}

.btn-success {
    background: #d1fae5;
    color: var(--success-color);
}
.btn-success:hover {
    background: #a7f3d0;
}

/* 卡片样式 */
.card {
    background: var(--card-background);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(0,0,0,0.05);
    transition: transform 0.2s, box-shadow 0.2s;
    overflow: hidden;
}

/* 登录/注册页面特定样式 */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-gradient);
    padding: 1rem;
}

.auth-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    width: 100%;
    max-width: 28rem;
    padding: 2.5rem;
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-xl);
}

.auth-title {
    text-align: center;
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: #333;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-light);
    margin-bottom: 2rem;
}

/* 表单样式 */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.form-input, .form-textarea, .form-select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: all 0.2s;
    background: #f9fafb;
    font-family: inherit;
}

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

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

/* 仪表板特定样式 */
.dashboard-container {
    padding: 2rem 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    padding: 1.5rem;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: transform 0.2s;
}

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

.stat-label {
    color: var(--text-light);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-color);
    word-break: break-word;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* 功能网格 */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.feature-card {
    padding: 1.5rem;
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.feature-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--border-color);
    transition: background 0.3s;
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.feature-card.blue::before { background: #667eea; }
.feature-card.blue:hover { border-color: #e0e7ff; }

.feature-card.red::before { background: #ff6b6b; }
.feature-card.red:hover { border-color: #ffe4e6; }

.feature-card.pink::before { background: #f472b6; }
.feature-card.pink:hover { border-color: #fce7f3; }

.feature-card.cyan::before { background: #06b6d4; }
.feature-card.cyan:hover { border-color: #cffafe; }

.feature-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    display: inline-block;
    background: #f3f4f6;
    padding: 0.75rem;
    border-radius: var(--radius-lg);
    transition: transform 0.3s;
    width: fit-content;
}

.feature-card:hover .feature-icon {
    transform: scale(1.1) rotate(5deg);
    background: white;
}

.feature-name {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.feature-desc {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 1rem;
    line-height: 1.6;
    flex-grow: 1;
}

.feature-cost {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: #f3f4f6;
    border-radius: 99px;
    font-size: 0.75rem;
    color: var(--text-light);
    font-weight: 500;
    width: fit-content;
}

/* 素材网格 */
.materials-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.5rem;
}

.material-card {
    background: white;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s;
    border: 1px solid var(--border-color);
}

.material-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.material-cover {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: #f3f4f6;
}

.material-info {
    padding: 1rem;
}

.material-title {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.material-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-light);
}

/* 消息提示 */
.message {
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    display: none;
}

.message.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.message.success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.credits-badge {
    background: var(--primary-gradient);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 99px;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
    white-space: nowrap;
}

/* 加载动画 */
.loading-spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

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

/* 表格样式 */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background: #f9fafb;
    font-weight: 600;
    color: var(--text-light);
    white-space: nowrap;
}

/* 移动端表格优化 */
@media (max-width: 640px) {
    th, td {
        padding: 0.5rem;
    }
}

/* 响应式调整 */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }

    .header-content {
        padding: 0 1rem;
        height: 3.5rem;
    }
    
    .auth-container {
        padding: 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .stat-card {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

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

    .card {
        border-radius: var(--radius-md);
    }

    /* 移动端导航栏优化 */
    .user-info span {
        display: none; /* 在移动端隐藏邮箱，只显示积分和退出按钮 */
    }
    .user-info #creditsInfo {
        display: inline-block; /* 保持显示积分 */
        font-size: 0.75rem;
    }
    
    .header-actions {
        gap: 0.5rem;
    }
    
    /* 表单元素优化 */
    .form-input, .form-select, .btn {
        min-height: 44px; /* 增大点击区域 */
    }
    
    /* 模态框优化 */
    .modal-content {
        width: 95%;
        padding: 1.5rem;
        margin: 1rem;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .auth-title {
        font-size: 1.5rem;
    }
    
    .logo {
        font-size: 1.125rem;
    }
    
    /* 确保按钮在小屏幕上全宽 */
    .result-actions .btn,
    .modal-actions .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .modal-actions {
        flex-direction: column;
    }
}
