/* 智能学习小管家 - 共享样式 */
:root {
  --brand: #4f46e5;
  --brand-light: #eef2ff;
  --child: #0ea5e9;
  --child-light: #e0f2fe;
  --ok: #16a34a;
  --warn: #f59e0b;
  --bad: #dc2626;
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
a { text-decoration: none; }

/* 顶部导航 */
.topbar {
  background: linear-gradient(120deg, var(--brand) 0%, #7c3aed 100%);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 12px rgba(79,70,229,.18);
}
.topbar .logo { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.topbar .logo .dot { width: 10px; height: 10px; border-radius: 50%; background: #fbbf24; }
.topbar .links { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.topbar .links a {
  color: #e9e6ff; padding: 6px 12px; border-radius: 8px; font-size: 14px; white-space: nowrap;
}
.topbar .links a:hover { background: rgba(255,255,255,.14); color: #fff; }
.topbar .links a.active { background: rgba(255,255,255,.22); color: #fff; font-weight: 600; }
.topbar .user { font-size: 14px; color: #e9e6ff; display: flex; align-items: center; gap: 10px; }
.topbar .user button {
  background: rgba(255,255,255,.18); border: none; color: #fff; padding: 5px 12px;
  border-radius: 8px; cursor: pointer; font-size: 13px;
}
.topbar .user button:hover { background: rgba(255,255,255,.3); }

.container-main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
.page-title { font-size: 22px; font-weight: 700; margin: 4px 0 18px; }

/* 卡片 */
.card-x {
  background: var(--card); border-radius: 16px; padding: 18px;
  box-shadow: 0 4px 18px rgba(17,24,39,.06); margin-bottom: 16px; border: 1px solid rgba(17,24,39,.04);
}
.card-x h5 { margin: 0 0 12px; font-weight: 700; }

/* 统计小卡 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 14px; }
.stat-box {
  background: var(--card); border-radius: 16px; padding: 16px; text-align: center;
  box-shadow: 0 4px 18px rgba(17,24,39,.06); border: 1px solid rgba(17,24,39,.04);
}
.stat-box .num { font-size: 28px; font-weight: 800; color: var(--brand); }
.stat-box .label { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* 作业卡片 */
.hw-card {
  border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; background: #fff;
  border-left: 5px solid var(--brand); box-shadow: 0 2px 10px rgba(17,24,39,.05);
  display: flex; flex-direction: column; gap: 8px;
}
.hw-card.p-high { border-left-color: var(--bad); }
.hw-card.p-mid { border-left-color: var(--warn); }
.hw-card.p-low { border-left-color: #94a3b8; }
.hw-card.done { opacity: .72; }
.hw-card .row1 { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.hw-card .subject { font-weight: 700; }
.hw-card .content { color: #374151; }
.hw-card .meta { font-size: 12px; color: var(--muted); }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.tag-high { background: #fee2e2; color: #b91c1c; }
.tag-mid { background: #fef3c7; color: #b45309; }
.tag-low { background: #f1f5f9; color: #475569; }
.tag-status-todo { background: #e0e7ff; color: #3730a3; }
.tag-status-doing { background: #d1fae5; color: #047857; }
.tag-status-done { background: #e5e7eb; color: #4b5563; }
.tag-status-pending { background: #fef3c7; color: #b45309; }
.tag-subject { background: var(--brand-light); color: var(--brand); }

/* 家长首页：每天完成用时明细表 */
.time-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 480px; }
.time-table th, .time-table td { border-bottom: 1px solid #eef2f7; padding: 8px 6px; text-align: left; white-space: nowrap; }
.time-table th { color: #64748b; font-weight: 600; background: #f8fafc; }

.btn-x { border: none; border-radius: 10px; padding: 8px 14px; font-size: 14px; cursor: pointer; font-weight: 600; }
.btn-primary-x { background: var(--brand); color: #fff; }
.btn-primary-x:hover { background: #4338ca; }
.btn-ghost-x { background: #f1f5f9; color: #334155; }
.btn-ghost-x:hover { background: #e2e8f0; }
.btn-danger-x { background: #fee2e2; color: #b91c1c; }
.btn-success-x { background: var(--ok); color: #fff; }
.btn-sm-x { padding: 5px 10px; font-size: 13px; }

.form-x { display: flex; flex-direction: column; gap: 10px; }
.form-x label { font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.form-x input, .form-x select, .form-x textarea {
  padding: 9px 12px; border: 1px solid #d1d5db; border-radius: 10px; font-size: 14px; width: 100%;
}
.form-x input:focus, .form-x select:focus, .form-x textarea:focus { outline: 2px solid var(--brand-light); border-color: var(--brand); }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 30px; background: #111827; color: #fff;
  padding: 10px 18px; border-radius: 10px; z-index: 999; opacity: 0; transition: opacity .25s; font-size: 14px;
}
.toast.show { opacity: .95; }

.modal-cover {
  position: fixed; inset: 0; background: rgba(15,23,42,.5); display: none; align-items: center; justify-content: center; z-index: 100;
  padding: 16px;
}
.modal-cover.show { display: flex; }
.modal-box { background: #fff; border-radius: 16px; padding: 20px; width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; }
.modal-box h4 { margin: 0 0 14px; }

/* 移动端适配 */
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; padding: 10px 14px; }
  .topbar .links { display: none; }            /* 移动端改用底部 Tab 栏 */
  .topbar .logo { font-size: 16px; }
  .container-main { padding: 14px 12px 76px; } /* 给底部 Tab 留空间 */
  .hw-card .row1 { flex-direction: column; align-items: flex-start; }
  .btn-x { padding: 10px 16px; min-height: 42px; }  /* 更大触控区 */
  .btn-sm-x { min-height: 36px; padding: 7px 12px; }
  .page-title { font-size: 19px; margin: 4px 0 14px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-box .num { font-size: 23px; }
  .form-x input, .form-x select, .form-x textarea { font-size: 16px; }  /* 防止 iOS 聚焦缩放 */
  .modal-box { max-width: 100%; }
  .tb-banner { flex-wrap: wrap; gap: 8px; }
  /* 考试明细表横向滚动 */
  .exam-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .exam-table { min-width: 520px; }
}

/* 移动端底部 Tab 栏 */
.tabbar { display: none; }
@media (max-width: 640px) {
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: #fff; border-top: 1px solid #eceef2;
    box-shadow: 0 -2px 14px rgba(17,24,39,.08); padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    padding: 8px 2px 10px; font-size: 11px; color: #9ca3af; text-decoration: none;
    transition: color .15s ease;
  }
  .tabbar a .ic { width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; }
  .tabbar a.active { color: var(--brand); font-weight: 700; }
  .tabbar a.active .ic { color: var(--brand); }
}
.mic-pulse { width: 90px; height: 90px; border-radius: 50%; background: var(--bad); margin: 14px auto; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 30px; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(220,38,38,.5);} 70%{box-shadow:0 0 0 22px rgba(220,38,38,0);} 100%{box-shadow:0 0 0 0 rgba(220,38,38,0);} }
.result-ok { color: var(--ok); font-weight: 700; }
.result-bad { color: var(--bad); font-weight: 700; }

/* ============ 淘宝风积分商城 ============ */
.tb-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: linear-gradient(90deg, #ff5000 0%, #ff8a00 100%);
  color: #fff; border-radius: 14px; padding: 14px 16px; margin-bottom: 16px;
  box-shadow: 0 6px 18px rgba(255,80,0,.18);
}
.tb-banner-title { font-size: 18px; font-weight: 800; }
.tb-banner-bal { font-size: 14px; }
.tb-banner-bal b { font-size: 20px; font-weight: 800; }
.tb-add-btn {
  background: rgba(255,255,255,.92); color: #ff5000; border: none; border-radius: 999px;
  padding: 7px 16px; font-size: 13px; font-weight: 800; cursor: pointer; white-space: nowrap;
}
.tb-add-btn:hover { background: #fff; }

.tb-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
}
.tb-card {
  background: #fff; border-radius: 12px; overflow: hidden; display: flex; flex-direction: column;
  box-shadow: 0 2px 10px rgba(17,24,39,.06); border: 1px solid rgba(17,24,39,.04);
  transition: transform .15s ease, box-shadow .15s ease;
}
.tb-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(17,24,39,.12); }
.tb-imgwrap {
  width: 100%; aspect-ratio: 1 / 1; background: #f3f4f6; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.tb-imgwrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tb-noimg { font-size: 44px; }
.tb-body { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 6px; }
.tb-name {
  font-size: 14px; line-height: 1.3; color: #222; min-height: 36px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tb-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.tb-price { color: #ff5000; font-weight: 800; font-size: 17px; }
.tb-price small { font-size: 11px; font-weight: 700; margin-left: 1px; }
.tb-btn {
  background: linear-gradient(90deg, #ff5000 0%, #ff8a00 100%); color: #fff; border: none;
  border-radius: 999px; padding: 6px 16px; font-size: 13px; font-weight: 700; cursor: pointer;
  white-space: nowrap;
}
.tb-btn:hover { filter: brightness(1.05); }
.tb-btn:disabled { background: #d1d5db; cursor: not-allowed; }
.tb-stock { font-size: 11px; color: #999; }
.tb-ops { display: flex; gap: 6px; }
.tb-op {
  border: 1px solid #e5e7eb; background: #fff; color: #475569; border-radius: 8px;
  padding: 5px 10px; font-size: 12px; cursor: pointer;
}
.tb-op:hover { border-color: #ff8a00; color: #ff5000; }
.tb-op-del:hover { border-color: #dc2626; color: #dc2626; }

@media (min-width: 720px) {
  .tb-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 360px) {
  .tb-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
}

/* 模板卡优先级色（顶部描边） */
.tb-card.p-high { border-top: 3px solid var(--bad); }
.tb-card.p-mid { border-top: 3px solid var(--warn); }
.tb-card.p-low { border-top: 3px solid #94a3b8; }

/* 考试明细表 */
.exam-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.exam-table th, .exam-table td { padding: 9px 10px; text-align: left; border-bottom: 1px solid #f1f5f9; white-space: nowrap; }
.exam-table th { color: var(--muted); font-weight: 600; background: #f8fafc; position: sticky; top: 0; }
.exam-table tr:hover td { background: #fafbff; }
.exam-score { font-weight: 800; color: var(--ok); }
.exam-pending { color: var(--warn); font-weight: 700; }
