/* ===== COMMENTS ===== */
.comments-section {
  padding: 48px 0 64px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.comments-title {
  font-family: "Montserrat", sans-serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--main-bg-color);
  margin-bottom: 32px;
  position: relative;
  display: inline-block;
}

.comments-title .comments-count {
  position: absolute;
  top: -6px;
  right: -28px;
  background: var(--gold-color);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  border-radius: 10px;
  padding: 0 6px;
}

/* --- Форма --- */
/* Показывать только первые 2 корневых комментария */
.comments-list:not(.is-expanded) > .comment:nth-child(n+3) {
  display: none;
}

.comments-show-all {
  display: block;
  width: 100%;
  padding: 14px;
  margin-top: 16px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: var(--border-radius);
  font-size: 15px;
  font-weight: 600;
  font-family: "Nunito", sans-serif;
  color: var(--gold-color);
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}

.comments-show-all:hover {
  background: var(--gold-color);
  color: #fff;
  border-color: var(--gold-color);
}

.comments-show-all + .comment-form {
  margin-top: 32px;
}

.comments-list + .comment-form {
  margin-top: 32px;
}

.comment-form {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--border-radius);
  padding: 24px;
  margin-bottom: 40px;
}

.comment-form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.comment-form input[type="text"] {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: var(--border-radius);
  font-size: 15px;
  font-family: "Nunito", sans-serif;
  background: var(--ligth-bg-color);
  color: var(--main-bg-color);
  transition: border-color 0.2s;
}

.comment-form input[type="text"]:focus {
  outline: none;
  border-color: var(--gold-color);
}

.comment-form textarea {
  width: 100%;
  min-height: 100px;
  padding: 12px 16px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: var(--border-radius);
  font-size: 15px;
  font-family: "Nunito", sans-serif;
  background: var(--ligth-bg-color);
  color: var(--main-bg-color);
  resize: vertical;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

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

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

.comment-form-hint {
  font-size: 13px;
  color: var(--dark-text-color);
}

.comment-form-cancel {
  background: none;
  border: none;
  color: var(--dark-text-color);
  font-size: 14px;
  cursor: pointer;
  padding: 8px 16px;
  display: none;
}

.comment-form-cancel:hover {
  color: var(--main-bg-color);
}

.comment-form-submit {
  padding: 10px 28px;
  background-color: var(--gold-color);
  color: #fff;
  border: none;
  border-radius: var(--border-radius);
  font-size: 15px;
  font-weight: 600;
  font-family: "Nunito", sans-serif;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.15s;
}

.comment-form-submit:hover {
  background-color: #a89000;
}

.comment-form-submit:active {
  transform: scale(0.97);
}

.comment-form-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.comment-form-submit.is-loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.comment-form-submit.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.comment-form-replying {
  font-size: 13px;
  color: var(--gold-color);
  font-weight: 600;
  margin-bottom: 12px;
  display: none;
}

/* --- Список комментариев --- */
.comments-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
}

.comment {
  padding: 20px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

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

.comment-children {
  margin-left: 52px;
  border-left: 2px solid rgba(0, 0, 0, 0.08);
  margin-top: 4px;
}

.comment-children .comment {
  padding: 16px 0 16px 20px;
  border-bottom: none;
}

.comment-children .comment-avatar {
  width: 28px;
  height: 28px;
  font-size: 12px;
}

.comment-children .comment-text,
.comment-children .comment-reply-btn,
.comment-children .comment-expand-btn {
  padding-left: 40px;
}

/* Не вкладывать глубже — все ответы 2+ уровня на одном уровне */
.comment-children .comment-children {
  margin-left: 0;
  border-left: none;
}

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

.comment-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gold-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
}

.comment-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.comment-author {
  font-weight: 700;
  font-size: 15px;
  color: var(--main-bg-color);
  line-height: 1.2;
}

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

.comment-text {
  font-size: 15px;
  line-height: 1.6;
  color: var(--main-bg-color);
  margin-bottom: 10px;
  padding-left: 52px;
  overflow-wrap: break-word;
  word-break: break-word;
}

.comment-text.is-long {
  max-height: 120px;
  overflow: hidden;
  position: relative;
}

.comment-text.is-long::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(transparent, var(--ligth-bg-color));
  pointer-events: none;
}

.comment-text.is-expanded {
  max-height: none;
}

.comment-text.is-expanded::after {
  display: none;
}

.comment-expand-btn {
  background: none;
  border: none;
  color: var(--gold-color);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0 4px 52px;
  display: block;
  transition: color 0.2s;
  margin-bottom: 4px;
}

.comment-expand-btn:hover {
  color: #a89000;
}

.comment-reply-btn {
  background: none;
  border: none;
  color: var(--gold-color);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  padding-left: 52px;
  transition: color 0.2s;
}

.comment-reply-btn:hover {
  color: #a89000;
}

/* --- Админские комментарии --- */
.comment--admin {
  background: linear-gradient(135deg, rgba(189, 160, 0, 0.04), rgba(189, 160, 0, 0.08));
  border: 1px solid rgba(189, 160, 0, 0.15);
  border-radius: var(--border-radius);
  padding: 20px 24px;
  margin: 4px 0;
}

.comment--admin.comment--reply {
  border-left: 3px solid var(--gold-color);
}

.comment-avatar--admin {
  background: none;
  border-radius: var(--border-radius);
  object-fit: contain;
}

.comment--admin .comment-author {
  color: var(--gold-color);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.comment-verified {
  flex-shrink: 0;
}

.comments-empty {
  text-align: center;
  padding: 32px 0;
  color: var(--dark-text-color);
  font-size: 15px;
}

/* --- Уведомление --- */
.comment-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--main-bg-color);
  color: #fff;
  padding: 14px 28px;
  border-radius: var(--border-radius);
  font-size: 14px;
  font-weight: 600;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  white-space: nowrap;
}

.comment-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .comments-section {
    padding: 32px 0 48px;
  }

  .comments-title {
    font-size: 20px;
  }

  .comment-form {
    padding: 16px;
  }

  .comment-form-row {
    flex-direction: column;
  }

  .comment-children {
    margin-left: 20px;
  }

  .comment-children .comment {
    padding-left: 14px;
  }

  .comment-text,
  .comment-reply-btn {
    padding-left: 0 !important;
  }

  .comment-children .comment-text,
  .comment-children .comment-reply-btn {
    padding-left: 0 !important;
  }

  .comment-form-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

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

  .comment-form-submit {
    width: 100%;
  }
}
