/* PDF tools - file pickers, page grids, status messages */

.pt-form { display: flex; flex-direction: column; gap: 14px; }
.pt-help { font-size: .8125rem; color: var(--color-text-muted); margin: 8px 0 0; }

.pt-status {
    margin-top: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: .875rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    min-height: 1px;
}
.pt-status:empty { display: none; }
.pt-status.is-info    { background: #DBEAFE; border-color: #BFDBFE; color: #1D4ED8; }
.pt-status.is-success { background: #DCFCE7; border-color: #86EFAC; color: #15803D; }
.pt-status.is-warn    { background: #FEF3C7; border-color: #FDE68A; color: #B45309; }
.pt-status.is-error   { background: #FEE2E2; border-color: #FCA5A5; color: #B91C1C; }

/* File-order list (merger) */
.pt-file-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.pt-file-row {
    display: grid;
    grid-template-columns: 24px 1fr 80px 36px 36px 36px;
    gap: 8px;
    align-items: center;
    padding: 8px 12px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
}
.pt-handle { color: var(--color-text-muted); cursor: grab; }
.pt-file-name { font-size: .875rem; font-weight: 500; word-break: break-all; }
.pt-file-size { font-size: .75rem; color: var(--color-text-muted); text-align: right; }

/* Page thumbnail grid (reorder, pdf-to-images) */
.pt-page-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    margin-top: 16px;
}
.pt-page-cell {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: grab;
    transition: border-color .15s, transform .15s;
}
.pt-page-cell.is-dragging { opacity: .4; }
.pt-page-cell.is-over     { border-color: var(--color-primary); transform: scale(1.02); }
.pt-page-cell canvas { max-width: 100%; height: auto; border: 1px solid var(--color-border); border-radius: 4px; }
.pt-page-num { font-size: .75rem; color: var(--color-text-muted); font-variant-numeric: tabular-nums; }

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

/* ─── Markdown → PDF: side-by-side editor + preview ─── */
.pt-md-input {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.6;
    resize: vertical;
    min-height: 360px;
}
.pt-md-preview {
    border: 1px solid var(--color-border, #e2e8f0);
    border-radius: 8px;
    padding: 20px 26px;
    background: #fff;
    /* "Paper card" feel - subtle shadow in light mode, gentle outer glow in dark mode
       so the white surface looks deliberate rather than a stark blank block. */
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 0 0 1px rgba(15, 23, 42, 0.02);
    min-height: 240px;
    max-height: 540px;
    overflow-y: auto;
    color: #1a1a1a;
    font-family: Georgia, "Times New Roman", serif;
    line-height: 1.6;
}
[data-theme="dark"] .pt-md-preview,
[data-bs-theme="dark"] .pt-md-preview {
    /* In dark mode, keep the page white (it's an accurate preview of the PDF output)
       but add a soft inner ring so the bright surface doesn't crash against the dark UI. */
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 6px 24px rgba(0, 0, 0, 0.45);
    border-color: transparent;
}

/* Hide the wrapper entirely when the preview has no content yet - saves the user
   from staring at an empty white block before they've uploaded a file. */
.pt-md-preview-wrap:has(.pt-md-preview:empty) {
    display: none;
}
/* Fallback for browsers without :has() - show a friendly empty state. */
.pt-md-preview:empty::before {
    content: 'Preview will appear here once a file is uploaded.';
    display: block;
    color: #94a3b8;
    text-align: center;
    padding: 64px 20px;
    font-style: italic;
    font-family: system-ui, sans-serif;
}
.pt-md-preview h1 {
    font-size: 22px;
    border-bottom: 2px solid var(--color-primary, #1F5BFF);
    padding-bottom: 6px;
    margin: 0 0 16px;
}
.pt-md-preview h2 { font-size: 18px; margin: 18px 0 8px; }
.pt-md-preview h3 { font-size: 15px; margin: 14px 0 6px; }
.pt-md-preview p  { margin: 8px 0; }
.pt-md-preview code {
    font-family: ui-monospace, monospace;
    font-size: 12px;
    background: #F1F5F9;
    padding: 1px 5px;
    border-radius: 3px;
}
.pt-md-preview pre {
    background: #F1F5F9;
    padding: 10px 12px;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 12px;
}
.pt-md-preview pre code { background: none; padding: 0; }
.pt-md-preview blockquote {
    margin: 10px 0;
    padding: 4px 14px;
    border-left: 3px solid #94A3B8;
    color: #475569;
}
.pt-md-preview table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 13px; }
.pt-md-preview th, .pt-md-preview td { border: 1px solid #CBD5E1; padding: 6px 10px; text-align: left; }
.pt-md-preview th { background: #F1F5F9; }
.pt-md-preview ul, .pt-md-preview ol { padding-left: 22px; }
.pt-md-preview li { margin: 3px 0; }
.pt-md-preview a { color: var(--color-primary, #1F5BFF); }
