/* =====================================================================
   EMOSE Backoffice — processos.css
   Styles for the Processos screen (processos.js) ONLY: process card grid
   + per-card CRUD actions/confirm (list view), the flow view's back
   link + Editar action + step-detail body extensions, the import/edit
   modal + review form (name, step type/I-O tag editors + autocomplete
   dropdown), and the data-dictionary panel with inline Create/Update/
   Delete. The pipeline/station/connector/legend visual itself is the
   SHARED styles.css §8, reused verbatim, NEVER redefined here.

   OWNERSHIP: owned by the Flow-Studio agent (processos.js/processos.css).
   Every rule below is either:
     (a) a brand-new class not defined anywhere else in the app, or
     (b) a scoped, additive modifier under a NEW parent class this file
         owns (e.g. `.import-steps-head .pipeline-legend` only compacts
         the legend WHEN it appears inside the import review — the base
         rule in styles.css §8 is never touched), or
     (c) a size/hover modifier on an EXISTING shared primitive
         (.icon-btn.is-danger, same recipe as casos.css's own — a
         harmless, intentional 2-line duplication of a generic pattern,
         not a dependency on that sibling agent's private file).
   Class names are scoped (proc-*, import-*, dict-*) to avoid any
   collision with casos.css's private "cmodal"/"cform" vocabulary.

   DEPENDENCIES: none new — only the design tokens + primitives already in
   styles.css (:root/[data-theme="dark"] tokens, .card, .pill, .btn,
   .icon-btn, .state-panel, .eyebrow, .screen-head/.subtitle-muted, and
   section 8's pipeline/station/connector/legend/blueprint-detail classes
   — all reused, none redefined).

   A-MUDAR: none blocking — see processos.js's own header comment for the
   backend-schema-lag caveat (label/options/origem not round-tripping
   through the live server yet — a backend gap, not a styling one).

   SECTIONS
     1. List: process card grid + per-card actions/confirm + soft notice + toast
     2. Flow view: back link + Editar action + header meta row
     3. Flow view: step-detail body additions (extends shared .bd-*)
     4. Import/edit modal shell (overlay/dialog/head/body/actions/field/error)
     5. Import modal — phase A: file picker + textarea
     6. Import/edit modal — phase B: review (warnings, step rows, type
        select, inputs/outputs tag editors, autocomplete dropdown)
     7. Data dictionary panel (Create/Read/Update/Delete)
     8. Responsive
   ===================================================================== */

/* ---------------------------------------------------------------------
   1. List: process card grid + per-card actions/confirm + soft notice + toast
--------------------------------------------------------------------- */
.proc-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:18px;}
.proc-card{display:flex;flex-direction:column;gap:12px;}
.proc-card-top{display:flex;align-items:center;justify-content:space-between;gap:10px;}
.proc-card-icon{width:42px;height:42px;flex:0 0 42px;border-radius:13px;background:var(--sunken);color:var(--red-primary);display:flex;align-items:center;justify-content:center;}
.proc-card-icon svg{width:19px;height:19px;}
.proc-card-name{font-size:16px;font-weight:800;color:var(--text);margin:0;letter-spacing:-.01em;}
.proc-card-meta{font-size:13px;color:var(--text2);font-weight:600;margin:0;}

/* Pins the actions to the bottom of the card even when names wrap to
   different heights — grid stretches every card in a row to the tallest;
   .proc-card is itself a flex column, so margin-top:auto on the last
   block is enough (same technique as conectores.css's .conn-steps). */
.proc-card-actions{display:flex;align-items:center;gap:8px;margin-top:auto;}
.proc-card-action{flex:1;justify-content:center;}
.proc-card-action svg{width:15px;height:15px;}
/* Size/hover modifier on the EXISTING shared .icon-btn primitive
   (styles.css §3) — same recipe as casos.css's own .icon-btn.is-danger,
   independently declared here (see header comment ownership note). */
.icon-btn.is-danger:hover{background:var(--error-surf);border-color:var(--error);color:var(--error);}

.proc-card-confirm{display:flex;flex-direction:column;gap:8px;margin-top:auto;}
.proc-card-confirm-text{font-size:12.5px;font-weight:700;color:var(--text2);}
.proc-card-confirm-error{font-size:11.5px;font-weight:700;color:var(--error);}
.proc-card-confirm-actions{display:flex;gap:8px;}
.proc-card-confirm-actions .btn{flex:1;}

/* Soft inline notice — e.g. the /api/processes endpoint isn't deployed
   yet on this server. Reuses the warning semantic tokens verbatim (no
   new color), same recipe as styles.css §7's .hitl-reason. */
.proc-notice{display:flex;align-items:center;gap:10px;padding:12px 16px;border-radius:14px;background:var(--warning-surf);color:var(--warning);font-size:13px;font-weight:700;}
.proc-notice svg{width:16px;height:16px;flex:0 0 16px;}

/* Toast — same recipe as casos.css's .case-toast, own namespace. */
.proc-toast{display:flex;align-items:center;gap:10px;padding:13px 18px;border-radius:14px;font-size:13.5px;font-weight:700;}
.proc-toast svg{width:17px;height:17px;flex:0 0 17px;}
.proc-toast.is-success{background:var(--success-surf);color:var(--success);}
.proc-toast.is-error{background:var(--error-surf);color:var(--error);}

/* ---------------------------------------------------------------------
   2. Flow view: back link + Editar action + header meta row
--------------------------------------------------------------------- */
.proc-flow-top{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;}
.proc-back{display:inline-flex;align-items:center;gap:6px;background:none;border:none;padding:4px 2px;margin:0;font:inherit;font-size:13.5px;font-weight:700;color:var(--text2);cursor:pointer;}
.proc-back:hover{color:var(--red-deep);}
.proc-back svg{width:16px;height:16px;}
/* The shared #icon-chevron-right (points right) reused as a "back" arrow
   — see processos.js's header comment ICONS note. */
.proc-back-icon{transform:rotate(180deg);}
.proc-flow-meta{display:flex;align-items:center;gap:10px;margin-top:4px;}

/* ---------------------------------------------------------------------
   3. Flow view: step-detail body additions. Header row reuses the
      SHARED .blueprint-detail/.bd-* classes (styles.css §8) verbatim —
      only the content BELOW that header, which blueprints.js doesn't
      need, is new here.
--------------------------------------------------------------------- */
.proc-detail-summary{margin:14px 2px 0;color:var(--text2);font-size:14px;line-height:1.55;font-weight:500;}
.proc-detail-grid{display:grid;grid-template-columns:1fr 1fr;gap:16px;margin-top:16px;}
.proc-detail-block{margin-top:16px;}
.proc-detail-grid .proc-detail-block{margin-top:0;}
.proc-detail-block .eyebrow{margin-bottom:8px;}
.proc-detail-empty{color:var(--text3);font-size:13px;font-weight:600;margin:0;}
.proc-decision-question{font-size:14px;font-weight:700;color:var(--text);margin:0 0 8px;}
.proc-chip-list{display:flex;flex-wrap:wrap;gap:7px;}
.proc-chip{font-size:12px;font-weight:700;padding:5px 11px;border-radius:999px;background:var(--sunken);color:var(--text2);}
.proc-chip-outcome{background:var(--warning-surf);color:var(--warning);}

/* ---------------------------------------------------------------------
   4. Import/edit modal shell
--------------------------------------------------------------------- */
/* Backdrop scrim: rgba (not a token) mirrors styles.css's own precedent
   for decorative depth/dimming — never used for UI content color. */
.import-overlay{position:fixed;inset:0;z-index:150;display:flex;align-items:center;justify-content:center;background:rgba(26,8,8,.46);padding:24px;overflow-y:auto;}
[data-theme="dark"] .import-overlay{background:rgba(0,0,0,.6);}

.import-dialog{width:680px;max-width:100%;padding:26px 26px 24px;box-shadow:var(--shadow-lg);max-height:calc(100vh - 48px);overflow-y:auto;}
.import-head{display:flex;align-items:flex-start;justify-content:space-between;gap:14px;margin-bottom:18px;}
.import-title{font-size:18px;font-weight:800;color:var(--text);margin:0;letter-spacing:-.01em;}

.import-body{display:flex;flex-direction:column;gap:14px;}
.import-help{font-size:13.5px;color:var(--text2);margin:0;line-height:1.5;}

.import-field{display:flex;flex-direction:column;gap:6px;}
.import-label{font-size:12.5px;font-weight:700;color:var(--text2);}
.import-input{width:100%;box-sizing:border-box;padding:11px 13px;border-radius:12px;border:1.5px solid var(--border);background:var(--surface-alt);color:var(--text);font-size:14px;font-family:inherit;outline:none;transition:border-color .15s,background .15s;}
.import-input:focus{border-color:var(--red-primary);background:var(--surface);}

.import-error{font-size:12.5px;font-weight:700;color:var(--error);margin:0;}
.import-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:4px;}

/* ---------------------------------------------------------------------
   5. Import modal — phase A: file picker + textarea
--------------------------------------------------------------------- */
.import-file-row{display:flex;align-items:center;gap:12px;flex-wrap:wrap;}
.import-file-btn{display:inline-flex;align-items:center;gap:8px;cursor:pointer;position:relative;}
/* Visually-hidden but still focusable/keyboard-operable (NOT the `hidden`
   attribute, which removes it from the tab order entirely). */
.import-file-input{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;}
.import-file-btn:focus-within{outline:2px solid var(--red-primary);outline-offset:2px;}
.import-file-name{font-size:12.5px;color:var(--text2);font-weight:600;}
.import-file-name-empty{color:var(--text3);font-style:italic;}

.import-textarea{width:100%;box-sizing:border-box;min-height:140px;padding:12px 14px;border-radius:12px;border:1.5px solid var(--border);background:var(--surface-alt);color:var(--text);font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:12.5px;line-height:1.5;outline:none;resize:vertical;transition:border-color .15s,background .15s;}
.import-textarea:focus{border-color:var(--red-primary);background:var(--surface);}

/* ---------------------------------------------------------------------
   6. Import/edit modal — phase B: review
--------------------------------------------------------------------- */
.import-warnings{display:flex;gap:12px;padding:13px 15px;border-radius:14px;background:var(--warning-surf);color:var(--warning);}
.import-warnings svg{width:17px;height:17px;flex:0 0 17px;margin-top:1px;}
.import-warnings-title{font-size:13px;font-weight:800;margin:0 0 4px;}
.import-warnings-list{margin:0;padding-left:18px;font-size:12.5px;font-weight:600;line-height:1.6;}

.import-steps-head{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;}
.import-steps-head .eyebrow{margin:0;}
/* Scoped compaction of the SHARED legend — only inside the import
   review, never touches the base .pipeline-legend/.legend-item rule. */
.import-steps-head .pipeline-legend{gap:12px;}
.import-steps-head .legend-item{font-size:11px;}

.import-steps-list{display:flex;flex-direction:column;gap:10px;max-height:400px;overflow-y:auto;border:1px solid var(--hairline);border-radius:14px;padding:10px;background:var(--surface-alt);}
.import-step-row{display:flex;flex-direction:column;gap:10px;padding:12px 12px 14px;border-radius:12px;background:var(--surface);}
.import-step-head{display:flex;align-items:center;gap:10px;}
.import-step-id{flex:0 0 auto;font-size:11px;font-weight:800;color:var(--text3);min-width:24px;}
.import-step-label{flex:1;min-width:0;font-size:13.5px;font-weight:700;color:var(--text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.import-type-select{flex:0 0 auto;padding:7px 10px;border-radius:10px;border:1.5px solid var(--border);background:var(--surface);color:var(--text);font-size:12.5px;font-weight:700;font-family:inherit;cursor:pointer;outline:none;}
.import-type-select:focus{border-color:var(--red-primary);}

/* Inputs/outputs tag editors. */
.import-step-io{display:grid;grid-template-columns:1fr 1fr;gap:12px;padding-left:16px;}
.import-tags-field{display:flex;flex-direction:column;gap:5px;min-width:0;}
.import-tags-label{font-size:11px;font-weight:800;letter-spacing:.03em;text-transform:uppercase;color:var(--text3);}
.import-tags-box{display:flex;flex-wrap:wrap;align-items:center;gap:6px;padding:7px 8px;border-radius:10px;border:1.5px solid var(--border);background:var(--surface-alt);min-height:38px;transition:border-color .15s,background .15s;}
.import-tags-box:focus-within{border-color:var(--red-primary);background:var(--surface);}
.import-tag{display:inline-flex;align-items:center;gap:5px;padding:4px 6px 4px 10px;border-radius:999px;background:var(--sunken);color:var(--text2);font-size:12px;font-weight:700;white-space:nowrap;}
.import-tag-remove{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;border-radius:50%;border:none;background:none;color:var(--text3);font-size:14px;line-height:1;cursor:pointer;padding:0;font-family:inherit;}
.import-tag-remove:hover{background:var(--border-strong);color:var(--text);}
/* Wraps the tag input + its autocomplete dropdown — position:relative is
   a harmless defensive default (the dropdown itself is position:fixed,
   computed via JS from getBoundingClientRect(), so it does not actually
   anchor off this — see processos.js's AUTOCOMPLETE section for why). */
.import-tags-input-wrap{position:relative;display:inline-flex;flex:1;min-width:70px;}
.import-tags-input{flex:1;min-width:0;border:none;background:none;outline:none;color:var(--text);font-size:12.5px;font-family:inherit;padding:4px 2px;}
.import-tags-input::placeholder{color:var(--text3);}

/* Autocomplete suggestion dropdown — position:fixed deliberately (see
   processos.js): it must escape BOTH .import-steps-list's and
   .import-dialog's own overflow:auto clipping. */
.import-suggest{position:fixed;z-index:170;background:var(--surface);border:1.5px solid var(--border-strong);border-radius:12px;box-shadow:var(--shadow-md);max-height:180px;overflow-y:auto;padding:4px;}
.import-suggest-item{padding:7px 10px;border-radius:8px;font-size:12.5px;font-weight:600;color:var(--text);cursor:pointer;}
.import-suggest-item:hover,.import-suggest-item.is-highlighted{background:var(--red-pale);color:var(--red-deep);}
[data-theme="dark"] .import-suggest-item:hover,[data-theme="dark"] .import-suggest-item.is-highlighted{background:var(--selected);color:var(--text);}

/* ---------------------------------------------------------------------
   7. Data dictionary panel (Create/Read/Update/Delete)
--------------------------------------------------------------------- */
.dict-panel{padding:14px 16px 6px;border-radius:14px;background:var(--surface-alt);border:1px solid var(--hairline);}
.dict-panel .eyebrow{margin:0 0 6px;}
.dict-help{font-size:12px;color:var(--text2);margin:0 0 12px;line-height:1.5;}
.dict-empty{font-size:12.5px;color:var(--text3);margin:0 0 10px;font-weight:600;}

.dict-list{display:flex;flex-direction:column;gap:8px;margin-bottom:12px;}
.dict-row{display:flex;flex-direction:column;gap:8px;padding:10px 10px 10px;border-radius:12px;background:var(--surface);border:1px solid var(--hairline);}
.dict-row-main{display:flex;flex-direction:column;gap:8px;}
.dict-row-fields{display:flex;align-items:center;gap:8px;flex-wrap:wrap;}
.dict-row-name-input{flex:1;min-width:120px;border:none;background:none;outline:none;font-size:13px;font-weight:800;color:var(--text);font-family:inherit;padding:4px 2px;border-bottom:1.5px dashed transparent;}
.dict-row-name-input:focus{border-bottom-color:var(--red-primary);}
.dict-row-label-input{flex:1;min-width:140px;border:none;background:none;outline:none;font-size:12.5px;font-weight:600;color:var(--text2);font-family:inherit;padding:4px 2px;border-bottom:1.5px dashed transparent;}
.dict-row-label-input:focus{border-bottom-color:var(--red-primary);color:var(--text);}
.dict-row-label-input::placeholder{color:var(--text3);font-weight:500;}
.dict-row-selects{display:flex;align-items:center;gap:8px;flex-wrap:wrap;}
.dict-row-delete{display:inline-flex;align-items:center;justify-content:center;width:26px;height:26px;border-radius:50%;border:none;background:none;color:var(--text3);cursor:pointer;flex:0 0 auto;margin-left:auto;}
.dict-row-delete:hover{background:var(--error-surf);color:var(--error);}
.dict-row-delete svg{width:13px;height:13px;}

.dict-row-name-error{font-size:11.5px;font-weight:700;color:var(--error);margin:0;}

.dict-row-confirm{display:flex;align-items:center;gap:8px;flex-wrap:wrap;}
.dict-row-confirm-text{font-size:12px;font-weight:700;color:var(--text2);flex:1;min-width:160px;}
/* .dict-row-main/.dict-row-confirm are toggled at runtime via the
   `hidden` HTML attribute (processos.js's onDictDeleteClick/
   onDictConfirmNo) — a plain class rule setting `display` has EQUAL CSS
   specificity to the UA stylesheet's `[hidden]{display:none}` and loads
   AFTER it, so it silently wins and the element never actually hides.
   Caught live while verifying (both rendered at once for every
   dictionary row). Fix: an attribute-qualified selector, which is MORE
   specific than the plain class rule regardless of source order. */
.dict-row-main[hidden],.dict-row-confirm[hidden]{display:none;}

/* Chip-select — shared by dictionary rows AND the add-row. */
.dict-chip-select{font-size:11.5px;font-weight:700;padding:6px 9px;border-radius:9px;border:1px solid var(--border);background:var(--surface-alt);color:var(--text2);font-family:inherit;cursor:pointer;outline:none;flex:0 0 auto;}
.dict-chip-select:focus{border-color:var(--red-primary);}

/* Per-variable options list — only shown when type === 'selecao'. */
.dict-row-options{padding-top:6px;border-top:1px dashed var(--hairline);}
.dict-row-options-label{display:block;font-size:10.5px;font-weight:800;letter-spacing:.03em;text-transform:uppercase;color:var(--text3);margin-bottom:5px;}
.dict-options-box{display:flex;flex-wrap:wrap;align-items:center;gap:6px;padding:6px 7px;border-radius:9px;border:1.5px solid var(--border);background:var(--surface-alt);min-height:34px;}
.dict-options-box:focus-within{border-color:var(--red-primary);background:var(--surface);}
.dict-options-input{flex:1;min-width:80px;border:none;background:none;outline:none;color:var(--text);font-size:12px;font-family:inherit;padding:3px 2px;}
.dict-options-input::placeholder{color:var(--text3);}

.dict-add-row{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:8px 2px 4px;}
.dict-add-input{flex:1;min-width:130px;padding:8px 10px;border-radius:10px;border:1.5px dashed var(--border-strong);background:var(--surface-alt);color:var(--text);font-size:12.5px;font-family:inherit;outline:none;}
.dict-add-input:focus{border-style:solid;border-color:var(--red-primary);background:var(--surface);}
.dict-add-error{margin:4px 2px 0;}

/* ---------------------------------------------------------------------
   8. Responsive
--------------------------------------------------------------------- */
@media (max-width:760px){
  .proc-grid{grid-template-columns:1fr;}
  .proc-detail-grid{grid-template-columns:1fr;}
}
@media (max-width:560px){
  .import-dialog{padding:22px 18px 20px;}
  .import-step-io{grid-template-columns:1fr;padding-left:0;}
  .import-type-select{width:100%;}
  .dict-row-fields,.dict-row-selects{flex-direction:column;align-items:stretch;}
  .dict-row-delete{margin-left:0;align-self:flex-end;}
  .dict-add-row{flex-direction:column;align-items:stretch;}
}
