/* Comments Section */
.comments-section {
    background: transparent;
}

/* Comment Filter */
.comment-filter-group .comment-filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 15px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s;
}

.comment-filter-group .comment-filter-pill:hover {
    border-color: rgba(255, 255, 255, 0.4);
    color: rgba(255, 255, 255, 0.8);
}

.comment-filter-group .comment-filter-pill .check-icon {
    display: none;
}

.comment-filter-group .btn-check:checked + .comment-filter-pill {
    background: var(--t4s-primary-color);
    border-color: var(--t4s-primary-color);
    color: #fff;
}

.comment-filter-group .btn-check:checked + .comment-filter-pill .check-icon {
    display: inline-block;
}

/* Comment Item */
.comment-item {
    position: relative;
    margin-bottom: 20px;
}

.comment-item:last-child {
    margin-bottom: 0;
}

/* Inner flex layout: avatar left, content right */
.comment-inner {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    position: relative;
}

/* Avatar column */
.comment-avatar-col {
    flex-shrink: 0;
    width: 40px;
}

/* Avatar */
.comment-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--t4s-background-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    color: #fff;
    object-fit: cover;
}

.comment-avatar.admin {
    background: var(--t4s-primary-color);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
}

img.comment-avatar {
    background: transparent;
    display: block;
}

/* Vertical thread line: inside .comment-inner, from avatar bottom to first reply (bridges 16px gap) */
.comment-branch {
    position: absolute;
    left: 20px;
    top: 40px;      /* bắt đầu từ đáy avatar (40px) */
    bottom: -16px;  /* kéo qua khoảng margin-top 16px của reply đầu tiên */
    width: 2px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 1px;
    pointer-events: none;
}

/* Vertical line nối giữa các reply siblings (trừ cái cuối) */
.reply-item:not(:last-child)::after {
    content: '';
    position: absolute;
    left: -32px;
    top: 12px;
    height: calc(100% + 4px);
    width: 2px;
    background: rgba(255, 255, 255, 0.12);
    pointer-events: none;
}

/* Reply item */
.reply-item {
    margin-left: 52px; /* 40px avatar + 12px gap */
    position: relative;
    margin-top: 16px;
    margin-bottom: 16px;
}

/* L-connector: turns from parent vertical line → reply avatar */
.reply-branch {
    position: absolute;
    top: 0;
    left: -32px; /* -(margin-left 52px − avatar-center 20px) */
    width: 32px;
    height: 20px; /* reach center of 40px avatar */
    border-left: 2px solid rgba(255, 255, 255, 0.12);
    border-bottom: 2px solid rgba(255, 255, 255, 0.12);
    border-bottom-left-radius: 10px;
}

/* Comment replies container */
.comment-replies {
    margin-left: 0;
    padding-left: 0;
}

/* Comment header: name + badge */
.comment-header {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.comment-author {
    font-weight: 600;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.3;
}

/* Badges */
.comment-badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 500;
    line-height: 1.6;
    white-space: nowrap;
}

.admin-badge {
    background: rgba(220, 53, 69, 0.56);
    color: #fff;
}

.pending-badge {
    background: #ffc107;
    color: #000;
}

/* Comment content */
.comment-content {
    flex: 1;
    min-width: 0;
}

.comment-body {
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    color: rgba(255, 255, 255, 0.8);
}

/* Footer: time + action buttons */
.comment-footer {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.comment-time {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
    margin-right: 6px;
    white-space: nowrap;
}

/* Buttons: icon or icon+text, hover = color change only */
.comment-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.45);
    font-size: 12px;
    cursor: pointer;
    padding: 3px 6px;
    border-radius: 4px;
    transition: color 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    line-height: 1;
}

.comment-btn:hover {
    color: var(--t4s-primary-color);
    background: transparent;
}

.comment-btn.active,
.comment-btn.has-votes {
    color: var(--t4s-secondary-color);
}

.comment-btn.btn-approve:hover {
    color: #28a745;
}

.comment-btn.btn-delete:hover {
    color: #dc3545;
}

/* Load More Button: dùng comment-btn làm base, chỉ override font-size lớn hơn btn-load-more-replies */
.btn-load-more {
    font-size: 14px;
}

.btn-load-more-replies {
    font-size: 12px;
    padding: 2px 8px;
}

.load-more-replies-wrapper {
    padding-left: 52px;
}

/* Modal Form */
.comment-modal {
    z-index: 99999;
}

.comment-modal .modal-title {
    color: #000;
    font-weight: 600;
}

.comment-modal .btn-close {
    filter: invert(1);
}

.comment-modal .modal-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.25rem;
}

.comment-modal .form-control {
    color: var(--t4s-text-head-color) !important;
    border: var(--bs-border-width) solid var(--bs-border-color) !important;
}

.comment-modal .form-control:read-only {
    background-color: var(--bs-secondary-bg) !important;
}

.comment-modal .form-control.is-invalid {
    border-color: #dc3545;
}

/* Character count */
.comment-modal .textarea-wrapper {
    position: relative;
}

.comment-modal .char-count {
    position: absolute;
    top: -10px;
    right: 5px;
    font-size: 11px;
    background: var(--t4s-primary-color) !important;
    color: #000 !important;
    border-radius: 10px;
    pointer-events: none;
    padding: 0 10px;
    height: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Fix modal backdrop z-index */
.comment-modal.show {
    z-index: 1060;
}

/* Reply info box */
.reply-to-info {
    border-left: 3px solid var(--t4s-primary-color);
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active{
    -webkit-text-fill-color: initial !important;
    transition: initial !important;
    box-shadow: initial !important;
}

/* Comments empty state */
.comments-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
}

.comments-empty-icon {
    color: rgba(255, 255, 255, 0.45);
    margin-bottom: 16px;
}

.comments-empty-title {
    font-size: 15px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
    margin: 0 0 6px 0;
}

.comments-empty-text {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.4);
    margin: 0;
}

/* Toast notification */
.comment-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--t4s-background-color);
    border: 1px solid var(--t4s-primary-color);
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    z-index: 9999;
    animation: slideIn 0.3s ease;
}

.comment-toast.success {
    border-color: #28a745;
}

.comment-toast.error {
    border-color: #dc3545;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Pending approval: slightly dimmed, no border */
.comment-pending {
    opacity: 0.7;
}

/* ── Swal Comment Dialog ─────────────────────────────────────────── */
.swal-comment-popup {
    border-radius: 16px !important;
    padding: 1.5rem 1.5rem 1.25rem !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2) !important;
}

/* Thu nhỏ icon: Swal dùng em nên giảm font-size để icon bé lại */
.swal-comment-popup .swal2-icon {
    font-size: 11px;
    margin: 0 auto 1rem;
    border-width: 2px;
}

.swal-comment-popup .swal2-title {
    font-size: 15px !important;
    font-weight: 600 !important;
    padding: 0 !important;
    margin-bottom: 0.3rem !important;
}

.swal-comment-popup .swal2-html-container {
    font-size: 13px !important;
    color: #666 !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1.5;
}

.swal-comment-popup .swal2-actions {
    margin-top: 1.2rem !important;
    gap: 8px !important;
    padding: 0 !important;
    justify-content: flex-end !important;
}

.swal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50px;
    padding: 5px 18px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    line-height: 1.5;
    transition: opacity 0.15s;
}

.swal-btn:hover {
    opacity: 0.82;
}

.swal-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.12);
}

.swal-btn-confirm {
    background: #dc3545;
    color: #fff;
}

.swal-btn-cancel {
    background: #6c757d;
    color: #fff;
}

/* Responsive */
@media (max-width: 768px) {
    .comment-avatar-col {
        width: 35px;
    }

    .comment-avatar {
        width: 35px;
        height: 35px;
        font-size: 14px;
    }

    .comment-inner {
        gap: 10px;
    }

    .comment-branch {
        left: 17px;     /* center of 35px avatar */
        top: 35px;      /* đáy avatar mobile (35px) */
        bottom: -14px;  /* bridge margin-top 14px của reply đầu tiên */
    }

    .reply-item {
        margin-left: 45px; /* 35px avatar + 10px gap */
        margin-top: 14px;
        margin-bottom: 14px;
    }

    .reply-branch {
        left: -28px; /* -(margin-left 45px − avatar-center 17px) */
        width: 28px;
        height: 17px; /* reach center of 35px avatar */
    }

    .reply-item:not(:last-child)::after {
        left: -28px;    /* thẳng hàng với .comment-branch mobile */
        top: 17px;      /* avatar center mobile (35px / 2) */
        bottom: -14px;  /* bridge collapsed margin gap mobile */
    }

    .load-more-replies-wrapper {
        padding-left: 45px;
    }

    .comment-filter-btn,
    .comment-filter-link {
        font-size: 13px;
        padding: 5px 10px;
    }

    .comment-filter-group {
        gap: 0.5rem;
    }
}
