/* ========================================
   ESTILOS DEL SISTEMA DE COMENTARIOS
   ======================================== */
.comments,
.comments-header,
.comment-form-container {
    width: 100%;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.comments {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 20px;
}

/* --- Muro Header --- */
.comments-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 0;
}

.comments-count {
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
}

.comments-sort {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #94a3b8;
    font-size: 0.9rem;
    cursor: pointer;
    transition: color 0.2s;
    position: relative;
}

.comments-sort:hover {
    color: #e2e8f0;
}

.sort-label {
    opacity: 0.8;
}

.sort-value {
    color: #fff;
    font-weight: 600;
}

.comments-sort i {
    font-size: 0.8rem;
    margin-top: 2px;
    transition: transform 0.2s;
}

.comments-sort.open i {
    transform: rotate(180deg);
}

/* Sort Options Dropdown */
.sort-options {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: #1e1e1e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px 0;
    min-width: 140px;
    display: none;
    z-index: 100;
    list-style: none;
}

.comments-sort.open .sort-options {
    display: block;
}

.sort-options li {
    padding: 8px 16px;
    color: #94a3b8;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.sort-options li:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.sort-options li.active {
    color: #fff;
    font-weight: 600;
}


.comment {
    display: flex;
    gap: 12px;
    padding: 0;
    position: relative;
}

/* --- Avatar --- */
.avatar-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 2;
}

.avatar-container img,
.avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50% !important;
    object-fit: cover;
    background: #334155;
    aspect-ratio: 1/1;
}

.avatar-reply {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
}

/* --- Comment Body --- */
.body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
    align-items: flex-start;
}

.comment-bubble {
    background: transparent;
    border: none;
    padding: 0;
}

/* --- Meta Header --- */
.meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 0.85rem;
    line-height: 1.3;
    margin-bottom: 0;
    width: 100%;
}

.comment-author {
    font-weight: 600;
    color: #f1f5f9;
    font-size: 0.9rem;
}

.separator {
    color: #475569;
    font-weight: bold;
}

.comment-time {
    color: #6b7280;
    font-size: 0.8rem;
}

.audio-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(168, 85, 247, 0.1);
    color: #a855f7;
    padding: 1px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid rgba(168, 85, 247, 0.2);
}

.audio-type-badge i {
    font-size: 0.7rem;
    opacity: 0.8;
}

.audio-pin-comment {
    color: #a855f7;
    cursor: pointer;
    font-size: 0.9rem;
    margin-left: 4px;
    transition: transform 0.2s, color 0.2s;
    display: inline-flex;
    align-items: center;
}

.audio-pin-comment:hover {
    transform: scale(1.2) rotate(-15deg);
    color: #c084fc;
}

/* --- Rank Badges --- */
.rank-badge {
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 0.6rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #fff;
    background: #475569;
    display: inline-flex;
    align-items: center;
    height: 16px;
}

.rank-admin {
    background: var(--accent-danger, #f43f5e);
}

.rank-7 {
    background: var(--accent-pink, #ec4899);
}

.rank-5 {
    background: #3b82f6;
}

.rank-3 {
    background: var(--accent-secondary, #3b82f6);
}

.rank-helper {
    background: #14b8a6;
    /* Teal */
}

.rank-moderator {
    background: #8b5cf6;
    /* Violet */
}

/* --- Content --- */
.comment-text {
    font-size: 0.9rem;
    color: #d1d5db;
    line-height: 1.45;
    white-space: pre-wrap;
    margin: 0;
    padding: 0;
    text-align: left;
    align-self: flex-start;
}

/* === LAYOUT & CONTAINER === */
.comentarios-page {
    /* Using post-page styling base */
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 15px;
}

/* --- Actions --- */
.actions {
    display: flex;
    gap: 12px;
    margin-top: 2px;
    padding: 0;
}

.action-btn {
    background: transparent;
    border: none;
    color: #64748b;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 0;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.2s;
}

.action-btn:hover {
    color: #a1a1aa;
}

.like-btn.liked {
    color: var(--accent-pink, #ec4899);
}

/* --- Threading Lines --- */

/* Vertical line starting from a parent towards its children */
.comment>.comment-thread-line {
    position: absolute;
    left: 20px;
    top: 40px;
    /* height is calculated dynamically based on replies, or uses CSS fallback */
    height: var(--thread-line-height, 0);
    width: 2px;
    background: #334155;
    transform: translateX(-50%);
    z-index: 1;
}

/* The horizontal L connector from the vertical line to the reply avatar */
.reply-l-connector {
    position: absolute;
    left: -62px;
    top: 0;
    width: 82px;
    height: 20px;
    border-left: 2px solid #334155;
    border-bottom: 2px solid #334155;
    border-bottom-left-radius: 12px;
    pointer-events: none;
    z-index: 1;
}

/* Mask the vertical line below the connector ONLY on the absolute last child of the thread */
/* This handles both messages and the reply form */
.replies-container>*:last-child>.reply-l-connector::after {
    content: '';
    position: absolute;
    left: -2px;
    top: 30px;
    /* Moved down to avoid cutting the curve */
    width: 4px;
    height: 1000px;
    background: var(--bg-app, #0a0a0c);
    z-index: 2;
}

/* Replies Container */
.replies-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
    width: 100%;
}

/* --- Form Pill Design --- */
.comment-form-container {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 40px;
}

.comment-input-wrapper {
    flex: 1;
    position: relative;
    padding-top: 5px;
}

.comment-input-field {
    width: 100%;
    background: transparent;
    border-bottom: 1px solid #334155;
    border-top: none;
    border-left: none;
    border-right: none;
    border-radius: 0;
    padding: 0 0 8px 0;
    color: white;
    font-size: 1rem;
    transition: border-color 0.2s;
    font-family: inherit;
}

.comment-input-field::placeholder {
    color: #64748b;
}

.comment-input-field:focus {
    border-bottom-color: var(--accent-primary, #a855f7);
    outline: none;
}

.comment-send-btn {
    position: absolute;
    right: 0;
    bottom: 10px;
    background: transparent;
    color: var(--accent-primary, #a855f7);
    border: none;
    font-weight: 600;
    cursor: pointer;
    text-transform: uppercase;
    font-size: 0.8rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}

.comment-input-wrapper.has-content .comment-send-btn {
    opacity: 1;
    visibility: visible;
}

/* --- Dropdown Menus --- */
.dropdown {
    margin-left: auto;
    position: relative;
}

.dropdown-toggle {
    color: #64748b;
    padding: 4px;
    background: transparent;
    border: none;
    cursor: pointer;
}

.dropdown-menu {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 4px;
    min-width: 140px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    z-index: 50;
    list-style: none;
}

.dropdown.open .dropdown-menu {
    display: block;
}

.dropdown-menu li a {
    display: block;
    padding: 8px 12px;
    color: #cbd5e1;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
}

.dropdown-menu li a:hover {
    background: #334155;
    color: #fff;
}