/* =========================================================
   COMMENTS UI — NESTED THREADS
   - replies rendered inside parent card
   - compact header spacing
   - prefix: image only
   - status: text only
   - vote: no bg/border, icon + label under it, count on the right
========================================================= */


/* =========================================================
   1) ROOT + LIST
========================================================= */
.comments-root{
  max-width: 900px;
  margin: 24px auto;
  padding: 0 16px;
}

.comments-list{
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}


/* =========================================================
   2) NEW COMMENT FORM
========================================================= */
.comment-form{
  background: #ffffff;
  border: none;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  transition: all .3s ease;
}
.comment-form:hover{
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.comment-input{
  width: 100%;
  resize: vertical;
  min-height: 90px;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 15px;
  font-family: 'Raleway', sans-serif;
  line-height: 1.6;
  outline: none;
  transition: all .3s ease;
  background: #f8fafc;
}
.comment-input:focus{
  border-color: #4a90e2;
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(74,144,226,0.1);
}
.comment-input::placeholder{ color: #94a3b8; }

.comment-form-actions{
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 14px;
}

.comment-send-btn{
  border: none;
  border-radius: 12px;
  padding: 12px 24px;
  cursor: pointer;
  background: linear-gradient(135deg,#4a90e2,#357abd);
  color: #ffffff;
  font-weight: 600;
  font-size: 14px;
  font-family: 'Kanit', sans-serif;
  transition: all .3s ease;
  box-shadow: 0 2px 8px rgba(74,144,226,0.2);
}
.comment-send-btn:hover:not(:disabled){
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(74,144,226,0.3);
}
.comment-send-btn:active:not(:disabled){ transform: translateY(0); }
.comment-send-btn:disabled{
  opacity: .5;
  cursor: not-allowed;
  transform: none;
}

.comment-form-msg{
  font-size: 13px;
  color: #64748b;
  font-family: 'Raleway', sans-serif;
}


/* =========================================================
   3) COMMENT CARD (wrapper for nested thread)
========================================================= */
.cmt-card{
  position: relative;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 16px;
  padding-bottom: 44px; /* додали, щоб дата не наїжджала на кнопки */
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  transition: all .3s ease;
}

.cmt-card:hover{
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  border-color: #cbd5e1;
}


/* =========================================================
   4) HEADER: AVATAR + META (compact)
========================================================= */
.comments-root .cmt-head{
  position: relative;
  display: flex;
  gap: 6px;
  align-items: flex-start;
  margin-bottom: 10px;
  padding-right: 0; /* було 92px */
}


/* avatar ring */
.cmt-avatar-ring{
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 50%;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #cbd5e1;
  text-decoration: none;
  transition: all .3s ease;
  background: linear-gradient(135deg,#f1f5f9,#e2e8f0);
}
.cmt-avatar-ring:hover{
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}


.cmt-avatar{
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: #f1f5f9;
}

/* meta container */
.cmt-meta{
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

/* row1: prefix + nick + tag */
.comments-root .cmt-line1{
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.comments-root .cmt-line1 > *{
  margin: 0 !important;
}

/* nick */
.cmt-login{
  font-weight: 700;
  font-size: 15px;
  font-family: 'Ubuntu', sans-serif;
  color: #0f172a;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
  transition: color .2s ease;
}
.cmt-login:hover{ color: #4a90e2; }

/* tags container */
.comments-root .cmt-badges{
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}


/* =========================================================
   5) PREFIX (image only)
========================================================= */
.comments-root .prefix-badge{
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  border-radius: 0 !important;
  min-width: 0 !important;
  height: auto !important;
}
.comments-root .prefix-badge::before,
.comments-root .prefix-badge::after{
  content: none !important;
  display: none !important;
}
.comments-root .cmt-prefix-ico{
  width: 18px;
  height: 18px;
  display: block;
  object-fit: contain;
  background: transparent !important;
  filter: none !important;
}


/* =========================================================
   6) TAG
========================================================= */
.comments-root .tag-badge{
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 10px;
  line-height: 1.1;
  display: inline-flex;
  align-items: center;
}


/* =========================================================
   7) STATUS (text only)
========================================================= */
.cmt-status-row{ margin-top: 0; }

.comments-root .status-badge{
  font-size: 11px;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  display: inline !important;
}
.comments-root .status-badge::before,
.comments-root .status-badge::after{
  content: none !important;
  display: none !important;
}
.comments-root .status-badge .status-text{
  font-size: 11px;
  line-height: 1.1;
  display: inline;
}


/* =========================================================
   8) BODY
========================================================= */
.cmt-body{
  font-size: 15px;
  font-family: 'Raleway', sans-serif;
  color: #1e293b;
  line-height: 1.7;
  word-wrap: break-word;
  white-space: pre-wrap;
  margin-top: 8px;
}


/* =========================================================
   9) ACTIONS (reply + vote)
========================================================= */
.cmt-actions{
  display: flex;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
  align-items: center;
}

/* base buttons (reply) */
.cmt-btn{
  border: 1px solid #e5e7eb;
  background: #ffffff;
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  font-family: 'Raleway', sans-serif;
  color: #475569;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  transition: all .2s ease;
  font-weight: 500;
}
.cmt-btn:hover{
  background: #f8fafc;
  border-color: #cbd5e1;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.cmt-btn:active{ transform: translateY(0); }

/* vote button: no border/bg */
.comments-root .cmt-btn-vote{
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  border-radius: 0 !important;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
}
.comments-root .cmt-btn-vote:hover{
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  transform: none !important;
}

/* left column */
.comments-root .cmt-vote-left{
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  line-height: 1;
}
.comments-root .cmt-vote-ico{
  width: 18px;
  height: 18px;
  display: block;
  object-fit: contain;
}
.comments-root .cmt-vote-label{
  font-size: 10px;
  font-family: 'Raleway', sans-serif;
  font-weight: 600;
  letter-spacing: .2px;
  color: #0f172a;
}
.comments-root .cmt-btn-vote.is-active .cmt-vote-label{
  color: #ef4444;
  font-weight: 800;
}

/* count */
.comments-root .cmt-btn-vote .cmt-count{
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  color: #0f172a;
}


/* =========================================================
   10) DATE (in header corner)
========================================================= */
.cmt-date-corner{
  position: static;
  margin-left: auto;
  font-size: 12px;
  font-family: 'Raleway', sans-serif;
  color: #94a3b8;
  white-space: nowrap;
  align-self: center;
}


/* =========================================================
   11) REPLY BOX
========================================================= */
.cmt-reply{
  margin-top: 14px;
  border-top: 1px dashed #e2e8f0;
  padding-top: 14px;
  display: none;
  animation: slideDown .3s ease;
}
.cmt-reply.open{ display: block; }

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

.reply-input{
  width: 100%;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px 14px;
  resize: vertical;
  min-height: 70px;
  font-size: 14px;
  font-family: 'Raleway', sans-serif;
  line-height: 1.6;
  outline: none;
  transition: all .3s ease;
  background: #f8fafc;
}
.reply-input:focus{
  border-color: #4a90e2;
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(74,144,226,0.1);
}

.reply-actions{
  display: flex;
  gap: 10px;
  margin-top: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.reply-send-btn{
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  cursor: pointer;
  background: linear-gradient(135deg,#4a90e2,#357abd);
  color: #ffffff;
  font-weight: 600;
  font-size: 13px;
  font-family: 'Kanit', sans-serif;
  transition: all .3s ease;
  box-shadow: 0 2px 6px rgba(74,144,226,0.2);
}
.reply-send-btn:hover{
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(74,144,226,0.3);
}

.reply-cancel-btn{
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px 18px;
  cursor: pointer;
  background: #ffffff;
  color: #64748b;
  font-weight: 600;
  font-size: 13px;
  font-family: 'Kanit', sans-serif;
  transition: all .2s ease;
}
.reply-cancel-btn:hover{
  background: #f8fafc;
  border-color: #cbd5e1;
}

.reply-msg{
  font-size: 12px;
  color: #64748b;
  font-family: 'Raleway', sans-serif;
}


/* =========================================================
   12) NESTED CHILDREN (the main change)
========================================================= */
.cmt-children{
  margin-top: 12px;
  padding-left: 14px;                  /* візуальна вкладеність */
  border-left: 2px solid rgba(148,163,184,0.35);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.cmt-children.is-empty{ display: none; }

/* робимо вкладені картки легшими */
.cmt-children .cmt-card{
  border-radius: 14px;
  padding: 14px;
  box-shadow: none;
  background: linear-gradient(to right,#f8fafc,#ffffff);
}
.cmt-children .cmt-card:hover{
  box-shadow: none;
}

/* глибина — поступово зменшувати відступ/рамку (до 6 рівнів, далі повтор) */
.cmt-card[data-depth="0"] > .cmt-children{ border-left-color: rgba(148,163,184,0.35); }
.cmt-card[data-depth="1"] > .cmt-children{ border-left-color: rgba(74,144,226,0.35); }
.cmt-card[data-depth="2"] > .cmt-children{ border-left-color: rgba(34,197,94,0.28); }
.cmt-card[data-depth="3"] > .cmt-children{ border-left-color: rgba(239,68,68,0.28); }
.cmt-card[data-depth="4"] > .cmt-children{ border-left-color: rgba(168,85,247,0.24); }
.cmt-card[data-depth="5"] > .cmt-children{ border-left-color: rgba(245,158,11,0.24); }

/* щоб глибокі рівні не "роздували" */
.cmt-card[data-depth]{
  max-width: 100%;
}
.cmt-card[data-depth="4"],
.cmt-card[data-depth="5"],
.cmt-card[data-depth="6"]{
  padding: 12px;
}


/* =========================================================
   13) EMPTY STATE
========================================================= */
.cmt-empty{
  padding: 40px 20px;
  color: #64748b;
  text-align: center;
  font-size: 15px;
  font-family: 'Raleway', sans-serif;
}


/* =========================================================
   14) DARK MODE
========================================================= */
body.dark-mode .comment-form{
  background: #2d3748;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
body.dark-mode .comment-input{
  background: #1a202c;
  border-color: #4a5568;
  color: #e2e8f0;
}
body.dark-mode .comment-input:focus{
  border-color: #4a90e2;
  background: #2d3748;
  box-shadow: 0 0 0 4px rgba(74,144,226,0.2);
}
body.dark-mode .comment-input::placeholder{ color: #718096; }
body.dark-mode .comment-form-msg{ color: #a0aec0; }

body.dark-mode .cmt-card{
  background: #2d3748;
  border-color: #4a5568;
}
body.dark-mode .cmt-body{ color: #e2e8f0; }
body.dark-mode .cmt-login{ color: #e2e8f0; }
body.dark-mode .cmt-login:hover{ color: #60a5fa; }

body.dark-mode .cmt-date-corner{ color: #94a3b8; }

body.dark-mode .cmt-btn{
  background: #1a202c;
  border-color: #4a5568;
  color: #a0aec0;
}
body.dark-mode .cmt-btn:hover{
  background: #374151;
  border-color: #718096;
}

/* vote label/count in dark */
body.dark-mode .cmt-btn-vote .cmt-vote-label{ color: #e2e8f0; }
body.dark-mode .cmt-btn-vote .cmt-count{ color: #e2e8f0; }
body.dark-mode .cmt-btn-vote.is-active .cmt-vote-label{ color: #ef4444; }

/* nested cards in dark */
body.dark-mode .cmt-children{
  border-left-color: rgba(148,163,184,0.25);
}
body.dark-mode .cmt-children .cmt-card{
  background: linear-gradient(to right,#1a202c,#2d3748);
  border-color: #4a5568;
}


/* =========================================================
   15) RESPONSIVE
========================================================= */
@media (max-width: 768px){
  .comments-root{ padding: 0 12px; }

  .comment-form{
    padding: 16px;
    border-radius: 14px;
  }

  .comment-input{
    font-size: 14px;
    min-height: 80px;
    padding: 12px 14px;
  }

  .comment-send-btn{
    padding: 10px 20px;
    font-size: 13px;
  }

  .cmt-card{
    padding-bottom: 44px;
    border-radius: 14px;
  }

  .cmt-avatar-ring{
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
  }

  .comments-root .cmt-head{ padding-right: 0; }
  .cmt-date-corner{
    margin-top: 6px;
    display: block;
  }

  .cmt-login{
    font-size: 14px;
    max-width: 200px;
  }

  .cmt-body{ font-size: 14px; }

  .cmt-btn{
    padding: 7px 12px;
    font-size: 12px;
  }

  .comments-root .cmt-vote-ico{ width: 17px; height: 17px; }
  .comments-root .cmt-vote-label{ font-size: 10px; }
  .comments-root .cmt-btn-vote .cmt-count{ font-size: 12px; }

  .cmt-children{
    padding-left: 12px;
    gap: 10px;
  }

  .reply-input{
    font-size: 13px;
    min-height: 60px;
  }

  .reply-send-btn,
  .reply-cancel-btn{
    padding: 8px 14px;
    font-size: 12px;
  }
}

@media (max-width: 480px){
  .cmt-avatar-ring{
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
  }
  .cmt-login{ max-width: 150px; }
  .cmt-children{ padding-left: 10px; }
}



.cmt-card { 
  --nick-color: #0f172a; /* дефолт */
}
.cmt-card .cmt-login{
  color: var(--nick-color) !important;
}
/* (опційно) hover теж можна підконтролити */
.cmt-card .cmt-login:hover{
  color: #4a90e2 !important;
}

.role-admin .cmt-avatar-ring,
.role-publisher .cmt-avatar-ring,
.role-user .cmt-avatar-ring{
  border-color: inherit !important;
  background: inherit !important;
}

.cmt-card{
  --ring-border: #cbd5e1;
  --ring-bg1: #f1f5f9;
  --ring-bg2: #e2e8f0;
}

/* базовий ринг бере тільки змінні з ПОТОЧНОЇ картки */
.cmt-card > .cmt-head .cmt-avatar-ring{
  border-color: var(--ring-border) !important;
  background: linear-gradient(135deg, var(--ring-bg1), var(--ring-bg2)) !important;
}

/* ролі задають змінні тільки своїй картці */
.cmt-card.role-admin{
  --ring-border: #ecc94b;
  --ring-bg1: #fef3c7;
  --ring-bg2: #fde68a;
}
.cmt-card.role-publisher{
  --ring-border: #60a5fa;
  --ring-bg1: #dbeafe;
  --ring-bg2: #bfdbfe;
}
.cmt-card.role-user{
  --ring-border: #44cf46;
  --ring-bg1: #dcfce7;
  --ring-bg2: #bbf7d0;
}
