/* 801班同学网 - 全局样式 */
:root {
  --primary: #4f6ef7;
  --primary-light: #6b86f8;
  --primary-dark: #3a56d4;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #f5f6fa;
  --bg-card: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-light: #94a3b8;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --radius: 12px;
  --radius-sm: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

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

button {
  cursor: pointer;
  border: none;
  outline: none;
  font-size: 14px;
  font-family: inherit;
}

input, textarea, select {
  font-size: 14px;
  outline: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  width: 100%;
  transition: border-color 0.2s;
  font-family: inherit;
  background: #fff;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.1);
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  transition: all 0.2s;
  gap: 6px;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; border: 1px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-block { width: 100%; display: block; text-align: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== 卡片 ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

/* ===== 页面容器 ===== */
.page-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 24px;
  padding-top: 80px;
}

.page-title {
  font-size: 20px;
  margin-bottom: 16px;
  font-weight: 700;
}

/* ===== 表单 ===== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  font-size: 14px;
  color: var(--text-secondary);
}
.form-group .required::after {
  content: '*';
  color: var(--danger);
  margin-left: 2px;
}
label.required::after {
  content: '*';
  color: var(--danger);
  margin-left: 2px;
}

/* ===== 头像 ===== */
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 16px;
  flex-shrink: 0;
}
.avatar-sm { width: 32px; height: 32px; font-size: 13px; }
.avatar-lg { width: 64px; height: 64px; font-size: 24px; }

/* ===== 标签 ===== */
.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}
.tag-student { background: #dbeafe; color: #1d4ed8; }
.tag-teacher { background: #fef3c7; color: #d97706; }
.tag-admin { background: #dcfce7; color: #16a34a; }
.tag-member-student { background: #e0f2fe; color: #0369a1; }
.tag-member-teacher { background: #fef9c3; color: #a16207; }
.tag-member-admin { background: #ede9fe; color: #6d28d9; }

/* ===== 状态 ===== */
.loading { text-align: center; padding: 40px; color: var(--text-light); }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-light); }
.empty-state p { font-size: 16px; margin-top: 12px; }
.error-msg { color: var(--danger); font-size: 14px; margin-bottom: 8px; text-align: center; }

/* ===== Toasts ===== */
.toast {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 1000;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  animation: slideIn 0.3s ease;
  max-width: 360px;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== 导航 ===== */
.navbar {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 100;
  background: #fff;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.nav-logo { font-size: 18px; font-weight: 700; color: var(--primary); white-space: nowrap; }
.nav-links { display: flex; gap: 8px; flex: 1; }
.nav-link {
  padding: 6px 14px;
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  position: relative;
  text-decoration: none;
}
.nav-link:hover, .nav-link.active { background: #eef1ff; color: var(--primary); text-decoration: none; }
.badge {
  position: absolute; top: -4px; right: -6px;
  background: var(--danger); color: #fff;
  font-size: 11px; padding: 1px 5px;
  border-radius: 10px; min-width: 18px; text-align: center;
}
.awd-unit { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; vertical-align: middle; }
.awd-amount { font-weight: 800; }
.awd-text { font-weight: 800; color: var(--primary); letter-spacing: 0; }
.nav-user { display: flex; align-items: center; gap: 12px; }
.nav-name { font-size: 14px; color: var(--text); font-weight: 500; }

/* ===== 动态卡片 ===== */
.moment-card { margin-bottom: 16px; cursor: pointer; transition: transform 0.15s; }
.moment-card:hover { transform: translateY(-1px); }
.moment-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.moment-user { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.moment-name { font-weight: 600; font-size: 15px; }
.moment-role { align-self: flex-start; }
.moment-time { font-size: 12px; color: var(--text-light); white-space: nowrap; }
.moment-content { font-size: 15px; line-height: 1.7; margin-bottom: 12px; white-space: pre-wrap; word-break: break-word; }
.moment-images { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-bottom: 12px; }
.moment-images img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; cursor: pointer; }
.moment-images.single { grid-template-columns: 1fr; }
.moment-images.single img { aspect-ratio: auto; max-height: 400px; object-fit: contain; background: #f8f9fc; }
.moment-actions { display: flex; gap: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.action-btn {
  background: none; border: none;
  font-size: 14px; color: var(--text-secondary);
  padding: 4px 8px; border-radius: 6px;
  transition: all 0.2s; cursor: pointer;
}
.action-btn:hover { background: #f1f3f5; }
.action-btn.liked { color: #ef4444; }

/* ===== 成员卡片 ===== */
.member-card { display: flex; align-items: center; gap: 14px; cursor: pointer; transition: transform 0.15s; }
.member-card:hover { transform: translateY(-1px); }
.member-info { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.member-name { font-weight: 600; font-size: 15px; }
.member-role { align-self: flex-start; }
.member-meta { font-size: 13px; color: var(--text-light); }

/* ===== 聊天 ===== */
.chat-page { display: flex; flex-direction: column; height: 100vh; }
.chat-header {
  position: fixed; top: 56px; left: 0; right: 0;
  z-index: 50; background: #fff;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  max-width: 1100px; margin: 0 auto; width: 100%;
}
.back-btn { background: none; border: none; font-size: 16px; color: var(--primary); padding: 4px 8px; cursor: pointer; }
.chat-name { font-weight: 600; font-size: 16px; }
.messages {
  flex: 1; overflow-y: auto; padding: 16px 24px;
  display: flex; flex-direction: column; gap: 12px;
  max-width: 1100px; width: 100%; margin: 0 auto;
  margin-top: 100px; margin-bottom: 70px;
}
.msg-row { display: flex; flex-direction: column; max-width: 70%; }
.msg-row.mine { align-self: flex-end; align-items: flex-end; }
.msg-bubble {
  padding: 10px 16px; border-radius: 18px; 
  font-size: 15px; line-height: 1.5; word-break: break-word;
  background: #f1f3f5; color: var(--text);
}
.msg-row.mine .msg-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.msg-row:not(.mine) .msg-bubble { border-bottom-left-radius: 4px; }
.msg-time { font-size: 11px; color: var(--text-light); margin-top: 4px; padding: 0 8px; }
.chat-input {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: #fff; padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px;
  max-width: 1100px; margin: 0 auto; width: 100%;
  padding: 12px 24px;
}
.chat-input input { flex: 1; }

/* ===== 会话列表 ===== */
.conversation-list { display: flex; flex-direction: column; gap: 10px; }
.conversation-item { display: flex; align-items: center; gap: 14px; cursor: pointer; transition: transform 0.15s; }
.conversation-item:hover { transform: translateY(-1px); }
.conv-info { flex: 1; display: flex; flex-direction: column; gap: 4px; overflow: hidden; }
.conv-top { display: flex; justify-content: space-between; align-items: center; }
.conv-name { font-weight: 600; font-size: 15px; }
.conv-time { font-size: 12px; color: var(--text-light); white-space: nowrap; }
.conv-bottom { display: flex; justify-content: space-between; align-items: center; }
.conv-last { font-size: 13px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== 个人资料 ===== */
.profile { display: flex; flex-direction: column; gap: 16px; }
.profile-header { text-align: center; padding: 32px 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.profile-header h2 { font-size: 22px; }
.info-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.info-row:last-child { border-bottom: none; }
.info-row span:first-child { color: var(--text-secondary); }

/* ===== 动态详情 ===== */
.detail { display: flex; flex-direction: column; gap: 12px; }
.detail-header { display: flex; justify-content: space-between; align-items: center; }
.user-row { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.comments { margin-top: 12px; }
.comments h3 { font-size: 16px; margin-bottom: 12px; }
.comment-item { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; line-height: 1.5; }
.comment-item strong { cursor: pointer; color: var(--primary); }
.comment-time { font-size: 12px; color: var(--text-light); margin-left: 8px; }
.comment-input { display: flex; gap: 8px; margin-top: 12px; }
.comment-input input { flex: 1; }

/* ===== 搜索 ===== */
.search-box { margin-bottom: 16px; }

/* ===== 发布框 ===== */
.post-box { margin-bottom: 20px; }
.post-box textarea { resize: vertical; min-height: 60px; border: none; background: #f8f9fc; padding: 14px; font-size: 15px; border-radius: var(--radius-sm); }
.post-box textarea:focus { background: #fff; }
.post-actions { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.upload-btn { font-size: 14px; color: var(--text-secondary); cursor: pointer; padding: 6px 12px; border-radius: 6px; transition: background 0.2s; }
.upload-btn:hover { background: #f1f3f5; }

/* ===== 管理后台 ===== */
.admin-layout { display: flex; min-height: 100vh; padding-top: 56px; }
.admin-sidebar {
  width: 220px;
  background: #1e293b;
  padding: 0;
  position: fixed;
  top: 56px;
  left: 0;
  bottom: 0;
  overflow: hidden;
}
.admin-sidebar-scroll {
  height: 100%;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.admin-sidebar-scroll::-webkit-scrollbar { width: 6px; }
.admin-sidebar-scroll::-webkit-scrollbar-thumb { background: #475569; border-radius: 999px; }
.admin-sidebar-scroll::-webkit-scrollbar-track { background: transparent; }
.sidebar-title { color: #fff; font-size: 18px; margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px solid #334155; }
.sidebar-link {
  padding: 10px 14px; border-radius: 8px;
  color: #94a3b8; font-size: 14px; transition: all 0.2s; text-decoration: none;
}
.sidebar-link:hover, .sidebar-link.active { background: #334155; color: #fff; text-decoration: none; }
.sidebar-link.back-link { margin-top: auto; }

.admin-main { flex: 1; margin-left: 220px; padding: 24px; background: var(--bg); min-height: 100vh; }

/* ===== 管理表格 ===== */
.table-wrap { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: #f8f9fc; font-weight: 600; color: var(--text-secondary); font-size: 13px; }
.content-cell { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-on { color: var(--success); font-weight: 500; }
.status-off { color: var(--danger); font-weight: 500; }
.small-select { padding: 4px 8px; font-size: 13px; width: auto; border-radius: 4px; border: 1px solid var(--border); }

/* ===== 统计卡片 ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat-card { text-align: center; padding: 28px 20px; }
.stat-number { font-size: 36px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 14px; color: var(--text-secondary); margin-top: 4px; }
.admin-page-title { font-size: 22px; margin-bottom: 24px; font-weight: 700; }

/* ===== 登录/注册 ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.auth-card { width: 100%; max-width: 420px; padding: 40px 32px; }
.auth-title { text-align: center; margin-bottom: 32px; font-size: 22px; color: var(--text); }
.auth-footer { text-align: center; margin-top: 20px; color: var(--text-secondary); font-size: 14px; }

/* ===== 图片预览 ===== */
.preview-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.9);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; cursor: pointer;
}
.preview-overlay img { max-width: 90%; max-height: 90%; object-fit: contain; }

/* ===== 汉堡菜单按钮 ===== */
.hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  padding: 4px 8px;
  color: var(--text);
  cursor: pointer;
  line-height: 1;
}
.sidebar-close {
  display: none;
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
}

/* ===== 侧边栏遮罩 ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 94;
}

.mobile-nav {
  display: none;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  /* 导航栏 */
  .hamburger { display: block; flex-shrink: 0; }
  .sidebar-close { display: block; }
  .nav-links { display: none; }
  .nav-logo { flex: 1; }
  .nav-inner { gap: 12px; padding: 0 16px; }
  .nav-name { display: none; }

  .mobile-nav {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 56px;
    left: -280px;
    bottom: 0;
    width: 260px;
    background: #fff;
    z-index: 95;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.08);
    padding: 16px 12px;
    gap: 6px;
    transition: left 0.25s ease;
    overflow-y: auto;
  }
  .mobile-nav.open { left: 0; }
  .mobile-nav-link {
    display: block;
    padding: 12px 14px;
    border-radius: 10px;
    color: var(--text);
    font-size: 15px;
    text-decoration: none;
    background: #f8f9fc;
  }
  .mobile-nav-link:hover { background: #eef1ff; text-decoration: none; }
  .mobile-logout {
    width: 100%;
    text-align: left;
    border: none;
  }

  /* 侧边栏移动端：滑入式 */
  .admin-layout { padding-top: 56px; }
  .admin-sidebar {
    position: fixed;
    top: 56px;
    left: -280px;
    bottom: 0;
    width: 260px;
    z-index: 95;
    transition: left 0.25s ease;
    overflow: hidden;
  }
  .admin-sidebar-scroll {
    padding: 16px 12px;
  }
  .admin-sidebar.open { left: 0; }
  .sidebar-overlay.show { display: block; }

  .admin-main { margin-left: 0; padding: 16px; }

  /* 表格横向滚动 */
  .table-wrap { -webkit-overflow-scrolling: touch; }

  /* 统计卡片 */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-number { font-size: 28px; }
}

@media (max-width: 480px) {
  .admin-sidebar { width: 240px; left: -260px; }
  .admin-main { padding: 12px; }
  .admin-page-title { font-size: 18px; margin-bottom: 16px; }
  .page-container { padding: 12px 16px; padding-top: 64px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 16px 12px; }
  .stat-number { font-size: 24px; }
  th, td { padding: 8px 10px; font-size: 12px; }
}
