/**
 * Optimized Comment Styles - COMPLETELY FIXED VERSION
 * Modern, responsive design with smooth animations
 * Version: 3.0 - TRIỆT ĐỂ FIX: Pagination không ảnh hưởng Menu
 * 
 * ✅ FIXED: Sử dụng selector CỰC KỲ CỤ THỂ cho comment pagination
 * ✅ KHÔNG conflict với menu navigation
 * ✅ Thêm namespace riêng cho comment pagination
 */

/* ==============================================
   COMMENT AREA CONTAINER
   ============================================== */
.comments-area {
    max-width: 100%;
    margin: 40px 0;
    padding: 0;
}

/* ==============================================
   COMMENT HEADER
   ============================================== */
.comment-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e8ecef;
    flex-wrap: wrap;
}

.comment-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.comment-header-icon {
    color: #007bff;
    filter: drop-shadow(0 2px 4px rgba(0, 123, 255, 0.2));
    flex-shrink: 0;
}

.comment-title {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: #1a202c;
    margin: 0;
    line-height: 1.2;
}

.comment-count {
    color: #007bff;
    font-weight: 800;
}

/* ==============================================
   COMMENT SORT FORM
   ============================================== */
.comment-sort-form {
    margin-left: auto;
}

.comment-sort-form select {
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    border: 2px solid #e8ecef;
    border-radius: 8px;
    background: #fff;
    color: #2d3748;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%232d3748' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.comment-sort-form select:hover {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.comment-sort-form select:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.15);
}

/* ==============================================
   COMMENT LIST
   ============================================== */
.comment-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.comment-list > li {
    margin-bottom: 24px;
    animation: fadeInUp 0.4s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==============================================
   COMMENT BODY
   ============================================== */
.comment-body {
    display: flex;
    gap: 16px;
    padding: 20px;
    background: #fff;
    border: 1px solid #e8ecef;
    border-radius: 12px;
    transition: all 0.3s ease;
    position: relative;
}

.comment-body:hover {
    border-color: #d1d9e0;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

/* ==============================================
   COMMENT AUTHOR
   ============================================== */
.comment-author {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.comment-author .comment-avatar,
.comment-author img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #e8ecef;
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.comment-body:hover .comment-avatar {
    transform: scale(1.05);
    border-color: #007bff;
}

.comment-author-info {
    flex: 1;
    min-width: 0;
}

.comment-author .fn {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: #1a202c;
    margin-bottom: 4px;
    word-wrap: break-word;
}

.comment-author .fn a {
    color: #1a202c;
    text-decoration: none;
    transition: color 0.3s ease;
}

.comment-author .fn a:hover {
    color: #007bff;
}

/* ==============================================
   COMMENT META
   ============================================== */
.comment-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #718096;
    margin-top: 4px;
    flex-wrap: wrap;
}

.comment-meta time {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.comment-meta .edit-link {
    color: #718096;
}

.comment-meta .edit-link a {
    color: #718096;
    text-decoration: none;
    transition: color 0.3s ease;
}

.comment-meta .edit-link a:hover {
    color: #007bff;
}

.in-reply-to {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #718096;
    padding: 2px 8px;
    background: #f7fafc;
    border-radius: 12px;
}

.in-reply-to a {
    color: #007bff;
    text-decoration: none;
    font-weight: 500;
}

.in-reply-to a:hover {
    text-decoration: underline;
}

/* ==============================================
   COMMENT MAIN CONTENT
   ============================================== */
.comment-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ==============================================
   COMMENT REPLY TO INDICATOR
   ============================================== */
.comment-reply-to {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #f0f7ff 0%, #e6f2ff 100%);
    border-left: 3px solid #007bff;
    border-radius: 6px;
    font-size: 13px;
    color: #2d3748;
    line-height: 1.4;
}

.comment-reply-to .reply-icon {
    flex-shrink: 0;
    color: #007bff;
}

.comment-reply-to strong {
    font-weight: 600;
}

.comment-reply-to a {
    color: #007bff;
    text-decoration: none;
}

.comment-reply-to a:hover {
    text-decoration: underline;
}

/* ==============================================
   COMMENT CONTENT
   ============================================== */
.comment-content {
    font-size: 15px;
    line-height: 1.7;
    color: #2d3748;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.comment-content p {
    margin: 0 0 12px 0;
}

.comment-content p:last-child {
    margin-bottom: 0;
}

.comment-content a {
    color: #007bff;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.3s ease;
}

.comment-content a:hover {
    border-bottom-color: #007bff;
}

/* ==============================================
   COMMENT ACTIONS
   ============================================== */
.comment-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.comment-actions .comment-reply-link,
.comment-actions a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    color: #4a5568;
    background: #f7fafc;
    border: 1px solid #e8ecef;
    border-radius: 20px;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
}

.comment-actions .comment-reply-link:hover,
.comment-actions a:hover {
    background: #e8ecef;
    border-color: #cbd5e0;
    color: #2d3748;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.comment-actions .icon {
    width: 16px;
    height: 16px;
}

/* ==============================================
   COMMENT LIKE BUTTON
   ============================================== */
.comment-like-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid #e8ecef;
    border-radius: 20px;
    background: #f7fafc;
    font-size: 13px;
    font-weight: 500;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.comment-like-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(220, 53, 69, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.comment-like-btn:hover {
    background: #e8ecef;
    border-color: #cbd5e0;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.comment-like-btn.liked {
    background: linear-gradient(135deg, #fff5f5 0%, #ffe8e8 100%);
    border-color: #fc8181;
    color: #c53030;
}

.comment-like-btn.liked:hover {
    background: linear-gradient(135deg, #ffe8e8 0%, #ffd4d4 100%);
    border-color: #e53e3e;
}

.comment-like-btn.liked .like-icon {
    color: #dc3545;
    animation: likeAnimation 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes likeAnimation {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.3);
    }
    100% {
        transform: scale(1);
    }
}

.comment-like-btn .like-icon {
    width: 16px;
    height: 16px;
    transition: color 0.3s ease;
}

.comment-like-btn .like-count {
    font-weight: 600;
    min-width: 16px;
    text-align: center;
}

/* Loading state */
.comment-like-btn[data-loading="1"] {
    opacity: 0.6;
    pointer-events: none;
}

/* ==============================================
   NESTED COMMENTS (CHILDREN)
   ============================================== */
.comment-list .children {
    list-style: none;
    margin: 16px 0 0 0;
    padding: 0 0 0 40px;
    border-left: 3px solid #e8ecef;
    position: relative;
}

.comment-list .children::before {
    content: '';
    position: absolute;
    left: -3px;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, #e8ecef 0%, transparent 100%);
}

.comment-list .children > li {
    position: relative;
}

.comment-list .children > li::before {
    content: '';
    position: absolute;
    left: -40px;
    top: 30px;
    width: 24px;
    height: 2px;
    background: #e8ecef;
}

/* ==============================================
   CURRENT USER COMMENTS
   ============================================== */
.comment-list li.by-current-user .comment-body {
    background: linear-gradient(135deg, #f0f7ff 0%, #e6f2ff 100%);
    border-color: #90cdf4;
}

.comment-list li.by-current-user .comment-body::after {
    content: '✓ You';
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 11px;
    font-weight: 600;
    color: #007bff;
    background: #fff;
    padding: 4px 8px;
    border-radius: 12px;
    border: 1px solid #007bff;
}

/* ==============================================
   POST AUTHOR COMMENTS
   ============================================== */
.comment-list li.bypostauthor .comment-body {
    background: linear-gradient(135deg, #fff5f5 0%, #ffebeb 100%);
    border-color: #fc8181;
}

.comment-list li.bypostauthor .comment-body::after {
    content: '★ Author';
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 11px;
    font-weight: 600;
    color: #c53030;
    background: #fff;
    padding: 4px 8px;
    border-radius: 12px;
    border: 1px solid #fc8181;
}

/* ==============================================
   🔥 COMMENT PAGINATION - TRIỆT ĐỂ FIXED VERSION 🔥
   ⚠️ QUAN TRỌNG: Sử dụng selector CỰC KỲ CỤ THỂ
   ✅ KHÔNG BAO GIỜ conflict với menu navigation
   ============================================== */

/* Container wrapper - chỉ cho comment pagination */
.mc-comment-nav-wrapper {
    margin: 40px 0;
    padding: 20px;
    background: #f7fafc;
    border-radius: 12px;
    /* Đánh dấu rõ ràng đây là comment pagination */
    position: relative;
}

/* 
 * 🎯 GIẢI PHÁP TRIỆT ĐỂ:
 * - Chỉ target navigation BÊN TRONG #comments
 * - Chỉ target navigation BÊN TRONG .mc-comment-nav-wrapper
 * - KHÔNG dùng class .navigation đơn thuần
 * - Thêm nhiều layer specificity để chắc chắn KHÔNG ảnh hưởng menu
 */
#comments .mc-comment-nav-wrapper .navigation.pagination,
div#comments div.mc-comment-nav-wrapper nav.navigation,
.comments-area .mc-comment-nav-wrapper .navigation.pagination,
.comments-area > .mc-comment-nav-wrapper > .navigation {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    flex-wrap: wrap !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* 🔒 PROTECTION: Đảm bảo KHÔNG ảnh hưởng menu navigation */
/* Các selector này CHỈ hoạt động trong context của comment area */
.mc-comment-nav-wrapper .page-numbers,
#comments .mc-comment-nav-wrapper .page-numbers,
.comments-area .mc-comment-nav-wrapper .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    font-size: 14px;
    font-weight: 500;
    color: #4a5568;
    background: #fff;
    border: 1px solid #e8ecef;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.mc-comment-nav-wrapper .page-numbers:hover,
#comments .mc-comment-nav-wrapper .page-numbers:hover {
    background: #007bff;
    border-color: #007bff;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.mc-comment-nav-wrapper .page-numbers.current,
#comments .mc-comment-nav-wrapper .page-numbers.current {
    background: #007bff;
    border-color: #007bff;
    color: #fff;
    font-weight: 700;
    cursor: default;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.mc-comment-nav-wrapper .page-numbers svg,
#comments .mc-comment-nav-wrapper .page-numbers svg {
    width: 16px;
    height: 16px;
}

/* 🚫 EXPLICIT EXCLUSION: Đảm bảo KHÔNG apply cho menu */
/* Nếu có menu với class .navigation NGOÀI comment area - KHÔNG apply */
header .navigation,
nav.main-navigation,
.site-navigation,
#site-navigation,
.primary-navigation,
.secondary-navigation {
    /* Menu navigation giữ nguyên style của theme */
    display: inherit !important;
    align-items: inherit !important;
    justify-content: inherit !important;
    gap: inherit !important;
}

/* ==============================================
   COMMENT FORM
   ============================================== */
.comment-respond {
    margin-top: 40px;
    padding: 32px;
    background: #fff;
    border: 2px solid #e8ecef;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.comment-reply-title {
    font-size: 24px;
    font-weight: 700;
    color: #1a202c;
    margin: 0 0 24px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.comment-reply-title small {
    font-size: 14px;
    font-weight: 500;
}

.comment-reply-title small a {
    color: #dc3545;
    text-decoration: none;
    padding: 6px 12px;
    background: #fff5f7;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.comment-reply-title small a:hover {
    background: #dc3545;
    color: #fff;
}

/* Form fields */
.comment-form-modern p {
    margin-bottom: 20px;
}

.comment-form-modern label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 8px;
}

.comment-form-modern .required {
    color: #dc3545;
}

.comment-form-modern input[type="text"],
.comment-form-modern input[type="email"],
.comment-form-modern textarea {
    width: 100%;
    padding: 14px 16px;
    font-size: 15px;
    font-family: inherit;
    color: #2d3748;
    background: #f7fafc;
    border: 2px solid #e8ecef;
    border-radius: 10px;
    transition: all 0.3s ease;
    outline: none;
}

.comment-form-modern input[type="text"]:focus,
.comment-form-modern input[type="email"]:focus,
.comment-form-modern textarea:focus {
    background: #fff;
    border-color: #007bff;
    box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.1);
}

.comment-form-modern textarea {
    min-height: 140px;
    resize: vertical;
}

.comment-form-modern input::placeholder,
.comment-form-modern textarea::placeholder {
    color: #a0aec0;
}

/* Submit button */
.comment-form-modern .submit-button {
    padding: 14px 32px;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.comment-form-modern .submit-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.4);
}

.comment-form-modern .submit-button:active {
    transform: translateY(0);
}

/* ==============================================
   RESPONSIVE DESIGN
   ============================================== */
@media (max-width: 768px) {
    .comment-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .comment-sort-form {
        margin-left: 0;
        width: 100%;
    }
    
    .comment-sort-form select {
        width: 100%;
    }
    
    .comment-title {
        font-size: 24px;
    }
    
    .comment-body {
        flex-direction: column;
        padding: 16px;
    }
    
    .comment-author {
        flex-direction: row;
        align-items: center;
        width: 100%;
    }
    
    .comment-author .comment-avatar {
        width: 40px;
        height: 40px;
    }
    
    .comment-list .children {
        padding-left: 20px;
    }
    
    .comment-list .children > li::before {
        left: -20px;
        width: 14px;
    }
    
    .comment-respond {
        padding: 20px;
    }
    
    .comment-actions {
        width: 100%;
    }
    
    .comment-actions .comment-reply-link,
    .comment-like-btn {
        flex: 1;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .comment-title {
        font-size: 20px;
    }
    
    .comment-header-icon {
        width: 24px;
        height: 24px;
    }
    
    .comment-content {
        font-size: 14px;
    }
    
    .comment-reply-title {
        font-size: 20px;
    }
}

/* ==============================================
   UTILITY CLASSES
   ============================================== */
.post_comments {
    color: #007bff;
    font-weight: 600;
    text-decoration: none;
    transition: color 0.3s ease;
}

.post_comments:hover {
    color: #0056b3;
    text-decoration: underline;
}

/* Print styles */
@media print {
    .comment-actions,
    .comment-sort-form,
    .comment-respond {
        display: none;
    }
}

/* ==============================================
   🛡️ FINAL PROTECTION LAYER
   Đảm bảo 100% không conflict với bất kỳ menu nào
   ============================================== */

/* Reset any potential conflicts with main navigation */
body > header nav.navigation,
body > nav.navigation,
.site-header .navigation,
.main-header .navigation {
    display: inherit !important;
    flex-direction: inherit !important;
    gap: inherit !important;
}

/* Ensure comment pagination only affects within comments area */
.mc-comment-nav-wrapper {
    isolation: isolate; /* Create new stacking context */
}
