/* ==========================================================================
   Personaldokumente (Arbeitszeugnis) — section in the Personalakte drawer plus
   editor/template modals. Own edd- prefix; tokens come from .cx-users (the
   drawer wrapper) with fallbacks so the rules stay self-contained.
   z-band 5040/5050 like the catalog editor (above the drawer at 1150 and the
   Syncfusion dialog floor at 5000).
   ========================================================================== */

/* ── Section in the drawer ─────────────────────────────────────────────── */
.edd-sec { display: flex; flex-direction: column; gap: 10px; }
.edd-muted { font-size: 12.5px; color: var(--stone, #8E8679); }
.edd-list { display: flex; flex-direction: column; gap: 6px; }
.edd-item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px; border: 1px solid var(--hairline, rgba(28,25,21,.08));
    border-radius: 10px; background: var(--white, #fff);
}
.edd-item-main {
    flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
    background: none; border: none; padding: 0; text-align: left; cursor: pointer; color: var(--ink, #1C1915);
}
.edd-item-title { font-size: 13px; font-weight: 600; display: flex; gap: 6px; align-items: center; }
.edd-item-meta { font-size: 11.5px; color: var(--stone, #8E8679); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.edd-icon {
    width: 30px; height: 30px; border-radius: 8px; border: none; background: transparent;
    color: var(--stone, #8E8679); display: grid; place-items: center; cursor: pointer;
}
.edd-icon:hover { background: var(--brick-50, #F7E7E5); color: var(--brick, #9A3B33); }
.edd-badge {
    font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap;
    background: var(--sand, #F0ECE4); color: var(--walnut, #4A443C);
}
.edd-badge.ok { background: var(--patina-50, #EAF3EE); color: var(--patina, #3F7D5B); }
.edd-badge.open { background: var(--ochre-50, #FAF1DE); color: var(--ochre, #A97514); }
.edd-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.edd-select { height: 36px; max-width: 220px; }

/* ── Modal shell ───────────────────────────────────────────────────────── */
.edd-scrim {
    position: fixed; inset: 0; z-index: 5040;
    background: rgba(28, 25, 21, 0.34); backdrop-filter: blur(2px);
}
.edd-modal {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: min(1400px, 96vw); max-height: 94vh; z-index: 5050;
    display: flex; flex-direction: column;
    background: var(--paper, #FAF7F2); color: var(--ink, #1C1915);
    border-radius: 18px; font-family: var(--font-sans, Inter, sans-serif);
    box-shadow: 0 28px 56px rgba(28,25,21,.18), 0 10px 20px rgba(28,25,21,.10);
}
.edd-modal-templates { width: min(1040px, 96vw); }
.edd-h {
    position: relative; display: flex; gap: 14px; align-items: flex-start; flex-shrink: 0;
    padding: 20px 24px 14px; border-bottom: 1px solid var(--hairline-soft, rgba(28,25,21,.05));
}
.edd-hi {
    width: 42px; height: 42px; border-radius: 11px; flex-shrink: 0; display: grid; place-items: center;
    background: var(--copper-50, #FBEFE5); color: var(--copper, #B8601F); font-size: 1.25rem;
}
.edd-t { font-family: var(--font-display, inherit); font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.edd-s { font-size: 12.5px; color: var(--walnut, #4A443C); margin-top: 3px; max-width: 90ch; }
.edd-close {
    position: absolute; top: 16px; right: 16px; width: 32px; height: 32px; border-radius: 8px; border: none;
    background: var(--sand, #F0ECE4); color: var(--walnut, #4A443C); display: grid; place-items: center; cursor: pointer;
}
.edd-b {
    flex: 1; min-height: 0; overflow-y: auto; padding: 18px 24px;
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; align-items: start;
}
.edd-modal-templates .edd-b { grid-template-columns: 280px minmax(0, 1fr); }
.edd-f {
    flex-shrink: 0; display: flex; align-items: center; gap: 8px; justify-content: flex-end;
    padding: 12px 24px; border-top: 1px solid var(--hairline-soft, rgba(28,25,21,.05));
}
.edd-f-status { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 12.5px; }
.edd-err { color: var(--brick, #9A3B33); }
.edd-warn { color: var(--ochre, #A97514); font-weight: 600; }

/* ── Form ──────────────────────────────────────────────────────────────── */
.edd-form { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.edd-row2 { display: grid; grid-template-columns: minmax(0, 1fr) 170px; gap: 12px; }
.edd-field { display: flex; flex-direction: column; gap: 4px; margin: 0; }
.edd-lab { font-size: 12px; font-weight: 600; color: var(--walnut, #4A443C); display: flex; gap: 8px; align-items: center; }
.edd-hint { font-size: 11.5px; color: var(--stone, #8E8679); margin: 0; }
.edd-req { font-size: 10.5px; font-weight: 600; color: var(--stone, #8E8679); }
.edd-req.open { color: var(--ochre, #A97514); }
.edd-input {
    width: 100%; min-height: 36px; padding: 7px 12px; font: inherit; font-size: 13px; color: var(--ink, #1C1915);
    background: var(--white, #fff); border: 1px solid var(--hairline-strong, rgba(28,25,21,.14)); border-radius: 8px; outline: none;
}
.edd-input:focus { border-color: var(--copper, #B8601F); box-shadow: 0 0 0 3px var(--copper-50, #FBEFE5); }
.edd-area { resize: vertical; line-height: 1.5; }
.edd-mono { font-family: var(--font-mono, ui-monospace, monospace); font-size: 12.5px; }
.edd-details { border: 1px solid var(--hairline, rgba(28,25,21,.08)); border-radius: 10px; padding: 10px 12px; background: var(--white, #fff); }
.edd-details > summary { cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--walnut, #4A443C); }
.edd-details[open] > summary { margin-bottom: 10px; }
.edd-details > * + * { margin-top: 8px; }
.edd-master { display: grid; grid-template-columns: 1fr; gap: 3px; font-size: 12px; }
.edd-master-row { display: flex; justify-content: space-between; gap: 12px; }
.edd-master-row span { color: var(--stone, #8E8679); }

.edd-card { padding: 16px; border: 1px solid var(--hairline-strong, rgba(28,25,21,.14)); border-radius: 10px; background: #fff; display: flex; flex-direction: column; gap: 12px; }
.edd-master-inputs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.edd-card .edd-details { padding: 12px 0 0; border: 0; border-top: 1px solid var(--hairline, rgba(28,25,21,.08)); border-radius: 0; }
.edd-input-missing { border-color: var(--ochre, #A97514); }
.edd-writing { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.edd-writing .edd-ai-button { align-self: flex-end; color: var(--copper, #B8601F); font-size: 12px; height: auto; min-height: 30px; }
.edd-ai-box { background: var(--copper-50, #FBEFE5); border: 1px solid rgba(184,96,31,.2); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.edd-ai-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.6; }
.edd-ai-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.edd-preview-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.edd-desk { padding: 24px 20px; background: #E8E6E1; border-radius: 12px; box-shadow: inset 0 2px 8px rgba(0,0,0,.04); max-height: calc(94vh - 260px); overflow: auto; }
.edd-letter-frame { position: relative; width: 100%; height: 700px; overflow: hidden; box-shadow: 0 8px 24px rgba(28,25,21,.12); background: #fff; }
.edd-letter-page { position: absolute; top: 0; left: 0; width: 794px; height: 1123px; border: 0; transform: scale(var(--edd-page-scale, .6)); transform-origin: top left; background: #fff; }

/* ── Placeholder reference ────────────────────────────────────────────── */
.edd-ph { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; font-size: 11.5px; }
.edd-ph-h { font-weight: 600; color: var(--walnut, #4A443C); margin-bottom: 4px; }
.edd-ph-row { display: flex; flex-direction: column; margin-bottom: 4px; }
.edd-ph-row code { font-size: 11.5px; color: var(--copper-dark, #8A4514); background: none; padding: 0; }
.edd-ph-row span { color: var(--stone, #8E8679); }

/* ── Preview ───────────────────────────────────────────────────────────── */
.edd-preview-col { display: flex; flex-direction: column; gap: 10px; position: sticky; top: 0; min-width: 0; }
.edd-issues {
    border: 1px solid rgba(169,117,20,.35); background: var(--ochre-50, #FAF1DE); border-radius: 10px;
    padding: 8px 12px; font-size: 12px; color: var(--ink, #1C1915);
}
.edd-issues-h { font-weight: 600; color: var(--ochre, #A97514); margin-bottom: 4px; }
.edd-issues li span { margin-left: 4px; }
.edd-issues .btn { white-space: normal; height: auto; min-height: 36px; max-width: 100%; margin-top: 8px; }
.edd-issues ul { margin: 0; padding-left: 18px; }
.edd-paper {
    background: #fff; border: 1px solid var(--hairline, rgba(28,25,21,.08)); border-radius: 6px;
    box-shadow: 0 2px 6px rgba(28,25,21,.08); padding: 28px 32px; min-height: 420px;
    font-size: 12.5px; line-height: 1.6; color: #1f2937;
}
.edd-paper-title { text-align: center; font-size: 17px; font-weight: 700; margin-bottom: 16px; }
.edd-paper-body p { margin: 0 0 10px; }
.edd-paper-body mark.edd-missing { background: var(--ochre-50, #FAF1DE); color: var(--ochre, #A97514); border-radius: 3px; padding: 0 3px; font-style: italic; }

/* ── Templates dialog ─────────────────────────────────────────────────── */
.edd-tpl-list { display: flex; flex-direction: column; gap: 6px; }
.edd-tpl {
    display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
    padding: 9px 12px; border-radius: 10px; border: 1px solid var(--hairline, rgba(28,25,21,.08));
    background: var(--white, #fff); cursor: pointer; color: var(--ink, #1C1915);
}
.edd-tpl.on { border-color: var(--copper, #B8601F); box-shadow: 0 0 0 3px var(--copper-50, #FBEFE5); }
.edd-tpl.archived { opacity: .7; }
.edd-tpl-name { font-size: 13px; font-weight: 600; }
.edd-tpl-meta { font-size: 11.5px; color: var(--stone, #8E8679); display: flex; gap: 6px; align-items: center; }
/* .cx-users .btn is nowrap + fixed height; this one sits in a 280px column and must wrap. */
.edd-tpl-list .btn.edd-tpl-add { margin-top: 6px; white-space: normal; height: auto; min-height: 36px; padding-top: 6px; padding-bottom: 6px; }
.edd-version { border-top: 1px solid var(--hairline-soft, rgba(28,25,21,.05)); padding-top: 8px; }
.edd-version-h { font-size: 12px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.edd-version-body { white-space: pre-wrap; font-size: 11.5px; color: var(--walnut, #4A443C); background: var(--paper-2, #F5F1E8); border-radius: 6px; padding: 8px; margin: 6px 0 0; max-height: 220px; overflow: auto; }

@media (max-width: 900px) {
    .edd-b, .edd-modal-templates .edd-b { grid-template-columns: 1fr; }
    .edd-preview-col { position: static; }
    .edd-desk { max-height: none; }
    .edd-ph { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .edd-h { padding: 16px 18px; }
    .edd-ht { min-width: 0; padding-right: 30px; }
    .edd-hi { display: none; }
    .edd-b { padding: 14px 18px; }
    .edd-row2 { grid-template-columns: minmax(0, 1fr); }
    .edd-master-inputs { grid-template-columns: minmax(0, 1fr); }
    .edd-desk { padding: 12px 8px; }
    .edd-ai-actions .btn, .edd-card .btn, .edd-writing .btn { max-width: 100%; white-space: normal; height: auto; min-height: 36px; }
    .edd-f { padding: 12px 18px; flex-wrap: wrap; }
    .edd-f-status { flex: 1 0 100%; flex-wrap: wrap; overflow-wrap: anywhere; }
    .edd-f-status > span { flex: 1 0 100%; }
    .edd-f > .btn { flex: 1 1 auto; }
    .edd-f .btn { max-width: 100%; white-space: normal; height: auto; min-height: 36px; }
}

/* Guided document creation: one decision at a time, persistent controls. */
.edd-wizard { width: min(1180px, 96vw); height: min(900px, 94dvh); }
.edd-wizard [hidden] { display: none !important; }
.edd-steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 14px 24px; border-bottom: 1px solid var(--hairline, #e7e1d8); }
.edd-step { border: 0; background: transparent; padding: 10px 12px; display: flex; align-items: center; gap: 10px; border-radius: 10px; font: inherit; font-size: 13px; color: var(--walnut, #4A443C); text-align: left; }
.edd-step > span { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--sand, #F0ECE4); flex-shrink: 0; }
.edd-step.active { background: var(--copper-50, #FBEFE5); color: var(--copper-dark, #8A4514); font-weight: 650; }
.edd-step.active > span { background: var(--copper, #B8601F); color: white; }
.edd-step.done > span { background: var(--patina-50, #EAF3EE); color: var(--patina, #3F7D5B); font-size: 13px; }
.edd-step:focus-visible, .edd-chip:focus-within { outline: 2px solid var(--copper, #B8601F); outline-offset: 2px; }
/* Steps 1–3: one reading column. Step 4 keeps its two-column review layout. */
.edd-wizard .edd-b { display: block; padding: 24px; }
.edd-wizard .edd-b:not(.edd-review) .edd-form { max-width: 760px; margin: 0 auto; }
.edd-wizard .edd-b.edd-review { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 28px; }
.edd-step-content { display: flex; flex-direction: column; gap: 16px; }
.edd-step-intro h2 { font-size: 22px; font-weight: 700; margin: 0 0 6px; letter-spacing: -.03em; outline: none; }
.edd-step-intro p { color: var(--walnut, #4A443C); font-size: 13px; line-height: 1.6; margin: 0 0 8px; }
.edd-wizard h3 { font-size: 15px; font-weight: 650; margin: 0; }
.edd-wizard .edd-hint { font-size: 12px; line-height: 1.5; }
.edd-group { display: flex; flex-direction: column; gap: 10px; }
.edd-group + .edd-group { padding-top: 14px; border-top: 1px solid var(--hairline, rgba(28,25,21,.08)); }
.edd-group-lab { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--stone, #8E8679); }
.edd-choice-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.edd-choice-heading .edd-lab { font-size: 13px; }
.edd-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.edd-chip {
    position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px;
    border: 1px solid var(--hairline-strong, #ded8ce); border-radius: 999px; background: var(--white, #fff);
    font-size: 13px; color: var(--walnut, #4A443C); cursor: pointer; user-select: none; margin: 0;
}
.edd-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.edd-chip .bi { font-size: 12px; color: var(--copper, #B8601F); }
.edd-chip.selected { border-color: var(--copper, #B8601F); background: var(--copper-50, #FBEFE5); color: var(--copper-dark, #8A4514); font-weight: 600; }
.edd-chip:has(input:disabled) { opacity: .6; cursor: default; }
.edd-proposal { padding: 14px; border-radius: 8px; background: var(--paper, #FAF7F2); display: flex; flex-direction: column; align-items: flex-start; gap: 8px; font-size: 12px; }
.edd-proposal p { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.65; margin: 0; }
.edd-choice-applied { color: var(--patina, #3F7D5B); font-size: 12px; }
.edd-wizard .edd-desk { max-height: none; overflow: hidden; padding: 12px; }
.edd-wizard .edd-preview-col { position: static; }
.edd-issue-link { border: 0; background: none; text-align: left; padding: 6px 0; font: inherit; color: inherit; }
.edd-issue-link span { text-decoration: underline; font-weight: 600; }
.edd-wizard .edd-f-status { flex-wrap: wrap; }
.edd-wizard .edd-f .btn { white-space: normal; height: auto; min-height: 38px; }
@media (max-width: 900px) {
    .edd-wizard .edd-b.edd-review { grid-template-columns: minmax(0, 1fr); }
    .edd-steps { gap: 4px; padding: 10px 16px; }
    .edd-step { flex-direction: column; padding: 8px 2px; gap: 6px; text-align: center; font-size: 11px; }
}
@media (max-width: 600px) {
    .edd-wizard .edd-b { padding: 16px; }
    .edd-step-intro h2 { font-size: 19px; }
    .edd-choice-heading { align-items: flex-start; }
    .edd-wizard .edd-f { padding: 10px 12px; gap: 6px; }
    .edd-wizard .edd-f > .btn { font-size: 12px; }
}
