/* ==========================================================================
   Nocturne — E-maily (email signatures, P9): template cards, variant rows,
   variant editor (texts · preview · HTML code), the GrapesJS page frame and
   the "Odeslat zkušební e-mail" modal. GrapesJS keeps its own UI.
   Forms reuse the sheet look from admin.css (.adm-sheet*).
   ========================================================================== */

/* ---- Template cards (like manual cards: white cover well + body) ------- */
.es-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 16px; }
.es-card { position: relative; display: flex; flex-direction: column; border-radius: 22px; background: var(--surface); border: 1px solid var(--line); overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.es-card:hover { border-color: var(--line-3); box-shadow: var(--shadow-2); }
.es-card:has(.es-name a:focus-visible) { outline: 2px solid var(--lav-ink); outline-offset: 2px; }
.es-cover { display: grid; place-items: center; height: 168px; padding: 18px; background: #fff; overflow: hidden; }
.es-cover img { max-width: 100%; max-height: 132px; object-fit: contain; }
.es-cover-ico { display: none; width: 72px; height: 72px; border-radius: 20px; place-items: center; background: var(--surface-3); color: var(--text-2); box-shadow: inset 0 0 0 1px var(--line-2); }
.es-cover.empty-cover { background: var(--surface-2); }
.es-cover.empty-cover .es-cover-ico { display: grid; }
.es-body { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px 18px; }
.es-head { display: flex; align-items: flex-start; gap: 8px; }
.es-name { flex: 1; min-width: 0; margin: 0; font-size: 17px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.es-name a { color: var(--text); text-decoration: none; }
.es-name a::after { content: ""; position: absolute; inset: 0; border-radius: 22px; }
.es-name a:focus-visible { outline: none; }
.es-name a:hover { color: var(--lav-ink); }
.es-acts { position: relative; z-index: 2; margin: -4px -6px 0 0; }

/* ---- Variant rows (people → rows in one bordered list) ------------------ */
.es-list { container-type: inline-size; border-radius: 22px; background: var(--surface); border: 1px solid var(--line); }
.es-list > ul { list-style: none; margin: 0; padding: 0; }
.es-row { position: relative; display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 14px 10px 18px; border-bottom: 1px solid var(--line); transition: background var(--dur-2); }
.es-row:first-child { border-radius: 21px 21px 0 0; }
.es-row:hover, .es-row:has(.show) { background: var(--surface-2); }
.es-row:has(.show) { z-index: 3; }
.es-row-name { flex: 1; min-width: 0; color: var(--text); font-size: 14px; font-weight: 600; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.es-row-name::after { content: ""; position: absolute; inset: 0; }
.es-row-name:hover { color: var(--lav-ink); }
.es-row-name:focus-visible { outline: none; }
.es-row:has(.es-row-name:focus-visible) { box-shadow: inset 0 0 0 2px var(--lav); }
.es-row-acts { position: relative; z-index: 2; display: flex; align-items: center; gap: 4px; }
.es-foot { padding: 14px 18px; }
@container (max-width: 560px) {
    .es-row-demo span { display: none; }
    .es-row-demo { width: 40px; padding: 0; }
}

/* ---- Variant editor: texts left, preview + code right ------------------- */
.es-edit-grid { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 20px; align-items: start; }
.es-fields { position: sticky; top: 24px; }
.es-fields .mb-3, .es-field { margin: 0 !important; }
.es-fields-f { display: flex; justify-content: flex-end; gap: 8px; padding-top: 16px; border-top: 1px solid var(--line); }
.es-out { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.es-out .pd-box-h h2 .i { color: var(--subtle); }
.es-out .pd-box-h { flex-wrap: wrap; }
/* the signature is customer output (inline-styled e-mail HTML): show it on white */
.es-preview { padding: 24px; border-radius: 16px; background: #fff; color: #111; overflow-x: auto; border: 1px solid var(--line-2); }
/* …in a sandboxed frame (email_signature_export_controller.js sizes it to its content;
   a signature wider than the box scrolls the box, as it did before the frame) */
.es-preview-frame { display: block; width: 100%; height: 0; border: 0; background: transparent; color-scheme: light; }
.es-code { min-height: 180px; font-size: 12px; line-height: 1.5; border-style: solid !important; background: var(--surface-2) !important; color: var(--text-2) !important; }
@media (max-width: 1100px) {
    .es-edit-grid { grid-template-columns: minmax(0, 1fr); }
    .es-fields { position: static; }
}

/* ---- Sheets (add/edit template + variant) -------------------------------- */
.es-sheet .mb-3 { margin-bottom: 0 !important; }
.es-bg-current { display: flex; flex-direction: column; gap: 8px; }
.es-bg-well { display: grid; place-items: center; min-height: 120px; padding: 16px; border-radius: 16px; background: #fff; border: 1px solid var(--line-2); }
.es-bg-well img { max-width: 100%; max-height: 160px; object-fit: contain; }
.es-bg-well.is-broken { background: var(--surface-2); border-style: dashed; }

/* ---- GrapesJS page frame -------------------------------------------------- */
.es-editor { display: flex; flex-direction: column; border-radius: 22px; background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.es-edbar { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 12px 10px 18px; border-bottom: 1px solid var(--line); }
.es-edbar-t { display: inline-flex; align-items: center; gap: 8px; margin-right: auto; font-size: 14px; font-weight: 600; color: var(--text-2); }
.es-edbar-t .i { color: var(--subtle); }
.es-saved { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--mnt-ink); }
.es-saved.d-none { display: none !important; }
.es-editor form { margin: 0; }
/* GrapesJS sizes its editor from the container; give it the viewport */
.es-gjs { height: clamp(460px, calc(100dvh - 300px), 980px) !important; }
.es-gjs .gjs-editor { font-family: var(--font); }
/* GrapesJS chrome on Nocturne tokens (P10b): its stock grey + pink/green
   accents read as a foreign widget in both themes. Colour classes only — the
   editor's layout and canvas (customer e-mail HTML) are untouched. */
.es-gjs .gjs-one-bg { background-color: var(--surface-2); }
.es-gjs .gjs-two-color { color: var(--text-2); }
.es-gjs .gjs-three-bg { background-color: var(--surface-3); color: var(--text); }
.es-gjs .gjs-four-color, .es-gjs .gjs-four-color-h:hover { color: var(--lav-ink); }
.es-gjs .gjs-pn-btn.gjs-pn-active { background: var(--lav-deep); box-shadow: none; }
.es-gjs .gjs-block { border-color: var(--line-2); border-radius: 12px; box-shadow: none; }
.es-gjs .gjs-block:hover { color: var(--lav-ink); border-color: var(--lav-line); }
.es-gjs .gjs-pn-panel, .es-gjs .gjs-blocks-c, .es-gjs .gjs-block-category .gjs-title { border-color: var(--line); }
.es-gjs .gjs-block-category .gjs-title { background-color: var(--surface-2); color: var(--text-2); }

/* ---- "Odeslat zkušební e-mail" modal ------------------------------------- */
.es-demo .modal-body { display: flex; flex-direction: column; gap: 16px; }
.es-demo-lead { margin: 0; color: var(--muted); line-height: 1.55; }
.es-demo-lead strong { color: var(--text); }
.es-demo-rows { display: flex; flex-direction: column; gap: 8px; }
.es-demo-row { display: flex; align-items: center; gap: 4px; }
.es-demo-row .inp { flex: 1; }
.es-demo-row .inp .i { color: var(--subtle); }
.es-demo-add { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; margin-left: -10px; border: 0; border-radius: 999px; background: transparent; color: var(--lav-ink); font-size: 13px; font-weight: 600; cursor: pointer; }
.es-demo-add:hover { background: var(--lav-deep); }
.es-demo-note { display: flex; align-items: flex-start; gap: 6px; margin: 0; line-height: 1.5; }
.es-demo-note .i { flex: none; margin-top: 2px; }
