/* ============================================
   Comments CSS
   Consolidated comment styles for forum, blog, and projects
   ============================================ */

/* ============================================
   Comment Base
   ============================================ */
.comment {
    padding: 0.75rem;
    background: rgb(var(--color-background-alt));
    border-radius: var(--radius-default);
    border: 1px solid rgb(var(--color-border-light));
    border-bottom: 1px solid rgba(var(--color-text), 0.1);
}

.comment-reply {
    border-left: 3px solid rgb(var(--color-info));
    background: rgba(var(--color-info), 0.03);
}

/* ============================================
   Comment Layout
   ============================================ */
.comment-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.comment-avatar {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    object-fit: cover;
    flex-shrink: 0;
}

.comment-meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex: 1;
}

.comment-body {
    font-size: 0.85rem;
    line-height: 1.5;
}

.comment-body p {
    margin: 0;
    font-size: inherit;
    white-space: pre-wrap;
}

.comment-content {
    flex: 1;
}

.comment-text {
    margin: 0;
    color: rgb(var(--color-text));
    font-size: 0.9rem;
    line-height: 1.5;
}

/* ============================================
   Comment Text Elements
   ============================================ */
.comment-author {
    font-weight: 600;
    font-size: 0.85rem;
    color: rgb(var(--color-text));
}

.comment-time {
    font-size: 0.75rem;
    color: rgb(var(--color-text-muted));
    flex-shrink: 0;
}

/* ============================================
   Comment Actions (inline buttons)
   ============================================ */
.comment-actions-inline {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: auto;
}

.comment-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    padding: 0.25rem 0.4rem;
    font-size: 0.75rem;
    color: rgb(var(--color-text-muted));
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.comment-action-btn:hover {
    background: rgba(var(--color-action), 0.1);
    color: rgb(var(--color-action));
}

.comment-action-btn.liked {
    color: rgb(var(--color-action));
}

/* Moderation actions */
.comment-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgb(var(--color-border-light));
}

.comment-action {
    background: none;
    border: none;
    font-size: 0.75rem;
    color: rgb(var(--color-text-secondary));
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: all var(--duration-fast);
}

.comment-action:hover {
    background: rgb(var(--color-surface));
    color: rgb(var(--color-text));
}

.comment-action.approve {
    color: rgb(var(--color-success));
}

.comment-action.approve:hover {
    background: rgba(var(--color-success), 0.15);
}

.comment-action.reject {
    color: rgb(var(--color-error));
}

.comment-action.reject:hover {
    background: rgba(var(--color-error), 0.15);
}

/* ============================================
   Comment Status Badge
   ============================================ */
.comment-status {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-sm);
    margin-left: 0.5rem;
}

.comment-status.pending {
    background: rgba(var(--color-warning), 0.2);
    color: rgb(var(--color-warning));
}

/* ============================================
   Comment Edit Mode
   ============================================ */
.comment-edit-textarea {
    font-family: inherit;
    font-size: 0.95rem;
    width: 100%;
    padding: 0.5rem;
    border: 1px solid rgb(var(--color-border-muted));
    border-radius: var(--radius-default);
    resize: vertical;
    min-height: 60px;
    margin-bottom: 0.5rem;
}

.comment-edit-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.comment-edit-footer-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.comment-edit-footer .char-count {
    font-size: 0.75rem;
    color: rgb(var(--color-text-muted));
}

.comment-edit-actions {
    display: flex;
    gap: 0.5rem;
}

/* ============================================
   Comment Form
   ============================================ */
.comment-form-container {
    margin-bottom: 2rem;
}

.comment-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.comment-form textarea {
    font-family: inherit;
    font-size: 1rem;
    padding: 0.75rem;
    border: 1px solid rgb(var(--color-border-muted));
    border-radius: var(--radius-md);
    resize: vertical;
    min-height: 80px;
    transition: border-color var(--duration-fast);
}

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

.comment-form-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.comment-form-footer-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

/* Sentiment indicator */
.sentiment-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
}

.comment-form-footer .sentiment-indicator {
    width: 60%;
}

.sentiment-bar {
    width: 60px;
    height: 6px;
    background: rgb(var(--color-surface-elevated));
    border-radius: var(--radius-full);
    overflow: hidden;
}

.comment-form-footer .sentiment-bar {
    flex: 1;
    height: 8px;
    background: rgba(var(--color-border), 0.3);
}

.sentiment-fill {
    height: 100%;
    width: 0;
    border-radius: var(--radius-full);
    transition: width 0.3s, background 0.3s;
}

.sentiment-fill.positive {
    background: rgb(var(--color-success));
}

.sentiment-fill.neutral {
    background: rgb(var(--color-warning));
}

.sentiment-fill.negative {
    background: rgb(var(--color-error));
}

.sentiment-label {
    font-size: 0.75rem;
    color: rgb(var(--color-text-muted));
    min-width: 50px;
}

.char-count {
    font-size: 0.8rem;
    color: rgb(var(--color-text-secondary));
}

.btn-submit-comment {
    background: rgb(var(--color-info));
    color: rgb(var(--color-background));
    border: none;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: opacity var(--duration-fast);
}

.btn-submit-comment:hover {
    opacity: 0.9;
}

.btn-submit-comment:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.moderation-notice {
    font-size: 0.8rem;
    color: rgb(var(--color-text-secondary));
    margin-top: 0.5rem;
}

/* ============================================
   Comments Section Container
   ============================================ */
.comments-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgb(var(--color-border-muted));
}

.comments-header {
    font-size: 1.5rem;
    font-weight: 600;
    color: rgb(var(--color-text));
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.comments-icon {
    font-size: 1.25rem;
}

.comments-count {
    font-size: 1rem;
    font-weight: 400;
    color: rgb(var(--color-text-secondary));
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.comments-loading,
.comments-empty {
    text-align: center;
    padding: 2rem;
    color: rgb(var(--color-text-secondary));
    font-size: 0.95rem;
}

/* ============================================
   Comments Toggle
   ============================================ */
.comments-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: transparent;
    border: none;
    color: rgb(var(--color-action));
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.5rem 0;
    cursor: pointer;
    transition: color 0.2s;
}

.comments-toggle:hover {
    color: rgb(var(--color-action-dark, var(--color-action)));
    text-decoration: underline;
}

.comments-toggle .toggle-icon {
    font-size: 0.7rem;
    transition: transform 0.2s;
}

/* ============================================
   Comments Login Prompt
   ============================================ */
.comment-login-prompt {
    background: rgb(var(--color-background-alt));
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 2rem;
    text-align: center;
}

.comment-login-prompt p {
    font-size: 0.95rem;
    color: rgb(var(--color-text-secondary));
    margin: 0;
}

.comment-login-prompt a {
    color: rgb(var(--color-info));
    font-weight: 500;
}

/* ============================================
   Comments Load More
   ============================================ */
.comments-load-more {
    text-align: center;
    margin-top: 1.5rem;
}

.btn-load-more {
    background: rgb(var(--color-background));
    border: 1px solid rgb(var(--color-border-muted));
    padding: 0.6rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--duration-fast);
}

.btn-load-more:hover {
    background: rgb(var(--color-surface));
    border-color: rgb(var(--color-text-secondary));
}

/* ============================================
   Comment Toast Notifications
   ============================================ */
.comment-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    opacity: 0;
    transition: all var(--duration-normal);
    z-index: 1000;
}

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

.comment-toast.success {
    background: rgb(var(--color-success));
    color: rgb(var(--color-background));
}

.comment-toast.error {
    background: rgb(var(--color-error));
    color: rgb(var(--color-background));
}

/* ============================================
   Legacy: comment-item structure
   (Used by some older forum code)
   ============================================ */
.comment-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
}

/* ============================================
   Legacy: inline-reply structure
   (Keeping for backwards compat)
   ============================================ */
.inline-reply {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(var(--color-text), 0.1);
}

.inline-reply.nested-reply {
    margin-left: 2.5rem;
    padding-left: 0.75rem;
    border-left: 2px solid rgba(var(--color-border), 0.15);
}

.inline-reply-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.inline-reply-content {
    flex: 1;
}

/* ============================================
   Mobile Responsive
   ============================================ */
@media (max-width: 768px) {
    .comments-header {
        font-size: 1.25rem;
    }

    .comment {
        padding: 0.75rem;
    }

    .comment-form-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .comment-form-footer-left {
        justify-content: space-between;
    }

    .sentiment-indicator {
        width: 100%;
    }
}
