/* 培训积分应用 - 移动端优先样式 */

:root {
    --primary: #1E6DF2;
    --primary-light: #E8F0FE;
    --success: #00B578;
    --warning: #FF8F1F;
    --danger: #F53F3F;
    --bg: #F5F6FA;
    --card: #FFFFFF;
    --text: #1D2129;
    --text-secondary: #86909C;
    --border: #E5E6EB;
    --radius: 12px;
    --shadow: 0 2px 8px rgba(0,0,0,0.06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    padding-bottom: 80px;
    -webkit-font-smoothing: antialiased;
}

/* ===== 头部 ===== */
.header {
    background: var(--primary);
    color: white;
    padding: 16px 16px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.header h1 { font-size: 18px; font-weight: 600; }
.header .sub { font-size: 12px; opacity: 0.85; margin-top: 2px; }
.header-top { display: flex; justify-content: space-between; align-items: center; }

/* ===== 内容容器 ===== */
.container { padding: 12px 16px; }

/* ===== 卡片 ===== */
.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.card-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 12px;
}

/* ===== 用户信息 ===== */
.user-card {
    display: flex; align-items: center; gap: 12px;
    background: linear-gradient(135deg, var(--primary), #4A8BF5);
    color: white;
    border-radius: var(--radius);
    padding: 16px;
    margin: 12px 16px;
    box-shadow: 0 4px 12px rgba(30, 109, 242, 0.3);
}
.user-avatar {
    width: 48px; height: 48px; border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; font-weight: 600;
}
.user-info { flex: 1; }
.user-info .name { font-size: 16px; font-weight: 600; }
.user-info .dept { font-size: 12px; opacity: 0.85; }
.user-level {
    text-align: center;
    min-width: 60px;
}
.user-level .icon { font-size: 28px; }
.user-level .name { font-size: 11px; opacity: 0.9; }

/* ===== 统计卡片 ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}
.stat-item {
    background: var(--card);
    border-radius: 10px;
    padding: 12px 8px;
    text-align: center;
    box-shadow: var(--shadow);
}
.stat-item .num { font-size: 20px; font-weight: 700; color: var(--primary); }
.stat-item .label { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

/* ===== 按钮 ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 10px 20px; border-radius: 8px; border: none;
    font-size: 14px; font-weight: 500; cursor: pointer;
    transition: opacity 0.2s; text-decoration: none; gap: 4px;
}
.btn:active { opacity: 0.8; }
.btn-primary { background: var(--primary); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline {
    background: transparent; border: 1px solid var(--border); color: var(--text);
}
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 14px 24px; font-size: 16px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== 列表 ===== */
.list-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item .icon {
    width: 40px; height: 40px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; flex-shrink: 0;
}
.list-item .body { flex: 1; min-width: 0; }
.list-item .body .title { font-size: 14px; font-weight: 500; }
.list-item .body .desc { font-size: 12px; color: var(--text-secondary); }
.list-item .action { flex-shrink: 0; }

/* 维度标签 */
.dim-tag {
    display: inline-block;
    font-size: 10px; padding: 2px 8px; border-radius: 10px;
    font-weight: 500;
}
.dim-管理 { background: #E8F0FE; color: #1E6DF2; }
.dim-业务 { background: #F0F8E8; color: #00B578; }
.dim-不锈钢专业 { background: #FFF3E8; color: #FF8F1F; }

.dim-badge {
    display: inline-block; padding: 4px 12px; border-radius: 12px;
    font-size: 11px; font-weight: 600;
}
.dim-badge.管理 { background: #1E6DF2; color: white; }
.dim-badge.业务 { background: #00B578; color: white; }
.dim-badge.不锈钢专业 { background: #FF8F1F; color: white; }

/* ===== 底部导航 ===== */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--card);
    display: flex; border-top: 1px solid var(--border);
    z-index: 200; padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-item {
    flex: 1; text-align: center; padding: 6px 0;
    color: var(--text-secondary); text-decoration: none;
    font-size: 10px; transition: color 0.2s;
}
.nav-item .nav-icon { font-size: 22px; display: block; }
.nav-item.active { color: var(--primary); }
.nav-item:active { opacity: 0.6; }

/* ===== 进度条 ===== */
.progress-bar {
    height: 4px; background: var(--border); border-radius: 2px;
    overflow: hidden; margin: 8px 0;
}
.progress-bar .fill {
    height: 100%; background: var(--primary);
    border-radius: 2px; transition: width 0.5s;
}
.progress-bar .fill.completed { background: var(--success); }

/* ===== 排行榜 ===== */
.rank-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.rank-item:last-child { border-bottom: none; }
.rank-num {
    width: 24px; text-align: center;
    font-size: 14px; font-weight: 700; color: var(--text-secondary);
}
.rank-num.top3 { font-size: 16px; }
.rank-num.gold { color: #FF8F1F; }
.rank-num.silver { color: #86909C; }
.rank-num.bronze { color: #C9A96E; }
.rank-info { flex: 1; }
.rank-info .name { font-size: 14px; font-weight: 500; }
.rank-info .dept { font-size: 11px; color: var(--text-secondary); }
.rank-points { font-size: 16px; font-weight: 700; color: var(--primary); }

/* ===== 表单 ===== */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block; font-size: 13px; font-weight: 500;
    margin-bottom: 4px; color: var(--text);
}
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: white;
    transition: border-color 0.2s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(30,109,242,0.1);
}
.form-textarea { min-height: 100px; resize: vertical; }

/* ===== 考试选项 ===== */
.quiz-option {
    display: block;
    padding: 12px 16px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}
.quiz-option:active { background: var(--primary-light); }
.quiz-option.selected {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}
.quiz-option.correct {
    border-color: var(--success);
    background: #E8F8F0;
    color: var(--success);
}
.quiz-option.wrong {
    border-color: var(--danger);
    background: #FFF0F0;
    color: var(--danger);
}

/* ===== 积分流水 ===== */
.txn-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.txn-item:last-child { border-bottom: none; }
.txn-info .txn-action { font-size: 14px; }
.txn-info .txn-time { font-size: 11px; color: var(--text-secondary); }
.txn-points { font-size: 16px; font-weight: 600; }
.txn-points.positive { color: var(--success); }
.txn-points.negative { color: var(--danger); }

/* ===== 段位进度 ===== */
.level-progress {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 0;
}
.level-icon { font-size: 24px; }
.level-bar {
    flex: 1; height: 8px; background: var(--border);
    border-radius: 4px; overflow: hidden;
}
.level-bar .fill {
    height: 100%; background: linear-gradient(90deg, var(--primary), #4A8BF5);
    border-radius: 4px; transition: width 0.5s;
}
.level-next { font-size: 12px; color: var(--text-secondary); white-space: nowrap; }

/* ===== 空状态 ===== */
.empty-state {
    text-align: center; padding: 40px 20px;
    color: var(--text-secondary);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state .text { font-size: 14px; }

/* ===== 兑换商品 ===== */
.redeem-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}
.redeem-item {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow);
}
.redeem-item .icon { font-size: 36px; margin-bottom: 8px; }
.redeem-item .name { font-size: 13px; font-weight: 500; }
.redeem-item .points {
    font-size: 18px; font-weight: 700; color: var(--warning);
    margin: 4px 0;
}
.redeem-item .stock { font-size: 11px; color: var(--text-secondary); }

/* ===== 消息提示 ===== */
.flash {
    padding: 10px 16px; margin: 8px 16px;
    border-radius: 8px; font-size: 13px;
}
.flash.success { background: #E8F8F0; color: #00B578; }
.flash.danger { background: #FFF0F0; color: #F53F3F; }
.flash.warning { background: #FFF7E8; color: #FF8F1F; }

/* ===== Markdown内容 ===== */
.markdown-content {
    line-height: 1.8;
}
.markdown-content h1 { font-size: 20px; margin: 16px 0 8px; }
.markdown-content h2 { font-size: 17px; margin: 14px 0 6px; }
.markdown-content h3 { font-size: 15px; margin: 12px 0 4px; }
.markdown-content p { margin: 8px 0; }
.markdown-content table {
    width: 100%; border-collapse: collapse;
    margin: 10px 0; font-size: 13px;
}
.markdown-content th, .markdown-content td {
    border: 1px solid var(--border);
    padding: 6px 10px; text-align: left;
}
.markdown-content th { background: var(--primary-light); }
.markdown-content code {
    background: #F5F6FA; padding: 2px 6px;
    border-radius: 4px; font-size: 13px;
}
.markdown-content pre {
    background: #1D2129; color: #E5E6EB;
    padding: 12px; border-radius: 8px;
    overflow-x: auto; font-size: 12px;
    margin: 10px 0;
}
.markdown-content blockquote {
    border-left: 3px solid var(--primary);
    padding: 8px 12px; margin: 10px 0;
    background: var(--primary-light);
    border-radius: 0 8px 8px 0;
}
.markdown-content ul, .markdown-content ol {
    padding-left: 20px; margin: 8px 0;
}
.markdown-content hr {
    border: none; border-top: 1px solid var(--border);
    margin: 16px 0;
}

/* ===== 登录页 ===== */
.login-page {
    display: flex; flex-direction: column;
    justify-content: center; align-items: center;
    min-height: 100vh; padding: 24px;
    background: linear-gradient(135deg, var(--primary), #4A8BF5);
}
.login-box {
    background: white; border-radius: 16px;
    padding: 32px 24px; width: 100%; max-width: 360px;
    text-align: center;
}
.login-box .logo { font-size: 48px; margin-bottom: 12px; }
.login-box h1 { font-size: 20px; margin-bottom: 4px; }
.login-box p { color: var(--text-secondary); font-size: 13px; margin-bottom: 24px; }
.login-box .btn { margin-top: 12px; }

/* ===== 管理后台 ===== */
.admin-header {
    background: #1D2129; color: white;
    padding: 12px 16px;
    display: flex; justify-content: space-between; align-items: center;
}
.admin-header h1 { font-size: 16px; }
.stat-card {
    background: var(--card); border-radius: var(--radius);
    padding: 16px; text-align: center;
    box-shadow: var(--shadow);
}
.stat-card .num { font-size: 28px; font-weight: 700; }
.stat-card .label { font-size: 12px; color: var(--text-secondary); }

/* ===== 部门排行榜 ===== */
.dept-bar {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 0;
}
.dept-bar .name { font-size: 13px; width: 60px; flex-shrink: 0; }
.dept-bar .bar {
    flex: 1; height: 10px; background: var(--border);
    border-radius: 5px; overflow: hidden;
}
.dept-bar .fill {
    height: 100%; background: var(--primary);
    border-radius: 5px;
}
.dept-bar .avg { font-size: 12px; color: var(--text-secondary); width: 50px; text-align: right; }

/* ===== 响应式/工具类 ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-secondary); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }

/* ===== 弹窗 ===== */
.modal {
    display: none;
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 300;
    justify-content: center; align-items: center;
}
.modal.active { display: flex; }
.modal-content {
    background: white; border-radius: var(--radius);
    padding: 24px; width: 85%; max-width: 340px;
    max-height: 80vh; overflow-y: auto;
}
.modal-content h3 { margin-bottom: 12px; }

/* ===== 签到按钮动画 ===== */
.btn-checkin {
    position: relative; overflow: hidden;
}
.btn-checkin.checked {
    background: var(--border); color: var(--text-secondary);
    pointer-events: none;
}
.btn-checkin::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    width: 100px; height: 100px;
    margin-top: -50px; margin-left: -50px;
    top: 50%; left: 50%;
    transform: scale(0);
}
.btn-checkin:active::after {
    transform: scale(4);
    opacity: 0;
    transition: all 0.6s;
}
