/*
 * DokWiki editing screens: editor, conflict panel, diff, history, attachments, admin tables.
 * Shared classes (.btn, .notice, .card, .toolbar, .form-row, ...) come from dokwiki.css; this file only
 * adds what is specific to editing. Colors are translucent or use the site's variables when it defines
 * them, so light and dark themes both work.
 */
.dok-edit-main { --ed-border: var(--border, rgba(127, 127, 127, .35)); --ed-muted-bg: var(--bg-soft, rgba(127, 127, 127, .08)); --ed-accent: var(--focus, #2563eb);
  --ed-mono: var(--mono, ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace); }
/* The editor uses the whole width (the reading column is narrower). */
body.dok-editing .main { max-width: none; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------------------------------------------------------------- editor */
.editor-form { display: flex; flex-direction: column; gap: .5rem; }
.editor-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; }
.editor-title { font-size: 1.1rem; min-width: 0; overflow-wrap: anywhere; }
.editor-path { font-size: .85rem; margin-left: .25rem; }
.editor-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.editor-status { font-size: .85rem; opacity: .85; max-width: 40rem; }
.editor-status-error { color: var(--error, #c62828); opacity: 1; font-weight: 600; }

.editor-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 4px; border: 1px solid var(--ed-border); border-radius: 6px; background: var(--ed-muted-bg); }
.editor-toolbar .tb { font: inherit; font-size: .85rem; line-height: 1.2; min-width: 2rem; padding: .3rem .5rem; border: 1px solid transparent; border-radius: 4px; background: transparent; color: inherit; cursor: pointer; }
.editor-toolbar .tb:hover, .editor-toolbar .tb:focus-visible { border-color: var(--ed-border); background: rgba(127, 127, 127, .12); }
.editor-toolbar .tb[aria-pressed="true"] { border-color: var(--ed-accent); background: rgba(37, 99, 235, .12); }
.editor-toolbar .tb code { background: none; padding: 0; font-size: .8rem; }
.tb-sep { width: 1px; align-self: stretch; margin: 2px 4px; background: var(--ed-border); }
.tb-spacer { flex: 1; }
.tb-layouts { display: inline-flex; gap: 2px; }

.editor-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--ed-border); }
.editor-tabs[hidden] { display: none; }
.editor-tab { font: inherit; padding: .35rem .9rem; border: 1px solid transparent; border-bottom: 0; border-radius: 6px 6px 0 0; background: transparent; color: inherit; cursor: pointer; margin-bottom: -1px; }
.editor-tab[aria-selected="true"] { border-color: var(--ed-border); background: var(--bg, Canvas); font-weight: 600; }

/* Fixed height with both panes scrolling on their own (needed for the scroll sync). */
.editor-panes { display: grid; gap: .75rem; flex: none; grid-template-rows: minmax(0, 1fr); height: calc(100vh - 16rem); min-height: 22rem; }
.editor-panes.layout-split { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.editor-panes.layout-source { grid-template-columns: minmax(0, 1fr); }
.editor-panes.layout-source .editor-pane-preview { display: none; }
.editor-panes.layout-tab { grid-template-columns: minmax(0, 1fr); }
.editor-panes.layout-tab.tab-write .editor-pane-preview { display: none; }
.editor-panes.layout-tab.tab-preview .editor-pane-src { display: none; }
.editor-pane { min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.editor-pane-preview { overflow: auto; border: 1px solid var(--ed-border); border-radius: 6px; padding: 0 1rem; }
.editor-text { flex: 1; width: 100%; height: 100%; min-height: 0; box-sizing: border-box; resize: none; overflow: auto; padding: .75rem; border: 1px solid var(--ed-border); border-radius: 6px;
  font-family: var(--ed-mono); line-height: 1.5; tab-size: 4; background: var(--bg, Canvas); color: inherit; }
.editor-text:focus { outline: 2px solid var(--ed-accent); outline-offset: -1px; }
.editor-text[wrap="off"] { white-space: pre; overflow-x: auto; }
.editor-text.drag-over { outline: 3px dashed var(--ed-accent); outline-offset: -4px; }
.editor-preview { max-width: 60rem; }
.editor-preview img { max-width: 100%; height: auto; }

.editor-foot { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; font-size: .9rem; }
.editor-note { display: flex; align-items: center; gap: .5rem; flex: 1 1 22rem; }
.editor-note input { flex: 1; min-width: 10rem; }
.editor-hint { flex: 1 1 18rem; }
.editor-hint code { font-size: .8rem; }

@media (max-width: 800px) {
  .editor-panes, .editor-panes.layout-split { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; grid-auto-rows: auto; height: auto; }
  .editor-panes.layout-split .editor-pane-preview { max-height: 60vh; }
  .editor-text { flex: none; height: 60vh; }
}

/* page-name autocomplete (positioned by editor.js, appended to body) */
.ac-list { position: absolute; z-index: 1000; min-width: 16rem; max-width: 30rem; max-height: 18rem; overflow-y: auto; padding: 4px 0;
  border: 1px solid var(--border, rgba(127, 127, 127, .45)); border-radius: 6px; background: var(--bg, Canvas); color: var(--fg, CanvasText);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .18); font-size: .9rem; }
.ac-list[hidden] { display: none; }
.ac-item { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem .7rem; cursor: pointer; }
.ac-item.ac-active, .ac-item:hover { background: rgba(37, 99, 235, .14); }
.ac-name { opacity: .65; font-family: var(--ed-mono); font-size: .8rem; white-space: nowrap; }

/* conflict panel and rescue boxes */
.editor-conflict h2 { margin-top: .25rem; font-size: 1.15rem; }
.editor-conflict details { margin-top: .75rem; }
.editor-conflict summary { cursor: pointer; font-weight: 600; }
.editor-theirs, .editor-rescue { width: 100%; box-sizing: border-box; font-family: var(--ed-mono); font-size: .85rem; padding: .5rem; }

/* ---------------------------------------------------------------- diff */
.diff-wrap { overflow-x: auto; border: 1px solid var(--ed-border); border-radius: 6px; }
table.diff { width: 100%; border-collapse: collapse; font-family: var(--ed-mono); font-size: .82rem; line-height: 1.45; margin: 0; }
table.diff td { padding: 0 .5rem; border: 0; vertical-align: top; }
table.diff .diff-n { width: 1%; min-width: 2.5rem; text-align: right; opacity: .55; user-select: none; white-space: nowrap; border-right: 1px solid var(--ed-border); }
table.diff .diff-t { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
table.diff .diff-op { display: inline-block; width: 1.2em; opacity: .6; user-select: none; }
tr.diff-add { background: rgba(46, 160, 67, .15); }
tr.diff-del { background: rgba(248, 81, 73, .15); }
tr.diff-add mark { background: rgba(46, 160, 67, .38); color: inherit; border-radius: 2px; }
tr.diff-del mark { background: rgba(248, 81, 73, .38); color: inherit; border-radius: 2px; }
tr.diff-skip td { background: var(--ed-muted-bg); opacity: .8; font-style: italic; padding: .15rem .5rem; }
.diff-stats { font-size: .9rem; }
.diff-stat-add, .diff-legend-add { color: var(--ok, #1a7f37); }
.diff-stat-del, .diff-legend-del { color: var(--error, #cf222e); }

/* ---------------------------------------------------------------- history, versions, attachments, admin */
.history-table, .history-log, .attach-table, .admin-table { width: 100%; border-collapse: collapse; }
.history-table th, .history-table td, .history-log th, .history-log td, .attach-table th, .attach-table td, .admin-table th, .admin-table td {
  text-align: left; padding: .4rem .6rem; border-bottom: 1px solid var(--ed-border); vertical-align: top; }
.history-current { font-weight: 600; }
.history-actions { white-space: nowrap; }
td.num, th.num { text-align: right; white-space: nowrap; }
.rev-banner { margin-bottom: 1rem; }
.rev-source pre { max-height: 30rem; overflow: auto; }
.attach-md { white-space: nowrap; }
.attach-md input { width: 22rem; max-width: 60vw; font-family: var(--ed-mono); font-size: .8rem; }
.upload-box { margin-top: 1.5rem; }
.upload-box.drag-over { outline: 3px dashed var(--ed-accent); outline-offset: 2px; }
.upload-status { font-size: .9rem; }
.upload-error { color: var(--error, #c62828); font-weight: 600; }
.admin-nav { margin-bottom: 1rem; }
.admin-errors { font-size: .85rem; }
.admin-errors code { white-space: pre-wrap; overflow-wrap: anywhere; }
.admin-settings dt { font-weight: 600; }
.admin-settings dd { margin: 0 0 .5rem 0; }
.user-edit summary { cursor: pointer; }
.user-edit form { margin: .5rem 0; padding: .5rem; border: 1px solid var(--ed-border); border-radius: 6px; }
.product-checks, .perm-checks { border: 1px solid var(--ed-border); border-radius: 6px; padding: .5rem .75rem; }
.product-checks label, .perm-checks label { display: block; margin: .15rem 0; }
.one-time-secret .secret-value { font-family: var(--ed-mono); font-size: .95rem; max-width: 100%; }
.auth-box { max-width: 26rem; margin: 2rem auto; }
.auth-box input[type="text"], .auth-box input[type="password"] { width: 100%; box-sizing: border-box; }
.prefs-form { max-width: 40rem; margin-bottom: 1.5rem; }
.new-page-form { max-width: 40rem; }
.new-page-form input[type="text"] { width: 100%; box-sizing: border-box; }

/* Checkbox rows: the shared .form-row makes inputs full width; checkboxes sit before their label text. */
.dok-edit-main .form-row input[type="checkbox"], .dok-edit-main .product-checks input[type="checkbox"], .dok-edit-main .perm-checks input[type="checkbox"] {
  width: auto; display: inline-block; margin: 0 .45rem 0 0; vertical-align: -2px; }
.dok-edit-main .form-row > label:has(> input[type="checkbox"]), .dok-edit-main .check-label { font-weight: normal; }
.dok-edit-main fieldset.form-row { display: block; }
.dok-edit-main fieldset.form-row legend { font-weight: 600; font-size: .92rem; padding: 0 .25rem; }
.one-time-secret pre { white-space: pre-wrap; word-break: break-all; }

/* trash: deleted pages on a page's history, /_admin/trash and the restore screen */
.trash-table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.trash-table th, .trash-table td { text-align: left; padding: .4rem .6rem; border-bottom: 1px solid var(--ed-border); vertical-align: top; }
.inline-form { display: inline; margin: 0; }
.editor-links a.editor-link-danger { color: var(--error, #c62828); }
