/* 小学数学个性化作业AI辅助系统 - 全局样式 V4.0 */
:root {
    --primary: #4f7cff;
    --primary-dark: #3a63d8;
    --success: #34a853;
    --danger: #ea4335;
    --warning: #fbbc05;
    --bg: #f5f7fb;
    --card: #ffffff;
    --text: #2c3e50;
    --muted: #8a94a6;
    --border: #e4e9f2;
    --radius: 10px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
/* 需求9：全局基础字号≥16px 防止iOS自动缩放 */
html { font-size: 16px; }
body { font-family: "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; display: flex; flex-direction: column; font-size: 15px; line-height: 1.55; }

/* 导航 */
.navbar { background: var(--card); box-shadow: 0 2px 8px rgba(0,0,0,.06); padding: 0 24px; height: 56px; display: flex; align-items: center; gap: 24px; position: sticky; top: 0; z-index: 100; flex-wrap: wrap; }
.brand { font-size: 18px; font-weight: 700; color: var(--primary); text-decoration: none; }
.nav-links { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.nav-links a { color: var(--text); text-decoration: none; padding: 8px 12px; border-radius: 6px; font-size: 14px; }
.nav-links a:hover { background: var(--bg); }
.nav-links a.active { color: var(--primary); background: #eef3ff; font-weight: 600; }
.nav-user { color: var(--muted); font-size: 13px; margin-left: 8px; }

/* 管理员子导航 */
.admin-nav { display: flex; gap: 4px; flex-wrap: wrap; background: var(--card); border-radius: 10px; padding: 6px; margin-bottom: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.05); }
.admin-nav a { color: var(--text); text-decoration: none; padding: 8px 14px; border-radius: 8px; font-size: 14px; }
.admin-nav a:hover { background: var(--bg); }
.admin-nav a.active { color: var(--primary); background: #eef3ff; font-weight: 600; }

/* 月历（管理员作业布置） */
.cal { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal th { padding: 8px 4px; font-size: 12px; color: var(--muted); font-weight: 500; text-align: center; background: #fafbfd; }
.cal td { height: 64px; vertical-align: top; border: 1px solid var(--border); padding: 4px; }
.cal td.other { background: #fafbfd; }
.cal td.has { background: #eef3ff; }
.cal .day { display: block; text-decoration: none; color: inherit; height: 100%; }
.cal .d { font-size: 13px; color: var(--muted); }
.cal .cnt { display: inline-block; margin-top: 6px; background: var(--primary); color: #fff; border-radius: 10px; padding: 1px 8px; font-size: 12px; font-weight: 600; }

/* 布局 */
.container { max-width: 1200px; width: 100%; margin: 20px auto; padding: 0 16px; flex: 1; }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 16px; }
.footer-beian { margin-top: 6px; font-size: 12px; }
.footer-beian a { color: var(--muted); text-decoration: none; }
.footer-beian a:hover { color: var(--primary); text-decoration: underline; }
h1 { font-size: 22px; margin-bottom: 16px; }
h2 { font-size: 17px; margin: 12px 0; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }

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

/* 表单 —— 需求9：输入框字号≥16px 防iOS聚焦缩放 */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 16px; font-family: inherit; color: var(--text); background: #fff; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
.form-inline { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.form-inline .form-group { margin-bottom: 0; }
.req { color: var(--danger); margin-left: 2px; font-weight: 700; }

/* 按钮 */
.btn { display: inline-block; padding: 9px 18px; border: none; border-radius: 6px; font-size: 14px; cursor: pointer; text-decoration: none; text-align: center; transition: all .15s; min-height: 36px; line-height: 1.4; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-info { background: #1a73e8; color: #fff; }
.btn-info:hover { background: #1765cc; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 5px 10px; font-size: 12px; min-height: 28px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn + .btn { margin-left: 6px; }

/* 提示 */
.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; font-size: 14px; }
.alert-success { background: #e6f4ea; color: #137333; }
.alert-danger { background: #fce8e6; color: #c5221f; }
.alert-info { background: #e8f0fe; color: #1a56db; }
.alert-warning { background: #fef7e0; color: #b26a00; }
.hint { color: var(--muted); font-size: 12px; }

/* 表格 */
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
.table th { color: var(--muted); font-weight: 500; font-size: 13px; background: #fafbfd; }
.table tr:hover td { background: #fafbff; }
.table-actions { display: flex; gap: 4px; flex-wrap: wrap; }

/* 学生卡片网格（边批边录）— 需求8：卡片整体按状态变色 */
.student-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.student-card { background: var(--card); border: 2px solid var(--border); border-radius: var(--radius); padding: 14px 8px; text-align: center; cursor: pointer; transition: all .15s; position: relative; min-height: 60px; display: flex; flex-direction: column; justify-content: center; }
.student-card:hover { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,.08); }
.student-card.selected { border-color: var(--primary); background: #eef3ff; }
.student-card .s-name { font-size: 15px; font-weight: 600; }
.student-card .s-no { font-size: 12px; color: var(--muted); margin-top: 2px; }
.student-card .s-status { margin-top: 6px; font-size: 11px; padding: 2px 8px; border-radius: 10px; display: inline-block; }

/* 需求8：学生卡片整体背景色三态（覆盖默认 .student-card） */
.student-card.st-pending { background: #f1f3f7; border-color: #c6ccd8; }
.student-card.st-pending:hover { background: #e7eaf1; }
.student-card.st-correct { background: #e6f4ea; border-color: #34a853; }
.student-card.st-correct:hover { background: #d4ecdb; }
.student-card.st-correct .s-name { color: #137333; }
.student-card.st-errors  { background: #fce8e6; border-color: #ea4335; }
.student-card.st-errors:hover { background: #f9d4d1; }
.student-card.st-errors .s-name { color: #c5221f; }
/* 已改错：蓝色 */
.student-card.st-corrected { background: #e8f0fe; border-color: #1a73e8; }
.student-card.st-corrected:hover { background: #d2e3fc; }
.student-card.st-corrected .s-name { color: #1967d2; }
/* s-status span 内部文字色独立（若保留显示） */
.st-pending-text { color: var(--muted); }
.st-correct-text { color: #137333; }
.st-errors-text { color: #c5221f; }

/* 错因标签 —— 5 类完整配色 */
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 5px 12px; border-radius: 14px; font-size: 12px; cursor: pointer; border: 1px solid transparent; margin: 3px; user-select: none; transition: all .15s; line-height: 1.35; }
.tag:hover { filter: brightness(.96); transform: scale(1.02); }
.tag-calc       { background: #fff3e0; color: #b26a00; border-color: #ffe0b2; }   /* 1 计算粗心 - 橙 */
.tag-count      { background: #f3e5f5; color: #6a1b9a; border-color: #e1bee7; }   /* 2 小数的计数单位混淆 - 紫 */
.tag-understand { background: #e3f2fd; color: #1565c0; border-color: #bbdefb; }   /* 3 概念理解错误 - 蓝 */
.tag-unit       { background: #e0f2f1; color: #00695c; border-color: #b2dfdb; }   /* 4 实际单位换算 - 青绿 */
.tag-analyze    { background: #fce4ec; color: #ad1457; border-color: #f8bbd0; }   /* 5 审题策略错误 - 粉 */
.tag-add { background: #f1f3f7; color: var(--muted); border: 1px dashed var(--border); }
.tag-default { background: #fafafa; color: #999; border: 1px solid #eee; opacity: 0.7; }  /* 其他年级教材（淡） */
.tag-rec { background: #fff8e1; color: #8d6e00; border-color: #ffecb3; font-style: italic; }   /* 老师手动录入（黄色） */
.tag-del { display: inline-flex; align-items: center; padding: 3px 6px; margin-left: -2px; font-size: 13px; cursor: pointer; opacity: .45; border-radius: 6px; transition: all .15s; }
.tag-del:hover { opacity: 1; background: #ffebee; }
.tag-edit { display: inline-flex; align-items: center; padding: 3px 6px; font-size: 13px; cursor: pointer; opacity: .45; border-radius: 6px; transition: all .15s; }
.tag-edit:hover { opacity: 1; background: #e3f2fd; }
.tag-del-confirm { display: inline-flex; align-items: center; margin-left: 4px; padding: 2px 4px; background: #fff3e0; border: 1px solid #ffcc80; border-radius: 6px; font-size: 12px; }
.mini-btn { border: none; border-radius: 4px; padding: 2px 8px; font-size: 12px; cursor: pointer; margin: 0 2px; }
.mini-ok { background: #e53935; color: #fff; }
.mini-ok:hover { background: #c62828; }
.mini-cancel { background: #e0e0e0; color: #555; }
.mini-cancel:hover { background: #bdbdbd; }

/* 麦克风按钮 —— 默认基础尺寸 */
.mic-btn { width: 72px; height: 72px; border-radius: 50%; border: none; background: var(--primary); color: #fff; font-size: 30px; cursor: pointer; box-shadow: 0 4px 12px rgba(79,124,255,.35); transition: all .2s; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; }
.mic-btn:hover { transform: scale(1.06); }
.mic-btn:active, .mic-btn.pressed { background: var(--primary-dark); }
.mic-btn.recording { background: var(--danger); animation: pulse 1.2s infinite; }
.mic-btn.processing { background: var(--muted); cursor: wait; animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(234,67,53,.55);} 70% { box-shadow: 0 0 0 20px rgba(234,67,53,0);} 100% { box-shadow: 0 0 0 0 rgba(234,67,53,0);} }
.mic-status { font-size: 13px; color: var(--muted); margin-top: 6px; }
.mic-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px; }

/* 错题列表 */
.error-item { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 8px; padding: 10px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.error-item:last-child { border-bottom: none; }
.error-item .q-no { font-weight: 700; color: var(--primary); flex-shrink: 0; min-width: 28px; }
.error-item .err-body { flex: 1; }
.error-item .err-name { font-weight: 600; margin-right: 6px; }
.error-item .err-cat { color: var(--muted); font-size: 12px; }
.error-item .del { color: var(--danger); cursor: pointer; margin-left: auto; flex-shrink: 0; font-size: 13px; padding: 2px 6px; border-radius: 4px; }
.error-item .del:hover { background: #fce8e6; }
.error-item .edit { color: #5f6368; flex-shrink: 0; font-size: 13px; padding: 2px 6px; border-radius: 4px; }
.error-item .edit:hover { background: #e8f0fe; }

/* 图表 */
.chart-box { position: relative; height: 320px; }

/* 布置作业 - 题目勾选 */
.q-check { display: flex; align-items: flex-start; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; cursor: pointer; }
.q-check:hover { border-color: var(--primary); }
.q-check.checked { background: #eef3ff; border-color: var(--primary); }
.q-no { font-weight: 700; color: var(--primary); flex-shrink: 0; min-width: 32px; }
.q-img { max-width: 260px; border-radius: 6px; margin-top: 6px; border: 1px solid var(--border); }
.q-body { flex: 1; }
.q-kp { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* 报告勾选列表 */
.assign-check { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; cursor: pointer; }
.assign-check:hover { border-color: var(--primary); }
.assign-check.checked { background: #eef3ff; border-color: var(--primary); }

/* 语音 demo */
.voice-log { background: #0f1a2b; color: #9fb5d8; font-family: Consolas, monospace; font-size: 13px; padding: 14px; border-radius: 8px; max-height: 260px; overflow-y: auto; }
.voice-log .t { color: #6b7f9e; }

/* 登录页 */
.auth-wrap { max-width: 380px; margin: 60px auto; }
.auth-wrap .card { padding: 28px; }
.auth-title { text-align: center; font-size: 20px; font-weight: 700; color: var(--primary); margin-bottom: 20px; }

/* 预览 */
.report-preview { border: 1px solid var(--border); border-radius: 8px; padding: 18px; margin-bottom: 14px; background: #fff; }

/* 页码分组（教材详情页） */
.page-group { margin-bottom: 24px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.page-group-head { display: flex; justify-content: space-between; align-items: center; background: #fafbfd; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.page-group-title { font-weight: 600; color: var(--text); }
.page-group-body { padding: 14px 16px; }
.offset-card { background: #fff8e1; border: 1px solid #ffecb3; border-radius: 8px; padding: 14px 16px; margin-bottom: 20px; }
.offset-card .card-title { color: #8d6e00; }

/* ================= Modal 样式（需求5：弹窗批改） ================= */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: none;
    align-items: center; justify-content: center;
    z-index: 200;
    padding: 10px;
    backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; animation: fadeIn .18s ease-out; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-body {
    background: var(--card);
    border-radius: var(--radius);
    max-width: 1100px;
    width: 100%;
    max-height: 94vh;
    overflow: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    animation: slideUp .2s ease-out;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; background: var(--card); z-index: 2;
}
.modal-title { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.modal-title .m-stu-no { color: var(--muted); font-weight: 400; font-size: 14px; }
.modal-head .head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.modal-close {
    width: 36px; height: 36px; border-radius: 50%; border: none;
    background: #f1f3f7; color: var(--muted); font-size: 18px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--danger); color: #fff; }
.modal-content { padding: 18px 20px 22px; }

/* 弹窗内双列布局 */
.m-grid {
    display: grid;
    grid-template-columns: minmax(280px, 380px) 1fr;
    gap: 18px;
}
.m-col { min-width: 0; }
.m-panel {
    background: #fafbfd;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 14px;
}
.m-panel-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.m-transcript { width: 100%; min-height: 90px; resize: vertical; font-size: 15px; }

/* 弹窗：逐题批改列表（右栏） */
.m-question {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 12px;
}
.m-question.m-has-error { border-color: #ea4335; background: #fffafa; }
.m-question.m-all-correct { border-color: #34a853; background: #f6fbf7; }
.m-q-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.m-q-no { font-weight: 700; color: var(--primary); font-size: 15px; flex-shrink: 0; }
.m-q-content { flex: 1; font-size: 14px; line-height: 1.55; }
.m-q-content img { max-width: 240px; border-radius: 4px; margin-top: 4px; border: 1px solid var(--border); }
.m-q-errors { margin-top: 6px; }
.m-q-rec-tags-title { color: var(--muted); font-size: 12px; margin: 6px 0 2px; }

/* 花名册 */
.roster-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

/* ================= 响应式：手机端（需求9：按钮≥44px，字体≥16px，单列） ================= */
@media (max-width: 700px) {
    html { font-size: 16px; }
    body { font-size: 15px; }
    .navbar { height: auto; padding: 10px 12px; gap: 10px; }
    .nav-links a { padding: 10px 12px; font-size: 15px; }
    .brand { font-size: 17px; }
    .container { max-width: 100%; margin: 10px auto; padding: 0 10px; }
    .card { padding: 14px 12px; border-radius: 12px; }
    h1 { font-size: 20px; }
    h2 { font-size: 17px; }

    /* 学生卡片：触摸面积≥44pt */
    .student-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
    .student-card {
        min-height: 56px;
        padding: 14px 8px;
        border-radius: 12px;
        border-width: 2px;
    }
    .student-card .s-name { font-size: 17px; }
    .student-card .s-no   { font-size: 13px; margin-top: 3px; }
    .student-card .s-status { font-size: 12px; padding: 3px 10px; }

    /* 按钮：min-height 44px */
    .btn:not(.btn-sm) {
        min-height: 44px;
        padding: 10px 18px;
        font-size: 15px;
        border-radius: 10px;
    }
    .btn-sm { min-height: 32px; padding: 6px 12px; font-size: 13px; }

    /* 标签按钮：min-height 44px */
    .tag {
        min-height: 40px;
        padding: 8px 16px;
        margin: 4px 4px;
        font-size: 14px;
        border-radius: 20px;
    }

    /* 麦克风按钮：更大 */
    .mic-btn {
        width: 96px; height: 96px;
        font-size: 42px;
        box-shadow: 0 6px 18px rgba(79,124,255,.35);
    }
    .mic-status { font-size: 14px; }

    /* 表单输入 */
    input, select, textarea { padding: 11px 14px; font-size: 16px; border-radius: 8px; }
    .form-group label { font-size: 14px; }

    /* Modal 单列 */
    .m-grid { grid-template-columns: 1fr; gap: 12px; }
    .modal-body { max-height: 96vh; border-radius: 14px; }
    .modal-head { padding: 12px 14px; }
    .modal-content { padding: 12px 14px 16px; }
    .modal-title { font-size: 16px; }
    .modal-title .m-stu-no { font-size: 13px; }
    .m-panel { padding: 12px; }
    .head-actions .btn { font-size: 13px; padding: 7px 12px; min-height: 36px; }
    .modal-close { width: 38px; height: 38px; font-size: 18px; }

    .chart-box { height: 240px; }
    .table th, .table td { padding: 10px 8px; font-size: 14px; }
    .page-group-head { padding: 10px 12px; }
    .page-group-body { padding: 12px; }
}

/* 更小屏（≤380）再收紧 */
@media (max-width: 380px) {
    .student-grid { grid-template-columns: repeat(2, 1fr); }
    .mic-btn { width: 88px; height: 88px; font-size: 38px; }
}
