/**
 * Modern Comments CSS - Inspired by Modern Social Media Design
 * Dark theme with collapsible replies and clean interface
 */

/* Reset and base styles */
.comments-section {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  background-color: #0f0f0f;
  color: #ffffff;
  margin: 0;
  padding: 0;
}

.comments-section *,
.comments-section *::before,
.comments-section *::after {
  box-sizing: border-box;
}

/* Header - Mobile First */
.comments-header {
  padding: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.comments-header h3 {
  color: white;
  font-weight: 600;
  font-size: 1.125rem;
  margin: 0;
  text-align: center;
}

/* Reactions Container - Mobile First */
.reactions-container {
  padding: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.reactions-container > div {
  max-width: 100%;
  margin: 0 auto;
}

.reactions-container h4 {
  font-size: 0.875rem;
  font-weight: 500;
  color: #e5e5e5;
  margin-bottom: 0.5rem;
  text-align: center;
}

.reactions-container p {
  font-size: 0.75rem;
  color: #a3a3a3;
  margin: 0 0 1rem 0;
  text-align: center;
}

/* Reactions Grid - Mobile First */
.reactions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  max-width: 100%;
  margin: 0 auto;
}

.reaction-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem 0.25rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  transform: scale(1);
  min-height: 80px;
  justify-content: center;
}

.reaction-btn:hover,
.reaction-btn:focus {
  transform: scale(1.02);
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}

.reaction-btn:active {
  transform: scale(0.98);
}

.reaction-btn.user-reacted {
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.5);
  transform: scale(1.02);
}

.reaction-emoji {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
  line-height: 1;
}

.reaction-count {
  font-size: 0.875rem;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 0.125rem;
  line-height: 1;
}

.reaction-label {
  font-size: 0.625rem;
  color: #a3a3a3;
  text-align: center;
  line-height: 1;
}

/* Comments Content - Mobile First */
.comments-content {
  padding: 1rem;
}

.comments-content > div {
  max-width: 100%;
  margin: 0 auto;
}

/* Comments Header with Sort */
.comments-content > div > div:first-child {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.comments-content h4 {
  font-size: 1rem;
  font-weight: 600;
  color: #ffffff;
  margin: 0;
  text-align: center;
}

/* Sort Options - Mobile First */
.sort-options {
  display: flex;
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 0.5rem;
  padding: 0.25rem;
  width: 100%;
  justify-content: space-between;
}

.sort-btn {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  background: none;
  color: #a3a3a3;
  border: none;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  white-space: nowrap;
}

.sort-btn:hover,
.sort-btn:focus {
  background-color: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  outline: none;
}

.sort-btn.active {
  background-color: #3b82f6;
  color: white;
}

/* Comment Form - Mobile First */
.comment-form-container {
  margin-bottom: 1.5rem;
}

.comment-form-card {
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.75rem;
  padding: 1rem;
}

.comment-form-content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.comment-form-avatar {
  display: flex;
  justify-content: center;
  margin-bottom: 0.5rem;
}

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

.comment-form-input {
  flex: 1;
}

.comment-textarea {
  width: 100%;
  padding: 0.75rem;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.5rem;
  color: #ffffff;
  resize: vertical;
  outline: none;
  font-family: inherit;
  font-size: 0.875rem;
  min-height: 80px;
}

.comment-textarea:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.comment-form-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.comment-form-info {
  text-align: center;
}

.moderation-notice {
  font-size: 0.75rem;
  color: #a3a3a3;
}

.comment-form-buttons {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.btn-primary,
.btn-secondary {
  padding: 0.75rem 1.5rem;
  border-radius: 0.375rem;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.875rem;
  border: none;
  transition: all 0.2s ease;
  flex: 1;
  max-width: 120px;
}

.btn-primary {
  background-color: #3b82f6;
  color: white;
}

.btn-primary:hover,
.btn-primary:focus {
  background-color: #2563eb;
  transform: translateY(-1px);
  outline: none;
}

.btn-secondary {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #a3a3a3;
}

.btn-secondary:hover,
.btn-secondary:focus {
  border-color: #3b82f6;
  color: #3b82f6;
  outline: none;
}

/* Login Prompt */
.login-prompt {
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.75rem;
  padding: 1.5rem;
  text-align: center;
}

.login-prompt p {
  color: #a3a3a3;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.login-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  background-color: #3b82f6;
  color: white;
  text-decoration: none;
  border-radius: 0.5rem;
  font-weight: 500;
  font-size: 0.875rem;
  transition: all 0.2s ease;
  gap: 0.5rem;
}

.login-btn:hover,
.login-btn:focus {
  background-color: #2563eb;
  transform: translateY(-1px);
  text-decoration: none;
  color: white;
}

.login-icon {
  width: 1rem;
  height: 1rem;
}

/* Comment Items - Modern Design Inspired by Reference */
.comment-item {
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.75rem;
  padding: 1rem;
  margin-bottom: 0.75rem;
  transition: all 0.2s ease;
  position: relative;
}

.comment-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.12);
}

.comment-highlighted {
  background-color: rgba(59, 130, 246, 0.1) !important;
  border: 1px solid rgba(59, 130, 246, 0.3) !important;
}

/* Comment Header */
.comment-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.comment-author-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.comment-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.1);
}

.comment-author-details {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.comment-author-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: #ffffff;
  font-size: 0.875rem;
}

.premium-badge {
  background: linear-gradient(45deg, #fbbf24, #f59e0b);
  color: #000;
  font-size: 0.625rem;
  padding: 0.125rem 0.5rem;
  border-radius: 1rem;
  font-weight: 700;
  text-transform: uppercase;
}
.admin-badge {
    background: linear-gradient(45deg, #ef4444, #dc2626);
    color: #000;
    font-size: 0.625rem;
    padding: 0.125rem 0.5rem;
    border-radius: 1rem;
    font-weight: 700;
    text-transform: uppercase;
}
.comment-time {
  font-size: 0.75rem;
  color: #a3a3a3;
}

/* Three Dots Menu */
.comment-options {
  position: relative;
}

.comment-options-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: none;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: #a3a3a3;
  transition: all 0.2s ease;
}

.comment-options-btn:hover,
.comment-options-btn:focus {
  background-color: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  outline: none;
}

.comment-options-btn svg {
  width: 1rem;
  height: 1rem;
}

.comment-options-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background-color: #262626;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.5rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  z-index: 1000;
  min-width: 120px;
  display: none;
  animation: slideDown 0.2s ease;
}

.comment-options-menu.show {
  display: block;
}

.comment-options-menu button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1rem;
  background: none;
  border: none;
  color: #ffffff;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
  border-radius: 0;
}

.comment-options-menu button:first-child {
  border-top-left-radius: 0.5rem;
  border-top-right-radius: 0.5rem;
}

.comment-options-menu button:last-child {
  border-bottom-left-radius: 0.5rem;
  border-bottom-right-radius: 0.5rem;
}

.comment-options-menu button:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.comment-options-menu button.danger:hover {
  background-color: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.comment-options-menu svg {
  width: 0.875rem;
  height: 0.875rem;
}

/* Comment Content */
.comment-content {
  color: #ffffff;
  line-height: 1.5;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  word-break: break-word;
}

/* Comment Actions */
.comment-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.875rem;
}

.comment-action-btn {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  background: none;
  border: none;
  color: #a3a3a3;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0.375rem 0.5rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
}

.comment-action-btn:hover {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.05);
}

.comment-action-btn.user-voted {
  color: #3b82f6;
}

.comment-action-btn svg {
  width: 1rem;
  height: 1rem;
}

/* Reply Toggle Button */
.replies-toggle {
  margin-top: 1rem;
}

.show-replies-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  color: #3b82f6;
  cursor: pointer;
  font-size: 0.875rem;
  padding: 0.5rem;
  border-radius: 0.375rem;
  transition: all 0.2s ease;
}

.show-replies-btn:hover {
  background-color: rgba(59, 130, 246, 0.1);
}

.show-replies-btn svg {
  width: 1rem;
  height: 1rem;
  transition: transform 0.2s ease;
}

.show-replies-btn.expanded svg {
  transform: rotate(180deg);
}

/* Nested Replies */
.comment-replies {
  margin-top: 1rem;
  padding-left: 1rem;
  border-left: 2px solid rgba(255, 255, 255, 0.1);
  display: none;
}

.comment-replies.show {
  display: block;
  animation: slideDown 0.3s ease;
}

.comment-replies .comment-item {
  margin-left: 0;
  background-color: rgba(255, 255, 255, 0.02);
}

/* Reply Form */
.reply-form {
  margin-top: 1rem;
  padding: 1rem;
  background-color: rgba(255, 255, 255, 0.03);
  border-radius: 0.5rem;
  border-left: 3px solid #3b82f6;
  animation: slideDown 0.3s ease;
}

.reply-form form {
  width: 100%;
}

.reply-form textarea {
  width: 100%;
  padding: 0.75rem;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.375rem;
  color: #ffffff;
  resize: vertical;
  outline: none;
  font-family: inherit;
  min-height: 80px;
  font-size: 0.875rem;
}

.reply-form textarea:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

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

.reply-form-actions button {
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  cursor: pointer;
  font-size: 0.875rem;
  border: none;
  transition: all 0.2s ease;
}

.reply-form-actions .reply-cancel {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #a3a3a3;
}

.reply-form-actions .reply-cancel:hover {
  border-color: #3b82f6;
  color: #3b82f6;
}

.reply-form-actions button[type="submit"] {
  background-color: #3b82f6;
  color: white;
}

.reply-form-actions button[type="submit"]:hover {
  background-color: #2563eb;
}

/* Nested Reply Forms */
.comment-replies .reply-form {
  margin-top: 0.75rem;
  margin-left: 0;
  padding: 0.75rem;
  background-color: rgba(255, 255, 255, 0.02);
  border-left: 3px solid #3b82f6;
  border-radius: 0.5rem;
}

.comment-replies .comment-item .reply-form {
  margin-left: 0;
  background-color: rgba(255, 255, 255, 0.04);
}

/* Ensure reply buttons are visible on all comment levels */
.comment-replies .comment-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.875rem;
}

.comment-replies .comment-action-btn {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  background: none;
  border: none;
  color: #a3a3a3;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0.375rem 0.5rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
}

/* Better visual hierarchy for nested comments */
.comment-replies .comment-item {
  margin-bottom: 0.5rem;
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.comment-replies .comment-replies .comment-item {
  background-color: rgba(255, 255, 255, 0.01);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

/* Limit deep nesting visually but allow functionality */
.comment-replies .comment-replies .comment-replies {
  padding-left: 1rem;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.comment-replies .comment-replies .comment-replies .comment-replies {
  padding-left: 0.5rem;
}

/* Modal */
#report-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
  padding: 1rem;
}

#report-modal > div {
  background-color: #262626;
  border-radius: 0.75rem;
  padding: 1.5rem;
  max-width: 400px;
  width: 100%;
  animation: slideUp 0.3s ease;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

#report-modal h3 {
  color: #ffffff;
  margin-bottom: 1rem;
  font-size: 1rem;
  text-align: center;
}

#report-modal label {
  display: block;
  color: #e5e5e5;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

#report-modal select,
#report-modal textarea {
  width: 100%;
  padding: 0.75rem;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.375rem;
  color: #ffffff;
  font-size: 0.875rem;
}

#report-modal textarea {
  resize: vertical;
  min-height: 80px;
}

#report-modal .form-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1.5rem;
}

#report-modal button {
  padding: 0.75rem 1rem;
  border-radius: 0.375rem;
  cursor: pointer;
  font-size: 0.875rem;
  border: none;
  transition: all 0.2s ease;
  flex: 1;
  max-width: 120px;
}

#cancel-report {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #a3a3a3;
}

#cancel-report:hover {
  border-color: #3b82f6;
  color: #3b82f6;
}

#report-modal button[type="submit"] {
  background-color: #dc2626;
  color: white;
}

#report-modal button[type="submit"]:hover {
  background-color: #b91c1c;
}

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

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

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
    max-height: 0;
  }
  to {
    opacity: 1;
    transform: translateY(0);
    max-height: 1000px;
  }
}

/* Loading States */
.loading {
  position: relative;
  pointer-events: none;
  opacity: 0.6;
}

.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border: 2px solid rgba(59, 130, 246, 0.3);
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.loading-spinner {
  display: inline-block;
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid rgba(59, 130, 246, 0.3);
  border-radius: 50%;
  border-top-color: #3b82f6;
  animation: spin 1s linear infinite;
}

/* Empty State */
.comments-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: #a3a3a3;
}

.comments-empty svg {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 1rem;
  opacity: 0.5;
}

.comments-empty h5 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  color: #ffffff;
}

.comments-empty p {
  font-size: 0.875rem;
  opacity: 0.7;
}

/* Tablet Styles (768px and up) */
@media (min-width: 768px) {
  .comments-header {
    padding: 2rem 1.5rem;
  }

  .comments-header h3 {
    font-size: 1.25rem;
    text-align: left;
  }

  .reactions-container {
    padding: 2rem 1.5rem;
  }

  .reactions-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    max-width: 600px;
  }

  .comments-content {
    padding: 2rem 1.5rem;
  }

  .comments-content > div {
    max-width: 48rem;
  }

  .comments-content > div > div:first-child {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .comments-content h4 {
    font-size: 1.125rem;
    text-align: left;
  }

  .sort-options {
    width: auto;
  }

  .comment-form-content {
    flex-direction: row;
    align-items: flex-start;
  }

  .comment-form-avatar {
    margin-bottom: 0;
    justify-content: flex-start;
  }

  .comment-form-actions {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .comment-form-buttons {
    justify-content: flex-end;
  }

  .comment-replies {
    padding-left: 2rem;
  }
}

/* Desktop Styles (1024px and up) */
@media (min-width: 1024px) {
  .reactions-grid {
    grid-template-columns: repeat(6, 1fr);
    gap: 1rem;
  }

  .comment-replies {
    padding-left: 3rem;
  }
}

/* Focus States for Accessibility */
.reaction-btn:focus,
.comment-action-btn:focus,
.sort-btn:focus,
.show-replies-btn:focus,
.btn-primary:focus,
.btn-secondary:focus,
.login-btn:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
  border-radius: 0.25rem;
}

.comment-textarea:focus,
#report-modal select:focus,
#report-modal textarea:focus {
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
  outline: none;
}

/* Enhanced Mobile Styles */
@media (max-width: 767px) {
  .comment-author-info {
    gap: 0.5rem;
  }

  .comment-avatar {
    width: 2rem;
    height: 2rem;
  }

  .comment-actions {
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  .comment-action-btn {
    padding: 0.25rem 0.375rem;
    font-size: 0.75rem;
  }

  .comment-replies {
    padding-left: 0.5rem;
  }
}
