/* === 飞牛怎么玩 公共样式 === */

:root {
  --fn-blue: #0d6efd;
  --fn-dark: #0a58ca;
  --fn-bg: #f8f9fa;
  --sidebar-width: 260px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.8;
}

/* 导航栏 */
.navbar-main {
  background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%) !important;
}

.navbar-main .navbar-brand {
  font-weight: 700;
  font-size: 1.4rem;
}

/* Hero */
.hero-section {
  background: linear-gradient(135deg, #0d6efd 0%, #6610f2 100%);
  color: white;
  padding: 4rem 0;
  margin-bottom: 2rem;
}

.hero-section h1 { font-weight: 700; font-size: 2.5rem; }
.hero-section .lead { opacity: 0.9; }

/* 搜索框 */
.search-box { max-width: 500px; margin: 0 auto; }
.search-box .form-control {
  border-radius: 50px 0 0 50px;
  border: none;
  padding: 0.75rem 1.5rem;
}
.search-box .btn {
  border-radius: 0 50px 50px 0;
  padding: 0.75rem 1.5rem;
}

/* 分类卡片 */
.category-card {
  border: none;
  border-radius: 12px;
  transition: all 0.3s ease;
  cursor: pointer;
  background: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.category-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(13,110,253,0.15);
}
.category-card .icon-wrapper {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, #0d6efd, #6610f2);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 1.5rem; margin-bottom: 1rem;
}

/* 文章卡片 */
.post-card {
  border: none;
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  height: 100%;
}
.post-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(13,110,253,0.12);
}
.post-card .card-img-top {
  height: 180px;
  object-fit: cover;
}
.post-card .badge {
  font-weight: 500;
  padding: 0.4em 0.8em;
}

/* 文章正文 */
.post-content { max-width: 800px; margin: 0 auto; }
.post-content h1, .post-content h2, .post-content h3 {
  margin-top: 2rem; margin-bottom: 1rem; font-weight: 700;
}
.post-content h1 { font-size: 2rem; border-bottom: 2px solid var(--fn-blue); padding-bottom: 0.5rem; }
.post-content h2 { font-size: 1.5rem; border-left: 4px solid var(--fn-blue); padding-left: 1rem; }
.post-content pre {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 1rem;
  position: relative;
}
.post-content code {
  font-family: "SF Mono", Monaco, "Cascadia Code", monospace;
  font-size: 0.9em;
}
.post-content img { max-width: 100%; border-radius: 8px; margin: 1rem 0; }
.post-content blockquote {
  border-left: 4px solid var(--fn-blue);
  padding-left: 1rem;
  color: #666;
  background: #f8f9fa;
  padding: 1rem 1rem 1rem 1.5rem;
  border-radius: 0 8px 8px 0;
}

/* 目录 - sticky 但限高，避免与下方卡片重叠 */
.toc-sidebar {
  position: sticky;
  top: 80px;
  align-self: flex-start;        /* 关键修复：防止 flex stretch */
  max-height: calc(100vh - 100px);
  overflow: hidden;
}
.toc-sidebar .card-header { flex-shrink: 0; }
.toc-sidebar .list-group {
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}
.toc-sidebar .list-group-item {
  border: none;
  padding: 0.4rem 0.8rem;
  font-size: 0.9rem;
}
.toc-sidebar .list-group-item.active { background: var(--fn-blue); }

/* 评论 */
.comment-box { background: #f8f9fa; border-radius: 12px; padding: 1.5rem; }
.comment-item { border-bottom: 1px solid #eee; padding: 1rem 0; }
.comment-item:last-child { border-bottom: none; }
.comment-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--fn-blue);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: bold;
  flex-shrink: 0;
}

/* 页脚 */
.site-footer {
  background: #1a1a2e;
  color: rgba(255,255,255,0.7);
  padding: 3rem 0 2rem;
  margin-top: 4rem;
}

/* 暗黑模式切换 */
.theme-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1050;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--fn-blue);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(13,110,253,0.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
}
.theme-toggle:hover { background: var(--fn-dark); }

/* 后台侧边栏 */
.admin-sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  left: 0; top: 0;
  background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
  color: rgba(255,255,255,0.8);
  overflow-y: auto;
  z-index: 1000;
}
.admin-sidebar .brand {
  padding: 1.5rem;
  font-size: 1.3rem;
  font-weight: 700;
  color: white;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.admin-sidebar .nav-link {
  color: rgba(255,255,255,0.7);
  padding: 0.9rem 1.5rem;
  border-radius: 0;
  transition: all 0.2s;
  display: flex;
  align-items: center;
}
.admin-sidebar .nav-link:hover, .admin-sidebar .nav-link.active {
  background: rgba(13,110,253,0.2);
  color: white;
  border-right: 3px solid var(--fn-blue);
}
.admin-sidebar .nav-link i { width: 24px; margin-right: 10px; font-size: 1.1rem; }

.admin-main {
  margin-left: var(--sidebar-width);
  padding: 2rem;
  background: #f8f9fa;
  min-height: 100vh;
}

.stat-card { border: none; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.stat-card .icon-box {
  width: 56px; height: 56px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; color: white;
}
.table-card { border: none; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.table-card .card-header { background: white; border-bottom: 1px solid #eee; padding: 1rem 1.5rem; }
.avatar-sm {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--fn-blue); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem;
}
.badge-draft { background: #6c757d; }
.badge-published { background: #198754; }

/* 暗黑模式适配 */
[data-bs-theme="dark"] .post-card,
[data-bs-theme="dark"] .category-card { background: #212529; }
[data-bs-theme="dark"] .hero-section { background: linear-gradient(135deg, #0a58ca 0%, #520dc2 100%); }
[data-bs-theme="dark"] .post-content pre { background: #212529; }
[data-bs-theme="dark"] .post-content blockquote { background: #212529; }
[data-bs-theme="dark"] .comment-box { background: #212529; }
[data-bs-theme="dark"] .admin-main { background: #212529; }
[data-bs-theme="dark"] .stat-card,
[data-bs-theme="dark"] .table-card { background: #2d333b; }
[data-bs-theme="dark"] .table-card .card-header { background: #2d333b; border-color: #444; }
[data-bs-theme="dark"] .table { color: #e6edf3; }
[data-bs-theme="dark"] .site-footer { background: #0d1117; }
[data-bs-theme="dark"] .card-header { background: #2d333b; color: #e6edf3; border-color: #444; }
[data-bs-theme="dark"] .list-group-item { background: transparent; color: #e6edf3; border-color: #444; }
