/* Editorul vizual de șabloane (v1.2) — clase .te-*; foaia folosește aceleași clase ca documentul final (.doc-sheet, .doc-body) */

/* ---------- saltul de pagină (în editor și în documentele generate) ---------- */
.doc-body .page-break { position: relative; height: 0; margin: 9mm 0; border-top: 1.5px dashed #b8c0ca; }
.doc-body .page-break::after { content: "Pagină nouă"; position: absolute; left: 50%; top: -8px; transform: translateX(-50%); padding: 0 8px; background: #fff; font: 700 9.5px/15px var(--font); letter-spacing: .5px; text-transform: uppercase; color: #8a939e; white-space: nowrap; }
@media print {
  .doc-body .page-break { break-before: page; page-break-before: always; height: 0; margin: 0; border: 0; }
  .doc-body .page-break::after { display: none; }
}

/* ---------- pagina editorului ---------- */
.te-grid { display: grid; grid-template-columns: minmax(0, 1fr) 312px; gap: 12px; align-items: start; }
@media (max-width: 1100px) { .te-grid { grid-template-columns: minmax(0, 1fr); } }
.te-main { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.te-bar { position: sticky; top: 42px; z-index: 6; display: flex; flex-direction: column; gap: 0; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); min-width: 0; }
@media (max-width: 1240px) { .te-bar { top: 0; } }
@media (max-width: 719px) { .te-bar { position: static; } }
.te-row { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 4px 5px; min-width: 0; }
.te-row > .seg button { height: 28px; padding: 0 9px; font-size: 12.5px; }
.te-b { min-width: 28px; height: 28px; padding: 0 5px; border: 1px solid transparent; border-radius: 6px; background: none; cursor: pointer; font-size: 13.5px; color: var(--text); display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
.te-b:hover { background: var(--bg); border-color: var(--border); }
.te-b.on { background: var(--blue-bg); border-color: #c5d7ef; color: var(--blue-text); }
.te-b.te-wide span { font-size: 12.5px; font-weight: 600; }
.te-b.te-txt { font-weight: 700; font-family: Georgia, serif; }
.te-b.te-txt small { font-size: 10px; }
.te-sep { width: 1px; height: 18px; background: var(--border); margin: 0 3px; }
.te-blk { height: 28px; width: 102px; padding: 0 4px; border: 1px solid var(--border); border-radius: 6px; background: #fff; font-size: 12.5px; }
.te-ctx { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; padding: 5px 7px; border-top: 1px solid var(--border-soft); background: var(--bg-soft); font-size: 12.5px; border-radius: 0 0 var(--radius-sm) var(--radius-sm); min-width: 0; }
.te-ctx .btn.sm { height: 26px; padding: 0 8px; font-size: 12px; }
.te-ctx code { font-size: 11.5px; background: #fff; border: 1px solid var(--border-soft); border-radius: 4px; padding: 0 4px; overflow-wrap: anywhere; }
.te-ctx b.ell { max-width: 260px; }
.te-ctx-c { background: var(--amber-bg); }
.te-cl { color: var(--text-weak); font-weight: 650; }
/* tabelul: alegerea mărimii */
.te-tp { padding: 6px; }
.te-tp-l { font-size: 12px; color: var(--text-weak); padding: 0 2px 6px; }
.te-tp-g { display: grid; grid-template-columns: repeat(6, 22px); gap: 3px; }
.te-tp-g button { width: 22px; height: 18px; padding: 0; border: 1px solid var(--border-strong); border-radius: 3px; background: #fff; cursor: pointer; }
.menu .te-tp-g button { display: block; width: 22px; padding: 0; }
.te-tp-g button.on { background: var(--blue-bg); border-color: var(--blue); }
.te-phone { display: flex; gap: 6px; align-items: flex-start; font-size: 12px; color: var(--amber-text); background: var(--amber-bg); border-radius: var(--radius-sm); padding: 6px 9px; }
.te-inactive { display: flex; align-items: center; gap: 8px; padding: 5px 6px 5px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-soft); font-size: 13px; color: var(--text-weak); }
.te-hint { font-size: 12px; color: var(--text-weak); }
.te-hint code { font-size: 11px; background: var(--bg); padding: 0 3px; border-radius: 3px; }
.te-hide { display: none !important; }
.te-src { min-height: 62vh; font-size: 12px; width: 100%; }

/* ---------- foaia: A4 cu antetul, micșorată cât să încapă (fără derulare laterală) ---------- */
.te-canvas { position: relative; min-width: 0; overflow: hidden; padding: 2px 0 10px; }
.te-zoom { width: 210mm; margin: 0 auto; transform-origin: 0 0; }
.te-zoom .doc-sheet { margin: 0; }
.te-body { outline: none; min-height: 150mm; caret-color: #000; }
.te-body:focus { outline: none; }
.te-body > :first-child { margin-top: 0; }
.te-simple .doc-body { padding: 12px 12px 26px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); font-family: "Times New Roman", Georgia, serif; font-size: 11.5pt; line-height: 1.45; color: #000; overflow-wrap: anywhere; }
.te-simple .te-body { min-height: 50vh; }
.te-simple .doc-body p, .te-simple .doc-body li { text-align: left !important; }
.te-simple table { table-layout: fixed; width: 100%; }
.te-simple te-f[data-t="s"] { min-width: 0; height: auto; min-height: 9mm; white-space: normal; }
.te-body table td, .te-body table th { min-width: 24px; }
.te-body table.plain td, .te-body table.sig td { outline: 1px dashed #d8dde3; outline-offset: -1px; }

/* câmpurile („etichetele” DocuSign): nu se pot edita din tastatură, se mută ca un tot */
.te-body te-f { display: inline-block; max-width: 100%; margin: 0 1px; padding: 0 5px; border: 1px solid #b9d0ee; border-radius: 4px; background: #e8f0fa; color: #1d4f8f;
  font: 600 .8em/1.55 var(--font); vertical-align: baseline; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; user-select: none; -webkit-user-select: none; }
.te-body te-f:hover { border-color: #7aa6dc; }
.te-body te-f[data-t="x"] { background: #f1ecfd; border-color: #d4c6f4; color: #5b3aa8; }
.te-body te-f[data-t="u"] { background: #fdecea; border-color: #f0b3ae; color: #a3201a; text-decoration: underline wavy #d9534f; }
.te-body te-f[data-t="r"] { display: block; margin: 6px 0; padding: 7px 10px; border-style: dashed; white-space: normal; font-size: .82em; }
.te-body te-f[data-t="r"]::before { content: "▦ "; }
.te-body te-f[data-t="s"] { display: inline-flex; align-items: flex-end; min-width: 46mm; height: 12mm; padding: 2px 7px; border: 1.5px dashed #d39b2a; background: #fff8d9; color: #7a5200; font-size: .78em; }
.te-body te-f[data-t="s"]::before { content: "✍"; margin-right: 5px; font-size: 1.35em; line-height: 1; }
.te-body te-f[data-t="d"] { border-color: #e7c66d; background: #fff8d9; color: #7a5200; }
.te-body te-f.te-on, .te-body te-m.te-on { outline: 2px solid var(--focus); outline-offset: 1px; }
/* condițiile */
.te-body te-m { display: inline-block; margin: 0 1px; padding: 0 5px; border: 1px dashed #d9a441; border-radius: 4px; background: #fdf4e2; color: #8a5a06; font: 700 .72em/1.6 var(--font); vertical-align: 1px; white-space: nowrap; cursor: pointer; user-select: none; -webkit-user-select: none; }
.te-body te-m[data-mk="else"] { background: #fff; }
.te-body div.te-if { position: relative; margin: 14px 0 8px; padding: 10px 8px 2px; border: 1.5px dashed #e0b45a; border-radius: 6px; background: rgba(253, 244, 226, .35); }
.te-body div.te-if::before { content: attr(data-label); position: absolute; top: -9px; left: 8px; max-width: calc(100% - 16px); padding: 0 6px; border: 1px solid #e0b45a; border-radius: 4px; background: #fdf4e2;
  font: 700 10.5px/16px var(--font); color: #8a5a06; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; user-select: none; }
.te-body div.te-if > te-m[data-mk="else"] { display: block; width: max-content; margin: 4px 0 6px; }
.te-body te-c { background: rgba(253, 236, 196, .55); border-bottom: 1.5px dashed #d9a441; border-radius: 2px; }
.te-body te-c::before { content: attr(data-label); display: inline-block; max-width: 30ch; margin-right: 3px; padding: 0 4px; border: 1px solid #e0b45a; border-radius: 3px; background: #fdf4e2;
  font: 700 .66em/1.5 var(--font); color: #8a5a06; vertical-align: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; user-select: none; }
.te-body te-c::after { content: "⟩"; margin-left: 1px; color: #c98a1b; font: 700 .8em var(--font); }
.te-body .page-break { cursor: default; }

/* ---------- panoul din dreapta ---------- */
.te-side { position: sticky; top: 50px; display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 60px); overflow-y: auto; min-width: 0; padding: 6px 10px 10px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
@media (max-width: 1240px) { .te-side { top: 8px; max-height: calc(100vh - 16px); } }
@media (max-width: 1100px) { .te-side { position: static; max-height: none; } }
.te-side .tabs { flex-wrap: wrap; }
.te-side .tabb { height: 32px; padding: 0 6px; font-size: 12.5px; gap: 4px; }
.te-sidebody { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.te-sidebody > .row { flex-wrap: nowrap; }
.te-sidebody .searchbox { flex: 1 1 auto; min-width: 0; }
.te-h { font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .3px; color: var(--text-faint); margin-top: 4px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.te-fl { display: flex; flex-direction: column; gap: 1px; max-height: 58vh; overflow-y: auto; min-width: 0; }
@media (max-width: 1100px) { .te-fl { max-height: 46vh; } }
.te-fl-dlg { max-height: 52vh; }
.te-fg { font-size: 10.5px; font-weight: 750; text-transform: uppercase; letter-spacing: .3px; color: var(--text-faint); padding: 8px 2px 3px; }
.te-fi-row { display: flex; align-items: center; gap: 2px; min-width: 0; }
.te-fi { flex: 1 1 auto; display: flex; flex-direction: column; align-items: flex-start; min-width: 0; padding: 3px 6px; border: 1px solid transparent; border-radius: 6px; background: none; text-align: left; cursor: pointer; }
.te-fi[draggable="true"] { cursor: grab; }
.te-fi:hover { background: var(--blue-bg); }
.te-fi span { font-size: 12.5px; color: var(--text); overflow-wrap: anywhere; }
.te-fi code { font-size: 10.5px; color: var(--text-faint); overflow-wrap: anywhere; }
.te-fi.extra span { color: #5b3aa8; font-weight: 600; }
.te-fi.cond span { color: #8a5a06; }
.te-fi.cond:hover { background: var(--amber-bg); }
.te-fi.raw span::before { content: "▦ "; color: var(--text-faint); }
.te-fi.on { background: var(--blue-bg); border-color: #b9d0ee; }
.te-roles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 6px; }
.te-role { display: flex; align-items: center; gap: 2px; min-width: 0; }
.te-role .btn.sm { height: 28px; padding: 0 7px; font-size: 12px; }
.te-sigbtn { flex: 1 1 auto; min-width: 0; justify-content: flex-start; background: #fff8d9; border-color: #e7c66d; color: #7a5200; overflow: hidden; }
.te-signers ol { margin: 0; padding: 0; list-style: none; counter-reset: s; display: flex; flex-direction: column; gap: 3px; }
.te-signers li { display: flex; align-items: center; gap: 4px; padding: 3px 4px 3px 6px; border: 1px solid var(--border-soft); border-radius: 6px; font-size: 13px; counter-increment: s; }
.te-signers li::before { content: counter(s) "."; color: var(--text-faint); font-weight: 700; font-size: 12px; min-width: 14px; }
.te-signers .btn.icon.sm { width: 24px; height: 24px; }
.te-req { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; color: var(--text-weak); white-space: nowrap; }
.te-addrole { width: auto; max-width: 100%; }
.te-cond-sel { font-size: 13px; padding: 6px 8px; border-radius: 6px; background: var(--amber-bg); color: var(--amber-text); overflow-wrap: anywhere; }
.te-cond-sel code { font-size: 11px; }

/* ---------- previzualizarea ---------- */
.te-prev { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.te-prev-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; min-width: 0; }
.te-prev-p { flex: 0 1 380px; min-width: 0; }
.te-prev-sheet { background: var(--bg); border-radius: var(--radius-sm); padding: 8px; min-width: 0; }
.te-prev-sheet .doc-blank { outline: 1.5px solid #e2001a; outline-offset: 0; background: #fde8e8; color: #a3201a; }

/* ---------- importul din Word ---------- */
.te-drop { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 26px 14px; border: 2px dashed var(--border-strong); border-radius: var(--radius); background: var(--bg-soft); text-align: center; cursor: pointer; }
.te-drop:hover { border-color: var(--blue); background: var(--blue-bg); }
.te-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.te-drop.busy { opacity: .6; pointer-events: none; }
.te-drop small { color: var(--text-weak); max-width: 520px; }
.te-imp-stats { display: flex; flex-wrap: wrap; gap: 4px; }
.te-map { display: flex; flex-direction: column; gap: 0; }
.te-map-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: 6px 12px; align-items: start; padding: 6px 0; border-bottom: 1px solid var(--border-soft); }
.te-map-src b { display: block; font-size: 13px; overflow-wrap: anywhere; }
.te-map-src small, .te-map-dst small { display: block; font-size: 11.5px; color: var(--text-weak); }
.te-map-dst { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.te-map-dst .inp { height: 30px; font-size: 13px; }
.te-map-new { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.te-map-new select.inp { width: auto; flex: 0 1 140px; }
.te-map-new input.inp { flex: 1 1 120px; min-width: 0; }
@media (max-width: 640px) { .te-map-row { grid-template-columns: minmax(0, 1fr); } }
.te-imp-prev { max-height: 46vh; overflow-y: auto; background: var(--bg); border-radius: var(--radius-sm); padding: 8px; }

/* ---------- lista șabloanelor ---------- */
.te-tn { min-width: 0; }
.te-tn b { display: block; overflow-wrap: anywhere; }
.te-tn small { display: block; font-size: 11.5px; color: var(--text-weak); overflow-wrap: anywhere; }
.te-acts { display: inline-flex; gap: 2px; }
.te-acts .btn.icon.sm { width: 28px; height: 28px; padding: 0; }
.te-sg { font-size: 12.5px; color: var(--text-weak); }
.te-sg.custom { color: var(--blue-text); font-weight: 600; }
.te-flt { width: auto; max-width: 210px; height: 32px; }
.te-flt.sm { max-width: 140px; }
.te-sw { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.te-sw input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.te-sw span { width: 32px; height: 18px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .15s; }
.te-sw span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: left .15s; }
.te-sw input:checked + span { background: var(--green); }
.te-sw input:checked + span::after { left: 16px; }
.te-sw input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }
@media (max-width: 640px) { .te-flt, .te-flt.sm { max-width: none; flex: 1 1 140px; } }
