/* ================================================================
   心灵驿站 · 学校心理档案平台 —— 卡通温暖心理风主题
   ================================================================ */

:root {
  --primary: #7c6cf0;         /* 柔和紫 · 心智 */
  --primary-dark: #6a58e0;
  --primary-soft: #f0ecff;
  --accent: #ff8a5c;          /* 珊瑚橙 · 暖心 */
  --accent-dark: #f4733f;
  --accent-soft: #fff0e9;
  --teal: #2ec4b6;            /* 薄荷绿 · 平静 */
  --teal-soft: #e2f8f4;
  --blue: #5b9cf6;            /* 天空蓝 */
  --blue-soft: #e8f1fe;
  --amber: #f0a226;           /* 暖黄 · 提醒 */
  --amber-soft: #fdf1db;
  --green: #39bd86;
  --orange: #ff8a5c;          /* 兼容旧引用 */
  --red: #ef6d7e;             /* 柔和红 · 危机 */
  --red-soft: #feecef;
  --danger: #ef6d7e;          /* 兼容旧引用 */

  --bg: #fbf6ef;              /* 暖奶油底 */
  --card: #ffffff;
  --text: #44384e;
  --muted: #978aa1;
  --border: #f1e7db;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 6px 20px rgba(124, 108, 240, .08), 0 2px 6px rgba(60, 40, 90, .05);
  --shadow-lg: 0 18px 48px rgba(60, 40, 90, .16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Microsoft JhengHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
}
body {
  background-color: var(--bg);
  background-image:
    radial-gradient(rgba(124, 108, 240, .05) 1.2px, transparent 1.2px),
    linear-gradient(rgba(251, 246, 239, .9), rgba(251, 246, 239, .93)),
    url('/assets/bg.jpg');
  background-size: 22px 22px, auto, cover;
  background-position: 0 0, center, center;
  background-repeat: repeat, no-repeat, no-repeat;
}

h1, h2, h3, h4 {
  font-family: "YouYuan", "Yuanti SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-weight: 700;
  color: var(--text);
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); text-decoration: underline; }

/* —— 顶部导航 —— */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 24px;
  height: 60px;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(60, 40, 90, .05);
}
.topbar::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent), var(--teal));
  opacity: .55;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 17px;
  font-weight: 700;
  color: var(--primary-dark);
  font-family: "YouYuan", "PingFang SC", "Microsoft YaHei", sans-serif;
  white-space: nowrap;
}
.brand-emoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--primary-soft), var(--accent-soft));
  font-size: 18px;
  box-shadow: inset 0 0 0 1px var(--border);
}
.brand-logo { display: block; height: 40px; width: auto; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav-link {
  padding: 7px 15px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--accent-soft); color: var(--accent-dark); text-decoration: none; }
.nav-link.active { color: var(--primary-dark); background: var(--primary-soft); }
.userbox { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.uname { color: var(--text); font-weight: 600; }

/* —— 容器 —— */
.container { max-width: 1200px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 24px; }
.page-head .sub { color: var(--muted); margin-top: 3px; }

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

/* —— 统计卡片 —— */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat {
  position: relative;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s;
}
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-icon {
  width: 42px; height: 42px;
  border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  margin-bottom: 12px;
}
.stat .num { font-size: 30px; font-weight: 700; line-height: 1.1; font-family: "YouYuan", "PingFang SC", sans-serif; color: var(--text); }
.stat .label { color: var(--muted); font-size: 13px; margin-top: 2px; }
.stat.c1 .stat-icon { background: var(--primary-soft); } .stat.c1 .num { color: var(--primary); }
.stat.c2 .stat-icon { background: var(--teal-soft); }  .stat.c2 .num { color: var(--teal); }
.stat.c3 .stat-icon { background: var(--accent-soft); } .stat.c3 .num { color: var(--accent); }
.stat.c4 .stat-icon { background: var(--blue-soft); }  .stat.c4 .num { color: var(--blue); }
.stat.c5 .stat-icon { background: var(--red-soft); }   .stat.c5 .num { color: var(--red); }
.stat.warn .num { color: var(--accent); }
.stat.danger .num { color: var(--red); }

/* —— 按钮 —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 14px;
  cursor: pointer;
  font-weight: 600;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 4px 12px rgba(124, 108, 240, .25);
  transition: transform .15s, box-shadow .15s, background .15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(124, 108, 240, .32); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
.btn-ghost { background: #fff; color: var(--text); border-color: var(--border); box-shadow: none; }
.btn-ghost:hover { background: var(--bg); border-color: var(--primary); color: var(--primary-dark); box-shadow: none; }
.btn-danger { background: linear-gradient(135deg, #f58394, var(--red)); box-shadow: 0 4px 12px rgba(239, 109, 126, .25); }
.btn-danger:hover { box-shadow: 0 6px 18px rgba(239, 109, 126, .35); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-lg { padding: 11px 24px; font-size: 15px; }

/* —— 表单 —— */
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
label > span { display: block; margin-bottom: 5px; color: var(--text); font-weight: 600; }
input, select, textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(124, 108, 240, .13);
}
textarea { min-height: 90px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 16px; }
.form-grid label { margin: 0; }
.form-grid .full { grid-column: 1 / -1; }

/* —— 风险徽章 —— */
.risk-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
}
.risk-normal { background: #e6f9ef; color: #1f9d68; }
.risk-attention { background: var(--amber-soft); color: #b8790a; }
.risk-key { background: var(--accent-soft); color: var(--accent-dark); }
.risk-crisis { background: var(--red-soft); color: #d84b60; }

/* —— 表格 —— */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 700; font-size: 13px; background: #fdfaf5; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #fbf6ff; }
.table tbody tr:last-child td { border-bottom: none; }
.table a.row-link { color: var(--text); font-weight: 600; }
.table a.row-link:hover { color: var(--primary-dark); text-decoration: none; }
tr.clickable { cursor: pointer; }

/* —— 空状态 —— */
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }

/* —— 搜索/工具条 —— */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input, .toolbar select { width: auto; min-width: 140px; }
.toolbar .spacer { flex: 1; }

/* —— 列表 —— */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.list-item:hover { border-color: var(--primary); box-shadow: var(--shadow); transform: translateX(2px); }
.list-item .li-main { font-weight: 600; }
.list-item .li-sub { color: var(--muted); font-size: 13px; }

/* —— 时间线（访谈） —— */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 4px; bottom: 4px; width: 2px; background: linear-gradient(var(--primary-soft), var(--accent-soft)); }
.tl-item { position: relative; margin-bottom: 18px; }
.tl-item::before {
  content: "";
  position: absolute;
  left: -20px; top: 7px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px var(--primary-soft);
}
.tl-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.tl-date { font-weight: 700; color: var(--primary-dark); }
.tl-meta { color: var(--muted); font-size: 13px; }
.tl-content { white-space: pre-wrap; word-break: break-word; margin: 6px 0; background: #fdfaf5; border-radius: var(--radius-sm); padding: 12px 14px; }
.tl-plan { background: var(--amber-soft); border-left: 4px solid var(--amber); padding: 9px 13px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: #8a5a06; margin-top: 8px; }
.tl-images { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* —— 图片 —— */
.img-thumb { position: relative; width: 96px; height: 96px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow); }
.img-thumb img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; transition: transform .2s; }
.img-thumb:hover img { transform: scale(1.06); }
.img-del {
  position: absolute;
  top: 4px; right: 4px;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(60, 40, 90, .6);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.img-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.preview-img { width: 80px; height: 80px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); }

/* —— 弹窗 —— */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(60, 40, 90, .4);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px;
  z-index: 200;
  overflow-y: auto;
  backdrop-filter: blur(2px);
}
.modal {
  background: #fff;
  border-radius: 22px;
  padding: 26px;
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow-lg);
  animation: pop .22s ease;
}
.modal-lg { max-width: 720px; }
.modal-sm { max-width: 400px; }
.modal h3 { margin: 0 0 16px; font-size: 18px; }
.modal label { margin-bottom: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* —— 提示 —— */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: #3a3245;
  color: #fff;
  padding: 11px 22px;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: all .25s;
  z-index: 300;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--red); }

/* —— 灯箱 —— */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(30, 20, 40, .9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
  cursor: zoom-out;
}
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 10px; }

/* —— 登录页 —— */
.login-wrap {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: url('/assets/bg.jpg') center / cover no-repeat;
  padding: 16px;
  overflow: hidden;
}
.login-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(253, 247, 239, .62), rgba(244, 238, 255, .72));
  z-index: 0;
}
.login-wrap > * { position: relative; z-index: 1; }
.login-card {
  position: relative;
  background: rgba(255, 255, 255, .93);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 26px;
  padding: 36px 36px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: pop .4s ease;
}
.login-logo { display: block; width: 100%; max-width: 250px; height: auto; margin: 0 auto 16px; }
.login-card .sub { color: var(--muted); margin-bottom: 24px; font-size: 13px; }
.login-card label { text-align: left; margin-bottom: 14px; }
.login-card .btn { width: 100%; margin-top: 8px; }
.login-err { color: var(--red); font-size: 13px; min-height: 20px; margin-top: 12px; text-align: center; }
.login-foot { margin-top: 16px; font-size: 12px; color: var(--muted); opacity: .85; }

.floaty {
  position: absolute;
  font-size: 34px;
  opacity: .5;
  pointer-events: none;
  animation: float 7s ease-in-out infinite;
}
.floaty.f1 { top: 12%; left: 10%; }
.floaty.f2 { top: 20%; right: 12%; animation-delay: 1.2s; font-size: 26px; }
.floaty.f3 { bottom: 18%; left: 14%; animation-delay: .6s; font-size: 42px; }
.floaty.f4 { bottom: 30%; right: 10%; animation-delay: 1.8s; }
.floaty.f5 { top: 8%; left: 46%; animation-delay: .9s; font-size: 28px; }
.floaty.f6 { bottom: 10%; left: 42%; animation-delay: 2.4s; font-size: 30px; }

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-16px) rotate(4deg); }
}
@keyframes pop {
  from { transform: scale(.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* —— 标签页 —— */
.tabs { display: flex; gap: 6px; border-bottom: 2px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tab { padding: 9px 18px; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -2px; border-radius: 8px 8px 0 0; transition: color .15s, background .15s; }
.tab:hover { color: var(--primary-dark); background: var(--primary-soft); }
.tab.active { color: var(--primary-dark); border-bottom-color: var(--primary); background: var(--primary-soft); }

/* —— 详情页基本信息 —— */
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.info-item { background: #fdfaf5; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 14px; }
.info-item .k { color: var(--muted); font-size: 12px; }
.info-item .v { font-weight: 600; }

/* —— 工具类 —— */
.muted { color: var(--muted); }
.mt0 { margin-top: 0; }
.mb0 { margin-bottom: 0; }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.right { margin-left: auto; }
.audit { font-size: 13px; }
.audit-row { font-family: ui-monospace, "SF Mono", Consolas, monospace; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.audit-row:last-child { border-bottom: none; }
.audit-row .t { color: var(--muted); }

@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .topbar { gap: 8px; padding: 0 12px; }
  .nav-link { padding: 6px 10px; }
  .uname { display: none; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}
