/**
 * =====================================================
 * CUSTOM PAGE CONTENT STYLES
 * File: custom-page.css
 * Mục đích: Style cho trang tùy chỉnh với typography đẹp, dễ đọc
 * =====================================================
 */

/* ========== CSS Variables ========== */
:root {
    --cp-max-width: 820px;
    --cp-bg: #ffffff;
    --cp-text: #334155;
    --cp-text-muted: #64748b;
    --cp-heading: #0f172a;
    --cp-link: var(--brand-color, #754ffe);
    --cp-border: #e2e8f0;
    --cp-code-bg: #f1f5f9;
    --cp-blockquote-border: var(--brand-color, #754ffe);
    --cp-blockquote-bg: #f8fafc;
}

/* ========== Main Container ========== */
.custom-page-wrapper {
    background: linear-gradient(180deg, #f8fafc 0%, #fff 300px);
    min-height: 60vh;
}

.custom-page-container {
    max-width: var(--cp-max-width);
    margin: 0 auto;
    padding: 48px 24px 80px;
}

/* ========== Page Header ========== */
.custom-page-header {
    margin-bottom: 40px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--cp-border);
}

.custom-page-title {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--cp-heading);
    line-height: 1.2;
    margin: 0 0 12px 0;
    letter-spacing: -0.02em;
}

.custom-page-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.9rem;
    color: var(--cp-text-muted);
}

.custom-page-meta i {
    margin-right: 6px;
}

/* ========== Content Typography ========== */
.custom-page-content {
    font-size: 1.125rem;
    line-height: 1.85;
    color: var(--cp-text);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Headings */
.custom-page-content h1,
.custom-page-content h2,
.custom-page-content h3,
.custom-page-content h4,
.custom-page-content h5,
.custom-page-content h6 {
    color: var(--cp-heading);
    font-weight: 700;
    margin-top: 2em;
    margin-bottom: 0.75em;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.custom-page-content h1 {
    font-size: 2rem;
    font-weight: 800;
}

.custom-page-content h2 {
    font-size: 1.625rem;
    padding-bottom: 0.5em;
    border-bottom: 2px solid var(--cp-border);
}

.custom-page-content h3 {
    font-size: 1.375rem;
}

.custom-page-content h4 {
    font-size: 1.2rem;
}

.custom-page-content h5 {
    font-size: 1.1rem;
}

.custom-page-content h6 {
    font-size: 1rem;
    color: var(--cp-text-muted);
}

.custom-page-content h1:first-child,
.custom-page-content h2:first-child,
.custom-page-content h3:first-child {
    margin-top: 0;
}

/* Paragraphs */
.custom-page-content p {
    margin-bottom: 1.5em;
}

.custom-page-content p:last-child {
    margin-bottom: 0;
}

/* Lead paragraph - first paragraph larger */
.custom-page-content > p:first-of-type {
    font-size: 1.25rem;
    color: var(--cp-text-muted);
    line-height: 1.7;
}

/* Links */
.custom-page-content a {
    color: var(--cp-link);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
}

.custom-page-content a:hover {
    border-bottom-color: var(--cp-link);
}

/* Strong & Emphasis */
.custom-page-content strong,
.custom-page-content b {
    font-weight: 700;
    color: var(--cp-heading);
}

.custom-page-content em,
.custom-page-content i:not(.fa):not(.fas):not(.far):not(.fab) {
    font-style: italic;
}

/* Lists */
.custom-page-content ul,
.custom-page-content ol {
    margin-bottom: 1.5em;
    padding-left: 1.75em;
}

.custom-page-content li {
    margin-bottom: 0.6em;
    line-height: 1.7;
}

.custom-page-content li:last-child {
    margin-bottom: 0;
}

.custom-page-content ul li {
    list-style-type: disc;
}

.custom-page-content ol li {
    list-style-type: decimal;
}

.custom-page-content ul ul,
.custom-page-content ol ol,
.custom-page-content ul ol,
.custom-page-content ol ul {
    margin-top: 0.6em;
    margin-bottom: 0.6em;
}

/* Nested list styling */
.custom-page-content ul ul li {
    list-style-type: circle;
}

.custom-page-content ul ul ul li {
    list-style-type: square;
}

/* ========== Images ========== */
.custom-page-content img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 2em 0;
    display: block;
    box-shadow: 0 8px 30px rgba(15, 23, 42, 0.1);
}

.custom-page-content img + img {
    margin-top: 1.5em;
}

/* Centered images */
.custom-page-content img.aligncenter,
.custom-page-content img[style*="margin: 0 auto"],
.custom-page-content img[style*="margin:0 auto"],
.custom-page-content p > img:only-child {
    margin-left: auto;
    margin-right: auto;
}

/* Image with caption */
.custom-page-content figure {
    margin: 2em 0;
}

.custom-page-content figure img {
    margin-bottom: 0.75em;
}

.custom-page-content figcaption {
    font-size: 0.9rem;
    color: var(--cp-text-muted);
    text-align: center;
    font-style: italic;
}

/* ========== Blockquote ========== */
.custom-page-content blockquote {
    margin: 2em 0;
    padding: 24px 32px;
    background: var(--cp-blockquote-bg);
    border-left: 4px solid var(--cp-blockquote-border);
    border-radius: 0 12px 12px 0;
    font-size: 1.1rem;
    font-style: italic;
    color: var(--cp-text);
}

.custom-page-content blockquote p:last-child {
    margin-bottom: 0;
}

.custom-page-content blockquote cite {
    display: block;
    margin-top: 1em;
    font-size: 0.9rem;
    font-style: normal;
    color: var(--cp-text-muted);
}

.custom-page-content blockquote cite::before {
    content: "— ";
}

/* ========== Code ========== */
.custom-page-content code {
    background: var(--cp-code-bg);
    padding: 3px 8px;
    border-radius: 6px;
    font-family: 'SF Mono', 'Fira Code', Consolas, Monaco, monospace;
    font-size: 0.9em;
    color: #e11d48;
}

.custom-page-content pre {
    margin: 2em 0;
    padding: 24px 28px;
    background: #1e293b;
    border-radius: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.custom-page-content pre code {
    background: transparent;
    padding: 0;
    color: #e2e8f0;
    font-size: 0.95rem;
    line-height: 1.6;
}

/* ========== Tables ========== */
.custom-page-content table {
    width: 100%;
    margin: 2em 0;
    border-collapse: collapse;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--cp-border);
    font-size: 1rem;
}

.custom-page-content th,
.custom-page-content td {
    padding: 14px 18px;
    text-align: left;
    border-bottom: 1px solid var(--cp-border);
}

.custom-page-content th {
    background: var(--cp-code-bg);
    font-weight: 600;
    color: var(--cp-heading);
}

.custom-page-content tr:last-child td {
    border-bottom: none;
}

.custom-page-content tr:hover td {
    background: rgba(0, 0, 0, 0.02);
}

/* ========== Horizontal Rule ========== */
.custom-page-content hr {
    border: none;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--cp-border), transparent);
    margin: 3em 0;
}

/* ========== Video Embeds ========== */
.custom-page-content iframe {
    max-width: 100%;
    border-radius: 12px;
    margin: 2em 0;
}

.custom-page-content .video-embed,
.custom-page-content .embed-responsive {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    margin: 2em 0;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(15, 23, 42, 0.15);
}

.custom-page-content .video-embed iframe,
.custom-page-content .embed-responsive iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    border-radius: 12px;
}

/* ========== Highlight / Mark ========== */
.custom-page-content mark {
    background: linear-gradient(120deg, #fef08a 0%, #fde047 100%);
    padding: 2px 6px;
    border-radius: 4px;
}

/* ========== Abbreviation ========== */
.custom-page-content abbr {
    border-bottom: 1px dotted var(--cp-text-muted);
    cursor: help;
}

/* ========== Subscript & Superscript ========== */
.custom-page-content sub,
.custom-page-content sup {
    font-size: 0.75em;
}

/* ========== Responsive ========== */
@media (max-width: 992px) {
    .custom-page-container {
        padding: 40px 20px 60px;
    }
    
    .custom-page-title {
        font-size: 1.875rem;
    }
    
    .custom-page-content {
        font-size: 1.0625rem;
    }
}

@media (max-width: 768px) {
    .custom-page-container {
        padding: 32px 16px 48px;
    }
    
    .custom-page-title {
        font-size: 1.625rem;
    }
    
    .custom-page-header {
        margin-bottom: 32px;
        padding-bottom: 24px;
    }
    
    .custom-page-content {
        font-size: 1rem;
        line-height: 1.8;
    }
    
    .custom-page-content > p:first-of-type {
        font-size: 1.1rem;
    }
    
    .custom-page-content h1 { font-size: 1.625rem; }
    .custom-page-content h2 { font-size: 1.375rem; }
    .custom-page-content h3 { font-size: 1.2rem; }
    
    .custom-page-content blockquote {
        padding: 20px 24px;
        font-size: 1rem;
    }
    
    .custom-page-content pre {
        padding: 18px 20px;
        font-size: 0.875rem;
        border-radius: 8px;
    }
    
    .custom-page-content img {
        border-radius: 8px;
        margin: 1.5em 0;
    }
    
    .custom-page-content th,
    .custom-page-content td {
        padding: 12px 14px;
        font-size: 0.9rem;
    }
}

@media (max-width: 576px) {
    .custom-page-container {
        padding: 24px 12px 40px;
    }
    
    .custom-page-title {
        font-size: 1.5rem;
    }
    
    .custom-page-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .custom-page-content ul,
    .custom-page-content ol {
        padding-left: 1.25em;
    }
}

/* ========== Dark Mode ========== */
html.dark-mode {
    --cp-bg: #1e293b;
    --cp-text: #cbd5e1;
    --cp-text-muted: #94a3b8;
    --cp-heading: #f1f5f9;
    --cp-border: #334155;
    --cp-code-bg: #0f172a;
    --cp-blockquote-bg: rgba(255, 255, 255, 0.05);
}

html.dark-mode .custom-page-wrapper {
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 300px);
}

html.dark-mode .custom-page-content code {
    color: #fb7185;
}

html.dark-mode .custom-page-content pre {
    background: #0f172a;
    border: 1px solid var(--cp-border);
}

html.dark-mode .custom-page-content th {
    background: #0f172a;
}

html.dark-mode .custom-page-content tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

html.dark-mode .custom-page-content img {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

html.dark-mode .custom-page-content mark {
    background: linear-gradient(120deg, #854d0e 0%, #a16207 100%);
    color: #fef3c7;
}

/* ========== Print Styles ========== */
@media print {
    .custom-page-wrapper {
        background: #fff;
    }
    
    .custom-page-container {
        max-width: 100%;
        padding: 0;
    }
    
    .custom-page-content {
        font-size: 12pt;
        line-height: 1.6;
    }
    
    .custom-page-content img {
        box-shadow: none;
        page-break-inside: avoid;
    }
    
    .custom-page-content h1,
    .custom-page-content h2,
    .custom-page-content h3 {
        page-break-after: avoid;
    }
}
