/**
 * Giscus 评论系统自定义样式
 * 提供现代化的评论界面设计
 */

/* 评论区域容器 */
.comments-section {
  margin: 3rem 0 2rem;
  padding: 0;
}

/* 评论标题区域 */
.comments-header {
  margin-bottom: 2rem;
  text-align: center;
  padding: 1.5rem;
  background: linear-gradient(135deg, rgba(0, 122, 204, 0.05), rgba(0, 168, 255, 0.05));
  border-radius: 12px;
  border: 1px solid rgba(0, 122, 204, 0.1);
}

.comments-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0 0 0.5rem 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--primary, #007acc);
}

.comments-icon {
  width: 24px;
  height: 24px;
  stroke: currentColor;
}

.comments-description {
  margin: 0;
  color: var(--text-secondary, #666);
  font-size: 0.95rem;
  opacity: 0.8;
}

/* Giscus 容器 */
.giscus-container {
  margin: 2rem 0;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: all 0.3s ease;
}

.giscus-container:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.giscus-wrapper {
  min-height: 200px;
  position: relative;
}

/* 加载状态 */
.giscus-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  color: var(--text-secondary, #666);
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(0, 122, 204, 0.2);
  border-top-color: var(--primary, #007acc);
  border-radius: 50%;
  animation: giscus-spin 1s linear infinite;
  margin-bottom: 1rem;
}

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

.giscus-loading p {
  margin: 0;
  font-size: 0.9rem;
  opacity: 0.8;
}

/* 错误状态 */
.giscus-error {
  text-align: center;
  padding: 2rem;
  color: #dc3545;
}

.giscus-error .error-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 1rem;
  stroke: currentColor;
}

.giscus-error h4 {
  margin: 0 0 0.5rem 0;
  font-size: 1.2rem;
  font-weight: 600;
}

.giscus-error p {
  margin: 0 0 1.5rem 0;
  opacity: 0.8;
}

.retry-button {
  background: #dc3545;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.retry-button:hover {
  background: #c82333;
  transform: translateY(-1px);
}

/* 配置提醒 */
.giscus-config-notice {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary, #666);
  background: rgba(255, 193, 7, 0.1);
  border: 1px solid rgba(255, 193, 7, 0.3);
  border-radius: 8px;
  margin: 1rem;
}

.giscus-config-notice .info-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 1rem;
  stroke: #ffc107;
}

.giscus-config-notice h4 {
  margin: 0 0 0.5rem 0;
  font-size: 1.2rem;
  font-weight: 600;
  color: #856404;
}

.giscus-config-notice p {
  margin: 0 0 1rem 0;
  opacity: 0.9;
}

.config-help {
  text-align: left;
  max-width: 400px;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 6px;
  padding: 1rem;
}

.config-help summary {
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--primary, #007acc);
}

.config-help ol {
  margin: 0.5rem 0 0 0;
  padding-left: 1.2rem;
}

.config-help li {
  margin-bottom: 0.3rem;
}

.config-help a {
  color: var(--primary, #007acc);
  text-decoration: none;
}

.config-help a:hover {
  text-decoration: underline;
}

/* Giscus iframe 样式调整 */
.giscus-frame {
  border-radius: 0 0 12px 12px;
  border: none;
  width: 100%;
  background: transparent;
}

/* 深色模式适配 */
@media (prefers-color-scheme: dark) {
  .comments-header {
    background: linear-gradient(135deg, rgba(79, 195, 247, 0.05), rgba(41, 182, 246, 0.05));
    border-color: rgba(79, 195, 247, 0.1);
  }

  .comments-title {
    color: #4fc3f7;
  }

  .giscus-container {
    background: rgba(30, 30, 30, 0.5);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  }

  .giscus-container:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  }

  .loading-spinner {
    border-color: rgba(79, 195, 247, 0.2);
    border-top-color: #4fc3f7;
  }

  .giscus-config-notice {
    background: rgba(255, 193, 7, 0.15);
    border-color: rgba(255, 193, 7, 0.4);
  }

  .config-help {
    background: rgba(30, 30, 30, 0.7);
  }
}

/* 手动深色模式类 */
body.dark .comments-header {
  background: linear-gradient(135deg, rgba(79, 195, 247, 0.05), rgba(41, 182, 246, 0.05));
  border-color: rgba(79, 195, 247, 0.1);
}

body.dark .comments-title {
  color: #4fc3f7;
}

body.dark .giscus-container {
  background: rgba(30, 30, 30, 0.5);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

body.dark .giscus-container:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

body.dark .loading-spinner {
  border-color: rgba(79, 195, 247, 0.2);
  border-top-color: #4fc3f7;
}

body.dark .giscus-config-notice {
  background: rgba(255, 193, 7, 0.15);
  border-color: rgba(255, 193, 7, 0.4);
}

body.dark .config-help {
  background: rgba(30, 30, 30, 0.7);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .comments-section {
    margin: 2rem -1rem 1rem;
  }

  .comments-header {
    margin: 0 1rem 2rem;
    padding: 1rem;
    border-radius: 8px;
  }

  .comments-title {
    font-size: 1.3rem;
  }

  .giscus-container {
    margin: 0 1rem 2rem;
    border-radius: 8px;
  }

  .giscus-loading {
    padding: 2rem 1rem;
  }

  .giscus-error,
  .giscus-config-notice {
    padding: 1.5rem 1rem;
    margin: 0.5rem;
  }

  .config-help {
    padding: 0.8rem;
  }
}

/* 高对比度模式 */
@media (prefers-contrast: high) {
  .comments-header {
    border-width: 2px;
  }

  .giscus-container {
    border-width: 2px;
  }

  .giscus-config-notice {
    border-width: 2px;
  }
}

/* 减少动画模式 */
@media (prefers-reduced-motion: reduce) {
  .giscus-container,
  .retry-button,
  .loading-spinner {
    transition: none;
  }

  .retry-button:hover {
    transform: none;
  }

  @keyframes giscus-spin {
    to {
      transform: none;
    }
  }
}

/* 打印样式 */
@media print {
  .comments-section {
    display: none;
  }
}

/* 评论统计样式（可选） */
.comments-stats {
  text-align: center;
  margin: 1rem 0;
  padding: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary, #666);
  opacity: 0.8;
}

.comments-stats .stat-item {
  display: inline-block;
  margin: 0 1rem;
}

.comments-stats .stat-number {
  font-weight: 600;
  color: var(--primary, #007acc);
}

/* 评论引导样式 */
.comments-guide {
  background: rgba(0, 122, 204, 0.05);
  border: 1px solid rgba(0, 122, 204, 0.1);
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
  font-size: 0.9rem;
  color: var(--text-secondary, #666);
}

.comments-guide h5 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary, #007acc);
}

.comments-guide ul {
  margin: 0;
  padding-left: 1.2rem;
}

.comments-guide li {
  margin-bottom: 0.3rem;
}

/* 无评论状态 */
.no-comments {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary, #666);
  font-style: italic;
}

.no-comments .empty-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 1rem;
  opacity: 0.5;
  stroke: currentColor;
}
