/* ============ 编程课堂助手 · 简约蓝白教学工具风格 ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #6aa9e9;
  --primary-dark: #4f94dd;
  --primary-light: #eaf3fd;
  --bg: #f3f8fe;
  --card: #ffffff;
  --text: #24344d;
  --muted: #6b7a8f;
  --border: #e2ecf8;
  --success: #16a34a;
  --danger: #dc2626;
  --radius: 12px;
}

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  padding-bottom: 60px;
}

/* ============ 顶部 ============ */
.app-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 1px 4px rgba(37, 99, 235, 0.06);
}

.header-row {
  max-width: 920px;
  margin: 0 auto;
  padding: 14px 16px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.brand h1 { font-size: 20px; color: var(--primary); line-height: 1.3; }
.brand .subtitle { font-size: 12px; color: var(--muted); margin-left: 8px; }

.sync-status {
  font-size: 12px;
  color: var(--muted);
  background: #f3f4f6;
  border-radius: 999px;
  padding: 4px 12px;
  white-space: nowrap;
}
.sync-status.ok { background: #e8f7ee; color: var(--success); }
.sync-status.err { background: #fdecec; color: var(--danger); }

.tabs {
  max-width: 920px;
  margin: 0 auto;
  display: flex;
  gap: 4px;
  padding: 12px 16px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tab {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  padding: 9px 16px;
  border-radius: 10px 10px 0 0;
  font-size: 15px;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  font-family: inherit;
}
.tab.active {
  color: var(--primary);
  background: var(--primary-light);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* ============ 记录页内部子标签 ============ */
.sub-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  background: #eaf3fd;
  border-radius: 10px;
  padding: 4px;
}
.sub-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.sub-tab.active {
  background: #fff;
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}
.sub-panel { display: none; }
.sub-panel.active { display: block; animation: fadeIn 0.18s ease; }

/* ============ 教案文档卡内部迷你标签（表格视图/原始文本） ============ */
.mini-tabs {
  display: inline-flex;
  gap: 4px;
  margin: 0 0 12px;
  background: #eef2f7;
  border-radius: 8px;
  padding: 3px;
}
.mini-tab {
  border: none;
  background: transparent;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.mini-tab.active {
  background: #fff;
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

/* ============ 主内容 ============ */
main { max-width: 920px; margin: 16px auto 0; padding: 0 16px; }
.panel { display: none; }
.panel.active { display: block; animation: fadeIn 0.18s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

/* 教案补充信息：可折叠卡片 */
.details-card > summary {
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  padding: 2px 0 8px;
  list-style: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.details-card > summary::before {
  content: "▸ ";
  color: var(--primary);
}
.details-card[open] > summary::before {
  content: "▾ ";
}
.details-card[open] > summary {
  padding-bottom: 14px;
}

.card-title {
  font-size: 16px;
  margin-bottom: 14px;
  color: #0f2a52;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title::before {
  content: "";
  width: 4px;
  height: 16px;
  background: var(--primary);
  border-radius: 2px;
}

/* ============ 表单 ============ */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.span2 { grid-column: 1 / -1; }
.field label { font-size: 13px; color: #374151; font-weight: 600; }

.field input,
.field select,
.field textarea {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.field textarea { resize: vertical; min-height: 40px; }

.computed-box {
  border: 1px dashed #93c5fd;
  background: var(--primary-light);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  min-height: 42px;
  word-break: break-all;
}

/* ============ 当天课程选择 ============ */
.week-badge {
  color: var(--primary);
  font-weight: 600;
  font-size: 13px;
  margin-left: 6px;
}
.course-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.course-chip {
  border: 1px solid #cfe4fa;
  background: var(--primary-light);
  color: #3d7ec7;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.4;
}
.course-chip:hover {
  background: #dbeafe;
  border-color: var(--primary);
}
.course-chip:active {
  background: #bfdbfe;
}
.course-empty {
  font-size: 13px;
  color: var(--muted);
  padding: 6px 0;
}

/* ============ 参考教案截图 ============ */
.ref-image-previews {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.ref-image-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  width: 132px;
  box-sizing: border-box;
}
.ref-image-item img {
  width: 100%;
  height: auto;
  border-radius: 6px;
  display: block;
}
.ref-image-item .btn {
  width: 100%;
  margin-top: 6px;
  padding: 6px 0;
  font-size: 12px;
}
/* 教案补充信息折叠卡：只保留参考教案截图，其余输入字段隐藏 */
.hidden-fields { display: none; }

/* 两个折叠设置条：同一行并排（窄屏折一列） */
.folders-row { display: flex; gap: 12px; margin-bottom: 16px; }
.folders-row .details-card { flex: 1; min-width: 0; margin-bottom: 0; }
@media (max-width: 640px) { .folders-row { flex-direction: column; } }

/* 出勤四个数字：一行四列（窄屏自动两列） */
.count4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.count4 .field { margin-bottom: 0; }
.count4 .field label { font-size: 13px; }
.count4 input, .count4 .computed-box { padding: 8px 10px; min-height: 40px; font-size: 15px; }
@media (max-width: 560px) { .count4 { grid-template-columns: repeat(2, 1fr); } }

/* 低频维护的后台设置卡片：小一号、淡色、不抢视线 */
.quiet-card { padding: 10px 14px; margin-bottom: 12px; border-color: #eaf1fa; }
.quiet-card > summary { font-size: 13px; font-weight: 500; color: var(--muted); padding: 2px 0; }
.quiet-card[open] > summary { padding-bottom: 10px; }
.quiet-card > summary::before, .quiet-card[open] > summary::before { color: #b6c6da; }
.quiet-card .field label { font-size: 13px; }

/* 课时时长：下拉 + 换算结果紧凑一行 */
.duration-flex { display: flex; gap: 10px; align-items: center; }
.duration-flex select { flex: 0 0 160px; }
.computed-box.compact { flex: 1; padding: 9px 12px; min-height: 42px; margin: 0; }

.lesson-ref-gallery {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.lesson-ref-title {
  width: 100%;
  font-size: 13px;
  font-weight: 700;
  color: #374151;
}
.lesson-ref-img {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 420px;
  height: auto;
}

/* ============ 按钮 ============ */
.btn-row { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.btn {
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  border-radius: 9px;
  padding: 10px 18px;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); color: #fff; }
.btn.primary:disabled, .btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 7px; }
.btn.danger { color: var(--danger); border-color: #fca5a5; }
.btn.danger:hover { background: #fef2f2; border-color: var(--danger); color: var(--danger); }

/* ============ 预览 ============ */
.preview-item { margin-top: 14px; }
.preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  gap: 10px;
  flex-wrap: wrap;
}
.preview-name { font-weight: 600; font-size: 14px; }
.count { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 6px; }

.preview-text {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-size: 14px;
  line-height: 1.7;
  background: #fafbfe;
  font-family: inherit;
  resize: vertical;
  min-height: 90px;
  color: #1f2937;
}

.hint { font-size: 12px; color: var(--muted); margin-top: 8px; line-height: 1.6; }

.filename-box {
  background: var(--primary-light);
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  word-break: break-all;
  margin-bottom: 14px;
  font-weight: 600;
}

/* ============ 统计 ============ */
.toolbar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .field.inline { flex-direction: row; align-items: center; gap: 8px; }
.toolbar .field.inline input { width: auto; }

.stat-chips { display: flex; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.chip {
  flex: 1;
  min-width: 110px;
  background: var(--primary-light);
  border: 1px solid #dbeafe;
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}
.chip-label { display: block; font-size: 12px; color: var(--muted); }
.chip-value { display: block; font-size: 24px; font-weight: 700; color: var(--primary); margin-top: 2px; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 740px; }
.data-table th,
.data-table td {
  border: 1px solid #dbe1ea;
  padding: 8px 10px;
  text-align: center;
  white-space: nowrap;
}
.data-table th { background: #f0f6ff; color: #1e3a6e; font-weight: 600; }
.data-table tbody tr:nth-child(even) { background: #fafbfe; }
.data-table tbody tr:hover { background: #f0f6ff; }

/* ============ 全部记录 ============ */
.records-list { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.record-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fff;
}
.record-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.badge-date { background: var(--primary); color: #fff; border-radius: 6px; padding: 2px 8px; font-size: 12px; flex: 0 0 auto; }
.record-class { font-weight: 700; }
.record-theme { color: var(--primary); }
.record-meta { font-size: 13px; color: #4b5563; margin-top: 6px; }
details summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--primary);
  margin-top: 6px;
  user-select: none;
  display: inline-block;
}
details pre {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 6px;
  font-family: inherit;
  line-height: 1.6;
}
.empty { text-align: center; color: var(--muted); padding: 30px 0; font-size: 14px; }

/* ============ Toast ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s;
  z-index: 100;
  max-width: 86vw;
  text-align: center;
  line-height: 1.5;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: rgba(220, 38, 38, 0.95); }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 90;
  padding: 20px;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff;
  border-radius: 14px;
  padding: 22px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.2);
}
.modal-text { font-size: 15px; line-height: 1.7; margin-bottom: 18px; color: #374151; }
.modal-btns { display: flex; gap: 10px; justify-content: flex-end; }

/* ============ 移动端 ============ */
@media (max-width: 640px) {
  .grid2 { grid-template-columns: 1fr; }
  .card { padding: 14px; }
  body { font-size: 16px; }
  .chip-value { font-size: 20px; }
  .tab { padding: 8px 13px; font-size: 14px; }
  .brand h1 { font-size: 18px; }
}
