/* Comments System Styles */
.comments-container {
  max-width: 800px;
  margin: 3rem auto;
  padding: 0 1rem;
}

.comments-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border-color, #e1e5e9);
}

.comments-header h3 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-color, #333);
}

.comments-count {
  color: var(--text-muted, #666);
  font-size: 0.875rem;
  background: var(--bg-light, #f8f9fa);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
}

/* Comment Form */
.comment-form {
  background: var(--bg-light, #f8f9fa);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  border: 1px solid var(--border-color, #e1e5e9);
}

.comment-form.reply-form {
  margin: 1rem 0;
  padding: 1rem;
  background: var(--bg-lighter, #ffffff);
}

.form-group {
  margin-bottom: 1rem;
}

.comment-textarea {
  width: 100%;
  min-height: 100px;
  padding: 0.75rem;
  border: 1px solid var(--border-color, #e1e5e9);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.comment-textarea:focus {
  outline: none;
  border-color: var(--brand-color, #4158D0);
  box-shadow: 0 0 0 3px rgba(65, 88, 208, 0.1);
}

.markdown-help {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
}

.markdown-help small {
  color: var(--text-muted, #666);
  font-size: 0.75rem;
}

.markdown-preview-btn {
  background: transparent;
  border: 1px solid var(--border-color, #e1e5e9);
  color: var(--text-muted, #666);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.markdown-preview-btn:hover {
  background: var(--bg-light, #f8f9fa);
  color: var(--text-color, #333);
}

.markdown-preview {
  background: white;
  border: 1px solid var(--border-color, #e1e5e9);
  border-radius: 6px;
  padding: 1rem;
  margin: 0.5rem 0;
  font-size: 0.9rem;
  line-height: 1.6;
}

.user-fields {
  margin-bottom: 1rem;
  transition: opacity 0.3s, height 0.3s;
}

.user-fields-collapsed {
  opacity: 0;
  height: 0;
  overflow: hidden;
  margin: 0;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color, #e1e5e9);
  border-radius: 6px;
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--brand-color, #4158D0);
  box-shadow: 0 0 0 3px rgba(65, 88, 208, 0.1);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.btn {
  padding: 0.5rem 1.25rem;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary {
  background: var(--brand-color, #4158D0);
  color: white;
}

.btn-primary:hover {
  background: #3652c7;
  transform: translateY(-1px);
}

.btn-secondary {
  background: transparent;
  color: var(--text-muted, #666);
  border: 1px solid var(--border-color, #e1e5e9);
}

.btn-secondary:hover {
  background: var(--bg-light, #f8f9fa);
  color: var(--text-color, #333);
}

/* Comments List */
.comments-list {
  margin-top: 2rem;
}

.no-comments {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted, #666);
}

.no-comments p {
  margin: 0;
  font-size: 1rem;
}

/* Comment */
.comment {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color, #e1e5e9);
}

.comment:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.comment-reply {
  margin-left: 3rem;
  border-left: 2px solid var(--border-color, #e1e5e9);
  padding-left: 1rem;
}

.comment-avatar {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
}

.comment-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.comment-content {
  flex: 1;
  min-width: 0;
}

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

.comment-author {
  font-weight: 600;
  color: var(--text-color, #333);
}

.comment-author a {
  color: inherit;
  text-decoration: none;
}

.comment-author a:hover {
  color: var(--brand-color, #4158D0);
}

.comment-meta {
  font-size: 0.75rem;
  color: var(--text-muted, #666);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.moderated-badge {
  background: #28a745;
  color: white;
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
  font-size: 0.625rem;
  font-weight: 600;
}

.comment-body {
  margin: 0.75rem 0;
  line-height: 1.6;
  color: var(--text-color, #333);
}

.comment-body p {
  margin: 0 0 1rem 0;
}

.comment-body p:last-child {
  margin-bottom: 0;
}

.comment-body strong {
  font-weight: 600;
}

.comment-body em {
  font-style: italic;
}

.comment-body code {
  background: var(--bg-light, #f8f9fa);
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875em;
}

.comment-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.75rem;
}

.comment-action {
  background: transparent;
  border: none;
  color: var(--text-muted, #666);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: all 0.2s;
}

.comment-action:hover {
  background: var(--bg-light, #f8f9fa);
  color: var(--brand-color, #4158D0);
}

.comment-reactions {
  display: flex;
  gap: 0.5rem;
}

.reaction-btn {
  background: transparent;
  border: 1px solid var(--border-color, #e1e5e9);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  transition: all 0.2s;
  color: var(--text-muted, #666);
}

.reaction-btn:hover {
  background: var(--bg-light, #f8f9fa);
  border-color: var(--brand-color, #4158D0);
}

.reaction-btn.reacted {
  background: var(--brand-color, #4158D0);
  color: white;
  border-color: var(--brand-color, #4158D0);
}

.reaction-count {
  font-weight: 500;
}

.comment-replies {
  margin-top: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
  .comments-container {
    padding: 0 0.5rem;
  }
  
  .comments-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  
  .form-row {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  
  .form-actions {
    flex-direction: column;
  }
  
  .btn {
    width: 100%;
    justify-content: center;
  }
  
  .comment {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .comment-reply {
    margin-left: 1rem;
    padding-left: 0.75rem;
  }
  
  .comment-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
  
  .comment-actions {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  
  .comment-reactions {
    align-self: flex-end;
  }
}

/* Dark Theme */
[data-theme="dark"] .comments-container {
  color: #e0e0e0;
}

[data-theme="dark"] .comments-header h3 {
  color: #e0e0e0;
}

[data-theme="dark"] .comment-form {
  background: #2a2a2a;
  border-color: #444;
}

[data-theme="dark"] .comment-textarea,
[data-theme="dark"] .form-input {
  background: #1a1a1a;
  border-color: #444;
  color: #e0e0e0;
}

[data-theme="dark"] .comment-textarea:focus,
[data-theme="dark"] .form-input:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

[data-theme="dark"] .markdown-preview {
  background: #1a1a1a;
  border-color: #444;
  color: #e0e0e0;
}

[data-theme="dark"] .comment {
  border-color: #444;
}

[data-theme="dark"] .comment-reply {
  border-color: #555;
}

[data-theme="dark"] .comment-author {
  color: #e0e0e0;
}

[data-theme="dark"] .comment-body {
  color: #e0e0e0;
}

[data-theme="dark"] .comment-body code {
  background: #2a2a2a;
  color: #ff6b6b;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .comment-textarea,
  .form-input,
  .btn,
  .comment-action,
  .reaction-btn,
  .markdown-preview-btn {
    transition: none;
  }
  
  .btn:hover {
    transform: none;
  }
  
  .user-fields {
    transition: none;
  }
}

/* Print Styles */
@media print {
  .comments-container {
    margin: 1rem 0;
  }
  
  .comment-form,
  .comment-actions,
  .comment-reactions {
    display: none;
  }
  
  .comment {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
  }
  
  .comment-avatar img {
    filter: grayscale(100%);
  }
}