/* Page viewer styles */
.page-container {
    max-width: 900px;
    margin: 120px auto 50px auto;
    padding: 30px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.08);
}

.page-loading,
.page-error {
    text-align: center;
    padding: 60px 20px;
}

.page-error h1 {
    color: #E74C3C;
    margin-bottom: 15px;
}

.back-link {
    display: inline-block;
    margin-top: 20px;
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
}

.back-link:hover {
    text-decoration: underline;
}

.page-content {
    line-height: 1.8;
}

.page-title {
    font-size: 36px;
    color: #2C3E50;
    margin-bottom: 30px;
    border-bottom: 3px solid #D4AF37;
    padding-bottom: 15px;
}

.page-body {
    font-size: 16px;
    color: #34495E;
    margin-bottom: 30px;
}

.page-body h2 {
    font-size: 28px;
    color: #2C3E50;
    margin-top: 30px;
    margin-bottom: 15px;
}

.page-body h3 {
    font-size: 22px;
    color: #34495E;
    margin-top: 25px;
    margin-bottom: 12px;
}

.page-body p {
    margin-bottom: 15px;
}

.page-body ul,
.page-body ol {
    margin-bottom: 15px;
    padding-left: 30px;
}

.page-body li {
    margin-bottom: 8px;
}

.page-body a {
    color: #667eea;
    text-decoration: none;
}

.page-body a:hover {
    text-decoration: underline;
}

.page-body blockquote {
    border-left: 4px solid #D4AF37;
    padding-left: 20px;
    margin: 20px 0;
    font-style: italic;
    color: #7F8C8D;
}

.page-body code {
    background: #F8F9FA;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 14px;
}

.page-body pre {
    background: #2C3E50;
    color: #ECF0F1;
    padding: 15px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 20px 0;
}

.page-body pre code {
    background: none;
    padding: 0;
    color: inherit;
}

/* Marker highlight */
.page-body mark {
    background: rgba(245, 235, 111, 0.5);
    padding: 2px 0;
}

/* Underline accent */
.page-body u {
    text-decoration-color: #667eea;
}

/* Text variant: Call-out */
.page-body .cdx-text-variant--call-out {
    background: #f0f4ff;
    border-left: 4px solid #667eea;
    padding: 14px 18px;
    border-radius: 6px;
    margin: 16px 0;
}

/* Text variant: Citation */
.page-body .cdx-text-variant--citation {
    font-style: italic;
    border-left: 3px solid #D4AF37;
    padding-left: 18px;
    margin: 16px 0;
    color: #555;
}

/* Text variant: Details */
.page-body .cdx-text-variant--details {
    background: #f8f8f8;
    padding: 14px 18px;
    border-radius: 6px;
    margin: 16px 0;
    font-size: 0.92em;
    color: #555;
}

/* ===== Editor.js Block Styles ===== */

/* Alert blocks */
.page-body .editorjs-alert {
    padding: 14px 18px;
    border-radius: 8px;
    margin: 16px 0;
    line-height: 1.6;
}
.page-body .editorjs-alert--info {
    background: #e8f4fd;
    border-left: 4px solid #2196F3;
    color: #1565C0;
}
.page-body .editorjs-alert--success {
    background: #e8f5e9;
    border-left: 4px solid #4CAF50;
    color: #2E7D32;
}
.page-body .editorjs-alert--warning {
    background: #fff8e1;
    border-left: 4px solid #FF9800;
    color: #E65100;
}
.page-body .editorjs-alert--danger {
    background: #fce4ec;
    border-left: 4px solid #F44336;
    color: #C62828;
}
.page-body .editorjs-alert--primary {
    background: #f0f4ff;
    border-left: 4px solid #667eea;
    color: #3949AB;
}

/* File attachments */
.page-body .editorjs-attaches {
    margin: 16px 0;
}
.page-body .editorjs-attaches-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    text-decoration: none;
    color: #34495E;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.page-body .editorjs-attaches-link:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
    text-decoration: none;
}
.page-body .editorjs-attaches-ext {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 44px;
    background: #667eea;
    color: #fff;
    font-weight: 700;
    font-size: 11px;
    border-radius: 6px;
    letter-spacing: 0.5px;
}
.page-body .editorjs-attaches-name {
    flex: 1;
    font-weight: 600;
}
.page-body .editorjs-attaches-size {
    color: #999;
    font-size: 13px;
}

/* Toggle / Collapsible */
.page-body details.editorjs-toggle {
    margin: 16px 0;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}
.page-body details.editorjs-toggle summary {
    padding: 14px 18px;
    background: #f8f9fa;
    cursor: pointer;
    font-weight: 600;
    color: #2C3E50;
    user-select: none;
    transition: background 0.2s;
}
.page-body details.editorjs-toggle summary:hover {
    background: #f0f0f0;
}
.page-body details.editorjs-toggle[open] summary {
    border-bottom: 1px solid #e0e0e0;
}
.page-body details.editorjs-toggle > *:not(summary) {
    padding: 0 18px;
}
.page-body details.editorjs-toggle > p:first-of-type {
    margin-top: 14px;
}

/* CTA Button */
.page-body .editorjs-button {
    margin: 20px 0;
    text-align: center;
}
.page-body .editorjs-button a,
.page-body .editorjs-button span {
    display: inline-block;
    padding: 12px 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
}
.page-body .editorjs-button a:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    text-decoration: none;
}

/* Link preview card */
.page-body .editorjs-link-card {
    display: flex;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    margin: 16px 0;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.page-body .editorjs-link-card:hover {
    border-color: #667eea;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    text-decoration: none;
}
.page-body .editorjs-link-card-image {
    width: 120px;
    min-height: 100px;
    object-fit: cover;
    flex-shrink: 0;
}
.page-body .editorjs-link-card-content {
    padding: 14px 18px;
    flex: 1;
    min-width: 0;
}
.page-body .editorjs-link-card-title {
    font-weight: 600;
    color: #2C3E50;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.page-body .editorjs-link-card-description {
    font-size: 13px;
    color: #666;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.page-body .editorjs-link-card-url {
    font-size: 12px;
    color: #999;
    margin-top: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Tooltip (inline) */
.page-body .cdx-tooltip {
    border-bottom: 1px dashed #D4AF37;
    cursor: help;
    position: relative;
}
.page-body .cdx-tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #2C3E50;
    color: #ECF0F1;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    white-space: nowrap;
    max-width: 300px;
    z-index: 100;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Warning block (improved) */
.page-body .cdx-warning {
    background: #fff8e1;
    border-left: 4px solid #FF9800;
    padding: 14px 18px;
    border-radius: 6px;
    margin: 16px 0;
}
.page-body .cdx-warning-title {
    font-weight: 700;
    color: #E65100;
    margin-bottom: 4px;
}
.page-body .cdx-warning-message {
    color: #5D4037;
}

/* Checklist (improved) */
.page-body .cdx-checklist {
    margin: 16px 0;
}
.page-body .cdx-checklist-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 4px 0;
}
.page-body .cdx-checklist-item--checked {
    color: #7F8C8D;
    text-decoration: line-through;
}

/* Image block styles */
.page-body figure.editorjs-image {
    margin: 20px 0;
    text-align: center;
}
.page-body figure.editorjs-image img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}
.page-body figure.editorjs-image.image-border img {
    border: 3px solid #e0e0e0;
}
.page-body figure.editorjs-image.image-stretched img {
    width: 100%;
}
.page-body figure.editorjs-image.image-background {
    background: #f8f8f8;
    padding: 16px;
    border-radius: 8px;
}
.page-body figure.editorjs-image figcaption {
    margin-top: 8px;
    font-size: 14px;
    color: #888;
    font-style: italic;
}

/* Featured Image */
.page-featured-image {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 24px;
}

/* Page Meta (category, tags, author) */
.page-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    font-size: 14px;
    color: #7F8C8D;
}

.page-category a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
}

.page-category a:hover {
    text-decoration: underline;
}

.page-author {
    color: #555;
}

.page-author::before {
    content: '|';
    margin-right: 12px;
    color: #ddd;
}

.page-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.page-tag {
    background: #F0F0F0;
    color: #555;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
}

/* Social Sharing (below content) */
.social-share-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 30px;
    padding: 16px 0;
    border-top: 1px solid #eee;
}

.share-label {
    font-size: 13px;
    color: #999;
    font-weight: 500;
}

.share-divider {
    color: #ddd;
    font-size: 18px;
    line-height: 1;
}

.share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

.share-btn:hover {
    transform: scale(1.12);
    opacity: 0.85;
}

.share-twitter { background: #000; color: #fff; }
.share-telegram { background: #0088cc; color: #fff; }
.share-discord { background: #5865F2; color: #fff; }
.share-facebook { background: #1877F2; color: #fff; }
.share-instagram { background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888); color: #fff; }
.share-youtube { background: #FF0000; color: #fff; }
.share-linkedin { background: #0A66C2; color: #fff; }
.share-github { background: #333; color: #fff; }
.share-tiktok { background: #000; color: #fff; }
.share-copy { background: #667eea; color: #fff; }

.share-copied {
    font-size: 12px;
    color: #27ae60;
    font-weight: 500;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Excerpt */
.page-excerpt {
    font-size: 18px;
    color: #666;
    line-height: 1.6;
    margin-bottom: 24px;
    font-style: italic;
    border-left: 3px solid #D4AF37;
    padding-left: 16px;
}

/* Child page image */
.child-page-image {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 12px;
}

/* Embedded video (iframe) */
.page-body iframe {
    max-width: 100%;
    border-radius: 8px;
    margin: 20px 0;
}

/* Tables in content */
.page-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

.page-body th,
.page-body td {
    border: 1px solid #ddd;
    padding: 10px 14px;
    text-align: left;
}

.page-body th {
    background: #f5f5f5;
    font-weight: 600;
}

.page-body tr:nth-child(even) {
    background: #fafafa;
}

/* Page Images */
.page-images {
    margin-top: 30px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.page-image {
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.page-image:hover {
    transform: scale(1.02);
}

/* Child Pages */
.child-pages {
    margin-top: 50px;
    padding-top: 30px;
    border-top: 2px solid #E0E0E0;
}

.child-pages h2 {
    font-size: 28px;
    color: #2C3E50;
    margin-bottom: 20px;
}

.child-pages-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.child-page-card {
    background: linear-gradient(135deg, #F8F9FA 0%, #FFEFD5 100%);
    padding: 25px;
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
    border: 2px solid #E8D5B7;
}

.child-page-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(212, 175, 55, 0.25);
    border-color: #D4AF37;
}

.child-page-card h3 {
    font-size: 20px;
    color: #2C3E50;
    margin-bottom: 10px;
}

.child-page-card p {
    font-size: 14px;
    color: #7F8C8D;
    line-height: 1.6;
}

/* Gallery Grid */
.page-gallery {
    margin-top: 30px;
}

.page-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.page-gallery-item {
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 1;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.page-gallery-item:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.page-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Lightbox */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    cursor: pointer;
}

.lightbox-image {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 4px;
    cursor: default;
}

.lightbox-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: none;
    border: none;
    color: #fff;
    font-size: 36px;
    cursor: pointer;
    padding: 8px;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.lightbox-close:hover {
    opacity: 1;
}

.lightbox-prev,
.lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    font-size: 48px;
    cursor: pointer;
    padding: 12px 16px;
    line-height: 1;
    border-radius: 4px;
    opacity: 0.7;
    transition: opacity 0.2s, background 0.2s;
}

.lightbox-prev:hover,
.lightbox-next:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-prev {
    left: 16px;
}

.lightbox-next {
    right: 16px;
}

.lightbox-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 14px;
    opacity: 0.7;
    cursor: default;
}

/* Responsive */
@media (max-width: 768px) {
    .page-container {
        margin: 100px 15px 30px 15px;
        padding: 20px;
    }

    .page-title {
        font-size: 28px;
    }

    .page-body {
        font-size: 15px;
    }

    .page-images {
        grid-template-columns: 1fr;
    }

    .child-pages-list {
        grid-template-columns: 1fr;
    }

    .page-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 8px;
    }

    .lightbox-prev,
    .lightbox-next {
        font-size: 32px;
        padding: 8px 12px;
    }
}
