/* assets/css/posts.css */

/* ========================================= */
/* 1. LAYOUT & POST DETAIL */
/* ========================================= */
.layout-grid-single {
    display: grid;
    grid-template-columns: minmax(500px, 750px); 
    justify-content: center;
    margin: 0 auto;
    padding-top: 20px;
    width: 100%;
    padding-bottom: 50px;
}

.post-detail { width: 100%; }

.post-detail .post-item {
    border-bottom: none;
    padding-bottom: 0;
    cursor: default;
}

.post-detail .post-item:hover { background-color: transparent; }

.post-detail .post-content {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 25px;
    color: var(--text-main);
}

/* ========================================= */
/* 2. FORM BÌNH LUẬN CHÍNH (CẤP 0) */
/* ========================================= */
.comment-form-wrapper { background-color: var(--bg-body); padding-top: 15px; }

.comment-form-container {
    display: flex; gap: 10px; align-items: center;
    margin: 10px 0; padding: 5px 0;
}

#new-comment-input {
    flex-grow: 1;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 10px 15px;
    background: var(--icon-hover-bg);
    color: var(--text-main);
    outline: none;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

#new-comment-input:focus {
    border-color: var(--primary-color);
    background: var(--bg-body);
}

#send-new-comment {
    background: var(--primary-color);
    color: white; border: none;
    padding: 8px 20px; border-radius: 20px;
    font-weight: 600; cursor: pointer;
    transition: opacity 0.2s; white-space: nowrap;
}
#send-new-comment:hover { opacity: 0.9; }

.comment-form-container label {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 50%;
    transition: background 0.2s; cursor: pointer;
}
.comment-form-container label:hover { background-color: var(--icon-hover-bg); }

#comment_media_preview {
    display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 5px;
}
#comment_media_preview .preview-image-wrapper {
    position: relative; border-radius: 8px; overflow: hidden;
    border: 1px solid var(--border-color);
}

/* ========================================= */
/* 3. BỘ LỌC BÌNH LUẬN (FILTER) */
/* ========================================= */
.comments-header-row {
    display: flex; justify-content: space-between; align-items: center; 
    margin-top: 20px; margin-bottom: 15px;
    border-bottom: 1px solid var(--border-color); padding-bottom: 10px;
}

.comments-header {
    font-size: 1.1rem; font-weight: 700; color: var(--text-main); margin: 0;
}

.filter-link {
    color: var(--text-muted); text-decoration: none;
    font-size: 0.9rem; font-weight: 500; margin: 0 5px;
    transition: color 0.2s;
}
.filter-link:hover { color: var(--primary-color); }
.filter-link.active {
    color: var(--text-main); font-weight: 700;
    border-bottom: 2px solid var(--primary-color);
}

/* ========================================= */
/* 4. STYLE BÌNH LUẬN ĐA CẤP (THREADED COMMENTS) */
/* ========================================= */
.comments-list { margin-top: 15px; }

.comment-item {
    position: relative;
    margin-bottom: 15px;
    animation: fadeIn 0.3s ease;
}

.comment-item.is-reply {
    border-left: 2px solid var(--border-color);
    padding-left: 12px; margin-top: 10px;
}

.comment-item[data-level="1"] { margin-left: 0; }
.comment-item[data-level="2"] { margin-left: 10px; }
.comment-item[data-level="3"] { margin-left: 10px; } 
.comment-item[data-level="4"] { margin-left: 10px; }

.comment-content-bubble {
    background-color: var(--bg-body); 
    padding: 8px 12px;
    border-radius: 12px;
    display: inline-block;
    border: 1px solid var(--border-color);
    min-width: 150px;
    position: relative;
}

.comment-user {
    font-weight: 700; margin-right: 5px;
    color: var(--text-main); display: block; margin-bottom: 4px;
}

.comment-text {
    color: var(--text-main); font-size: 0.95rem;
    line-height: 1.4; word-break: break-word;
}

.comment-media-image, .comment-media-video {
    max-width: 100%; height: auto; display: block;
    border-radius: 8px; margin-top: 5px;
    border: 1px solid var(--border-color);
}
.comment-media-video { max-height: 250px; }

/* ========================================= */
/* 5. FOOTER HÀNH ĐỘNG (LIKE, REPLY, TIME) */
/* ========================================= */
.comment-actions-footer {
    margin-top: 4px; font-size: 0.8rem;
    display: flex; align-items: center; gap: 12px;
    color: var(--text-muted); padding-left: 5px;
}

.comment-actions-footer button {
    background: none; border: none; cursor: pointer;
    font-weight: 600; font-size: 0.8rem;
    color: var(--text-muted); padding: 0;
    transition: color 0.2s;
}

.comment-actions-footer button:hover {
    text-decoration: underline; color: var(--text-main);
}

.btn-like-comment.liked { color: #ff3b5b !important; }
.btn-like-comment.liked i { font-weight: 900; }
.btn-delete-comment { color: #ff4d4d !important; }
.btn-reply-comment { margin-left: 0; }

/* ========================================= */
/* 6. FORM PHẢN HỒI (REPLY BOX) */
/* ========================================= */
.reply-input-container { margin-top: 8px; margin-bottom: 10px; }

.reply-form-wrapper {
    background-color: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: 18px; padding: 8px 12px;
    display: flex; flex-direction: column;
    margin-top: 5px;
}

.reply-form-row { display: flex; align-items: center; gap: 10px; }

.reply-input-field {
    flex-grow: 1; border: none; background: transparent;
    padding: 8px 0; color: var(--text-main);
    outline: none; font-size: 0.9rem;
}

.reply-attach-btn {
    color: var(--text-muted); cursor: pointer;
    font-size: 1.2rem; padding: 5px;
    display: flex; align-items: center;
    transition: color 0.2s;
}
.reply-attach-btn:hover { color: var(--primary-color); }

.btn-submit-reply {
    background: none; border: none;
    color: var(--primary-color); font-weight: 600;
    cursor: pointer; font-size: 1.1rem; padding: 5px;
    transition: transform 0.2s;
}
.btn-submit-reply:hover { transform: scale(1.1); }

.reply-media-preview {
    display: flex; gap: 8px; overflow-x: auto;
    padding-bottom: 8px; margin-bottom: 8px;
    border-bottom: 1px dashed var(--border-color);
}
.reply-media-preview:empty {
    display: none; border-bottom: none;
    padding-bottom: 0; margin-bottom: 0;
}

.reply-preview-item {
    width: 60px; height: 60px; object-fit: cover;
    border-radius: 8px; flex-shrink: 0;
    border: 1px solid var(--border-color);
}

/* ========================================= */
/* 7. MODAL PHÓNG TO ẢNH (FIXED) */
/* ========================================= */
.modal {
    display: none; position: fixed; z-index: 99999; 
    left: 0; top: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.92); overflow: hidden;
}

.modal-content-wrapper {
    position: relative; width: 100%; height: 100%;
    display: flex; justify-content: center; align-items: center; 
}

.modal-image {
    max-width: 90%; max-height: 90vh;
    object-fit: contain; box-shadow: 0 0 30px rgba(0,0,0,0.5);
    animation: zoomIn 0.25s ease-out;
}

@keyframes zoomIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.close-modal-btn {
    position: absolute; top: 20px; right: 30px;
    color: #f1f1f1; font-size: 40px; font-weight: bold;
    cursor: pointer; z-index: 100001; line-height: 1;
    width: 40px; height: 40px; text-align: center;
    background: rgba(255, 255, 255, 0.1); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
.close-modal-btn:hover { background: rgba(255, 255, 255, 0.2); }

.prev-btn, .next-btn {
    cursor: pointer; position: absolute; top: 50%;
    transform: translateY(-50%); width: 50px; height: 50px;
    display: flex; align-items: center; justify-content: center;
    color: rgb(237, 10, 10); font-weight: bold; font-size: 24px;
    background-color: rgba(24, 202, 202); border-radius: 50%;
    user-select: none; z-index: 100000; transition: background 0.2s;
}
.prev-btn { left: 20px; }
.next-btn { right: 20px; }
.prev-btn:hover, .next-btn:hover { background-color: rgba(224, 17, 17, 0.861); }

@media only screen and (max-width: 768px) {
    .modal-image { max-width: 100%; max-height: 80vh; }
    .prev-btn, .next-btn { width: 40px; height: 40px; font-size: 18px; }
}

/* ========================================= */
/* 8. CAROUSEL 1 ẢNH (16:9 CONTAIN - NỀN ĐEN - CĂN GIỮA) */
/* ========================================= */
.image-pager-container {
    position: relative; 
    margin: 15px 0; 
    padding: 0; 
    display: block;
    width: 100%;
    /* Ép tỷ lệ 16:9 */
    height: 0;
    padding-bottom: 56.25%; 
    border-radius: 8px;
    background-color: #000; /* Nền đen */
    overflow: hidden; 
    border: none;
}

.post-images-grid { 
    /* Dùng Flexbox để căn giữa ảnh trong nền đen */
    position: absolute;
    top: 0; left: 0;
    display: flex; 
    justify-content: center; /* Căn giữa ngang */
    align-items: center;     /* Căn giữa dọc */
    width: 100%; height: 100%;
    margin: 0; padding: 0;
}

.image-page-item {
    display: none; /* Mặc định ẩn */
    
    /* Ảnh không được vượt quá khung 16:9 */
    max-width: 100%; 
    max-height: 100%;
    
    /* Contain: Hiển thị toàn bộ ảnh, chấp nhận có khoảng đen 2 bên */
    object-fit: contain; 
    
    border-radius: 0; /* Không bo góc ảnh vì đã bo container */
    cursor: zoom-in;
    margin: 0 auto;
}

/* Chỉ hiện ảnh Active (dạng block để hiển thị) */
.image-page-item.active {
    display: block;
    animation: fadeIn 0.2s ease-in-out;
}

/* Nút chuyển trang */
.pager-prev-btn, .pager-next-btn {
    position: absolute; top: 50%; transform: translateY(-50%); z-index: 10; 
    background-color: rgba(11, 157, 230, 0.7); border: none;
    border-radius: 50%; width: 35px; height: 35px;
    font-size: 1rem; line-height: 1; color: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    display: flex; justify-content: center; align-items: center;
    cursor: pointer; transition: background-color 0.2s; 
    margin: 0;
}
.pager-prev-btn { left: 10px; } 
.pager-next-btn { right: 10px; } 
.pager-prev-btn:hover, .pager-next-btn:hover { background-color: #0c75bc; }

.image-pager-counter {
    position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); 
    background: rgba(0,0,0,0.5); color: white; padding: 4px 10px; 
    border-radius: 12px; font-size: 0.8rem; line-height: 1.2;
    z-index: 10; pointer-events: none;
}

/* Misc */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.no-comments { color: var(--text-muted); text-align: center; padding: 30px 0; font-style: italic; }
.comment-tag-link { color: var(--primary-color, #007bff); font-weight: 600; text-decoration: none; cursor: pointer; }
.comment-tag-link:hover { opacity: 0.8; text-decoration: underline; }
.comment-text { white-space: pre-wrap; font-size: 0.95rem; line-height: 1.4; }
.btn-view-more-replies { display: inline-flex; align-items: center; gap: 5px; font-size: 0.85rem; font-weight: 600; color: var(--text-muted); text-decoration: none; padding: 5px 0; }
.btn-view-more-replies:hover { color: var(--primary-color); text-decoration: underline; }