/* ============================================
   远翔贴吧 — 校园纪事 · Campus Chronicle
   温暖学术编辑风格
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700&family=Noto+Serif+SC:wght@400;600;700;900&display=swap');

/* ---- CSS 变量 ---- */
:root {
  --navy: #1a1a2e;
  --navy-light: #252542;
  --amber: #c8843c;
  --amber-light: #e8a850;
  --amber-bg: rgba(200, 132, 60, 0.08);
  --cream: #faf7f2;
  --cream-dark: #f0ebe0;
  --white: #ffffff;
  --charcoal: #2d2d2d;
  --gray: #8a8a8a;
  --gray-light: #b0a89a;
  --border: #e8e4df;
  --danger: #c0392b;
  --danger-bg: #fdf0ee;
  --success: #2d6a4f;
  --success-bg: #edf7f2;
  --shadow-sm: 0 1px 3px rgba(26, 26, 46, 0.06);
  --shadow-md: 0 4px 16px rgba(26, 26, 46, 0.08);
  --shadow-lg: 0 12px 40px rgba(26, 26, 46, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --font-display: 'Noto Serif SC', 'SimSun', 'STSong', serif;
  --font-body: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- 全局重置 ---- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  color: var(--charcoal);
  background: var(--cream);
  line-height: 1.7;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---- 银杏叶背景动画 ---- */
.ginkgo-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.ginkgo-leaf {
  position: absolute;
  top: -60px;
  opacity: 0.12;
  animation: ginkgoFall linear infinite;
  font-size: 28px;
  color: var(--amber);
}

.ginkgo-leaf:nth-child(1)  { left: 5%;  animation-duration: 14s; animation-delay: 0s;   font-size: 22px; }
.ginkgo-leaf:nth-child(2)  { left: 15%; animation-duration: 18s; animation-delay: 2s;   font-size: 30px; }
.ginkgo-leaf:nth-child(3)  { left: 25%; animation-duration: 12s; animation-delay: 5s;   font-size: 18px; }
.ginkgo-leaf:nth-child(4)  { left: 38%; animation-duration: 20s; animation-delay: 1s;   font-size: 26px; }
.ginkgo-leaf:nth-child(5)  { left: 50%; animation-duration: 16s; animation-delay: 7s;   font-size: 34px; }
.ginkgo-leaf:nth-child(6)  { left: 62%; animation-duration: 22s; animation-delay: 3s;   font-size: 20px; }
.ginkgo-leaf:nth-child(7)  { left: 75%; animation-duration: 15s; animation-delay: 9s;   font-size: 28px; }
.ginkgo-leaf:nth-child(8)  { left: 85%; animation-duration: 19s; animation-delay: 4s;   font-size: 24px; }
.ginkgo-leaf:nth-child(9)  { left: 92%; animation-duration: 13s; animation-delay: 6s;   font-size: 16px; }
.ginkgo-leaf:nth-child(10) { left: 10%; animation-duration: 17s; animation-delay: 11s;  font-size: 32px; }

@keyframes ginkgoFall {
  0%   { transform: translateY(-10vh) rotate(0deg)   translateX(0);    opacity: 0; }
  5%   { opacity: 0.12; }
  90%  { opacity: 0.12; }
  100% { transform: translateY(105vh) rotate(720deg) translateX(80px); opacity: 0; }
}

/* ---- 导航栏 ---- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--navy);
  border-bottom: 2px solid rgba(200, 132, 60, 0.3);
  backdrop-filter: blur(10px);
}

.nav-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--white);
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  transition: var(--transition);
}

.nav-brand:hover { color: var(--amber-light); }

.nav-brand-icon {
  width: 36px;
  height: 36px;
  background: var(--amber);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--navy);
  font-weight: 900;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
}

.nav-links a, .nav-links button {
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
}

.nav-links a:hover, .nav-links button:hover {
  color: var(--white);
  background: rgba(255,255,255,0.08);
}

.nav-links a.active {
  color: var(--amber-light);
  background: rgba(200, 132, 60, 0.15);
}

.nav-user {
  color: var(--amber-light);
  font-weight: 500;
  padding: 8px 12px;
  font-size: 0.9rem;
}

.nav-badge {
  display: inline-block;
  background: var(--danger);
  color: white;
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 4px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ---- 主内容区 ---- */
.main-container {
  position: relative;
  z-index: 1;
  max-width: 800px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

/* ---- 页面标题 ---- */
.page-header {
  margin-bottom: 32px;
  text-align: center;
}

.page-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 900;
  color: var(--navy);
  letter-spacing: 0.03em;
  margin-bottom: 8px;
}

.page-subtitle {
  font-size: 0.95rem;
  color: var(--gray);
  font-weight: 400;
}

/* ---- 搜索栏 ---- */
.search-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 28px;
}

.search-input {
  flex: 1;
  padding: 12px 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: var(--font-body);
  background: var(--white);
  color: var(--charcoal);
  transition: var(--transition);
  outline: none;
}

.search-input:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-bg);
}

.search-input::placeholder {
  color: var(--gray-light);
}

/* ---- 按钮 ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--navy);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--navy-light);
  box-shadow: var(--shadow-md);
}

.btn-amber {
  background: var(--amber);
  color: var(--white);
}

.btn-amber:hover {
  background: var(--amber-light);
  box-shadow: var(--shadow-md);
}

.btn-outline {
  background: transparent;
  color: var(--navy);
  border: 2px solid var(--navy);
}

.btn-outline:hover {
  background: var(--navy);
  color: var(--white);
}

.btn-danger {
  background: var(--danger);
  color: var(--white);
}

.btn-danger:hover {
  background: #a93226;
  box-shadow: var(--shadow-md);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

.btn-xs {
  padding: 4px 10px;
  font-size: 0.75rem;
  border-radius: 6px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ---- 帖子卡片 ---- */
.post-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  animation: cardReveal 0.5s ease both;
}

.post-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(139, 119, 90, 0.015) 2px,
      rgba(139, 119, 90, 0.015) 4px
    );
  pointer-events: none;
  border-radius: var(--radius);
}

.post-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--amber);
}

.post-card.pinned {
  border-left: 4px solid var(--amber);
  background: linear-gradient(135deg, var(--white) 0%, var(--amber-bg) 100%);
}

.post-card-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 10px;
  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.pin-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.7rem;
  background: var(--amber);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  font-family: var(--font-body);
}

.post-card-excerpt {
  font-size: 0.9rem;
  color: #555;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 14px;
}

.post-card-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.8rem;
  color: var(--gray);
}

.post-card-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.post-card-author {
  font-weight: 600;
  color: var(--navy);
}

@keyframes cardReveal {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 交替延迟 */
.post-card:nth-child(1)  { animation-delay: 0.05s; }
.post-card:nth-child(2)  { animation-delay: 0.1s;  }
.post-card:nth-child(3)  { animation-delay: 0.15s; }
.post-card:nth-child(4)  { animation-delay: 0.2s;  }
.post-card:nth-child(5)  { animation-delay: 0.25s; }
.post-card:nth-child(6)  { animation-delay: 0.3s;  }
.post-card:nth-child(7)  { animation-delay: 0.35s; }
.post-card:nth-child(8)  { animation-delay: 0.4s;  }
.post-card:nth-child(9)  { animation-delay: 0.45s; }
.post-card:nth-child(10) { animation-delay: 0.5s;  }
.post-card:nth-child(n+11) { animation-delay: 0.55s; }

/* ---- 帖子详情 ---- */
.post-detail {
  background: var(--white);
  border-radius: var(--radius);
  padding: 32px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  position: relative;
}

.post-detail-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--navy);
  margin-bottom: 16px;
  line-height: 1.4;
}

.post-detail-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--gray);
  flex-wrap: wrap;
}

.post-detail-content {
  font-size: 1rem;
  line-height: 1.9;
  color: var(--charcoal);
  white-space: pre-wrap;
  word-break: break-word;
}

.post-detail-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ---- 评论区 ---- */
.comments-section {
  margin-top: 8px;
}

.comments-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--amber);
}

.comment-item {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 18px 20px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  transition: var(--transition);
}

.comment-item:hover {
  border-color: #d0cbc4;
  box-shadow: var(--shadow-sm);
}

.comment-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.comment-author {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--navy);
}

.comment-time {
  font-size: 0.75rem;
  color: var(--gray);
}

.comment-content {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--charcoal);
  white-space: pre-wrap;
  word-break: break-word;
}

.comment-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray);
  font-size: 0.95rem;
}

.comment-form {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
  margin-top: 20px;
}

.comment-form textarea {
  width: 100%;
  min-height: 80px;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.9rem;
  resize: vertical;
  outline: none;
  transition: var(--transition);
  background: var(--cream);
}

.comment-form textarea:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-bg);
  background: var(--white);
}

.comment-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

/* ---- 登录页 ---- */
.login-container {
  max-width: 420px;
  margin: 80px auto;
  padding: 0 24px;
}

.login-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 40px 36px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-logo {
  width: 64px;
  height: 64px;
  background: var(--navy);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--amber-light);
}

.login-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--navy);
  margin-bottom: 6px;
}

.login-subtitle {
  font-size: 0.9rem;
  color: var(--gray);
  margin-bottom: 28px;
}

.form-group {
  margin-bottom: 18px;
  text-align: left;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--charcoal);
  outline: none;
  transition: var(--transition);
}

.form-input:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-bg);
  background: var(--white);
}

.form-error {
  color: var(--danger);
  font-size: 0.8rem;
  margin-top: 4px;
  min-height: 20px;
}

.login-btn {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  margin-top: 8px;
}

/* ---- 发帖弹窗 ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 46, 0.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--white);
  border-radius: var(--radius);
  padding: 32px;
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalSlideIn 0.3s ease;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 20px;
}

.modal textarea {
  width: 100%;
  min-height: 140px;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.9rem;
  resize: vertical;
  outline: none;
  transition: var(--transition);
  background: var(--cream);
}

.modal textarea:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-bg);
  background: var(--white);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(30px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---- 分页 ---- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 28px;
  flex-wrap: wrap;
}

.pagination button {
  min-width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--navy);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-body);
}

.pagination button:hover:not(:disabled) {
  border-color: var(--amber);
  color: var(--amber);
}

.pagination button.active {
  background: var(--navy);
  color: var(--white);
  border-color: var(--navy);
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination-info {
  font-size: 0.8rem;
  color: var(--gray);
  margin-left: 12px;
}

/* ---- 管理面板 ---- */
.admin-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  background: var(--white);
  border-radius: var(--radius);
  padding: 4px;
  border: 1px solid var(--border);
}

.admin-tab {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--gray);
  transition: var(--transition);
  font-family: var(--font-body);
}

.admin-tab.active {
  background: var(--navy);
  color: var(--white);
}

.admin-tab:hover:not(.active) {
  color: var(--navy);
  background: rgba(26, 26, 46, 0.04);
}

.admin-table {
  width: 100%;
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.admin-table th,
.admin-table td {
  padding: 14px 16px;
  text-align: left;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border);
}

.admin-table th {
  background: var(--navy);
  color: var(--white);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table tr:hover td {
  background: var(--amber-bg);
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-banned {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-active {
  background: var(--success-bg);
  color: var(--success);
}

.badge-admin {
  background: var(--amber-bg);
  color: var(--amber);
}

.badge-deleted {
  background: rgba(142, 142, 147, 0.12);
  color: #8e8e93;
  text-decoration: line-through;
}

/* ---- Toast 提示 ---- */
.toast-container {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: white;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  max-width: 360px;
}

.toast-success { background: var(--success); }
.toast-error   { background: var(--danger); }
.toast-info    { background: var(--navy); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(40px); }
}

/* ---- 空状态 ---- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state-text {
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 4px;
}

.empty-state-sub {
  font-size: 0.85rem;
  color: var(--gray-light);
}

/* ---- 加载动画 ---- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---- 响应式 ---- */
@media (max-width: 640px) {
  .nav-inner {
    padding: 0 16px;
  }

  .nav-brand {
    font-size: 1.1rem;
  }

  .nav-links a, .nav-links button {
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  .main-container {
    padding: 20px 16px 60px;
  }

  .page-title {
    font-size: 1.5rem;
  }

  .post-card {
    padding: 18px;
  }

  .post-detail {
    padding: 20px;
  }

  .post-detail-title {
    font-size: 1.3rem;
  }

  .login-card {
    padding: 28px 24px;
  }

  .modal {
    padding: 24px;
    width: 95%;
  }

  .admin-table {
    font-size: 0.8rem;
  }

  .admin-table th,
  .admin-table td {
    padding: 10px 8px;
  }
}

/* ---- 自定义滚动条 ---- */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--cream);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gray-light);
}