/* ==========================================================================
   IMLAB Comments — Inline Form + Reactions + Nested Reply Visual Separation
   ========================================================================== */

/* ---------------------------------------------------
 * FORCE HIDE: Email, Website, Cookies fields
 * Safety net — hide from ALL comment forms regardless of source
 * --------------------------------------------------- */
.comment-form-email,
.comment-form-url,
.comment-form-cookies-consent,
p.comment-form-email,
p.comment-form-url,
p.comment-form-cookies-consent {
  display: none !important;
}

/* ---------------------------------------------------
 * HIDE everything in cs-entry__comments-inner except .imlab-comment-respond
 * --------------------------------------------------- */
.cs-entry__comments-inner > *:not(.imlab-comment-respond) {
  display: none !important;
}

/* ---------------------------------------------------
 * Comment List — Reset & Layout
 * --------------------------------------------------- */
.imlab-comments {
  --imlab-accent: var(--cs-color-accent, #6366f1);
  --imlab-accent-light: color-mix(in srgb, var(--imlab-accent) 12%, transparent);
  --imlab-border: var(--cs-color-border, #e5e7eb);
  --imlab-bg: var(--cs-layout-background, #ffffff);
  --imlab-bg-alt: var(--cs-layout-background, #f9fafb);
  --imlab-text: var(--cs-color-primary, #1f2937);
  --imlab-text-muted: var(--cs-color-secondary, #6b7280);
  --imlab-radius: 12px;
  --imlab-gap: 20px;
  --imlab-blue: #3b82f6;
}

[data-scheme="dark"] .imlab-comments {
  --imlab-border: var(--cs-color-border, #343434);
  --imlab-bg: var(--cs-layout-background, #232323);
  --imlab-bg-alt: var(--cs-layout-background, #232323);
}

.imlab-comments__title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: var(--imlab-gap);
}

/* ---------------------------------------------------
 * Nested Replies — Visual Separation
 * --------------------------------------------------- */
.imlab-comment-list {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--imlab-gap) 0;
}

.imlab-comment-list > li {
  margin-bottom: var(--imlab-gap);
}

.imlab-comment-list .comment-body {
  position: relative;
  padding: var(--imlab-gap);
  border-radius: var(--imlab-radius);
  background: var(--imlab-bg);
  border: 1px solid var(--imlab-border);
  transition: box-shadow 0.2s ease;
}

.imlab-comment-list .comment-body:hover {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

/* Nested replies — indented with colored left border */
.imlab-comment-list .children {
  list-style: none;
  margin: 12px 0 0 0;
  padding: 0 0 0 24px;
  border-left: 3px solid var(--imlab-accent);
  position: relative;
}

.imlab-comment-list .children::before {
  content: '';
  position: absolute;
  left: -3px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(to bottom, var(--imlab-accent), transparent);
  border-radius: 3px;
}

.imlab-comment-list .children > li {
  margin-top: 12px;
}

.imlab-comment-list .children .comment-body {
  background: var(--imlab-bg-alt);
  border-color: transparent;
  border-radius: 8px;
}

/* Deeper nesting levels */
.imlab-comment-list .children .children {
  border-left-color: color-mix(in srgb, var(--imlab-accent) 50%, transparent);
}

.imlab-comment-list .children .children .children {
  border-left-color: color-mix(in srgb, var(--imlab-accent) 30%, transparent);
}

/* Reply depth indicator badge */
.imlab-comment-list .children .comment-body::before {
  content: '\21B3';
  position: absolute;
  left: -20px;
  top: 18px;
  font-size: 14px;
  color: var(--imlab-accent);
  font-weight: 700;
  line-height: 1;
}

/* Comment author & meta */
.imlab-comment-list .comment-meta {
  margin-bottom: 10px;
}

.imlab-comment-list .comment-author .fn {
  font-weight: 600;
  font-size: 0.95rem;
}

.imlab-comment-list .comment-metadata {
  font-size: 0.8rem;
  color: var(--imlab-text-muted);
}

/* Reply link styling */
.imlab-comment-list .reply {
  margin-top: 10px;
}

.imlab-comment-list .comment-reply-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--imlab-accent);
  text-decoration: none;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--imlab-accent);
  background: transparent;
  transition: all 0.2s ease;
  cursor: pointer;
}

.imlab-comment-list .comment-reply-link:hover {
  background: var(--imlab-accent);
  color: #fff;
}

/* ---------------------------------------------------
 * Reactions Bar (below each comment)
 * --------------------------------------------------- */
.imlab-reactions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.imlab-reaction-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border: 1px solid var(--imlab-border);
  border-radius: 20px;
  background: var(--imlab-bg);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1.4;
}

.imlab-reaction-btn:hover {
  border-color: var(--imlab-accent);
  background: var(--imlab-accent-light);
}

.imlab-reaction-btn--active {
  border-color: var(--imlab-accent);
  background: var(--imlab-accent-light);
}

.imlab-reaction-btn__emoji {
  font-size: 1rem;
}

.imlab-reaction-btn__count {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--imlab-text-muted);
  min-width: 8px;
}

.imlab-reaction-btn--active .imlab-reaction-btn__count {
  color: var(--imlab-accent);
}

/* ---------------------------------------------------
 * Inline Comment Form
 * --------------------------------------------------- */
.imlab-comment-respond {
  margin-top: 0;
}

/* Cancel reply link */
#cancel-comment-reply-link {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--imlab-text-muted);
  text-decoration: none;
  margin-bottom: 12px;
}

#cancel-comment-reply-link:hover {
  color: var(--imlab-blue);
}

/* Form container — no outer border */
.imlab-comment-form {
  background: var(--imlab-bg);
  border: none;
  border-radius: var(--imlab-radius);
  padding: var(--imlab-gap);
}

/* Author field */
.imlab-comment-form__fields {
  margin-bottom: 12px;
}

.imlab-comment-form__field input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--imlab-border);
  border-radius: 8px;
  background: var(--imlab-bg);
  font-size: 0.9rem;
  color: var(--imlab-text);
  outline: none;
  transition: border-color 0.3s ease;
  box-sizing: border-box;
}

.imlab-comment-form__field input:hover {
  border-color: var(--imlab-blue);
}

.imlab-comment-form__field input:focus {
  border-color: var(--imlab-blue);
}

.imlab-comment-form__field input::placeholder {
  color: var(--imlab-text-muted);
}

/* Textarea */
.imlab-comment-form__textarea-wrap textarea {
  width: 100%;
  min-height: 80px;
  max-height: 300px;
  padding: 12px 14px;
  border: 1px solid var(--imlab-border);
  border-radius: 8px;
  background: var(--imlab-bg);
  font-size: 0.9rem;
  color: var(--imlab-text);
  outline: none;
  resize: none;
  overflow-y: auto;
  transition: border-color 0.3s ease;
  font-family: inherit;
  box-sizing: border-box;
}

.imlab-comment-form__textarea-wrap textarea:hover {
  border-color: var(--imlab-blue);
}

.imlab-comment-form__textarea-wrap textarea:focus {
  border-color: var(--imlab-blue);
}

.imlab-comment-form__textarea-wrap textarea::placeholder {
  color: var(--imlab-text-muted);
}

/* Toolbar — submit */
.imlab-comment-form__toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: 10px;
}

/* Submit button */
.imlab-comment-form__submit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  border: none;
  border-radius: 8px;
  background: var(--imlab-accent);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.imlab-comment-form__submit:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.imlab-comment-form__submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.imlab-comment-form__submit--loading {
  position: relative;
}

.imlab-comment-form__submit--loading::after {
  content: '';
  position: absolute;
  right: 8px;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: imlab-spin 0.6s linear infinite;
}

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

/* ---------------------------------------------------
 * Notice
 * --------------------------------------------------- */
.imlab-comment-form__notice {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
}

.imlab-comment-form__notice--success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.imlab-comment-form__notice--error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.imlab-comment-form__notice--info {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

[data-scheme="dark"] .imlab-comment-form__notice--success {
  background: rgba(16, 185, 129, 0.1);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.2);
}

[data-scheme="dark"] .imlab-comment-form__notice--error {
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.2);
}

[data-scheme="dark"] .imlab-comment-form__notice--info {
  background: rgba(59, 130, 246, 0.1);
  color: #93c5fd;
  border-color: rgba(59, 130, 246, 0.2);
}

/* ---------------------------------------------------
 * New Comment Animation
 * --------------------------------------------------- */
.imlab-comment--new {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.imlab-comment--new.imlab-comment--visible {
  opacity: 1;
  transform: translateY(0);
}

/* ---------------------------------------------------
 * Mobile Adjustments
 * --------------------------------------------------- */
@media (max-width: 600px) {
  .imlab-comment-list .children {
    padding-left: 16px;
  }

  .imlab-comment-list .children .comment-body::before {
    left: -14px;
  }

  .imlab-comment-list .comment-body {
    padding: 14px;
  }

  .imlab-comment-form {
    padding: 14px;
  }
}
