/* ============================================
   MARKDOWN PREVIEW - PREVIEW & MARKDOWN STYLES
   ============================================ */

/* Markdown Preview Styles */
.preview-container h1,
.preview-container h2,
.preview-container h3,
.preview-container h4,
.preview-container h5,
.preview-container h6 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
    line-height: 1.3;
}

.preview-container h1:first-child,
.preview-container h2:first-child,
.preview-container h3:first-child {
    margin-top: 0;
}

.preview-container h1 { font-size: 1.75rem; border-bottom: 1px solid var(--border-color); padding-bottom: 0.3em; }
.preview-container h2 { font-size: 1.5rem; border-bottom: 1px solid var(--border-color); padding-bottom: 0.3em; }
.preview-container h3 { font-size: 1.25rem; }
.preview-container h4 { font-size: 1.1rem; }

.preview-container p {
    margin: 0 0 1em 0;
}

.preview-container a {
    color: var(--accent-it);
    text-decoration: none;
}

.preview-container a:hover {
    text-decoration: underline;
}

.preview-container code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875em;
    background: var(--bg-card);
    padding: 0.2em 0.4em;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.preview-container pre {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    overflow-x: auto;
    margin: 1em 0;
}

.preview-container pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.8125rem;
}

.preview-container blockquote {
    margin: 1em 0;
    padding: 0.5em 1em;
    border-left: 4px solid var(--accent-it);
    background: var(--bg-card);
    color: var(--text-secondary);
}

.preview-container blockquote p:last-child {
    margin-bottom: 0;
}

.preview-container ul,
.preview-container ol {
    margin: 1em 0;
    padding-left: 2em;
}

.preview-container li {
    margin: 0.25em 0;
}

.preview-container input[type="checkbox"] {
    margin-right: 0.5em;
    pointer-events: none;
}

.preview-container table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
}

.preview-container th,
.preview-container td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: left;
}

.preview-container th {
    background: var(--bg-card);
    font-weight: 600;
}

.preview-container tr:nth-child(even) {
    background: var(--bg-card);
}

.preview-container img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1em 0;
}

.preview-container hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 2em 0;
}

.preview-container del,
.preview-container s {
    text-decoration: line-through;
    color: var(--text-muted);
}

/* Print Styles */
@media print {
    /* Hide everything except the preview pane */
    body::before,
    header,
    footer,
    .sidebar,
    .toolbar,
    .pane-header,
    .editor-pane,
    .find-replace-bar,
    .split-resizer {
        display: none !important;
    }

    .calculator-layout {
        display: block;
    }

    .calculator-panel {
        border: none;
        padding: 0;
    }

    .workspace {
        display: block;
    }

    .preview-pane {
        border: none;
    }

    .preview-container {
        padding: 0;
    }

    /* Fallback print mode - ensure light theme for printing */
    body.printing-fallback,
    body.printing-fallback .preview-pane,
    body.printing-fallback .preview-container {
        background: white !important;
        color: black !important;
    }

    body.printing-fallback .preview-container h1,
    body.printing-fallback .preview-container h2,
    body.printing-fallback .preview-container h3 {
        border-bottom-color: #ccc !important;
    }

    body.printing-fallback .preview-container code,
    body.printing-fallback .preview-container pre {
        background: #f5f5f5 !important;
        border-color: #ddd !important;
        color: #333 !important;
    }

    body.printing-fallback .preview-container blockquote {
        border-left-color: #06b6d4 !important;
        background: #f5f5f5 !important;
    }

    body.printing-fallback .preview-container a {
        color: #06b6d4 !important;
    }

    /* Print optimizations */
    pre {
        white-space: pre-wrap;
        word-break: break-word;
    }

    img {
        max-width: 100%;
        page-break-inside: avoid;
    }

    h1, h2, h3 {
        page-break-after: avoid;
    }

    /* Avoid orphaned/widowed lines */
    p, li {
        orphans: 3;
        widows: 3;
    }
}
