/* Comments Panel - slide-in from right */

/* Panel container */
.comments-panel {
  position: fixed;
  top: 82px;
  right: 20px;
  bottom: 59px;
  width: 420px;
  max-width: calc(100vw - 40px);
  background: #ffffff;
  z-index: 9999999;
  transform: translateX(calc(100% + 40px));
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
  border-radius: 16px;
}

.comments-panel.open {
  transform: translateX(0);
}

/* Panel header */
.comments-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #e8e8e8;
  flex-shrink: 0;
  background: #454554;
  border-radius: 16px 16px 0 0;
}

.comments-panel-site-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.comments-panel-favicon {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  flex-shrink: 0;
  object-fit: contain;
}

.comments-panel-url {
  color: #ffffff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.comments-panel-url:hover {
  text-decoration: underline;
}

.comments-panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.comments-panel-goto {
  width: 28px;
  height: 28px;
  cursor: pointer;
  opacity: 1;
  filter: brightness(1.3) saturate(1.5);
  transition: transform 0.1s ease;
}

.comments-panel-goto:hover {
  transform: scale(1.1);
}

.comments-panel-close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s ease;
  padding: 0;
}

.comments-panel-close:hover {
  background: rgba(255, 255, 255, 0.15);
}

.comments-panel-close svg {
  width: 20px;
  height: 20px;
  color: #fff;
}

/* Comment list */
.comments-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 20px;
}

.comments-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #999;
  font-size: 14px;
  text-align: center;
  gap: 8px;
}

.comments-empty svg {
  width: 48px;
  height: 48px;
  opacity: 0.3;
}

/* Input area */
.comments-input-area {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid #e8e8e8;
  flex-shrink: 0;
  background: #fafafa;
  border-radius: 0 0 16px 16px;
}

.comments-input {
  flex: 1;
  resize: none;
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.4;
  max-height: 120px;
  min-height: 40px;
  outline: none;
  transition: border-color 0.15s ease;
  background: #fff;
}

.comments-input:focus {
  border-color: #888;
}

.comments-input::placeholder {
  color: #aaa;
}

.comments-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: #FFCF25;
  color: #90773c;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease, transform 0.1s ease;
}

.comments-send-btn:hover {
  background: #f0c210;
}

.comments-send-btn:active {
  transform: scale(0.95);
}

.comments-send-btn svg {
  width: 18px;
  height: 18px;
}

/* Mobile: full width minus 24px each side, spaced from top/bottom */
@media (max-width: 600px) {
  .comments-panel {
    top: 24px;
    bottom: 24px;
    right: 24px;
    left: 24px;
    width: auto;
    border-radius: 16px;
    transform: translateX(calc(100% + 48px));
  }

  .comments-panel.open {
    transform: translateX(0);
  }

  .comments-panel-close {
    display: flex;
  }
}

/* ==================== Comment Items ==================== */

.comment-item {
  position: relative;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
}

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

.comment-content {
  display: flex;
  gap: 10px;
}

.comment-thread-line {
  display: none;
}

.comment-avatar-col {
  flex-shrink: 0;
}

.comment-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: #eee;
}

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

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

.comment-username {
  font-size: 13px;
  font-weight: 600;
  color: #1a1a1a;
}

.comment-time {
  font-size: 11px;
  color: #999;
}

.comment-edit-btn {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: #bbb;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s ease;
}

.comment-edit-btn:hover {
  color: #1a1a1a;
}

.comment-delete-btn {
  margin-left: 4px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: #bbb;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s ease;
}

.comment-delete-btn:hover {
  color: #e53935;
}

/* Edit mode */
.comment-edit-area {
  margin-top: 4px;
}

.comment-edit-input {
  width: 100%;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.45;
  resize: none;
  outline: none;
  transition: border-color 0.15s ease;
  box-sizing: border-box;
}

.comment-edit-input:focus {
  border-color: #ffcf25;
}

.comment-edit-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

.comment-edit-cancel,
.comment-edit-save {
  border: none;
  border-radius: 6px;
  padding: 4px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.comment-edit-cancel {
  background: #f0f0f0;
  color: #666;
}

.comment-edit-cancel:hover {
  background: #e0e0e0;
}

.comment-edit-save {
  background: #ffcf25;
  color: #1a1a1a;
}

.comment-edit-save:hover {
  background: #f5c518;
}

.comment-text {
  font-size: 14px;
  line-height: 1.45;
  color: #333;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

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

.comment-like-btn,
.comment-reply-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  color: #888;
  padding: 2px 0;
  transition: color 0.15s ease;
}

.comment-like-btn:hover {
  color: #e53935;
}

.comment-like-btn.liked {
  color: #e53935;
}

.comment-like-btn .like-icon {
  fill: currentColor;
}

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

.like-count,
.reply-count {
  font-size: 12px;
}

/* ==================== Nested Replies with Thread Lines ==================== */

.comment-replies {
  margin-top: 0;
  padding-left: 20px;
  position: relative;
}

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

/* Vertical thread line running down the left side of each reply group */
.comment-replies::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 12px;
  width: 1.5px;
  background: #ddd;
  border-radius: 1px;
}

/* Each reply item */
.comment-reply {
  position: relative;
  padding: 8px 0;
  border-bottom: none;
}

.comment-reply .comment-avatar {
  width: 26px;
  height: 26px;
}

.comment-reply .comment-text {
  font-size: 13px;
}

.comment-reply .comment-username {
  font-size: 12px;
}

/* Horizontal connector line from vertical thread to the reply */
.comment-reply .comment-thread-line {
  display: block;
  position: absolute;
  left: -12px;
  top: 21px;
  width: 12px;
  height: 1.5px;
  background: #ddd;
  border-radius: 1px;
}

/* Deeper nesting: each level shifts in with smaller avatars */
.comment-replies .comment-replies {
  padding-left: 18px;
}

.comment-replies .comment-replies::before {
  left: 7px;
}

.comment-replies .comment-replies .comment-reply .comment-thread-line {
  left: -11px;
  width: 11px;
}

.comment-replies .comment-replies .comment-reply .comment-avatar {
  width: 22px;
  height: 22px;
}

.comment-replies .comment-replies .comment-replies .comment-reply .comment-avatar {
  width: 20px;
  height: 20px;
}

/* ==================== Reply Bar ==================== */

.comments-reply-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  background: #f5f5f5;
  border-top: 1px solid #e8e8e8;
  flex-shrink: 0;
  font-size: 13px;
  color: #555;
}

.comments-reply-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comments-reply-cancel {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: #999;
  padding: 0 4px;
  line-height: 1;
  flex-shrink: 0;
}

.comments-reply-cancel:hover {
  color: #333;
}

/* ==================== Load More ==================== */

.comments-load-more {
  display: block;
  width: 100%;
  padding: 10px;
  margin-top: 8px;
  background: none;
  border: 1px solid #ddd;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: #666;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.comments-load-more:hover {
  background: #f5f5f5;
  border-color: #bbb;
}

/* ==================== Loading Spinner ==================== */

.comments-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px 0;
}

.comments-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #eee;
  border-top-color: #FFCF25;
  border-radius: 50%;
  animation: comments-spin 0.7s linear infinite;
}

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

/* ==================== POPUP MODAL ==================== */
.comments-popup-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  z-index: 100002;
  justify-content: center;
  align-items: center;
  pointer-events: none;
}
.comments-popup-overlay.active > * {
  pointer-events: auto;
}
.comments-popup-overlay.active {
  display: flex;
}
.comments-popup-box {
  position: relative;
  background: #ffcf25;
  border-radius: 16px;
  padding: 30px 25px 25px;
  width: 280px;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  animation: commentsPopupIn 0.2s ease-out;
}
@keyframes commentsPopupIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.comments-popup-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.comments-popup-close::before {
  content: "\00d7";
  font-size: 18px;
  color: #333;
  line-height: 1;
}
.comments-popup-close:hover {
  background: #f0f0f0;
}
.comments-popup-title {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}
.comments-popup-message {
  margin: 0 0 20px;
  font-size: 14px;
  color: #666;
  line-height: 1.4;
}
.comments-popup-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.comments-popup-btn {
  padding: 8px 22px;
  border: none;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: #fff;
  color: #333;
  transition: background 0.2s;
}
.comments-popup-btn:hover {
  background: #f0f0f0;
}
.comments-popup-btn.confirm {
  background: #e74c3c;
  color: #fff;
}
.comments-popup-btn.confirm:hover {
  background: #c0392b;
}
