/* dialogs.css - document dialogs from docdialogs.js: document properties, watermark, header &
   footer, settings and keyboard shortcuts. Everything here lives inside a ui.modal body (the
   modal frame, title and action buttons are styled by base.css); class prefix .dlg-.

   Same voice as the panel: labels left, controls right, hairline sub-sections, numbers and keys
   in mono. Live previews sit on a small patch of desk with a white sheet, like the workspace. */

.dlg-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
    font-size: var(--fs-m);
    color: var(--text);
}

/* Rows set their own display; make the hidden attribute win. */
.dlg-body [hidden] { display: none !important; }

/* ------------------------------------------------------------------ rows */

.dlg-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.dlg-row {
    display: grid;
    grid-template-columns: 124px minmax(0, 1fr);
    align-items: center;
    gap: 4px 14px;
    min-height: 36px;
}

.dlg-label {
    font-size: var(--fs-s);
    color: var(--text-2);
}

.dlg-ctl {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    min-width: 0;
}

.dlg-ctl > * { max-width: 100%; }

/* A segmented control keeps each option's label readable instead of shrinking it below its
   own text width when the control column (or the page-range row, competing with its text
   input) is tight (props-6): a few px of overflow reads far better than "Cen…". */
.dlg-ctl .seg-btn,
.dlg-range-row .seg-btn {
    min-width: max-content;
}

.dlg-input { width: 100%; min-width: 0; }
.dlg-grow { align-self: stretch; width: 100%; }
.dlg-inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dlg-stack { display: flex; flex-direction: column; gap: 4px; align-self: stretch; }

.dlg-hint {
    margin: 0;
    font-size: var(--fs-xs);
    line-height: 1.45;
    color: var(--text-3);
}

/* Validation messages: amber, not proof red (red is for destructive actions). */
.dlg-error {
    margin: 0;
    font-size: var(--fs-xs);
    line-height: 1.45;
    color: var(--amber);
}

.dlg-subhead {
    margin: 6px 0 0;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    font: 600 var(--fs-xs)/1.3 var(--font-ui);
    letter-spacing: 0.01em;
    color: var(--text-2);
}

.dlg-body > .dlg-subhead:first-child,
.dlg-form > .dlg-subhead:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.dlg-press[aria-pressed="true"] {
    background: var(--ink-soft);
    color: var(--ink);
    box-shadow: inset 0 0 0 1px var(--ink-line);
}

/* ------------------------------------------------------------------ chips */

.dlg-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.dlg-chips-label {
    min-width: 56px;
    font-size: var(--fs-xs);
    color: var(--text-3);
}

.dlg-chip {
    appearance: none;
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 10px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-xs);
    background: var(--surface);
    color: var(--text-2);
    font: 500 var(--fs-xs)/1 var(--font-ui);
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.dlg-chips-mono .dlg-chip { font-family: var(--font-mono); }
.dlg-chip:hover { background: var(--surface-3); color: var(--text); }
.dlg-chip:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

@media (pointer: coarse) {
    .dlg-chip { min-height: 36px; }
}

/* ------------------------------------------------------------------ page range */

.dlg-range {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-self: stretch;
}

.dlg-range-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.dlg-range-input {
    flex: 1 1 110px;
    width: auto;
    min-width: 96px;
    font-family: var(--font-mono);
}

.dlg-range-input.is-idle { opacity: 0.6; }

/* ------------------------------------------------------------------ document properties */

.dlg-facts {
    display: grid;
    grid-template-columns: 124px minmax(0, 1fr);
    gap: 6px 14px;
    margin: 0;
    font-size: var(--fs-s);
}

.dlg-facts dt { color: var(--text-2); }

.dlg-facts dd {
    margin: 0;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

/* ------------------------------------------------------------------ previews (watermark, header & footer) */

.dlg-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    align-items: start;
    gap: 20px;
}

.dlg-preview {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 340px;
    padding: 16px;
    border-radius: var(--radius);
    background-color: var(--desk);
    background-image: radial-gradient(var(--desk-dot) 1px, transparent 1.5px);
    background-size: 14px 14px;
}

.dlg-preview-caption {
    margin: 0;
    font: 500 var(--fs-xs)/1 var(--font-mono);
    color: var(--text-3);
}

.dlg-sheet {
    position: relative;
    flex: none;
    overflow: hidden;
    border-radius: 1px;
    background: var(--paper);
    box-shadow: var(--shadow-page);
}

.dlg-sheet-bg {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
}

.dlg-sheet-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.dlg-sheet-text {
    position: absolute;
    white-space: pre;
    line-height: 1.2;
    transform-origin: center;
}

/* Six header & footer slots: Header [left][centre][right] / Footer [...] */
.dlg-slots {
    display: grid;
    grid-template-columns: 56px repeat(3, minmax(0, 1fr));
    align-items: center;
    gap: 8px;
}

.dlg-slots-label {
    font-size: var(--fs-s);
    color: var(--text-2);
}

.dlg-slot { min-width: 0; }
.dlg-slot-center { text-align: center; }
.dlg-slot-right { text-align: right; }

/* ------------------------------------------------------------------ settings */

.dlg-storage {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 12px;
}

.dlg-storage > .dlg-hint {
    flex: 1 1 220px;
    font-size: var(--fs-s);
    color: var(--text-2);
}

/* ------------------------------------------------------------------ keyboard shortcuts */

.dlg-search { width: 100%; }

.dlg-keys {
    columns: 2 300px;
    column-gap: 32px;
}

.dlg-keys-group {
    break-inside: avoid;
    margin: 0 0 18px;
}

.dlg-keys-title {
    margin: 0 0 4px;
    font: 600 var(--fs-xs)/1.3 var(--font-ui);
    color: var(--text-2);
}

.dlg-keys-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.dlg-key-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 32px;
    padding: 4px 0;
    border-bottom: 1px solid var(--line);
    font-size: var(--fs-s);
}

.dlg-key-label {
    display: flex;
    flex-direction: column;
    min-width: 0;
    color: var(--text);
}

.dlg-key-modes {
    font-size: var(--fs-xs);
    color: var(--text-3);
}

.dlg-key-keys {
    flex: none;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    max-width: 58%;
}

.dlg-key-or {
    font-size: var(--fs-xs);
    color: var(--text-3);
}

.dlg-combo { display: inline-flex; align-items: center; gap: 3px; }

/* Where an alternate key applies when that is narrower than its entry ("View only"). */
.dlg-key-note {
    margin-left: 3px;
    font-size: var(--fs-xs);
    color: var(--text-3);
    white-space: nowrap;
}

.dlg-kbd {
    display: inline-block;
    min-width: 22px;
    padding: 2px 6px;
    border: 1px solid var(--line-strong);
    border-bottom-width: 2px;
    border-radius: var(--radius-xs);
    background: var(--surface-2);
    color: var(--text);
    font: 500 var(--fs-xs)/1.4 var(--font-mono);
    text-align: center;
    white-space: nowrap;
}

.dlg-empty {
    margin: 16px 0;
    text-align: center;
    font-size: var(--fs-s);
    color: var(--text-3);
}

/* ------------------------------------------------------------------ narrow screens */

@media (max-width: 720px) {
    .dlg-split { grid-template-columns: minmax(0, 1fr); }
    .dlg-preview { order: -1; position: static; min-height: 0; }
    .dlg-sheet { zoom: 0.72; }
}

@media (max-width: 560px) {
    .dlg-row,
    .dlg-facts { grid-template-columns: minmax(0, 1fr); gap: 4px; }
    .dlg-facts dd { margin-bottom: 6px; }
    .dlg-slots { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .dlg-slots-label { grid-column: 1 / -1; }
    .dlg-key-keys { max-width: 50%; }
}
