/* PAGIOS Documents: page styles. Every class starts with pd- so nothing collides with the console.
 * Colors are custom properties a console can override on .pd-root. Light theme by default.
 * The licence line (.pd-licence) is never hidden, clipped or truncated at any width (ADR 01). */
.pd-root {
  --pd-bg: #e2e8f0;
  --pd-card: #ffffff;
  --pd-edge: #cbd5e1;
  --pd-text: #1f2937;
  --pd-muted: #4b5563;
  --pd-accent: #1e3a8a;
  --pd-accent-text: #ffffff;
  --pd-danger: #b91c1c;
  --pd-ok: #166534;
  --pd-bar: #1e3a8a;
  --pd-bar-text: #ffffff;
  color: var(--pd-text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  box-sizing: border-box;
}
.pd-root *, .pd-editor, .pd-editor * { box-sizing: border-box; }
.pd-page { background: var(--pd-bg); padding: 16px; min-height: 100%; max-width: 100%; }
.pd-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.pd-title { margin: 0; font-size: 20px; font-weight: 600; }
.pd-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pd-file { display: none; }

.pd-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 34px; padding: 6px 12px; border-radius: 6px;
  border: 1px solid var(--pd-edge); background: var(--pd-card); color: var(--pd-text);
  font: inherit; cursor: pointer; white-space: nowrap; list-style: none;
}
.pd-btn:hover { border-color: var(--pd-accent); }
.pd-btn:disabled { opacity: .55; cursor: default; }
.pd-btn:focus-visible, .pd-name:focus-visible, .pd-tab:focus-visible { outline: 2px solid var(--pd-accent); outline-offset: 2px; }
.pd-btn-primary { background: var(--pd-accent); border-color: var(--pd-accent); color: var(--pd-accent-text); }
.pd-btn-danger { color: var(--pd-danger); }
.pd-btn-primary.pd-btn-danger { background: var(--pd-danger); border-color: var(--pd-danger); color: #fff; }
.pd-btn-small { min-height: 30px; padding: 4px 10px; font-size: 13px; }

.pd-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.pd-tab { border: 1px solid var(--pd-edge); background: var(--pd-card); color: var(--pd-muted); border-radius: 999px; padding: 4px 14px; font: inherit; cursor: pointer; }
.pd-tab-on { background: var(--pd-accent); border-color: var(--pd-accent); color: var(--pd-accent-text); }

.pd-message { margin: 0 0 10px; padding: 8px 12px; border-radius: 6px; background: var(--pd-card); border: 1px solid var(--pd-edge); overflow-wrap: anywhere; }
.pd-message[data-tone="error"] { border-color: var(--pd-danger); color: var(--pd-danger); }
.pd-message[data-tone="ok"] { border-color: var(--pd-ok); color: var(--pd-ok); }

.pd-list { list-style: none; margin: 0; padding: 0; background: var(--pd-card); border: 1px solid var(--pd-edge); border-radius: 8px; }
.pd-empty { padding: 18px 14px; color: var(--pd-muted); }
.pd-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--pd-edge); }
.pd-row:first-child { border-top: 0; }
.pd-row-main { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; }
.pd-name { all: unset; cursor: pointer; font-weight: 600; color: var(--pd-accent); overflow-wrap: anywhere; word-break: break-word; }
.pd-name:hover { text-decoration: underline; }
.pd-meta { display: flex; flex-wrap: wrap; gap: 8px; color: var(--pd-muted); font-size: 12px; }
.pd-kind { border: 1px solid var(--pd-edge); border-radius: 4px; padding: 0 6px; }
.pd-kind-sheet { border-color: #15803d; color: #15803d; }
.pd-kind-doc { border-color: #1d4ed8; color: #1d4ed8; }
.pd-row-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; flex: 0 1 auto; }

.pd-download { position: relative; }
.pd-download > summary::-webkit-details-marker { display: none; }
.pd-download > summary::marker { content: ""; }
.pd-download-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 160px; background: var(--pd-card); border: 1px solid var(--pd-edge); border-radius: 6px; box-shadow: 0 6px 18px rgba(15, 23, 42, .15); padding: 4px 0; }
.pd-download-item { display: block; padding: 6px 12px; color: var(--pd-text); text-decoration: none; white-space: nowrap; }
.pd-download-item:hover { background: var(--pd-bg); }

/* The licence line stays on screen however long the list is (ADR 01: prominently visible). */
.pd-foot { position: sticky; bottom: 0; z-index: 10; margin: 14px -16px -16px; padding: 8px 16px; background: var(--pd-bg); border-top: 1px solid var(--pd-edge); }
.pd-licence { margin: 0; font-size: 12px; line-height: 1.4; color: var(--pd-muted); overflow-wrap: anywhere; white-space: normal; }
.pd-licence a { color: inherit; text-decoration: underline; }

.pd-backdrop { position: fixed; inset: 0; z-index: 2147482000; background: rgba(15, 23, 42, .45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.pd-dialog { background: var(--pd-card); color: var(--pd-text); border-radius: 10px; border: 1px solid var(--pd-edge); padding: 16px; width: min(440px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 12px 32px rgba(15, 23, 42, .25); }
.pd-history { width: min(640px, 100%); }
.pd-dialog-title { margin: 0 0 10px; font-size: 16px; overflow-wrap: anywhere; }
.pd-dialog-text { margin: 0 0 10px; overflow-wrap: anywhere; }
.pd-dialog-error, .pd-history-note { margin: 8px 0 0; color: var(--pd-danger); overflow-wrap: anywhere; }
.pd-history-note[data-tone="ok"] { color: var(--pd-ok); }
.pd-input { width: 100%; min-height: 36px; padding: 6px 10px; border: 1px solid var(--pd-edge); border-radius: 6px; font: inherit; }
.pd-dialog-buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.pd-versions { list-style: none; margin: 0; padding: 0; }
.pd-version { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 0; border-top: 1px solid var(--pd-edge); }
.pd-version:first-child { border-top: 0; }
.pd-version-n { font-weight: 600; min-width: 90px; }
.pd-version-meta { flex: 1 1 200px; color: var(--pd-muted); font-size: 13px; }

/* Full-window editor (outside .pd-root: appended to <body>). */
html.pd-editor-open, html.pd-editor-open body { overflow: hidden; }
.pd-editor {
  position: fixed; inset: 0; z-index: 2147481000; display: flex; flex-direction: column;
  background: #ffffff; color: #1f2937;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.pd-editor-bar { flex: 0 0 auto; background: #1e3a8a; color: #ffffff; padding: 6px 12px; display: flex; flex-direction: column; gap: 4px; }
.pd-editor-top { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pd-editor-title { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.pd-editor-bar .pd-btn { background: #ffffff; color: #1e3a8a; border-color: #ffffff; }
.pd-editor-bar .pd-licence { color: #e2e8f0; font-size: 11px; }
.pd-editor-status { flex: 0 0 auto; padding: 10px 14px; background: #f1f5f9; border-bottom: 1px solid #cbd5e1; overflow-wrap: anywhere; }
.pd-editor[data-pd-state="error"] .pd-editor-status { color: #b91c1c; background: #fef2f2; }
.pd-editor-host { flex: 1 1 auto; position: relative; min-height: 0; }
.pd-editor-host > iframe, .pd-editor-host > div { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* Phones: rows become cards, every action stays visible (wraps), dialogs go full width. */
@media (max-width: 639px) {
  .pd-page { padding: 12px; }
  .pd-foot { margin: 12px -12px -12px; padding: 6px 12px; }
  .pd-head { flex-direction: column; align-items: stretch; }
  .pd-actions .pd-btn { flex: 1 1 auto; }
  .pd-list { background: transparent; border: 0; display: flex; flex-direction: column; gap: 10px; }
  .pd-row { flex-direction: column; align-items: stretch; background: var(--pd-card); border: 1px solid var(--pd-edge); border-radius: 8px; }
  .pd-row:first-child { border-top: 1px solid var(--pd-edge); }
  .pd-empty { background: var(--pd-card); border: 1px solid var(--pd-edge); border-radius: 8px; }
  .pd-row-actions { justify-content: flex-start; }
  .pd-download-menu { left: 0; right: auto; }
  .pd-backdrop { padding: 8px; align-items: flex-start; }
  .pd-dialog, .pd-history { width: 100%; }
  .pd-editor-bar { padding: 4px 8px; }
  .pd-editor-bar .pd-licence { font-size: 10px; line-height: 1.3; }
}
