/* ============================================================================
   BLOG DETAIL v2 — EDITORIAL ACADEMIC READING EXPERIENCE
   ============================================================================ */

/* Reading Progress Bar */
.ed-read-progress {
    position: fixed;
    top: var(--header-desktop-h);
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, var(--brand-primary), var(--brand-gold));
    z-index: 1025;
    transition: width 0.08s linear;
}

.ed-article-section {
    padding: 22px 0 46px;
}

/* Main Article Card + Reader Themes (Light / Sepia / Dark) */
.ed-article-card {
    background: #ffffff;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 26px 30px 28px;
    box-shadow: var(--shadow-xs);
    margin-bottom: 24px;
    transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
    --reader-font-size: 17px;
}

.ed-article-card[data-reader-theme="sepia"] {
    background: #f6efe2;
    border-color: #e4d6be;
    color: #3a2e1f;
}

.ed-article-card[data-reader-theme="sepia"] .ed-article-h1,
.ed-article-card[data-reader-theme="sepia"] .blog-content h2,
.ed-article-card[data-reader-theme="sepia"] .blog-content h3 {
    color: #2b2114;
}

.ed-article-card[data-reader-theme="dark"] {
    background: #162224;
    border-color: #263a3d;
    color: #e2ecec;
}

.ed-article-card[data-reader-theme="dark"] .ed-article-h1,
.ed-article-card[data-reader-theme="dark"] .blog-content,
.ed-article-card[data-reader-theme="dark"] .blog-content p,
.ed-article-card[data-reader-theme="dark"] .blog-content li,
.ed-article-card[data-reader-theme="dark"] .blog-content h2,
.ed-article-card[data-reader-theme="dark"] .blog-content h3,
.ed-article-card[data-reader-theme="dark"] .blog-content strong {
    color: #e6f0f0 !important;
}

.ed-article-card[data-reader-theme="dark"] .ed-article-meta,
.ed-article-card[data-reader-theme="dark"] .ed-article-meta a {
    color: #9bb5b7;
}

.ed-article-card[data-reader-theme="dark"] .ed-reader-toolbar,
.ed-article-card[data-reader-theme="dark"] .ed-toc-box {
    background: #1d2d30;
    border-color: #2d4347;
    color: #d7e6e6;
}

.ed-article-card[data-reader-theme="dark"] .ed-toc-list a {
    color: #c2dada;
}

.ed-article-card[data-reader-theme="dark"] .ed-tool-chip {
    background: #223538;
    border-color: #324b4f;
    color: #dceaea;
}

.ed-article-card[data-reader-theme="dark"] .blog-content blockquote {
    background: #1d2e30;
    color: #d9e8e8;
}

.ed-article-card[data-reader-theme="dark"] #blog-content table,
.ed-article-card[data-reader-theme="dark"] #blog-content th,
.ed-article-card[data-reader-theme="dark"] #blog-content td {
    border-color: #355054;
    color: #e2ecec;
}

/* Article Header */
.ed-article-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.ed-article-h1 {
    font-family: var(--font-sans);
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1.34;
    letter-spacing: -0.02em;
    color: var(--brand-deep);
    margin: 0 0 14px;
}

.ed-article-meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 16px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--border-subtle);
}

.ed-article-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    font-size: 13.5px;
    color: var(--ink-secondary);
}

.ed-article-meta span,
.ed-article-meta a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--ink-secondary);
}

.ed-article-meta a:hover {
    color: var(--brand-primary);
}

.ed-meta-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.save-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 13px;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: var(--bg-paper);
    color: var(--ink-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.save-pill:hover,
.save-pill.saved {
    background: var(--brand-deep);
    border-color: var(--brand-deep);
    color: #ffffff;
}

/* Reader Toolbar (Font size + Light/Sepia/Dark) */
.ed-reader-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    background: var(--bg-muted);
    border: 1px solid var(--border-subtle);
    margin-bottom: 18px;
}

.ed-toolbar-section {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.ed-toolbar-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--ink-muted);
    margin-right: 2px;
}

.ed-tool-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
    background: #ffffff;
    color: var(--ink-primary);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}

.ed-tool-chip:hover,
.ed-tool-chip.is-active {
    background: var(--brand-deep);
    border-color: var(--brand-deep);
    color: #ffffff;
}

/* Hero Banner Image */
.ed-article-hero-img {
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 18px;
    background: var(--bg-muted);
    aspect-ratio: 16 / 9;
}

.ed-article-hero-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    cursor: zoom-in;
}

/* AdSense Slot (Anti-CLS container) */
.ed-ad-slot {
    margin: 18px 0;
    min-height: 100px;
    text-align: center;
    overflow: hidden;
}

/* Auto Table of Contents (TOC) */
.ed-toc-box {
    background: #f5f9f9;
    border: 1px solid var(--border-subtle);
    border-left: 4px solid var(--brand-primary);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    margin: 16px 0 22px;
}

.ed-toc-box[hidden] {
    display: none !important;
}

.ed-toc-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.ed-toc-title {
    font-size: 14.5px;
    font-weight: 800;
    color: var(--brand-deep);
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin: 0;
}

.ed-toc-toggle-btn {
    border: none;
    background: transparent;
    color: var(--brand-primary);
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
}

.ed-toc-list {
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ed-toc-list[hidden] {
    display: none !important;
}

.ed-toc-list li a {
    display: block;
    font-size: 13.8px;
    color: var(--ink-secondary);
    padding: 3px 6px;
    border-radius: 6px;
    line-height: 1.45;
}

.ed-toc-list li a:hover {
    background: rgba(44, 95, 93, 0.1);
    color: var(--brand-deep);
}

.ed-toc-list li.toc-level-3 a {
    padding-left: 20px;
    font-size: 13px;
}

/* Article Body Typography (chuẩn hóa cả bài cũ paste từ Word/CKEditor sang Inter đồng nhất) */
.blog-content {
    font-family: var(--font-sans);
    font-size: var(--reader-font-size, 17px);
    line-height: 1.85;
    color: #203133;
    word-wrap: break-word;
}

.blog-content p,
.blog-content span,
.blog-content li,
.blog-content td,
.blog-content th,
.blog-content div,
.blog-content blockquote,
.blog-content h1,
.blog-content h2,
.blog-content h3,
.blog-content h4 {
    font-family: var(--font-sans) !important;
}

.blog-content p {
    margin: 0 0 1.05em;
}

.blog-content h2 {
    font-family: var(--font-serif);
    font-size: 1.4em;
    font-weight: 700;
    color: var(--brand-deep);
    margin: 1.5em 0 0.65em;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-subtle);
    scroll-margin-top: 120px;
}

.blog-content h3 {
    font-size: 1.15em;
    font-weight: 700;
    color: var(--brand-primary);
    margin: 1.25em 0 0.5em;
    scroll-margin-top: 120px;
}

.blog-content ul,
.blog-content ol {
    padding-left: 1.5em;
    margin: 0 0 1.1em;
}

.blog-content li {
    margin-bottom: 0.45em;
}

.blog-content blockquote {
    margin: 1.25em 0;
    padding: 14px 18px;
    border-left: 4px solid var(--brand-gold);
    background: #fdf9f0;
    border-radius: 0 10px 10px 0;
    font-style: italic;
    color: #3b3528;
}

.blog-content img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    margin: 14px auto;
    display: block;
}

#blog-content .table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 16px 0;
}

#blog-content table {
    width: 100%;
    min-width: 520px;
    border-collapse: collapse;
    font-size: 0.94em;
}

#blog-content th,
#blog-content td {
    border: 1px solid var(--border-strong);
    padding: 8px 11px;
    text-align: left;
}

#blog-content th {
    background: var(--brand-soft);
    color: var(--brand-deep);
    font-weight: 700;
}

/* Copy Protection */
.protected-copy,
.protected-copy * {
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
    -webkit-touch-callout: none !important;
}

/* Tags & Social Engagement */
.ed-post-footer {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--border-subtle);
}

.ed-tags-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
    margin-bottom: 16px;
}

.ed-tag-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 11px;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand-primary);
    font-size: 12.5px;
    font-weight: 600;
}

.ed-tag-pill:hover {
    background: var(--brand-deep);
    color: #ffffff;
}

.ed-engagement-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: var(--bg-muted);
}

.ed-engagement-stats {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ink-secondary);
}

.ed-engagement-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 9px;
    border: 1px solid var(--border-strong);
    background: #ffffff;
    color: var(--ink-primary);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
}

.action-btn:hover {
    border-color: var(--brand-primary);
    color: var(--brand-primary);
}

.action-btn.liked {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: #ffffff;
}

/* Prev / Next Article Navigation */
.ed-prev-next-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.ed-pn-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 15px 18px;
    border-radius: var(--radius-md);
    background: #ffffff;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-xs);
}

.ed-pn-card:hover {
    border-color: var(--brand-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.ed-pn-card.is-next {
    text-align: right;
}

.ed-pn-label {
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--brand-primary);
}

.ed-pn-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--ink-primary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Related Posts Grid */
.ed-block-card {
    background: #ffffff;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-xs);
}

.ed-related-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.ed-related-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: var(--radius-md);
    border: 1px solid #edf3f2;
    background: #fcfdfd;
}

.ed-related-item:hover {
    border-color: var(--brand-primary);
    background: #ffffff;
    box-shadow: var(--shadow-xs);
}

.ed-related-thumb {
    width: 92px;
    height: 64px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.ed-related-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--ink-primary);
    line-height: 1.38;
    margin: 0 0 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ed-related-meta {
    font-size: 12px;
    color: var(--ink-muted);
}

/* Rating Box */
.rating-container {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 18px;
    padding-top: 8px;
    flex-wrap: wrap;
}

.rating-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.rating-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.rating-label {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    font-size: 26px;
    border-radius: 14px;
    background: #f8fbfb;
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.rating-label:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
    border-color: var(--brand-primary);
}

.rating-input:checked + .rating-label {
    background: #fef6e4;
    border-color: var(--brand-gold);
}

.rating-text {
    font-size: 12.5px;
    color: var(--ink-secondary);
}

/* Comments & Replies */
.comment-editor {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.editor-avatar img,
.author-thumb img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.editor-field {
    flex: 1 1 auto;
}

.editor-field textarea,
.reply-textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1.5px solid var(--border-subtle);
    font-size: 14.5px;
    font-family: inherit;
    resize: vertical;
}

.editor-field textarea:focus,
.reply-textarea:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(44, 95, 93, 0.12);
}

.editor-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
}

.char-counter {
    font-size: 12px;
    color: var(--ink-muted);
}

.success-message {
    display: none;
    padding: 10px 14px;
    border-radius: 10px;
    background: #dcfce7;
    color: #166534;
    font-weight: 600;
    margin-bottom: 12px;
}

.comment-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.comment-main {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.comment-content {
    flex: 1 1 auto;
    background: #f8fbfb;
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 12px 14px;
}

.comment-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 6px;
}

.comment-header .username {
    font-weight: 700;
    font-size: 14px;
    color: var(--brand-deep);
}

.author-badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--brand-gold-light);
    color: #0e2e30;
    font-size: 11px;
    font-weight: 700;
    margin-left: 4px;
}

.comment-date {
    font-size: 12px;
    color: var(--ink-muted);
}

.delete-btn {
    margin-left: auto;
    font-size: 12px;
    color: #dc2626 !important;
    font-weight: 600;
}

.comment-text {
    font-size: 14.5px;
    line-height: 1.6;
    color: var(--ink-primary);
    margin-bottom: 8px;
}

.reply-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: none;
    background: transparent;
    color: var(--brand-primary);
    font-size: 12.8px;
    font-weight: 700;
    cursor: pointer;
    padding: 0;
}

.reply-form {
    display: none;
    margin-top: 10px;
}

.reply-form.active {
    display: block;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.reply-item {
    margin-top: 10px;
    margin-left: 48px;
}

/* Image Zoom Overlay & Delete Modal (tương thích blog_detail.js) */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.overlay img {
    max-width: 92%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 8px;
}

.close-btn {
    position: absolute;
    top: 14px;
    right: 18px;
    color: #ffffff;
    font-size: 32px;
    cursor: pointer;
    background: none;
    border: none;
}

.popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(14, 46, 48, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2050;
}

.popup-overlay.active,
.popup-overlay.show {
    display: flex;
}

.popup-container {
    background: #ffffff;
    border-radius: 16px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.popup-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: #fee2e2;
    color: #dc2626;
    display: flex;
    align-items: center;
    justify-content: center;
}

.popup-icon svg {
    width: 24px;
    height: 24px;
}

.popup-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 18px;
}

.popup-btn {
    padding: 9px 18px;
    border-radius: 9px;
    border: none;
    font-weight: 700;
    cursor: pointer;
}

.popup-btn-cancel {
    background: #edf2f7;
    color: #334155;
}

.popup-btn-delete {
    background: #dc2626;
    color: #ffffff;
}

/* Menu Bot (Danh mục liên quan khác) */
.service-container {
    background: #ffffff;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 24px;
}

.service-container .service-heading {
    font-family: var(--font-serif);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--brand-deep);
    margin: 0 0 14px;
}

.services-grid {
    display: flex;
    overflow-x: auto;
    gap: 12px;
    padding-bottom: 6px;
    scrollbar-width: thin;
}

.service-card {
    flex: 0 0 148px;
    min-width: 148px;
    background: var(--bg-paper);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 14px 12px;
    text-align: center;
    color: var(--ink-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
}

.service-card:hover,
.service-card.active {
    background: var(--brand-deep);
    border-color: var(--brand-deep);
    color: #ffffff;
}

.service-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--brand-soft);
    color: var(--brand-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.service-card:hover .service-icon,
.service-card.active .service-icon {
    background: rgba(245, 200, 108, 0.22);
    color: var(--brand-gold-light);
}

.service-title {
    font-size: 13px;
    font-weight: 700;
}

.service-chevron {
    display: none;
}

@media (max-width: 991px) {
    .ed-read-progress {
        top: var(--header-mobile-h);
    }
}

@media (max-width: 767px) {
    .ed-article-card {
        padding: 18px 16px 20px;
        border-radius: 14px;
    }
    .ed-article-h1 {
        font-size: 1.4rem;
    }
    .ed-prev-next-grid,
    .ed-related-grid {
        grid-template-columns: 1fr;
    }
    .ed-pn-card.is-next {
        text-align: left;
    }
    .reply-item {
        margin-left: 20px;
    }
}
