/* ============================================
   COMMENTS SECTION
   ============================================ */

.post-comments {
  margin-bottom: 48px;
}

.comments-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.comments-header h3 {
  font-size: 22px;
  margin: 0;
  color: var(--text-dark);
}

@media (min-width: 768px) {
  .comments-header h3 {
    font-size: 24px;
  }
}

.comments-sort {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.sort-select {
  padding: 6px 12px;
  border: 1px solid var(--bg-light);
  border-radius: var(--radius-small);
  background-color: var(--bg-white);
  font-size: 14px;
  cursor: pointer;
}

/* ============================================
   COMMENT FORM (Top-Level)
   ============================================ */

.comment-form {
  margin-bottom: 32px;
  padding: 20px;
  background-color: var(--bg-light);
  border-radius: var(--radius-medium);
}

@media (min-width: 768px) {
  .comment-form {
    padding: 24px;
  }
}

.comment-form-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.comment-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-circle);
  background-color: var(--primary-blue);
  color: var(--text-on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
}

@media (min-width: 768px) {
  .comment-avatar {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }
}

.comment-username {
  font-weight: 600;
  color: var(--text-dark);
  font-size: 14px;
}

@media (min-width: 768px) {
  .comment-username {
    font-size: 16px;
  }
}

.comment-textarea {
  width: 100%;
  min-height: 100px;
  padding: 12px;
  border: 1px solid var(--bg-light);
  border-radius: var(--radius-small);
  font-family: var(--font-family);
  font-size: 15px;
  resize: vertical;
  transition: border-color var(--transition-fast);
}

@media (min-width: 768px) {
  .comment-textarea {
    font-size: 16px;
    padding: 14px;
  }
}

.comment-textarea:focus {
  outline: none;
  border-color: var(--primary-blue);
}

.comment-form-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}

.char-count {
  font-size: 12px;
  color: var(--text-light);
}

@media (min-width: 768px) {
  .char-count {
    font-size: 14px;
  }
}

.char-count.warning {
  color: var(--warning-yellow);
}

.char-count.danger {
  color: var(--error-red);
}

.comments-login-prompt {
  text-align: center;
  padding: 32px;
  background-color: var(--bg-light);
  border-radius: var(--radius-medium);
}

.comments-login-prompt a {
  color: var(--primary-blue);
  text-decoration: underline;
}

.comments-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-light);
}

/* ============================================
   COMMENT THREAD (Nested Structure)
   ✅ ONLY CHANGED THIS SECTION - REDDIT STYLE
   ============================================ */

.comments-list {
  margin-top: 24px;
}

.comment-thread {
  margin-bottom: 16px;
}

.comment-thread[data-level="0"] {
  margin-bottom: 24px;
}

/* ✅ REDDIT STYLE: 10px indentation on mobile, 40px on desktop */
.comment-thread[data-level="1"] {
  margin-left: 10px;
  border-left: 2px solid var(--bg-light);
  padding-left: 8px;
}

.comment-thread[data-level="2"] {
  margin-left: 10px;
  border-left: 2px solid var(--bg-light);
  padding-left: 8px;
}

.comment-thread[data-level="3"] {
  margin-left: 10px;
  border-left: 2px solid var(--bg-light);
  padding-left: 8px;
}

.comment-thread[data-level="4"] {
  margin-left: 10px;
  border-left: 2px solid var(--bg-light);
  padding-left: 8px;
}

.comment-thread[data-level="5"] {
  margin-left: 10px;
  border-left: 2px solid var(--bg-light);
  padding-left: 8px;
}

.comment-thread[data-level="6"] {
  margin-left: 10px;
  border-left: 2px solid var(--bg-light);
  padding-left: 8px;
}

.comment-thread[data-level="7"] {
  margin-left: 10px;
  border-left: 2px solid var(--bg-light);
  padding-left: 8px;
}

/* ✅ REDDIT STYLE: Stop indenting after level 10 */
.comment-thread[data-level="8"],
.comment-thread[data-level="9"],
.comment-thread[data-level="10"] {
  margin-left: 0;
  border-left: none;
  padding-left: 0;
}

@media (min-width: 768px) {
  .comment-thread[data-level="1"] {
    margin-left: 40px;
    padding-left: 12px;
  }

  .comment-thread[data-level="2"] {
    margin-left: 40px;
    padding-left: 12px;
  }

  .comment-thread[data-level="3"] {
    margin-left: 40px;
    padding-left: 12px;
  }

  .comment-thread[data-level="4"] {
    margin-left: 40px;
    padding-left: 12px;
  }

  .comment-thread[data-level="5"] {
    margin-left: 40px;
    padding-left: 12px;
  }

  .comment-thread[data-level="6"] {
    margin-left: 40px;
    padding-left: 12px;
  }

  .comment-thread[data-level="7"] {
    margin-left: 40px;
    padding-left: 12px;
  }
}

/* ============================================
   COMMENT ITEM
   ============================================ */

.comment-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  background-color: var(--bg-white);
  border: 1px solid var(--bg-light);
  border-radius: var(--radius-medium);
}

@media (min-width: 768px) {
  .comment-item {
    padding: 16px;
    gap: 16px;
  }
}

/* ============================================
   COMMENT VOTING (Left Side)
   ============================================ */

.comment-vote {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 32px;
}

@media (min-width: 768px) {
  .comment-vote {
    min-width: 40px;
  }
}

.vote-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-light);
  padding: 4px;
  transition: all var(--transition-fast);
  line-height: 1;
}

@media (min-width: 768px) {
  .vote-btn {
    font-size: 20px;
  }
}

.vote-btn:hover {
  color: var(--primary-blue);
}

.vote-btn.vote-up.active {
  color: var(--primary-blue);
  font-weight: bold;
}

.vote-btn.vote-down.active {
  color: var(--error-red);
  font-weight: bold;
}

.vote-score {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dark);
}

@media (min-width: 768px) {
  .vote-score {
    font-size: 14px;
  }
}

.vote-score-readonly {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
}

@media (min-width: 768px) {
  .vote-score-readonly {
    font-size: 14px;
  }
}

/* ============================================
   COMMENT CONTENT (Right Side)
   ============================================ */

.comment-content-wrapper {
  flex: 1;
  min-width: 0; /* ✅ ADDED: Allow flexbox to shrink properly */
}

.comment-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.comment-date {
  font-size: 12px;
  color: var(--text-light);
}

@media (min-width: 768px) {
  .comment-date {
    font-size: 14px;
  }
}

.comment-edited {
  font-size: 11px;
  color: var(--text-light);
  font-style: italic;
}

@media (min-width: 768px) {
  .comment-edited {
    font-size: 12px;
  }
}

.comment-body {
  margin-bottom: 8px;
}

.comment-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-dark);
  margin: 0;
  word-wrap: break-word; /* ✅ KEEP YOUR ORIGINAL */
  overflow-wrap: break-word; /* ✅ ADDED: Better word breaking */
}

@media (min-width: 768px) {
  .comment-text {
    font-size: 16px;
    line-height: 1.7;
  }
}

/* ============================================
   COMMENT ACTIONS
   ============================================ */

.comment-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.comment-action-btn {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  transition: color var(--transition-fast);
}

@media (min-width: 768px) {
  .comment-action-btn {
    font-size: 13px;
  }
}

.comment-action-btn:hover {
  color: var(--primary-blue);
}

.comment-action-btn.delete-btn:hover {
  color: var(--error-red);
}

.collapse-icon {
  font-weight: bold;
}

/* ============================================
   REPLY FORM (Inline)
   ============================================ */

.comment-reply-form {
  margin-top: 12px;
  padding: 12px;
  background-color: var(--bg-light);
  border-radius: var(--radius-small);
}

@media (min-width: 768px) {
  .comment-reply-form {
    padding: 16px;
  }
}

.reply-form-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.reply-textarea {
  width: 100%;
  min-height: 80px;
  padding: 10px;
  border: 1px solid var(--bg-light);
  border-radius: var(--radius-small);
  font-family: var(--font-family);
  font-size: 14px;
  resize: vertical;
}

@media (min-width: 768px) {
  .reply-textarea {
    font-size: 15px;
    padding: 12px;
  }
}

.reply-textarea:focus {
  outline: none;
  border-color: var(--primary-blue);
}

.reply-form-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  gap: 8px;
  flex-wrap: wrap;
}

.reply-char-count {
  font-size: 11px;
  color: var(--text-light);
}

@media (min-width: 768px) {
  .reply-char-count {
    font-size: 12px;
  }
}

.reply-char-count.warning {
  color: var(--warning-yellow);
}

.reply-char-count.danger {
  color: var(--error-red);
}

/* ============================================
   EDIT FORM (Inline)
   ============================================ */

.comment-edit-form {
  margin-top: 8px;
}

.comment-edit-textarea {
  width: 100%;
  min-height: 80px;
  padding: 10px;
  border: 1px solid var(--bg-light);
  border-radius: var(--radius-small);
  font-family: var(--font-family);
  font-size: 14px;
  resize: vertical;
}

@media (min-width: 768px) {
  .comment-edit-textarea {
    font-size: 15px;
    padding: 12px;
  }
}

.comment-edit-textarea:focus {
  outline: none;
  border-color: var(--primary-blue);
}

.comment-edit-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* ============================================
   COLLAPSED COMMENTS
   ============================================ */

.comment-thread.collapsed > .comment-replies {
  display: none;
}

.comment-thread.collapsed .collapse-icon::before {
  content: '+';
}

/* ============================================
   HIDDEN STATE
   ============================================ */

.hidden {
  display: none !important;
}

.comments-sort label{
  width: 100% !important;
}

/* ============================================
   ANIMATIONS
   ============================================ */

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

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

.animate-in {
  animation: fadeIn 0.5s ease forwards;
}


/* ============================================
   NEW COMMENT HIGHLIGHT
   ============================================ */

.comment-new {
  animation: highlightNew 5s ease;
}

@keyframes highlightNew {
  0% {
    background-color: rgba(91, 141, 219, 0.2);
  }
  100% {
    background-color: transparent;
  }
}