/* ════════════════════════════════════════════════════════════════
   NP2 — PDF Templates editor + Invoice list
   Append to cic.css (or load as its own stylesheet). Values match the
   existing NP2 palette: #3b82f6 primary blue, the amber warning family
   from the reverse-payment modal, neutral grays from the report tables.
   ════════════════════════════════════════════════════════════════ */

/* ─── Invoice status badges ─────────────────────────────── */
/* Reuse .cic-badge base; these add the status colors. */
.cic-badge.inv-badge-draft  { background:#f3f4f6; color:#4b5563; }
.cic-badge.inv-badge-issued { background:#dbeafe; color:#1e40af; }
.cic-badge.inv-badge-paid   { background:#dcfce7; color:#166534; }
.cic-badge.inv-badge-void   { background:#fee2e2; color:#991b1b; }

.inv-money { font-variant-numeric: tabular-nums; }

/* ─── PDF Templates: layout ─────────────────────────────── */
.pt-body { margin-top: 16px; }

.pt-grid {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
    align-items: start;
}

/* ─── Variable palette ──────────────────────────────────── */
.pt-palette {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 14px;
    position: sticky;
    top: 16px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}
.pt-palette-head {
    font-size: 13px;
    font-weight: 600;
    color: #111827;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.pt-palette-hint {
    font-size: 12px;
    color: #6b7280;
    margin: 4px 0 12px;
}
.pt-palette-subhead {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 16px 0 8px;
}
.pt-var-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.pt-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    text-align: left;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 7px 10px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
    font-family: inherit;
}
.pt-chip:hover {
    background: #eff6ff;
    border-color: #93c5fd;
}
.pt-chip:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 1px;
}
.pt-chip-sigil { font-size: 14px; line-height: 1; flex-shrink: 0; }
.pt-chip-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─── Editor pane ───────────────────────────────────────── */
.pt-editor-pane {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.pt-editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid #e5e7eb;
    background: #fafafa;
}
.pt-status { font-size: 13px; color: #6b7280; }
.pt-toolbar-actions { display: flex; gap: 8px; }

/* ─── Toolbar icon+text buttons (match stylesets action look) ── */
.pt-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 13px;
    font-family: inherit;
    color: #2563eb;
    background: #fff;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    white-space: nowrap;
}
.pt-tool-btn:hover {
    background: #eff6ff;
    border-color: #60a5fa;
}
.pt-tool-btn:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 1px;
}
.pt-tool-btn .pt-tool-icon {
    display: inline-flex;
    align-items: center;
}
.pt-tool-btn .pt-tool-icon svg {
    width: 15px;
    height: 15px;
}
/* Primary action (Save) — filled */
.pt-tool-btn-primary {
    color: #fff;
    background: #2563eb;
    border-color: #2563eb;
}
.pt-tool-btn-primary:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

.pt-html {
    width: 100%;
    min-height: 520px;
    border: 0;
    padding: 14px;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.6;
    color: #1f2937;
    resize: vertical;
    tab-size: 2;
}
.pt-html:focus { outline: none; box-shadow: inset 0 0 0 2px #bfdbfe; }
.pt-html[readonly] { background: #f9fafb; color: #6b7280; }

/* ─── Validation errors ─────────────────────────────────── */
.pt-errors {
    border-top: 1px solid #fecaca;
    background: #fef2f2;
    padding: 12px 14px;
}
.pt-errors-head {
    font-size: 13px;
    font-weight: 600;
    color: #991b1b;
    margin-bottom: 6px;
}
.pt-errors ul { margin: 0; padding-left: 18px; }
.pt-errors li { font-size: 13px; color: #b91c1c; margin: 2px 0; }

/* ─── Responsive: palette stacks above the editor ───────── */
@media (max-width: 860px) {
    .pt-grid { grid-template-columns: 1fr; }
    .pt-palette {
        position: static;
        max-height: none;
    }
    .pt-var-group { flex-direction: row; flex-wrap: wrap; }
    .pt-chip { width: auto; }
}

/* ─── LLM handoff panel ─────────────────────────────────── */
.pt-llm {
    border-top: 1px solid #e5e7eb;
    background: #f8fafc;
}
.pt-llm > summary {
    list-style: none;
    cursor: pointer;
    padding: 12px 14px;
    display: flex;
    align-items: baseline;
    gap: 10px;
    user-select: none;
}
.pt-llm > summary::-webkit-details-marker { display: none; }
.pt-llm > summary::before {
    content: "▸";
    color: #6b7280;
    font-size: 12px;
    transition: transform 0.15s;
}
.pt-llm[open] > summary::before { transform: rotate(90deg); }
.pt-llm-summary-title { font-size: 13px; font-weight: 600; color: #1e40af; }
.pt-llm-summary-hint { font-size: 12px; color: #6b7280; }

.pt-llm-body { padding: 0 14px 14px; }
.pt-llm-explain {
    font-size: 13px;
    color: #4b5563;
    line-height: 1.5;
    margin: 0 0 10px;
}
.pt-llm-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.pt-llm-copied { font-size: 12px; color: #166534; font-weight: 600; }
.pt-llm-text {
    width: 100%;
    min-height: 140px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 10px 12px;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 1.5;
    color: #374151;
    background: #fff;
    resize: vertical;
}
.pt-llm-text:focus { outline: none; box-shadow: inset 0 0 0 2px #bfdbfe; }