/* 基础样式重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: #000;
  color: #e7e9ea;
  line-height: 1.6;
}

/* 容器布局 */
.container {
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  max-width: 1200px;
  margin: 0 auto;
  min-height: 100vh;
  gap: 20px;
  padding: 0 20px;
}

/* 侧边栏样式 */
.sidebar {
  position: sticky;
  top: 20px;
  height: fit-content;
  background: #16181c;
  border-radius: 16px;
  padding: 24px;
  border: 1px solid #2f3336;
}

.profile {
  text-align: center;
  margin-bottom: 32px;
}

.avatar {
  font-size: clamp(3rem, 5vw, 4rem);
  color: #1d9bf0;
  margin-bottom: 16px;
}

.profile h2 {
  font-size: clamp(1.25rem, 2vw, 1.5rem);
  font-weight: 800;
  margin-bottom: 8px;
}

.bio {
  color: #71767b;
  font-size: 0.9375rem;
  margin-bottom: 16px;
}

.stats {
  display: flex;
  justify-content: space-around;
  padding: 16px 0;
  border-top: 1px solid #2f3336;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat .number {
  font-size: 1.25rem;
  font-weight: 700;
}

.stat .label {
  font-size: 0.8125rem;
  color: #71767b;
}

/* 导航菜单 */
.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-radius: 24px;
  text-decoration: none;
  color: #e7e9ea;
  font-size: 1.25rem;
  font-weight: 400;
  transition: background-color 0.2s;
}

.nav-item:hover {
  background-color: #1a1a1a;
}

.nav-item.active {
  background-color: #1d9bf0;
  font-weight: 700;
}

.nav-item i {
  margin-right: 16px;
  width: 24px;
}

/* 主内容区 */
.main-content {
  background: #000;
  border-left: 1px solid #2f3336;
  border-right: 1px solid #2f3336;
  min-height: 100vh;
}

.header {
  position: sticky;
  top: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(12px);
  padding: 16px 20px;
  border-bottom: 1px solid #2f3336;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}

.header h1 {
  font-size: clamp(1.125rem, 1.5vw, 1.25rem);
  font-weight: 800;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.data-source {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(29, 155, 240, 0.1);
  border: 1px solid rgba(29, 155, 240, 0.3);
  border-radius: 16px;
  font-size: 0.8125rem;
  color: #1d9bf0;
  cursor: help;
}

.data-source i {
  font-size: 0.75rem;
}

.data-source.database {
  background: rgba(0, 186, 124, 0.1);
  border-color: rgba(0, 186, 124, 0.3);
  color: #00ba7c;
}

.data-source.json {
  background: rgba(249, 24, 128, 0.1);
  border-color: rgba(249, 24, 128, 0.3);
  color: #f91880;
}

.compose-btn {
  background: #1d9bf0;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.2s;
}

.compose-btn:hover {
  background: #1a8cd8;
}

/* 文章卡片样式 */
.post {
  border-bottom: 1px solid #2f3336;
  padding: 16px 20px;
  transition: background-color 0.2s;
}

.post:hover {
  background-color: rgba(255, 255, 255, 0.03);
}

.post-header {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

.post-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #1d9bf0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  color: white;
  font-weight: 700;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.post-author {
  font-weight: 700;
  color: #e7e9ea;
}

.post-time {
  color: #71767b;
  font-size: 0.9375rem;
}

.post-type {
  background: #1d9bf0;
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.post-type.long {
  background: #f91880;
}

.post-type.project {
  background: #00ba7c;
}

.post-source {
  color: #71767b;
  font-size: 0.8125rem;
  opacity: 0.8;
}

.post-content {
  margin-bottom: 12px;
}

.post-title {
  font-size: clamp(1rem, 1.5vw, 1.125rem);
  font-weight: 700;
  margin-bottom: 8px;
  color: #e7e9ea;
}

.post-text {
  font-size: 0.9375rem;
  line-height: 1.5;
  color: #e7e9ea;
}

.post-code {
    background: #16181c;
    border: 1px solid #2f3336;
    border-radius: 8px;
    padding: 16px;
    margin: 12px 0;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    
    /* --- 新增/修改的属性 --- */
    white-space: pre-wrap;      /* 关键：保留空白符序列，但是正常地进行换行 */
    overflow-wrap: break-word;  /* 关键：允许在单词内换行，防止超长字符串撑开布局 */
    word-break: break-all;      /* 备用/增强：更强的断词规则，确保任何情况都换行 */
    overflow-x: auto;           /* 保留：作为备用，处理一些极端情况 */
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.post-tag {
  color: #1d9bf0;
  font-size: 0.875rem;
  text-decoration: none;
}

.post-tag:hover {
  text-decoration: underline;
}

.post-actions {
  display: flex;
  justify-content: space-between;
  max-width: 400px;
  color: #71767b;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: #71767b;
  cursor: pointer;
  padding: 8px;
  border-radius: 20px;
  transition: all 0.2s;
}

.action-btn:hover {
  background: rgba(29, 155, 240, 0.1);
  color: #1d9bf0;
}

.action-btn i,
.action-btn span {
  transition: transform 0.2s ease, color 0.2s ease;
}

/* 右侧栏 */
.right-sidebar {
  position: sticky;
  top: 20px;
  height: fit-content;
}

.widget {
  background: #16181c;
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid #2f3336;
}

.widget h3 {
  font-size: clamp(1.125rem, 1.5vw, 1.25rem);
  font-weight: 800;
  margin-bottom: 16px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  background: rgba(29, 155, 240, 0.1);
  color: #1d9bf0;
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 0.875rem;
  text-decoration: none;
  transition: background-color 0.2s;
}

.tag:hover {
  background: rgba(29, 155, 240, 0.2);
}

.projects {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.project-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  transition: background-color 0.2s;
}

.project-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.project-item i {
  font-size: 1.25rem;
  color: #71767b;
}

/* 响应式设计 */
/* 中等屏幕 - 两栏布局（保留左侧边栏，隐藏右侧边栏） */
@media (max-width: 1200px) {
  .container {
    grid-template-columns: 280px 1fr;
    gap: 20px;
  }

  .right-sidebar {
    display: none;
  }
}

/* 小屏幕 - 单栏布局（隐藏所有侧边栏） */
@media (max-width: 1024px) {
  .container {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 0;
  }

  .sidebar,
  .right-sidebar {
    display: none;
  }

  .main-content {
    border: none;
  }
}

@media (max-width: 768px) {
  .header {
    padding: 12px 16px;
  }

  .post {
    padding: 12px 16px;
  }

  .post-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .post-meta {
    flex-wrap: wrap;
  }

  .compose-btn {
    padding: 6px 12px;
    font-size: 0.875rem;
  }
}

/* 加载动画 */
.loading {
  display: flex;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #2f3336;
  border-top: 3px solid #1d9bf0;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* 网站底部样式 */
.footer {
  background: #16181c;
  border-top: 1px solid #2f3336;
  margin-top: 40px;
  padding: 20px 0;
  width: 100%;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.footer-info {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  color: #71767b;
  font-size: 0.875rem;
}

.copyright {
  color: #71767b;
  white-space: nowrap;
}

.separator {
  color: #2f3336;
  font-weight: 300;
}

.beian-link {
  color: #71767b;
  text-decoration: none;
  transition: color 0.2s ease;
  white-space: nowrap;
}

.beian-link:hover {
  color: #1d9bf0;
  text-decoration: underline;
}

/* Footer响应式设计 */
@media (max-width: 768px) {
  .footer {
    margin-top: 20px;
    padding: 16px 0;
  }

  .footer-content {
    padding: 0 16px;
  }

  .footer-info {
    font-size: 0.8125rem;
    gap: 6px;
    flex-direction: column;
  }

  .separator {
    display: none;
  }
}

@media (max-width: 480px) {
  .footer {
    padding: 12px 0;
  }

  .footer-content {
    padding: 0 12px;
  }

  .footer-info {
    font-size: 0.75rem;
  }
}

/* 无限滚动 - 加载指示器 */
.loading-indicator {
  padding: 40px 20px;
  text-align: center;
  border-bottom: 1px solid #2f3336;
}

.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: #71767b;
}

.loading-spinner i {
  font-size: 2rem;
  color: #1d9bf0;
}

.loading-spinner span {
  font-size: 0.875rem;
}

/* 无限滚动 - 没有更多数据提示 */
.no-more-message {
  padding: 40px 20px;
  text-align: center;
  border-bottom: 1px solid #2f3336;
}

.no-more-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: #71767b;
}

.no-more-content i {
  font-size: 2rem;
  color: #00ba7c;
}

.no-more-content span {
  font-size: 0.875rem;
}

/* 滚动动画 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.post {
  animation: fadeIn 0.3s ease-out;
}

/* 加载指示器动画 */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.fa-spin {
  animation: spin 1s linear infinite;
}

/* --- 回到顶部按钮样式 --- */
#backToTopBtn {
  position: fixed; /* 固定在视口，不随页面滚动 */
  bottom: 30px;
  right: 30px;
  z-index: 999; /* 确保在最上层 */
  
  /* 初始状态：隐藏 */
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px); /* 轻微下移，用于动画 */
  
  /* 按钮外观 */
  width: 48px;
  height: 48px;
  border-radius: 50%; /* 圆形 */
  background-color: #1d9bf0; /* 主题色 */
  color: #ffffff;
  border: none;
  cursor: pointer;
  
  /* 图标样式 */
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  
  /* 动画过渡 */
  transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out, transform 0.3s ease-in-out;
}

/* 按钮显示时的状态 */
#backToTopBtn.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0); /* 恢复原位，产生上浮动画 */
}

/* 鼠标悬停效果 */
#backToTopBtn:hover {
  background-color: #1a8cd8; /* 颜色加深 */
  transform: scale(1.1); /* 轻微放大 */
}

/* 响应式调整：在小屏幕上按钮稍微小一点 */
@media (max-width: 768px) {
  #backToTopBtn {
    width: 42px;
    height: 42px;
    font-size: 18px;
    right: 20px;
    bottom: 20px;
  }
}
