/* ============ 超声医学科业务学习管理系统 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --sidebar-1: #0f2d4e;
  --sidebar-2: #174b7a;
  --bg: #eef2f6;
  --card: #ffffff;
  --text: #1e293b;
  --text-2: #64748b;
  --border: #e2e8f0;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 45, 78, .08), 0 4px 14px rgba(15, 45, 78, .06);
}
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.layout { display: flex; min-height: 100vh; }

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: 232px; flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar-1), var(--sidebar-2) 70%, #1a568c);
  color: #dbeafe;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px 18px; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  background: linear-gradient(135deg, #38bdf8, #2563eb);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: #fff; letter-spacing: 1px;
  box-shadow: 0 4px 10px rgba(37, 99, 235, .4);
}
.brand-title { font-size: 16px; font-weight: 700; color: #fff; }
.brand-sub { font-size: 11px; color: #93c5fd; margin-top: 2px; }
.nav { padding: 10px 12px; flex: 1; }
.nav-group-title { font-size: 11px; color: #7ea9d4; padding: 14px 10px 6px; letter-spacing: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; margin: 3px 0; border-radius: 10px;
  color: #cfe3f7; cursor: pointer; font-size: 14px;
  transition: all .18s; user-select: none;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .9; }
.nav-item:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav-item.active {
  background: linear-gradient(90deg, #2563eb, #3b82f6);
  color: #fff; font-weight: 600;
  box-shadow: 0 4px 12px rgba(37, 99, 235, .35);
}
.sidebar-foot { padding: 14px 18px; font-size: 11px; color: #7ea9d4; border-top: 1px solid rgba(255,255,255,.08); }

/* ---------- 主区域 ---------- */
.main { flex: 1; min-width: 0; padding: 22px 26px 40px; }
.topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.topbar h1 { font-size: 20px; font-weight: 700; margin-right: auto; }
.topbar h1 small { font-size: 12px; color: var(--text-2); font-weight: 400; margin-left: 8px; }

select, input[type="text"], input[type="datetime-local"], input[type="number"], input[type="file"] {
  font-family: inherit; font-size: 14px; color: var(--text);
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 9px;
  background: #fff; outline: none; transition: border .15s, box-shadow .15s;
}
select:focus, input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 8px 16px; border: none; border-radius: 9px; cursor: pointer;
  transition: all .16s; white-space: nowrap; text-decoration: none; line-height: 1.4;
}
.btn-primary { background: linear-gradient(135deg, #3b82f6, #2563eb); color: #fff; box-shadow: 0 3px 10px rgba(37, 99, 235, .3); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(37, 99, 235, .4); }
.btn-ghost { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-green { background: linear-gradient(135deg, #22c55e, #16a34a); color: #fff; }
.btn-green:hover { filter: brightness(1.06); }
.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 8px; }
.btn-danger-ghost { background: #fff; color: var(--red); border: 1px solid #fecaca; }
.btn-danger-ghost:hover { background: #fef2f2; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

/* ---------- 学习记录卡片 ---------- */
.cards { display: flex; flex-direction: column; gap: 14px; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; border-left: 4px solid var(--primary);
  transition: box-shadow .18s;
}
.card:hover { box-shadow: 0 6px 22px rgba(15, 45, 78, .12); }
.card-head { display: flex; align-items: flex-start; gap: 10px; }
.card-title { font-size: 16px; font-weight: 700; line-height: 1.5; }
.chip {
  font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 99px; flex-shrink: 0;
  background: #eff6ff; color: var(--primary); border: 1px solid #bfdbfe;
}
.chip-green { background: #f0fdf4; color: var(--green); border-color: #bbf7d0; }
.chip-amber { background: #fffbeb; color: var(--amber); border-color: #fde68a; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-top: 8px; color: var(--text-2); font-size: 13px; }
.card-meta b { color: var(--text); font-weight: 600; }
.meta-link { color: var(--primary); text-decoration: none; }
.meta-link:hover { text-decoration: underline; }
.count-link { cursor: pointer; color: var(--primary); font-weight: 600; }
.count-link:hover { text-decoration: underline; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding-top: 13px; border-top: 1px dashed var(--border); }

.empty {
  text-align: center; color: var(--text-2); padding: 60px 20px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
}
.empty .big { font-size: 42px; margin-bottom: 10px; opacity: .35; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(3px); display: none; align-items: flex-start; justify-content: center;
  z-index: 100; padding: 7vh 16px 16px; overflow-y: auto;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 560px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25); animation: pop .22s ease;
}
.modal.wide { max-width: 760px; }
@keyframes pop { from { transform: translateY(18px) scale(.98); opacity: 0; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 17px 22px 0; }
.modal-head h3 { font-size: 17px; }
.modal-close { border: none; background: #f1f5f9; width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 15px; color: var(--text-2); }
.modal-close:hover { background: #e2e8f0; color: var(--text); }
.modal-body { padding: 16px 22px 22px; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #334155; }
.form-row input, .form-row select { width: 100%; }
.form-hint { font-size: 12px; color: var(--text-2); margin-top: 5px; line-height: 1.6; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* 二维码弹窗 */
.qr-wrap { text-align: center; padding: 8px 0 4px; }
.qr-wrap img { width: 280px; height: 280px; border: 1px solid var(--border); border-radius: 12px; padding: 8px; background: #fff; }
.qr-url { font-size: 12px; color: var(--text-2); margin-top: 10px; word-break: break-all; background: #f8fafc; border-radius: 8px; padding: 8px 12px; }
.addr-list { text-align: left; max-height: 170px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; margin-top: 6px; }
.addr-item { display: flex; align-items: center; gap: 8px; padding: 6px 2px; font-size: 13px; cursor: pointer; }
.addr-item small { color: var(--text-2); }
.switch-row { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.switch-row input { width: 17px; height: 17px; accent-color: var(--primary); }

/* ---------- 表格 ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { background: #f8fafc; color: #475569; font-weight: 600; padding: 9px 10px; text-align: left; border-bottom: 2px solid var(--border); white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.tbl tr:hover td { background: #f8fafc; }

/* ---------- 统计 ---------- */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; position: relative; overflow: hidden; }
.stat-card::after { content: ""; position: absolute; right: -18px; top: -18px; width: 74px; height: 74px; border-radius: 50%; background: rgba(37, 99, 235, .07); }
.stat-num { font-size: 30px; font-weight: 800; color: var(--primary); margin-top: 4px; }
.stat-label { font-size: 13px; color: var(--text-2); }
.chart-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; }
.chart-card h3 { font-size: 15px; margin-bottom: 16px; }
.bars { display: flex; align-items: flex-end; gap: 8px; height: 160px; padding: 0 4px; border-bottom: 2px solid var(--border); }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.bar { width: 70%; max-width: 34px; background: linear-gradient(180deg, #60a5fa, #2563eb); border-radius: 6px 6px 0 0; min-height: 2px; transition: height .4s; position: relative; }
.bar-val { font-size: 11px; color: var(--primary); font-weight: 700; }
.bar-x { display: flex; gap: 8px; padding: 6px 4px 0; }
.bar-x span { flex: 1; text-align: center; font-size: 11px; color: var(--text-2); }

/* ---------- 后台维护 ---------- */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; align-items: start; }
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.panel h3 { font-size: 15px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.inline-form input { flex: 1; min-width: 110px; }

/* ---------- 记录/照片弹窗 ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; margin-top: 6px; }
.photo-item { position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); aspect-ratio: 4/3; background: #f1f5f9; }
.photo-item img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; display: block; }
.photo-del { position: absolute; top: 5px; right: 5px; background: rgba(220, 38, 38, .9); color: #fff; border: none; border-radius: 7px; width: 24px; height: 24px; cursor: pointer; font-size: 13px; line-height: 1; }
.shot-thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.shot-thumbs img { width: 52px; height: 40px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); cursor: zoom-in; }

/* 图片预览浮层 */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: none; align-items: center; justify-content: center; z-index: 200; cursor: zoom-out; }
.lightbox.show { display: flex; }
.lightbox img { max-width: 92%; max-height: 92%; border-radius: 8px; box-shadow: 0 10px 50px rgba(0,0,0,.5); }

/* ---------- Toast ---------- */
#toast {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%) translateY(-80px);
  background: #0f172a; color: #fff; padding: 11px 22px; border-radius: 10px;
  font-size: 14px; z-index: 300; transition: transform .3s; box-shadow: 0 10px 30px rgba(0,0,0,.3);
  max-width: 80vw;
}
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--red); }
#toast.success { background: var(--green); }

@media print {
  .sidebar, .sidebar-foot, .nav { display: none !important; }
  .topbar .btn { display: none !important; }
  body { background: #fff; }
  .main { padding: 0; }
  .card, .panel, .chart-card, .stat-card { box-shadow: none; border: 1px solid #e2e8f0; }
  .bars { height: 120px; }
}

@media (max-width: 860px) {
  .sidebar { width: 64px; }
  .brand div:last-child, .nav-item span, .nav-group-title, .sidebar-foot { display: none; }
  .nav-item { justify-content: center; }
  .main { padding: 14px; }
}
