/* ========================================
   习空间 · 样式表
   设计语言与 i创空间主站保持一致（同配色/组件/导航体系）
   ======================================== */

/* --- CSS Variables（与主站一致） --- */
:root {
  --primary: #1a5fb4;
  --primary-light: #3584e4;
  --primary-dark: #0d3b66;
  --accent: #ff8c42;
  --accent-light: #ffab76;
  --bg: #ffffff;
  --bg-light: #f5f7fa;
  --bg-dark: #0d1b2a;
  --text: #2d3436;
  --text-light: #636e72;
  --text-white: #ffffff;
  --border: #e0e6ed;
  --green: #27ae60;
  --red: #c0392b;
  --shadow: 0 2px 16px rgba(0,0,0,0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --max-width: 1200px;
  --nav-height: 64px;
}

/* --- Reset & Base --- */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg-light);
  line-height: 1.7;
  overflow-x: hidden;
}
a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; }
.hidden { display: none !important; }

/* --- Buttons（沿用主站 .btn 体系） --- */
.btn, .btn-primary, .btn-block, .btn-ghost, .btn-mini, .btn-mini-b {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 24px; border-radius: var(--radius-sm); font-size: 0.95rem;
  font-weight: 600; cursor: pointer; transition: all 0.2s ease;
  border: 2px solid transparent; font-family: inherit;
}
.btn:disabled, .btn-block:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; width: 100%; padding: 13px; }
.btn-primary:hover:not(:disabled) { background: var(--primary-light); }
.btn-block { width: 100%; background: var(--primary); color: #fff; margin-top: 6px; }
.btn-block:hover:not(:disabled) { background: var(--primary-light); }
.btn-block.gray { background: #95a5b3; }
.btn-block.gray:hover:not(:disabled) { background: #8496a3; }
.btn-block.purple { background: var(--primary); } /* 工作坊主色统一为品牌蓝 */
.btn-ghost { background: transparent; border-color: var(--primary); color: var(--primary); padding: 8px 14px; }
.btn-ghost:hover { background: var(--primary); color: #fff; }
.btn-mini { border: 1px solid rgba(255,255,255,0.6); background: transparent; color: #fff; border-radius: var(--radius-sm); padding: 4px 12px; font-size: 0.8rem; }
.btn-mini-b { border: 1px solid var(--primary); color: var(--primary); background: #fff; border-radius: var(--radius-sm); padding: 5px 12px; font-size: 0.8rem; }
.btn-mini-b:hover { background: var(--primary); color: #fff; }

/* --- Forms（沿用主站 form 体系） --- */
input, select, textarea {
  width: 100%; padding: 10px 14px; border: 2px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.95rem; margin-bottom: 12px; background: #fff; outline: none; font-family: inherit;
  color: var(--text); transition: border-color 0.2s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
input:disabled { background: var(--bg-light); }
.code-row { display: flex; gap: 10px; }
.code-row input { flex: 1; }
.tip { color: var(--red); font-size: 0.85rem; margin-top: 10px; text-align: center; min-height: 18px; }

/* --- Navbar（沿用主站导航） --- */
.navbar {
  position: sticky; top: 0; z-index: 100;
  min-height: var(--nav-height);
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
}
.nav-container {
  max-width: var(--max-width); margin: 0 auto; padding: 0 24px; width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.nav-logo { display: flex; align-items: center; gap: 10px; color: var(--primary); font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.logo-icon { color: var(--accent); font-size: 1.4rem; }
.nav-user { font-size: 0.85rem; color: var(--text-light); }
.nav-user b { color: var(--text); }

/* --- Cards（沿用主站卡片） --- */
.card {
  background: var(--bg); border-radius: var(--radius); padding: 20px;
  margin-bottom: 16px; box-shadow: var(--shadow);
}
.card h3 { font-size: 1rem; margin-bottom: 12px; color: var(--text); }
.muted { color: var(--text-light); font-size: 0.85rem; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }

/* --- Pills --- */
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.75rem; background: rgba(26,95,180,0.08); color: var(--primary); margin-right: 6px; font-weight: 600; }
.pill.red { background: #fdecea; color: var(--red); }
.pill.green { background: #e8f8ef; color: var(--green); }

/* --- Toast（沿用主站 toast） --- */
.toast {
  position: fixed; top: calc(var(--nav-height) + 12px); left: 50%; transform: translateX(-50%);
  background: #fff; border-radius: 999px; padding: 10px 22px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.15); font-size: 0.92rem; font-weight: 600;
  color: var(--primary); border: 1px solid #c3d6f9; z-index: 9999;
  animation: toast-in 0.3s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -16px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ========================================
   家长端（移动优先 PWA）
   ======================================== */

/* 登录 */
#view-login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: linear-gradient(135deg, #0d1b2a 0%, #1a3a5c 50%, #1a5fb4 100%);
}
.login-box { width: 100%; max-width: 380px; background: #fff; border-radius: var(--radius); padding: 36px 28px; box-shadow: 0 8px 40px rgba(0,0,0,0.2); }
.logo { text-align: center; color: var(--primary); font-size: 2rem; letter-spacing: 4px; font-weight: 700; }
.slogan { text-align: center; color: var(--text-light); font-size: 0.85rem; margin: 8px 0 26px; }

/* 顶部成员栏（沿用导航风格，白底） */
#member-bar {
  position: sticky; top: 0; z-index: 100;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  background: rgba(255,255,255,0.95); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  color: var(--text); font-weight: 600; font-size: 0.95rem;
}
#member-bar .btn-mini { border-color: var(--primary); color: var(--primary); }

#page { padding: 16px 14px calc(80px + env(safe-area-inset-bottom, 0px)); max-width: 640px; margin: 0 auto; }

/* 底部标签栏 */
#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  display: flex; background: rgba(255,255,255,0.97); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  backdrop-filter: blur(10px);
}
.tab { flex: 1; border: none; background: none; padding: 8px 0 6px; font-size: 20px; color: var(--text-light); display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; }
.tab span { font-size: 0.7rem; }
.tab.active { color: var(--primary); }

/* 题目 */
.q-item { border-top: 1px dashed var(--border); padding: 14px 0; }
.q-item:first-child { border-top: none; padding-top: 0; }
.q-stem { font-size: 0.95rem; line-height: 1.7; margin: 6px 0 10px; }
.opt { display: block; width: 100%; text-align: left; padding: 11px 14px; margin-bottom: 8px; border: 2px solid var(--border); border-radius: var(--radius-sm); background: #fff; font-size: 0.95rem; cursor: pointer; transition: all 0.15s; }
.opt:hover:not(:disabled) { border-color: var(--primary-light); }
.opt:disabled { cursor: default; }
.opt.right { border-color: var(--green); background: #e8f8ef; }
.opt.wrong { border-color: var(--red); background: #fdecea; }
.explain { background: #fff8ec; border: 1px solid #ffe4c4; border-radius: var(--radius-sm); padding: 10px 14px; font-size: 0.85rem; color: #8a6d1a; margin-top: 8px; line-height: 1.6; }

/* 拍照 */
#photo-preview { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
#photo-preview img { width: 72px; height: 72px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.file-btn {
  display: block; text-align: center; padding: 26px; border: 2px dashed #b8c8de; border-radius: var(--radius);
  color: var(--primary); font-size: 0.95rem; background: #f8fbff; cursor: pointer; font-weight: 600;
}

/* 错题本 */
.wrong-item { border-left: 4px solid var(--accent); padding: 12px 14px; margin-bottom: 12px; background: #fff; border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.wrong-item.mastered { border-left-color: var(--green); opacity: 0.7; }

/* 学情 */
.bar-wrap { display: flex; align-items: flex-end; gap: 6px; height: 110px; padding: 8px 4px 0; }
.bar { flex: 1; background: linear-gradient(180deg, var(--primary-light), var(--primary)); border-radius: 6px 6px 0 0; position: relative; min-height: 4px; }
.bar b { position: absolute; top: -18px; left: 0; right: 0; text-align: center; font-size: 0.65rem; color: var(--text-light); font-weight: 400; }
.bar-date { flex: 1; text-align: center; font-size: 0.65rem; color: var(--text-light); }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; text-align: center; }
.stat-grid .num { font-size: 1.4rem; font-weight: 700; color: var(--primary); }
.stat-grid .lbl { font-size: 0.75rem; color: var(--text-light); margin-top: 2px; }

.member-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); gap: 8px; }
.member-row:last-child { border-bottom: none; }

/* ========================================
   管理后台 / 教师工作坊（沿用主站布局）
   ======================================== */
.admin-wrap, .w-wrap { max-width: 900px; margin: 0 auto; padding: 24px 16px 60px; }
.admin-login { max-width: 360px; margin: 12vh auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--text-light); font-weight: 600; }
textarea { min-height: 120px; font-family: inherit; font-size: 0.9rem; }
code { background: var(--bg-light); padding: 2px 6px; border-radius: 4px; font-size: 0.8rem; color: var(--primary-dark); }

/* 工作坊 */
.w-tabs { display: flex; gap: 8px; padding: 4px 0 16px; }
.w-tabs button { flex: 1; padding: 10px; border: 2px solid var(--border); background: #fff; border-radius: var(--radius-sm); font-size: 0.9rem; color: var(--text-light); cursor: pointer; font-weight: 600; transition: all 0.2s; font-family: inherit; }
.w-tabs button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.res-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); gap: 10px; }
.res-item:last-child { border-bottom: none; }
.res-item .fname { word-break: break-all; font-size: 0.9rem; }
.exam-q { border: 2px solid var(--border); border-radius: var(--radius-sm); padding: 14px; margin-bottom: 12px; }
.exam-q label { display: block; padding: 8px 10px; margin: 6px 0; border: 2px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; transition: border-color 0.15s; }
.exam-q label:hover { border-color: var(--primary-light); }
.exam-q input { width: auto; margin: 0 8px 0 0; }
.uploading { color: var(--text-light); font-size: 0.85rem; }
video { width: 100%; border-radius: var(--radius-sm); margin-top: 8px; background: #000; }
