/* ==============================
   Variables visuales del módulo
   Interactúa con:
   - #commentPanel.comment-panel
   - Todos los descendientes del módulo de comentarios
   ============================== */
.comment-panel {
    --comment-bg: #ffffff;
    --comment-soft-bg: #f8fafc;
    --comment-card-bg: #f9fafb;
    --comment-border: #e5e7eb;
    --comment-border-strong: #cbd5e1;
    --comment-text: #111827;
    --comment-muted: #6b7280;
    --comment-muted-strong: #4b5563;
    --comment-accent: #0f172a;
    --comment-radius: 1rem;
    --comment-radius-sm: 0.75rem;
    background: var(--comment-bg);
}

/* ==============================
   Editor superior de comentarios
   Interactúa con:
   - .comment-composer
   - .comment-composer-box
   - .comment-composer-input-wrap
   - #commentInput.comment-composer-input
   - #commentCounter
   - #commentSubmitButton.comment-submit-btn
   ============================== */
.comment-composer {
    background: var(--comment-soft-bg);
}

.comment-composer-box,
.comment-content {
    min-width: 0;
}

.comment-composer-input-wrap,
.comment-inline-editor-wrapper {
    background: var(--comment-bg);
    border: 1px solid var(--comment-border);
    border-radius: var(--comment-radius);
}

.comment-composer-input-wrap {
    padding: 0.65rem;
}

.comment-composer-input,
.comment-inline-editor-input {
    min-height: 6.5rem;
    border: 0;
    box-shadow: none;
    background: transparent;
    color: var(--comment-text);
    font-size: 0.95rem;
    line-height: 1.6;
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

.comment-composer-input:focus,
.comment-inline-editor-input:focus {
    border: 0;
    box-shadow: none;
    outline: none;
}

/* ==============================
   Placeholder de editores contenteditable
   Interactúa con:
   - #commentInput.comment-composer-input.is-empty::before
   - .comment-inline-editor-input.is-empty::before
   ============================== */
.comment-composer-input[contenteditable="true"].is-empty::before,
.comment-inline-editor-input[contenteditable="true"].is-empty::before {
    content: attr(data-placeholder);
    color: var(--comment-muted);
    pointer-events: none;
}

/* ==============================
   Botones del editor y publicación
   Interactúa con:
   - .comment-toolbar-btn
   - .comment-top-editor-format-button
   - .comment-inline-toolbar-btn
   - #commentSubmitButton.comment-submit-btn
   - .comment-inline-editor-submit
   - .comment-inline-editor-cancel
   ============================== */
.comment-toolbar-btn,
.comment-inline-toolbar-btn,
.comment-replies-toggle-button {
    border: 1px solid var(--comment-border);
    background: var(--comment-bg);
    color: var(--comment-muted-strong);
    border-radius: 999px;
    font-weight: 700;
}

.comment-toolbar-btn,
.comment-inline-toolbar-btn {
    min-width: 2.25rem;
}

.comment-toolbar-btn:hover,
.comment-inline-toolbar-btn:hover,
.comment-replies-toggle-button:hover {
    background: var(--comment-soft-bg);
    border-color: var(--comment-border-strong);
    color: var(--comment-accent);
}

.comment-submit-btn,
.comment-inline-editor-submit {
    border: 0;
    border-radius: 999px;
    background: var(--comment-accent);
    color: #ffffff;
    font-weight: 700;
}

.comment-submit-btn:hover,
.comment-inline-editor-submit:hover {
    background: #1f2937;
    color: #ffffff;
}

/* ==============================
   Lista y tarjetas de comentarios
   Interactúa con:
   - #commentThread.comment-thread
   - .comment-node
   - .comment-card
   - .comment-card-deleted
   ============================== */
.comment-thread {
    background: var(--comment-bg);
}

.comment-node + .comment-node {
    margin-top: 1.1rem;
}

.comment-card {
    background: var(--comment-card-bg);
    border: 1px solid var(--comment-border);
    border-radius: var(--comment-radius);
    padding: 1rem;
}

.comment-card-deleted {
    background: #f3f4f6;
    opacity: 0.78;
}

/* ==============================
   Avatares
   Interactúa con:
   - .comment-avatar
   - .comment-avatar-lg
   - .comment-avatar-image
   ============================== */
.comment-avatar {
    width: 2.15rem;
    height: 2.15rem;
    min-width: 2.15rem;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e5e7eb;
    color: var(--comment-text);
    font-size: 0.78rem;
    font-weight: 800;
    flex-shrink: 0;
}

.comment-avatar-lg {
    width: 2.5rem;
    height: 2.5rem;
    min-width: 2.5rem;
}

.comment-avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ==============================
   Encabezado y contenido del comentario
   Interactúa con:
   - .comment-author
   - .comment-badge
   - .comment-badge-owner
   - .comment-time
   - .comment-edited
   - .comment-text
   - .comment-text p:last-child
   ============================== */
.comment-author {
    color: var(--comment-text);
    font-size: 0.92rem;
    font-weight: 800;
}

.comment-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.18rem 0.55rem;
    border-radius: 999px;
    background: var(--comment-accent);
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 700;
}

.comment-badge-owner {
    background: #0f766e;
}

.comment-time,
.comment-edited,
.comment-replying-to,
.comment-reactions,
.comment-replies-count {
    color: var(--comment-muted);
    font-size: 0.78rem;
}

.comment-text {
    color: #1f2937;
    font-size: 0.93rem;
    line-height: 1.6;
    word-break: break-word;
}

.comment-text p:last-child {
    margin-bottom: 0;
}

/* ==============================
   Acciones de comentarios
   Interactúa con:
   - .comment-actions
   - .comment-action-link
   - .comment-reply-button
   - .comment-reaction-button
   - .comment-replies-toggle-button
   - .comment-menu-btn
   ============================== */
.comment-actions {
    font-size: 0.84rem;
}

.comment-action-link {
    color: var(--comment-muted-strong);
    font-weight: 700;
}

.comment-action-link:hover,
.comment-action-link.active {
    color: var(--comment-accent);
}

.comment-replies-toggle-button {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--comment-muted-strong);
    font-size: 0.84rem;
}

.comment-menu-btn {
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--comment-muted);
    padding: 0.1rem 0.4rem;
    font-size: 1rem;
    line-height: 1;
}

.comment-menu-btn:hover {
    background: #eef2f7;
    color: var(--comment-accent);
}

/* ==============================
   Respuestas e hilo
   Interactúa con:
   - .comment-children
   - .comment-node-child
   - .comment-replies-collapse
   - #commentReplies{id}
   ============================== */
.comment-children {
    margin-top: 0.85rem;
    padding-left: 0.9rem;
    margin-left: 0.15rem;
    border-left: 1px solid var(--comment-border);
}

.comment-node-child + .comment-node-child {
    margin-top: 0.8rem;
}

.comment-replies-collapse {
    overflow: hidden;
}

/* ==============================
   Menciones y contexto de respuesta
   Interactúa con:
   - .comment-replying-to
   - .comment-mention
   - .comment-inline-editor-context
   ============================== */
.comment-mention {
    color: var(--comment-accent);
    font-weight: 800;
}

.comment-inline-editor-context {
    margin-bottom: 0.5rem;
    padding-bottom: 0.45rem;
    border-bottom: 1px solid var(--comment-border);
}

/* ==============================
   Editor embebido insertado por JS
   Interactúa con:
   - .comment-inline-editor-wrapper
   - .comment-inline-editor-input
   - .comment-inline-editor-counter
   - .comment-inline-editor-cancel
   - .comment-inline-editor-submit
   ============================== */
.comment-inline-editor-wrapper {
    margin-top: 0.75rem;
    padding: 0.8rem;
}

.comment-inline-editor-input {
    min-height: 5rem;
    padding: 0.7rem;
    border-radius: var(--comment-radius-sm);
}

/* ==============================
   Citas en comentarios y editores
   Interactúa con:
   - .comment-text blockquote
   - #commentInput.comment-composer-input blockquote
   - .comment-inline-editor-input blockquote
   ============================== */
.comment-text blockquote,
.comment-composer-input blockquote,
.comment-inline-editor-input blockquote {
    margin: 0.7rem 0;
    padding: 0.65rem 0.85rem;
    border-left: 4px solid var(--comment-border-strong);
    border-radius: var(--comment-radius-sm);
    background: #f3f4f6;
    color: #374151;
}

.comment-text blockquote:last-child {
    margin-bottom: 0;
}

/* ==============================
   Ajustes responsivos
   Interactúa con:
   - .comment-composer
   - .comment-thread
   - .comment-card
   - .comment-avatar
   - .comment-avatar-lg
   - .comment-children
   - .comment-actions
   - .comment-composer-toolbar
   ============================== */
@media (max-width: 767.98px) {

    .comment-composer,
    .comment-thread {
        padding-left: 0.85rem !important;
        padding-right: 0.85rem !important;
    }

    .comment-card {
        padding: 0.72rem;
        border-radius: 0.85rem;
    }

    .comment-avatar {
        width: 1.75rem;
        height: 1.75rem;
        min-width: 1.75rem;
        font-size: 0.65rem;
    }

    .comment-avatar-lg {
        width: 2rem;
        height: 2rem;
        min-width: 2rem;
    }

    .comment-children {
        padding-left: 0.55rem;
        margin-left: 0.1rem;
        border-left-width: 1px;
    }

    .comment-node-child + .comment-node-child {
        margin-top: 0.65rem;
    }

    .comment-actions,
    .comment-composer-toolbar {
        gap: 0.45rem !important;
        flex-wrap: wrap;
    }

    .comment-text,
    .comment-composer-input,
    .comment-inline-editor-input {
        font-size: 0.84rem;
        line-height: 1.5;
    }

    .comment-author {
        font-size: 0.8rem;
    }

    .comment-time,
    .comment-edited,
    .comment-replying-to,
    .comment-reactions,
    .comment-actions,
    .comment-action-link,
    .comment-replies-toggle-button {
        font-size: 0.72rem;
    }

    .comment-badge {
        font-size: 0.6rem;
        padding: 0.12rem 0.38rem;
    }

    .comment-inline-editor-input {
        min-height: 4.3rem;
        padding: 0.55rem;
    }

    .comment-composer-input {
        min-height: 5rem;
    }
}