/*
 * ============================================================================
 * CKEditor Content Styles — Dành cho Server MVC (render bài viết ngoài cổng)
 * ============================================================================
 * File này được trích xuất từ magazineStyles.css của TDEditor client.
 * Chỉ chứa CSS cần thiết để hiển thị nội dung đúng bên ngoài editor.
 * KHÔNG chứa CSS cho editor UI (toolbar, style panel, viền soạn thảo...).
 *
 * Cách dùng: <link rel="stylesheet" href="~/css/ckeditor-content-styles.css" />
 * đặt trong layout/view hiển thị bài viết.
 *
 * Cập nhật lần cuối: 2026-03-26
 * ============================================================================
 */

/* ==========================================================================
   1. MAGAZINE STYLES — Kiểu bài viết E-Magazine
   ========================================================================== */

/* Chữ cái đầu lớn */
.drop-cap::first-letter {
    float: left;
    font-size: 4em;
    line-height: 0.8;
    margin: 0.1em 0.15em 0 0;
    font-weight: bold;
    color: #1a365d;
}

/* Đoạn dẫn */
.lead-paragraph {
    font-size: 1.25em;
    font-weight: 500;
    color: #374151;
    border-left: 4px solid #3b82f6;
    padding-left: 1em;
    margin: 1.5em 0;
}

/* Quote nổi bật */
.pull-quote {
    font-size: 1.5em;
    font-style: italic;
    text-align: center;
    color: #1e40af;
    border: none;
    padding: 1.5em 2em;
    margin: 2em auto;
    max-width: 80%;
    position: relative;
    background: #f8fafc;
    border-radius: 8px;
}

.pull-quote::before {
    content: '\275D';
    font-size: 2.5em;
    position: absolute;
    top: -0.1em;
    left: 0.2em;
    color: #8ca9cf;
    font-family: serif;
}

/* Highlight Box */
.highlight-box {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-radius: 8px;
    padding: 1.5em;
    margin: 1.5em 0;
    border-left: 4px solid #f59e0b;
}

/* Thông tin tác giả */
.author-info {
    font-style: italic;
    color: #6b7280;
    border-top: 1px solid #e5e7eb;
    padding-top: 1em;
    margin-top: 2em;
}

/* 2 cột */
.two-columns {
    column-count: 2;
    column-gap: 2em;
    column-rule: 2px solid #e5e7eb;
    background: #f8fafc;
    padding: 1.5em;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

/* 3 cột */
.three-columns {
    column-count: 3;
    column-gap: 1.5em;
    column-rule: 2px solid #e5e7eb;
    background: #f8fafc;
    padding: 1.5em;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

/* Caption ảnh */
.image-caption {
    font-size: 0.875em;
    color: #6b7280;
    text-align: center;
    font-style: italic;
    margin-top: 0.5em;
}

@media (max-width: 768px) {
    .three-columns {
        column-count: 1;
    }

    .two-columns {
        column-count: 1;
    }
}

/* ==========================================================================
   2. STYLES BÁO CHÍ/MAGAZINE NÂNG CAO
   ========================================================================== */

/* Số liệu nổi bật */
.stat-number {
    text-align: center;
    padding: 2em 1.5em;
    margin: 2em 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    color: #ffffff;
    box-shadow: 0 10px 40px rgba(102, 126, 234, 0.3);
}

.stat-number strong,
.stat-number b {
    display: block;
    font-size: 3.5em;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 0.1em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.stat-number p {
    margin: 0;
    font-size: 1.1em;
    opacity: 0.9;
}

/* Thông tin quan trọng */
.info-alert {
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
    border-left: 5px solid #0284c7;
    border-radius: 0 12px 12px 0;
    padding: 1.25em 1.5em;
    margin: 1.5em 0;
    color: #0c4a6e;
    position: relative;
}

.info-alert::before {
    content: '\2139\FE0F';
    position: absolute;
    left: -2px;
    top: -12px;
    font-size: 1.5em;
    background: white;
    border-radius: 50%;
    padding: 2px 6px;
}

/* Cảnh báo */
.warning-alert {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-left: 5px solid #d97706;
    border-radius: 0 12px 12px 0;
    padding: 1.25em 1.5em;
    margin: 1.5em 0;
    color: #92400e;
    position: relative;
}

.warning-alert::before {
    content: '\26A0\FE0F';
    position: absolute;
    left: -2px;
    top: -12px;
    font-size: 1.5em;
    background: white;
    border-radius: 50%;
    padding: 2px 6px;
}

/* Thành công */
.success-alert {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border-left: 5px solid #059669;
    border-radius: 0 12px 12px 0;
    padding: 1.25em 1.5em;
    margin: 1.5em 0;
    color: #065f46;
    position: relative;
}

.success-alert::before {
    content: '\2705';
    position: absolute;
    left: -2px;
    top: -12px;
    font-size: 1.5em;
    background: white;
    border-radius: 50%;
    padding: 2px 6px;
}

/* Dấu phân cách trang trí */
.section-divider {
    text-align: center;
    margin: 2em 0;
    display: flex;
    align-items: center;
    gap: 1em;
}

.section-divider::before,
.section-divider::after {
    content: '';
    flex: 1;
    height: 2px;
    background: linear-gradient(90deg, transparent, #3b82f6, #8b5cf6);
}

.section-divider::after {
    background: linear-gradient(90deg, #8b5cf6, #3b82f6, transparent);
}

/* Hộp kết luận */
.conclusion-box {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: #f1f5f9;
    padding: 2em;
    border-radius: 16px;
    margin: 2em 0;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.conclusion-box::before {
    content: '\1F4CC KẾT LUẬN';
    display: block;
    font-weight: 700;
    font-size: 0.85em;
    letter-spacing: 0.1em;
    color: #fbbf24;
    margin-bottom: 1em;
    padding-bottom: 0.5em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.conclusion-box p {
    margin: 0;
    line-height: 1.8;
}

/* Đoạn nhấn mạnh */
.emphasis-paragraph {
    font-size: 1.15em;
    font-weight: 500;
    color: #1e40af;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    padding: 1.25em 1.5em;
    border-radius: 12px;
    margin: 1.5em 0;
    border-left: 4px solid #3b82f6;
    position: relative;
}

.emphasis-paragraph::before {
    content: '\1F4A1';
    position: absolute;
    left: 12px;
    top: -10px;
    font-size: 1.3em;
    background: white;
    border-radius: 50%;
    padding: 2px 4px;
}

/* ==========================================================================
   3. BASE CONTENT STYLES
   ========================================================================== */

.category {
    font-weight: bold;
    color: #ef4444;
    text-transform: uppercase;
    font-size: 0.9em;
}

.document-title {
    font-size: 2.25em;
    font-weight: 800;
    margin-bottom: 0.5em;
    color: #111827;
    line-height: 1.2;
}

.document-subtitle {
    font-size: 1.5em;
    font-weight: 600;
    color: #4b5563;
    margin-top: 0.5em;
}

.info-box {
    background: #f3f4f6;
    border-radius: 6px;
    padding: 1.25em;
    border: 1px solid #e5e7eb;
    margin: 1em 0;
}

.side-quote {
    border-left: 4px solid #3b82f6;
    padding-left: 1.25em;
    font-style: italic;
    color: #4b5563;
    margin: 1.5em 0;
}

.marker {
    background-color: #fef08a;
    padding: 0.1em 0.2em;
    border-radius: 2px;
}

.spoiler {
    background-color: #1f2937;
    color: #1f2937;
    border-radius: 4px;
    padding: 0 0.2em;
    cursor: help;
}

.spoiler:hover {
    color: #ffffff;
}

.fancy-code {
    background: #111827;
    color: #f9fafb;
    padding: 1.25em;
    border-radius: 8px;
    font-family: 'Fira Code', monospace;
    overflow-x: auto;
    font-size: 0.9em;
}

.fancy-code-bright {
    background: #ffffff;
    color: #111827;
    border: 1px solid #e5e7eb;
}

/* ==========================================================================
   4. IMAGE GALLERY & COMPARISON
   ========================================================================== */

/* Grid 2x2 */
.image-grid-2x2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin: 1.5em 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.image-grid-2x2 figure,
.image-grid-2x2 img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    margin: 0;
    transition: transform 0.3s ease;
}

.image-grid-2x2 figure:hover img,
.image-grid-2x2 img:hover {
    transform: scale(1.05);
}

/* Grid 3 cột */
.image-grid-3col {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 1.5em 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.image-grid-3col figure,
.image-grid-3col img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    margin: 0;
    transition: transform 0.3s ease;
}

.image-grid-3col figure:hover img,
.image-grid-3col img:hover {
    transform: scale(1.05);
}

/* Grid 2x1 */
.image-grid-2x1 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin: 1.5em 0;
}

.image-grid-2x1 figure,
.image-grid-2x1 img {
    width: 100%;
    height: auto;
    object-fit: cover;
    margin: 0;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* So sánh TRƯỚC/SAU */
.image-comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    position: relative;
    margin: 2em 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    background: #f1f5f9;
    padding: 12px;
}

.image-comparison figure {
    margin: 0;
}

.image-comparison figure img {
    width: 100%;
    height: auto;
    border-radius: 8px;
}

.image-comparison figure figcaption {
    text-align: center;
    padding: 0.5em;
    font-weight: 600;
    color: #374151;
}

.image-comparison figure:first-of-type::after {
    content: 'TRƯỚC';
    position: absolute;
    top: 60px;
    left: 10px;
    background: #ef4444;
    color: white;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.75em;
    font-weight: 700;
}

.image-comparison figure:last-of-type::after {
    content: 'SAU';
    position: absolute;
    top: 60px;
    right: 10px;
    background: #22c55e;
    color: white;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.75em;
    font-weight: 700;
}

@media (max-width: 768px) {

    .image-grid-2x2,
    .image-grid-3col {
        grid-template-columns: repeat(2, 1fr);
    }

    .image-grid-2x1 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {

    .image-grid-2x2,
    .image-grid-3col,
    .image-grid-2x1 {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   5. IMAGE CAPTION — Figure & Figcaption
   ========================================================================== */

figure.image {
    margin: 1em 0;
    display: table;
    max-width: 100%;
}

figure.image>figcaption {
    display: block;
    min-height: auto;
    max-height: 100px;
    height: auto;
    padding: 8px 12px;
    margin: 0;
    background-color: #f8f9fa;
    border: 1px solid #e5e7eb;
    border-top: none;
    font-size: 0.875em;
    color: #6b7280;
    text-align: center;
    font-style: italic;
    overflow-y: auto;
    word-wrap: break-word;
    white-space: normal;
}

figure.image img {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
}

figure.image.image_resized {
    max-width: 100%;
    display: block;
    margin: 1em auto;
}

figure.image.image_resized>figcaption {
    display: block;
    width: 100%;
    min-height: auto;
    max-height: 100px;
    height: auto;
}

/* ==========================================================================
   6. GRID LAYOUT — Bố cục đa cột
   ========================================================================== */

.td-grid-layout {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 12px;
    width: 100%;
    margin: 1em 0;
    box-sizing: border-box;
}

.td-grid-layout .td-grid-col {
    flex: 1;
    min-width: 0;
    box-sizing: border-box;
    min-height: 60px;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* 1 cột */
.td-grid-1col .td-grid-col {
    flex: 1;
}

/* 2 cột đều */
.td-grid-2col-equal .td-grid-col {
    flex: 1;
}

/* 3 cột đều */
.td-grid-3col-equal .td-grid-col {
    flex: 1;
}

/* 4 cột đều */
.td-grid-4col-equal .td-grid-col {
    flex: 1;
}

/* 5 cột đều */
.td-grid-5col-equal .td-grid-col {
    flex: 1;
}

/* 2 cột (33/67) */
.td-grid-2col-33-67 .td-grid-col:nth-child(1) {
    flex: 1;
}

.td-grid-2col-33-67 .td-grid-col:nth-child(2) {
    flex: 2;
}

/* 2 cột (67/33) */
.td-grid-2col-67-33 .td-grid-col:nth-child(1) {
    flex: 2;
}

.td-grid-2col-67-33 .td-grid-col:nth-child(2) {
    flex: 1;
}

/* 2 cột (25/75) */
.td-grid-2col-25-75 .td-grid-col:nth-child(1) {
    flex: 1;
}

.td-grid-2col-25-75 .td-grid-col:nth-child(2) {
    flex: 3;
}

/* 2 cột (75/25) */
.td-grid-2col-75-25 .td-grid-col:nth-child(1) {
    flex: 3;
}

.td-grid-2col-75-25 .td-grid-col:nth-child(2) {
    flex: 1;
}

/* 3 cột (25/50/25) */
.td-grid-3col-25-50-25 .td-grid-col:nth-child(1) {
    flex: 1;
}

.td-grid-3col-25-50-25 .td-grid-col:nth-child(2) {
    flex: 2;
}

.td-grid-3col-25-50-25 .td-grid-col:nth-child(3) {
    flex: 1;
}

/* 3 cột (50/25/25) */
.td-grid-3col-50-25-25 .td-grid-col:nth-child(1) {
    flex: 2;
}

.td-grid-3col-50-25-25 .td-grid-col:nth-child(2) {
    flex: 1;
}

.td-grid-3col-50-25-25 .td-grid-col:nth-child(3) {
    flex: 1;
}

/* 3 cột (25/25/50) */
.td-grid-3col-25-25-50 .td-grid-col:nth-child(1) {
    flex: 1;
}

.td-grid-3col-25-25-50 .td-grid-col:nth-child(2) {
    flex: 1;
}

.td-grid-3col-25-25-50 .td-grid-col:nth-child(3) {
    flex: 2;
}

/* Sidebar trái (20/80) */
.td-grid-2col-sidebar-left .td-grid-col:nth-child(1) {
    flex: 1;
}

.td-grid-2col-sidebar-left .td-grid-col:nth-child(2) {
    flex: 4;
}

/* Sidebar phải (80/20) */
.td-grid-2col-sidebar-right .td-grid-col:nth-child(1) {
    flex: 4;
}

.td-grid-2col-sidebar-right .td-grid-col:nth-child(2) {
    flex: 1;
}

/* 3 cột (60/20/20) */
.td-grid-3col-60-20-20 .td-grid-col:nth-child(1) {
    flex: 3;
}

.td-grid-3col-60-20-20 .td-grid-col:nth-child(2) {
    flex: 1;
}

.td-grid-3col-60-20-20 .td-grid-col:nth-child(3) {
    flex: 1;
}

@media (max-width: 768px) {
    .td-grid-layout {
        flex-direction: column !important;
    }

    .td-grid-layout .td-grid-col {
        flex: 1 1 100% !important;
        width: 100% !important;
    }
}

/* ==========================================================================
   7. BLOCKQUOTE — Trích dẫn chuyên nghiệp
   ========================================================================== */

blockquote {
    position: relative;
    margin: 1.5em 0;
    padding: 1em 3em 1em 3em;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-left: 4px solid #007bff;
    border-radius: 0 8px 8px 0;
    font-style: italic;
    color: #495057;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

blockquote::before {
    content: '\275D';
    position: absolute;
    left: 8px;
    top: 20px;
    font-size: 3.5em;
    line-height: 0;
    font-family: Georgia, serif;
    color: #007bff;
    opacity: 0.4;
    pointer-events: none;
}

blockquote::after {
    content: '\275E';
    position: absolute;
    right: 8px;
    bottom: 8px;
    font-size: 3.5em;
    line-height: 0;
    font-family: Georgia, serif;
    color: #007bff;
    opacity: 0.4;
    pointer-events: none;
}

blockquote p {
    margin: 0 0 0.6em;
}

blockquote p:last-child {
    margin-bottom: 0;
}

/* ==========================================================================
   8. PARAGRAPH SHADING — Khối nền Box cho đoạn văn
   ========================================================================== */

[style*="background-color"] {
    display: block;
    padding: 15px 20px !important;
    margin-top: 15px !important;
    margin-bottom: 15px !important;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

/* Nối liền mạch các đoạn sát nhau có cùng nền */
[style*="background-color"]+[style*="background-color"] {
    margin-top: 0 !important;
    padding-top: 7px !important;
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
}

[style*="background-color"]:has(+ [style*="background-color"]) {
    margin-bottom: 0 !important;
    padding-bottom: 7px !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

/* Figure chứa phần tử con có background-color */
figure:has(> [style*="background-color"]),
figure[style*="background-color"] {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
}

figure:has(> [style*="background-color"])>[style*="background-color"],
figure[style*="background-color"]>[style*="background-color"] {
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
}

/* figcaption kế thừa nền */
figure:has(> [style*="background-color"])>figcaption,
figure[style*="background-color"]>figcaption {
    background-color: inherit;
    padding: 10px 20px !important;
    margin: 0 !important;
}

/* Figure + Block nối liền */
figure:has(> [style*="background-color"])+[style*="background-color"] {
    margin-top: 0 !important;
    padding-top: 7px !important;
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
}

[style*="background-color"]:has(+ figure:has(> [style*="background-color"])) {
    margin-bottom: 0 !important;
    padding-bottom: 7px !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

figure:has(> [style*="background-color"]):has(+ [style*="background-color"]) {
    margin-bottom: 0 !important;
}

/* Màu tối → chữ trắng */
[style*="background-color: #111827"],
[style*="background-color: #1f2937"],
[style*="background-color: #374151"],
[style*="background-color: #1d4ed8"],
[style*="background-color: #2563eb"],
[style*="background-color: #15803d"],
[style*="background-color: #16a34a"],
[style*="background-color: #7e22ce"],
[style*="background-color: #9333ea"],
[style*="background-color: #ef4444"],
[style*="background-color: #f97316"],
[style*="background-color: #9ca3af"] {
    color: #ffffff;
}

/* ==========================================================================
   9. TODO LIST — Danh sách công việc (CKEditor TodoList plugin)
   ========================================================================== */

.todo-list {
    list-style: none;
    padding-left: 0;
}

.todo-list li {
    position: relative;
    padding-left: 1.5em;
    margin-bottom: 0.5em;
}

.todo-list li::before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #d1d5db;
    border-radius: 3px;
    position: absolute;
    left: 0;
    top: 0.15em;
}

.todo-list li.checked::before {
    background: #3b82f6;
    border-color: #3b82f6;
}

.todo-list li.checked::after {
    content: '\2713';
    position: absolute;
    left: 2px;
    top: -1px;
    color: white;
    font-size: 0.75em;
    font-weight: bold;
}

.todo-list li.checked span {
    text-decoration: line-through;
    color: #9ca3af;
}

/* ==========================================================================
   TABLE STYLES — Hiển thị bảng đúng trên cổng công khai
   ========================================================================== */

figure.table {
    display: table;
    margin: 1em auto;
    max-width: 100%;
    width: 100%;
}

figure.table>table {
    width: 100%;
}

table.ck-table-resized {
    table-layout: fixed;
    width: 100%;
    border-collapse: collapse;
}

figure.table table {
    border-collapse: collapse;
    width: 100%;
    border: 1px solid #bfbfbf;
}

figure.table table td,
figure.table table th {
    border: 1px solid #bfbfbf;
    padding: 0.4em 0.6em;
    min-width: 2em;
    vertical-align: top;
    word-break: break-word;
}

figure.table table th {
    font-weight: bold;
    background: #f3f4f6;
}

figure.table table tr:nth-child(even) {
    background: #fafafa;
}

figure.table>figcaption {
    display: block;
    text-align: center;
    font-size: 0.875em;
    color: #6b7280;
    font-style: italic;
    padding: 0.5em 0;
}

@media (max-width: 768px) {
    figure.table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    figure.table table {
        min-width: 600px;
    }
}