/* Editor polish (all sizes) + phone layout. Loaded after the app's styles. */

/* A selected step was outlined in error-red; use the brand navy instead. */
.step-card.selected{border:2px solid #0b1b40;box-shadow:0 0 0 3px #dfe5f3}
.step-card.selected .step-chevron{color:#0b1b40}

/* Focus was the same red as errors; use a clear blue ring. */
.field-input:focus,.field-input:focus-visible,.workflow-title:focus-visible{outline:3px solid #2457d6;outline-offset:1px;border-color:#2457d6}

/* Were inline styles (blocked by CSP). */
#ai-recovery-dialog{width:min(760px,94vw)}
#ai-recovery-select{display:block;width:100%;margin:12px 0}
#ai-recovery-text{width:100%;height:45vh;box-sizing:border-box;padding:14px}

/* Phone tab bar (created by editor.js) is hidden unless the phone layout is active. */
.m-tabs,.m-add{display:none}

@media (max-width:720px){
  body.m-editor{padding-bottom:calc(132px + env(safe-area-inset-bottom))}
  body.m-editor .policy-links,body.m-editor .workspace-footer{display:none}

  /* Header: title on one line, actions as a single scrolling row of compact buttons. */
  body.m-editor .workspace-header{padding:12px 16px 10px}
  body.m-editor .workflow-title{font-size:22px}
  body.m-editor .workflow-details{font-size:13px}
  body.m-editor .header-actions{display:flex;flex-wrap:nowrap;justify-content:flex-start;gap:8px;margin:10px -16px 0;padding:0 16px 4px;overflow-x:auto;scrollbar-width:none}
  body.m-editor .header-actions::-webkit-scrollbar{display:none}
  body.m-editor .header-actions>*{flex:none}
  body.m-editor .header-actions .button{min-height:40px;padding:0 14px;font-size:14px;white-space:nowrap}

  /* One view at a time instead of a scroll box stacked on a map. */
  body.m-editor .builder{margin:0;border-radius:0;border-left:0;border-right:0;overflow:visible}
  body.m-editor .builder[data-mview="steps"] .diagram-panel,
  body.m-editor .builder[data-mview="map"] .steps-panel,
  body.m-editor .builder[data-mview="sop"] .steps-panel{display:none}
  body.m-editor .steps-panel{max-height:none;border-bottom:0}
  body.m-editor .step-list{max-height:none;overflow:visible;padding:0 12px 8px}
  body.m-editor .steps-panel .panel-header{position:sticky;top:0;z-index:3;background:#fff}
  body.m-editor .steps-map-jump,body.m-editor #steps-panel-toggle,body.m-editor #workspace-expand{display:none}
  body.m-editor .diagram-panel{height:calc(100dvh - 190px - env(safe-area-inset-bottom));min-height:420px}
  body.m-editor .builder[data-mview="sop"] .diagram-panel{height:auto;min-height:calc(100dvh - 190px)}
  body.m-editor .diagram-header{display:none}
  /* On the Flowchart tab the chart gets the screen: title stays, buttons and details go. */
  body.m-editor.m-map .header-actions,body.m-editor.m-map .workflow-details,body.m-editor.m-map .workspace-header .subtitle,body.m-editor.m-map .workspace-header .eyebrow{display:none}
  body.m-editor.m-map .diagram-panel{height:calc(100dvh - 150px - env(safe-area-inset-bottom))}

  /* Flowchart controls sit above the tab bar, with thumb-sized buttons. */
  body.m-editor .builder[data-mview="map"] .diagram-bottom{position:fixed;left:12px;right:12px;bottom:calc(72px + env(safe-area-inset-bottom));justify-content:flex-end}
  body.m-editor .diagram-legend{display:none}
  body.m-editor .canvas-controls{padding:4px;border-radius:12px;box-shadow:0 4px 16px #0b1b4026}
  body.m-editor .canvas-controls .icon-button{width:44px;height:44px;border-radius:10px}
  body.m-editor .canvas-controls .icon-button svg.icon{width:20px;height:20px}
  body.m-editor .canvas-controls>span:not(.control-divider){font-size:14px;min-width:50px}
  body.m-editor .canvas-controls .control-divider{height:24px}

  /* Step cards: big touch targets, no tiny text. */
  body.m-editor .step-card{margin-bottom:10px;border-radius:10px}
  body.m-editor .step-select{min-height:52px;font-size:16px}
  body.m-editor .step-card .icon-button{min-width:44px;min-height:44px}
  body.m-editor .step-form textarea,body.m-editor .step-form input,body.m-editor .step-form select{font-size:16px;min-height:48px}
  body.m-editor .step-form .field-label,body.m-editor .step-form label{font-size:15px}

  /* The app's own add buttons move into the fixed bar below. */
  body.m-editor .add-step-area{display:none}

  .m-add{position:fixed;left:0;right:0;bottom:calc(60px + env(safe-area-inset-bottom));z-index:40;display:flex;gap:8px;padding:8px 12px;background:#fffffff5;border-top:1px solid #d6dcea;backdrop-filter:blur(6px)}
  .m-add button{flex:1;min-height:48px;border-radius:10px;font:600 16px 'DM Sans',sans-serif;border:2px solid #0b1b40}
  .m-add .m-add-step{background:#0b1b40;color:#fff;flex:1.6}
  .m-add .m-add-decision{background:#fff;color:#0b1b40}
  body.m-editor .builder:not([data-mview="steps"])~.m-add,body.m-editor.m-not-steps .m-add{display:none}

  .m-tabs{position:fixed;left:0;right:0;bottom:0;z-index:41;display:grid;grid-template-columns:repeat(3,1fr);padding-bottom:env(safe-area-inset-bottom);background:#fff;border-top:1px solid #d6dcea}
  .m-tabs button{min-height:60px;border:0;background:none;font:600 15px 'DM Sans',sans-serif;color:#4a5672;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px}
  .m-tabs button svg{width:22px;height:22px}
  .m-tabs button[aria-selected="true"]{color:#0b1b40;box-shadow:inset 0 3px 0 #c2410c}
  body:not(.m-editor) .m-tabs,body:not(.m-editor) .m-add{display:none}
}
