/* ===== 基础样式 ===== */
:root {
    --primary-color: #4a90e2;
    --primary-hover: #357abd;
    --success-color: #52c41a;
    --error-color: #ff4d4f;
    --warning-color: #faad14;
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --border-color: #e8ecf0;
    --shadow: 0 2px 12px rgba(0,0,0,0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ===== 登录页面 ===== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container { width: 100%; max-width: 400px; padding: 20px; }

.login-box {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 40px;
    box-shadow: var(--shadow);
}

.login-title {
    font-size: 28px;
    text-align: center;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.login-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.demo-account {
    margin-top: 20px;
    padding: 12px;
    background: #f0f7ff;
    border-radius: 8px;
    text-align: center;
    font-size: 13px;
    color: var(--primary-color);
}

/* ===== 表单样式 ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74,144,226,0.15);
}

.login-form { margin-top: 20px; }

/* ===== 按钮样式 ===== */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: var(--primary-color);
    color: #fff;
}

.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { background: #ccc; cursor: not-allowed; }

.btn-block { width: 100%; }

.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.login-footer {
    margin-top: 24px;
    text-align: center;
    color: var(--text-secondary);
}

.login-footer a {
    color: var(--primary-color);
    text-decoration: none;
}

.login-footer a:hover { text-decoration: underline; }

/* ===== 导航栏 ===== */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    padding: 0 24px;
    height: 64px;
    background: var(--card-bg);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.navbar-brand h1 {
    font-size: 20px;
    color: var(--primary-color);
    margin-right: 40px;
}

.navbar-menu {
    display: flex;
    gap: 8px;
    flex: 1;
}

.navbar-menu a {
    padding: 8px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s;
}

.navbar-menu a:hover { background: var(--bg-color); color: var(--text-primary); }
.navbar-menu a.active { background: var(--primary-color); color: #fff; }

.navbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ===== 主内容区 ===== */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
}

.welcome-section {
    margin-bottom: 32px;
}

.welcome-section h2 { font-size: 28px; margin-bottom: 8px; }
.welcome-section p { color: var(--text-secondary); }

/* ===== 仪表盘卡片 ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.dashboard-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 28px;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    box-shadow: var(--shadow);
}

.dashboard-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.card-icon { font-size: 48px; margin-bottom: 16px; }
.dashboard-card h3 { font-size: 18px; margin-bottom: 8px; }
.dashboard-card p { color: var(--text-secondary); font-size: 14px; }

/* ===== 配额区域 ===== */
.quota-section {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow);
}

.quota-info h4 { margin-bottom: 16px; }

.quota-bar {
    height: 8px;
    background: #e8ecf0;
    border-radius: 4px;
    overflow: hidden;
}

.quota-progress {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #7c5ce0);
    border-radius: 4px;
    transition: width 0.5s;
}

/* ===== 页面头部 ===== */
.page-header { margin-bottom: 28px; }
.page-header h2 { font-size: 24px; margin-bottom: 8px; }
.page-header p { color: var(--text-secondary); }

/* ===== 生成表单 ===== */
.generate-form {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 28px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.generate-form textarea { resize: vertical; }

/* ===== 结果区域 ===== */
.result-section {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 28px;
    box-shadow: var(--shadow);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.result-content {
    line-height: 1.8;
    white-space: pre-wrap;
    font-size: 15px;
}

/* ===== 上传区域 ===== */
.upload-section {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 28px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.upload-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    align-items: end;
}

.upload-form .btn { justify-self: start; }

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

.material-card {
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.2s;
}

.material-card:hover { transform: scale(1.02); }

.material-preview {
    height: 140px;
    background: #f0f2f5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: #ccc;
}

.material-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.material-info { padding: 12px; }
.material-info h4 {
    font-size: 14px;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.material-meta {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
}

.material-actions {
    display: flex;
    gap: 8px;
    padding: 0 12px 12px;
}

.material-actions .btn { flex: 1; font-size: 12px; padding: 6px 8px; }

/* ===== 历史记录 ===== */
.filter-tabs {
    display: flex;
    gap: 8px;
    margin: 16px 0;
}

.tab-btn {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

.history-list { display: flex; flex-direction: column; gap: 16px; }

.history-item {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s;
}

.history-item:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.1); }

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.history-title { font-size: 16px; font-weight: 600; }
.history-type {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    background: #e6f7ff;
    color: var(--primary-color);
}

.history-meta {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    gap: 16px;
}

.history-content {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-color);
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.6;
    max-height: 120px;
    overflow: hidden;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
}

.pagination button {
    padding: 8px 14px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    border-radius: 6px;
    cursor: pointer;
}

.pagination button:hover { border-color: var(--primary-color); }
.pagination button.active { background: var(--primary-color); color: #fff; border-color: var(--primary-color); }
.pagination button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== 个人中心 ===== */
.profile-container {
    max-width: 600px;
    background: var(--card-bg);
    border-radius: 16px;
    padding: 32px;
    box-shadow: var(--shadow);
}

.profile-avatar {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

.avatar-placeholder {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #fff;
    font-size: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-form { margin-bottom: 32px; }

.quota-stats h3 { margin-bottom: 16px; }

.stat-card {
    background: var(--bg-color);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

.stat-label { font-size: 14px; color: var(--text-secondary); margin-bottom: 8px; }
.stat-value { font-size: 32px; font-weight: 700; color: var(--primary-color); }
.stat-total { font-size: 14px; color: var(--text-secondary); }

/* ===== 管理后台 ===== */
.admin-content .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-box {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
}

.stat-icon { font-size: 36px; }
.stat-number { font-size: 28px; font-weight: 700; color: var(--text-primary); }
.stat-label { font-size: 14px; color: var(--text-secondary); }

.admin-section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
}

.admin-section h3 { margin-bottom: 16px; }

.action-buttons { display: flex; gap: 12px; }

/* ===== 用户表格 ===== */
.users-table-container {
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.users-table {
    width: 100%;
    border-collapse: collapse;
}

.users-table th,
.users-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.users-table th {
    background: var(--bg-color);
    font-weight: 600;
    font-size: 14px;
}

.users-table tr:hover { background: #fafafa; }

.status-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.status-badge.active { background: #f6ffed; color: var(--success-color); }
.status-badge.disabled { background: #fff1f0; color: var(--error-color); }
.status-badge.admin { background: #fff7e6; color: var(--warning-color); }

/* ===== 提示消息 ===== */
.toast {
    position: fixed;
    top: 80px;
    right: 24px;
    padding: 14px 20px;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

.toast.success { background: var(--success-color); }
.toast.error { background: var(--error-color); }
.toast.info { background: var(--primary-color); }

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

/* ===== 加载状态 ===== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .navbar { padding: 0 16px; }
    .navbar-menu { display: none; }
    .main-content { padding: 20px 16px; }
    .login-box { padding: 24px; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .upload-form { grid-template-columns: 1fr; }
}