/* Advanced Comment System Styles - Refined to match UI/UX design */


.comments-header {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #1e293b;
}

.comments-count-badge {
    color: #249E94;
    font-weight: 800;
}

.comment-form {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: var(--pd-block);
}

.comment-form textarea {
    width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 16px;
    min-height: 120px;
    margin-bottom: 16px;
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
}

.comment-form textarea:focus {
    border-color: #249E94;
}

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

.comment-item {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: var(--pd-block);
    margin-bottom: var(--pd-block);
    position: relative;
}

/* Threading line */
.comment-item::before {
    content: '';
    position: absolute;
    top: 100%;
    right: 48px; /* Center of avatar in RTL */
    width: 1px;
    height: 24px;
    background-color: #e2e8f0;
    display: none;
}
.replies-list .comment-wrapper .comment-item::before {
    display: none !important;
}
.has-replies > .comment-item::before {
    display: block;
}

.comment-item.is-expert {
    border-color: #249E94;
    background-color: #f0fdfa;
}

.remove-preview {
    background-color: #ef4444;
    color: #fff;
    border: none;
    z-index: 10;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-preview:hover {
    background-color: #dc2626;
}

.border-dashed {
    border: 2px dashed #e2e8f0;
}

.comment-attachment a {
    display: block;
    border: 1px solid #f1f5f9;
}

.comment-attachment a:hover {
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.comment-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar-container {
    position: relative;
    width: 48px;
    height: 48px;
}

.comment-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    background: #f1f5f9;
}

.online-dot {
    position: absolute;
    top: 5px;
    right: 0;
    width: 8px;
    height: 8px;
    background-color: #22c55e;
    border-radius: 50%;
}

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

.comment-header.ltr-meta {
    flex-direction: row-reverse;
}

.comment-header.ltr-meta .comment-user-info {
    flex-direction: row-reverse;
}

.comment-author {
    font-weight: 600;
    font-size: 0.95rem;
    color: #1e293b;
    margin-bottom: 2px;
}

.comment-date {
    font-size: 0.8rem;
    color: #94a3b8;
}

.user-level-badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 6px;
    color: #fff;
    font-weight: 700;
    margin-right: 4px;
    background-color: #94a3b8;
}
.user-level-badge.level-2 { background-color: #3b82f6; }
.user-level-badge.level-3 { background-color: #a855f7; }
.user-level-badge.level-4 { background-color: #f97316; }
.user-level-badge.level-5 { background-color: #ef4444; box-shadow: 0 0 10px rgba(239, 68, 68, 0.4); }

.header-actions {
    display: flex;
    gap: 8px;
}

.comment-header-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.2s;
}

.comment-header-btn:hover {
    background-color: #f8fafc;
    color: #1e293b;
    border-color: #cbd5e1;
}

.comment-header-btn.report-btn:hover { color: #ef4444; }
.comment-header-btn.edit-btn:hover { color: #3b82f6; }

.comment-content {
    font-size: 0.95rem;
    line-height: 1.8;
    color: #334155;
}
.comment-body-text {
    margin-bottom: 12px;
}
.comment-body-text p {
    margin-bottom: 12px;
}

.comment-body-text blockquote {
    border-right: 4px solid #249E94;
    padding: 8px 16px;
    margin: 16px 0;
    background: #f0fdfa;
    color: #475569;
    border-radius: 4px 0 0 4px;
}

.comment-body-text ul,
.comment-body-text ol {
    padding-right: 28px;
    margin-bottom: 16px;
    list-style: inherit;
}

.comment-body-text li {
    margin-bottom: 4px;
}

.comment-body-text b, .comment-body-text strong {
    font-weight: 700;
    color: #1e293b;
}

.comment-body-text i, .comment-body-text em {
    font-style: italic;
}

.comment-body-text p:last-child,
.comment-body-text ul:last-child,
.comment-body-text ol:last-child,
.comment-body-text blockquote:last-child {
    margin-bottom: 0;
}

.comment-content a.mention, a.mention {
    color: #249E94;
    font-weight: 700;
    text-decoration: none;
    display: inline-block;
    direction: ltr;
}

.reply-preview-block {
    background-color: #f8fafc;
    border-right: 3px solid #249E94;
    padding: 8px 12px;
    border-radius: 4px;
    margin-bottom: 12px;
    font-size: 0.85rem;
    cursor: default;
    display: block;
}

.reply-preview-author {
    color: #249E94;
    font-weight: 600;
    display: inline-block;
    direction: ltr;
    text-align: right;
}

.reply-preview-content {
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

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

.footer-right {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.comment-footer-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    color: #64748b;
    cursor: pointer;
    transition: color 0.2s;
    position: relative;
}

.comment-footer-btn:hover {
    color: #249E94;
}

.comment-footer-btn.reply-btn {
    color: #249E94;
}

.reaction-pill {
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: #f1f5f9;
    border-radius: 20px;
    height: 28px;
    padding: 0 14px 0 7px;
}

.reaction-pill-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 700;
    color: #64748b;
    cursor: pointer;
}

.reaction-pill-item.active {
    color: #249E94;
}

.replies-container {
    margin-right: 48px;
    position: relative;
}

.replies-container .comment-item.is-reply {
    /* No additional indentation for reply-to-reply as per requirement */
}

/* Vertical line for replies */
.replies-container::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 24px;
    width: 1px;
    background-color: #e2e8f0;
}

.reactions-popover {
    position: absolute;
    bottom: -45px;
    left: 0;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 100px;
    padding: 3px 10px 0;
    display: flex;
    gap: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    z-index: 50;
    display: none;
}

.reactions-popover.show {
    display: flex;
}

.emoji-btn {
    font-size: 1.25rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: transform 0.1s;
}

.emoji-btn:hover {
    transform: scale(1.2);
}

.attachment-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background-color: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #334155;
    margin-top: 12px;
    cursor: pointer;
}

.attachment-btn:hover {
    background-color: #e2e8f0;
}

.header-actions { margin-right: auto; margin-left: 0; }
.user-level-badge { margin-right: 5px; margin-left: 5px; }
.replies-container { margin-right: 48px; border-right: none; }
.replies-container::before { right: -23px; }
.has-replies > .comment-item::before { right: 24px; }

.thread-list .replies-container {
    margin: unset;
    border: none
}
.thread-list .replies-container::before {
    right: unset;
    display: none
}
/* Mention Tag UI */
.mention-tag-area {
    background: #f8fafc;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    cursor: text;
}

.mention-tag-input {
    border: none !important;
    background: transparent !important;
    padding: 4px 0 !important;
    flex-grow: 1;
    min-width: 120px;
    outline: none !important;
    box-shadow: none !important;
}

.mention-tag {
    background: #249E94;
    color: #fff;
    padding: 2px 10px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    animation: tag-pop 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes tag-pop {
    from { transform: scale(0.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.mention-tag .remove-tag {
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    opacity: 0.8;
}

.mention-tag .remove-tag:hover { opacity: 1; }

.mention-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #249E94;
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    margin-top: 5px;
}

.suggestion-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.suggestion-item:hover { background: #f0fdfa; }

.suggestion-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.suggestion-name {
    font-weight: 700;
    font-size: 0.85rem;
    color: #1e293b;
}

.suggestion-username {
    font-size: 0.75rem;
    color: #64748b;
    direction: ltr;
}

@media (max-width: 600px) {
    .mention-suggestions {
        position: fixed;
        bottom: 80px;
        top: auto;
        left: 12px;
        right: 12px;
        max-height: 160px;
    }
}

/* Highlight effect for anchor scroll */
.highlight-comment {
    animation: highlight-fade 3s ease-out;
}

@keyframes highlight-fade {
    0% {
        box-shadow: 0 0 0 4px rgba(36, 158, 148, 0.4);
        border-color: #249E94;
    }
    100% {
        box-shadow: 0 0 0 0 rgba(36, 158, 148, 0);
        border-color: #e2e8f0;
    }
}

.comment-type-radio {
    width: 18px;
    height: 18px;
    accent-color: #249E94;
    cursor: pointer;
}

.upload-zone {
    border: 2px dashed #e2e8f0;
}

.upload-zone:hover, .upload-zone.drag-over {
    border-color: #249E94;
    background-color: #f0fdfa;
    transform: scale(1.01);
}

.upload-zone {
    transition: all 0.2s ease;
}

/* Comments Filters & Sorting */
.comments-filters {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    padding: 20px;
    margin-top: 32px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}

#comments-controls {
    container-type: inline-size;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between
}
.filter-group-container {
    order: 1
}
@container (max-width: 754px) {
    .filter-group-container {
        width: 100%;
        order: 0;
    }
    .sort-group {
        flex-grow: 1;
    }
}
.filter-toggle-group {
    background-color: #f1f5f9 !important;
    padding: 4px !important;
    border-radius: 10px !important;
    display: flex !important;
    width: 100%;
}

.filter-toggle-group .pill-btn {
    font-size: 13px;
    color: #64748b;
    padding: 4px 20px;
    flex: 1;
    text-align: center;
}

.filter-toggle-group .pill-btn.active {
    background-color: #fff !important;
    color: #000 !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05) !important;
}

.sort-item {
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: color 0.2s;
    white-space: nowrap;
}

.sort-item:hover {
    color: #1e293b;
}

.sort-item.active {
    color: #249E94;
    position: relative;
}

.sort-group .icon-size-4 {
    color: #1e293b;
}

@media (max-width: 600px) {
    .comments-filters {
        padding: 16px;
        gap: 20px !important;
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 20px;
    }

    .filter-toggle-group .pill-btn {
        font-size: 13px;
        padding: 8px 10px;
    }

    .sort-group {
        flex-direction: row;
        justify-content: space-between;
        width: 100%;
        gap: 0 !important;
        margin-top: 4px;
    }

    .sort-group .d-flex.gap-1-5 {
        gap: 16px !important;
    }

    .sort-item {
        font-size: 0.85rem;
    }
}

/* Thread Modal Styles */
.thread-modal-container {
    display: flex !important;
    flex-direction: column !important;
    max-height: 80vh !important;
    height: auto !important;
}

.thread-modal-header {
    flex-shrink: 0;
    background: #fff;
    z-index: 10;
}

.sticky-info {
    flex-shrink: 0;
    background: #f8fafc;
    z-index: 5;
}

.thread-modal-body {
    flex: 1;
    overflow-y: auto;
    background: #fff;
}

.thread-target-info {
    border: 1px solid #e2e8f0;
}

.comment-wrapper.has-replies .comment-item::before {
    display: block;
}

/* Modal responsive full-height on mobile */
@media (max-width: 600px) {
    .thread-modal-container {
        max-height: 95vh !important;
    }

    .thread-modal-body {
        padding-bottom: 40px;
    }
}
.thread-reply-item:last-child {
   border: none;
}

.infinite-scroll-sentinel {
    min-height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.sentinel-loader {
    animation: fade-in 0.3s ease-out;
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.comment-fade-in {
    animation: fade-in 0.5s ease-out forwards;
}