/* Container chính cho màn hình show post */
#comments-section {
    margin: 20px auto;
    padding: 15px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgb(0 0 0 / 0.1);
}

/* Tiêu đề */
#comments-section > h3 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 20px;
    color: #222;
    border-bottom: 2px solid #4CAF50;
    padding-bottom: 5px;
}

/* Form bình luận */
#comment-form {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 25px;
}

#comment-content {
    flex: 1; /* Chiếm hết chiều rộng còn lại */
    resize: vertical;
    max-width: 90%;
    min-height: 50px;
    padding: 10px 15px;
    font-size: 1rem;
    border-radius: 8px;
    border: 1.5px solid #ccc;
    transition: border-color 0.3s ease;
    font-family: inherit;
    min-width: 0; /* Để tránh flex item bị tràn */
}

#comment-content:focus {
    border-color: #4CAF50;
    outline: none;
    box-shadow: 0 0 8px #4CAF5080;
}

#comment-form button[type="submit"] {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 0 25px;
    font-weight: 600;
    font-size: 1rem;
    border-radius: 30px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    height: 50px; /* Đều chiều cao với textarea */
    flex-shrink: 0; /* Không bị co nhỏ */
}

#comment-form button[type="submit"]:hover {
    background-color: #388E3C;
}

/* Nút xem thêm */
.load-more-wrapper {
    text-align: center;
    margin-top: 15px;
}

#load-more-comments {
    background-color: #eee;
    border: 1px solid #ccc;
    padding: 10px 20px;
    font-weight: 600;
    color: #555;
    border-radius: 25px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgb(0 0 0 / 0.1);
    transition: background-color 0.3s ease, color 0.3s ease;
}

#load-more-comments:hover {
    background-color: #4CAF50;
    color: white;
}

/* hiển thị lỗi chưa đăng nhập và chưa có cmt*/
.comment-message {
    color: #666;
    font-style: italic;
    padding-bottom: 15px;
    font-size: 15px;
}

.comment-message a {
    color: #007BFF;
    text-decoration: underline;
}

.comment-message a:hover {
    text-decoration: none;
}

.comment-message.no-comments {
    color: #999;
}





/* Tổng thể comment-item */
.comment-item {
    background: #f1f3f5;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    padding: 15px 20px;
    margin-bottom: 15px;
    transition: box-shadow 0.3s ease, background-color 0.3s ease;
    position: relative; /* để ::before position:absolute tính đúng */
    overflow: visible
}

/* Hover nổi bật */
.comment-item:hover {
    background-color: #f1f3f5; /* đổi nhẹ màu nền khi hover */
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.highlight-scroll,
.comment-item.highlight-comment {
    background-color: #f0f0f0;
    border-left: 2px solid #007bff;
    transition: background-color 1s ease;
}
.comment-item:hover {
    background-color: #e8e8e8;
}



/* Hàng chứa avatar và tên người dùng */
.comment-header-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

/* Avatar */
.comment-avatar img {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.1);
    border: 2px solid #3182ce;
    transition: border-color 0.3s ease;
}

.comment-avatar img:hover {
    border-color: #2b6cb0;
}

/* Container chứa tên user và thời gian */
.comment-user-name-time {
    display: flex;
    flex-direction: column;
    font-size: 14.5px;
    color: #2d3748;
    user-select: none;
}

/* Tên người dùng */
.comment-user-name-time strong {
    font-weight: 700;
    font-size: 16px;
    color: #1a202c;
    line-height: 1.1;
}

/* Thời gian */
.comment-time {
    font-style: italic;
    color: #718096;
    font-size: 12.8px;
    margin-top: 2px;
}

/* Nội dung comment */
.comment-body p {
    margin: 0;
    font-size: 15px;
    line-height: 1.55;
    color: #4a5568;
    white-space: pre-wrap;
    word-break: break-word;
    padding-left: 54px; /* tạo khoảng cách so với avatar bên trên */
}

/* Hành động bên dưới */
.comment-actions {
    margin-top: 10px;
    padding-left: 54px; /* canh thẳng với nội dung */
    display: flex;
    gap: 16px;
    font-size: 14px;
}

/* Link Trả lời và Hiển thị tin nhắn */
.comment-actions a ,
.delete-comment-btn {
    background: none;
    padding: 0;
    color: #3182ce;
    cursor: pointer;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.25s ease;
    user-select: none;
    border-bottom: 1.5px solid transparent;
}

.comment-actions a:hover,
.delete-comment-btn:hover {
    padding: 0;
    background: none;
    color: #2b6cb0;
    border-color: #2b6cb0;
}

/* Khu vực comment con (reply) thụt vào */
/* Dây dọc chính (đường viền trái) */
.comment-replies {
    position: relative;
    margin-top: 18px;
    margin-left: 25px;
    padding-left: 16px;
    border-left: 2px solid #cbd5e0;
    transition: max-height 0.35s ease;
}

/* Tạo "dây ngang" nối comment con ra với dây dọc */
/* Áp dụng cho mỗi comment con */
.comment-replies > .comment-item {
    position: relative;
    padding-left: 20px;
    overflow: visible;
}

.comment-replies > .comment-item::before {
    content: "";
    position: absolute;
    top: 50%;
    left: -18px;
    width: 18px;
    height: 2px;
    background-color: #cbd5e0;
    border-top-left-radius: 6px;
    border-bottom-left-radius: 6px;
}

/* Bo cong góc dây dọc ở vị trí giao nhau với dây ngang (comment đầu tiên trong replies) */
.comment-replies > .comment-item:first-child::before {
    border-top-left-radius: 10px;
}

/* Bo cong góc dưới dây dọc ở comment cuối cùng trong replies */
.comment-replies > .comment-item:last-child {
    border-bottom-left-radius: 10px;
}


/* Responsive nhỏ */
@media (max-width: 600px) {
    #comments-section {
        padding: 10px;
    }

    #comment-form button[type="submit"] {
        padding: 8px 20px;
        font-size: 0.9rem;
    }

    #comment-content {
        font-size: 16px;
    }
    .comment-item {
        padding: 10px 10px;
    }
    .comment-header-row {
        gap: 8px;
    }
    .comment-avatar img {
        width: 36px;
        height: 36px;
    }
    .comment-body p,
    .comment-actions {
        padding-left: 15px;
    }
    .comment-replies {
        margin-left: 25px;
        padding-left: 15px;
        border-left-width: 1.8px;
    }
    .comment-replies > .comment-item {
        padding-left: 14px;
    }
    .comment-replies > .comment-item::before {
        width: 15px;
        height: 1.8px;
        right: 0;
    }
}
