/* ============================================================================
   bpmn-shell.css
   Adapted from mindzie.BpmnStudio.Demo/wwwroot/css/antd.css.
   Adapted: the original file's global element selectors (body, html, *, button,
   a) are scoped to .bpmn-shell so this stylesheet does not leak into
   mindzieStudio's pages when loaded inside the shared host.
   The :root CSS variables remain global - they are namespaced (--ant-*,
   --gray-*, --text-*, --bg-*, --border, --radius*, --shadow*, --font-*,
   --sider-w, --header-h) and harmless to other pages.
   The class rules (.layout, .sider, .menu, .brand, .header, .tag, .btn, etc.)
   are kept as-is - they only apply to elements that opt in by class name and
   live inside the BPMN Studio shell wrapper.
   ============================================================================ */

/* Ant Design tokens (single source of truth, copied verbatim from design handoff) */
:root {
  --ant-primary: #1677ff;
  --ant-primary-hover: #4096ff;
  --ant-primary-active: #0958d9;
  --ant-primary-bg: #e6f4ff;
  --ant-primary-border: #91caff;

  --ant-success: #52c41a;
  --ant-success-bg: #f6ffed;
  --ant-success-border: #b7eb8f;
  --ant-warning: #faad14;
  --ant-warning-bg: #fffbe6;
  --ant-warning-border: #ffe58f;
  --ant-error: #ff4d4f;
  --ant-error-bg: #fff2f0;
  --ant-error-border: #ffccc7;

  --gray-1: #ffffff;
  --gray-2: #fafafa;
  --gray-3: #f5f5f5;
  --gray-4: #f0f0f0;
  --gray-5: #d9d9d9;
  --gray-6: #bfbfbf;
  --gray-7: #8c8c8c;
  --gray-8: #595959;
  --gray-9: #434343;
  --gray-10: #262626;
  --gray-11: #1f1f1f;
  --gray-12: #141414;

  --text-primary: rgba(0,0,0,0.88);
  --text-secondary: rgba(0,0,0,0.65);
  --text-tertiary: rgba(0,0,0,0.45);
  --text-quaternary: rgba(0,0,0,0.25);

  --border: #d9d9d9;
  --border-secondary: #f0f0f0;
  --bg-container: #ffffff;
  --bg-layout: #f5f5f5;

  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 8px;

  --shadow-1: 0 1px 2px 0 rgba(0,0,0,0.03), 0 1px 6px -1px rgba(0,0,0,0.02), 0 2px 4px 0 rgba(0,0,0,0.02);
  --shadow-2: 0 6px 16px 0 rgba(0,0,0,0.08), 0 3px 6px -4px rgba(0,0,0,0.12), 0 9px 28px 8px rgba(0,0,0,0.05);

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  /* Display font for big titles (Repository title, Editor title text, etc.).
     Per moodboard / IMPLEMENTATION_PLAN.md §8. */
  --font-display: "Bricolage Grotesque", "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  /* Editorial serif for italic accent treatments. */
  --font-editorial: "Instrument Serif", Georgia, "Times New Roman", serif;

  /* Display accent (magenta from the Figma moodboard). Used for italic
     accent treatments and small "live" highlights. The Ant Design primary
     blue (--ant-primary) remains the action / interactive color. */
  --accent-display: #c026d3;
  --accent-display-bg: #fdf4ff;
  --accent-display-border: #f0abfc;

  --sider-w: 224px;
  --header-h: 52px;
}

/* Scoped global element rules - only inside .bpmn-shell */
.bpmn-shell, .bpmn-shell *, .bpmn-shell *::before, .bpmn-shell *::after { box-sizing: border-box; }
.bpmn-shell {
  font-family: var(--font-sans); font-size: 14px;
  color: var(--text-primary); background: var(--bg-layout);
  line-height: 1.5714; -webkit-font-smoothing: antialiased;
}
.bpmn-shell button { font: inherit; color: inherit; }
.bpmn-shell .mono, .bpmn-shell code { font-family: var(--font-mono); font-size: 0.92em; }
.bpmn-shell a { color: var(--ant-primary); text-decoration: none; }
.bpmn-shell a:hover { color: var(--ant-primary-hover); }
.bpmn-shell .svg-icon { width: 16px; height: 16px; display: inline-block; flex-shrink: 0; }

/* Layout */
.layout { display: grid; grid-template-columns: var(--sider-w) 1fr; height: 100vh; }
.content { display: grid; grid-template-rows: var(--header-h) 1fr; min-width: 0; overflow: hidden; }
.main { overflow-y: auto; background: var(--bg-layout); }

/* Surface tokens for the dark top band (brand block + header). */
.bpmn-shell {
  --bg-band: #0f172a;       /* dark navy, moodboard chrome */
  --band-border: #1e293b;
  --band-text-primary: rgba(255,255,255,0.92);
  --band-text-secondary: rgba(255,255,255,0.62);
  --band-text-tertiary: rgba(255,255,255,0.42);
  --band-surface-2: #1e293b;
  --band-surface-3: #273449;
}

/* Sider */
.sider {
  background: var(--gray-2); border-right: 1px solid var(--border-secondary);
  display: flex; flex-direction: column; overflow: hidden;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--band-border);
  height: var(--header-h);
  background: var(--bg-band);
  color: var(--band-text-primary);
}
.brand-logo {
  width: 28px; height: 28px; border-radius: var(--radius);
  background: linear-gradient(135deg, #1677ff 0%, #0958d9 100%);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 14px; flex-shrink: 0;
  position: relative;
}
.brand-logo::after {
  content: ""; position: absolute; bottom: -2px; right: -2px;
  width: 8px; height: 8px; border-radius: 50%;
  background: #00d4e0; border: 2px solid var(--bg-band);
}
.brand-text { font-weight: 600; font-size: 14px; line-height: 1.2; color: var(--band-text-primary); }
/* The product word inside the brand wordmark renders in italic editorial
   magenta - moodboard's "Web Design Moodboard" accent treatment. */
.brand-text .brand-product {
  font-family: var(--font-editorial);
  font-style: italic; font-weight: 400;
  color: var(--accent-display);
  letter-spacing: 0;
  margin-left: 2px;
}
.brand-text-sub { font-size: 11px; color: var(--band-text-tertiary); }

.menu { padding: 4px 8px; flex: 1; overflow-y: auto; }
.menu a.menu-item, .menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius); cursor: pointer;
  color: var(--text-primary); font-size: 14px; text-decoration: none;
  white-space: nowrap; margin-bottom: 2px;
  position: relative; /* host for the active-state right accent border */
}
.menu-item:hover { background: var(--gray-3); color: var(--text-primary); }
.menu-item.is-active {
  background: var(--ant-primary-bg);
  color: var(--ant-primary); font-weight: 500;
}
/* Per design handoff: active nav item gets a 2px right accent border. */
.menu-item.is-active::after {
  content: ""; position: absolute;
  right: -8px; top: 4px; bottom: 4px;
  width: 2px; border-radius: 2px;
  background: var(--ant-primary);
}
.menu-item-icon { width: 16px; display: flex; align-items: center; color: inherit; }
.menu-item-label { flex: 1; }
.menu-item-badge {
  background: var(--ant-error); color: white; border-radius: 10px;
  padding: 1px 6px; font-size: 11px; font-weight: 500; min-width: 16px; text-align: center;
}
.menu-section {
  font-size: 12px; color: var(--text-tertiary); padding: 12px 12px 4px;
  font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em;
}

.sider-footer { border-top: 1px solid var(--border-secondary); padding: 8px; }

/* Header — dark navy band, moodboard chrome */
.header {
  background: var(--bg-band); border-bottom: 1px solid var(--band-border);
  display: flex; align-items: center; padding: 0 24px; gap: 16px;
  color: var(--band-text-primary);
}
.breadcrumb { display: flex; align-items: center; gap: 8px; color: var(--band-text-secondary); font-size: 14px; }
.breadcrumb-sep { color: var(--band-text-tertiary); }
.breadcrumb-item { cursor: pointer; }
.breadcrumb-item:hover { color: var(--ant-primary-hover); }
.breadcrumb-item.is-current { color: var(--band-text-primary); }
.header-spacer { flex: 1; }
.header-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--band-surface-2); border: 1px solid transparent; border-radius: var(--radius);
  padding: 5px 10px; width: 280px; color: var(--band-text-tertiary);
}
.header-search:focus-within { background: var(--band-surface-3); border-color: var(--ant-primary); }
.header-search input { flex: 1; border: none; background: transparent; outline: none; font-size: 13px; color: var(--band-text-primary); }
.header-search input::placeholder { color: var(--band-text-tertiary); }
.header-kbd {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--band-text-secondary); background: var(--band-surface-3);
  border: 1px solid var(--band-border); border-radius: 3px; padding: 1px 5px;
}

.icon-btn {
  width: 32px; height: 32px; border-radius: var(--radius);
  background: transparent; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--band-text-secondary);
}
.icon-btn:hover { background: var(--band-surface-2); color: var(--band-text-primary); }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px; border-radius: 16px; cursor: pointer;
  color: var(--band-text-primary);
}
.user-chip:hover { background: var(--band-surface-2); }
.user-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent-display); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
}
.user-name { font-size: 13px; font-weight: 500; color: var(--band-text-primary); }

/* Page header */
.page {
  padding: 32px 32px 24px; background: var(--gray-1);
  border-bottom: 1px solid var(--border-secondary);
}
.page-title-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; }
.page-actions { display: flex; gap: 8px; flex-shrink: 0; padding-bottom: 4px; }

/* Mono uppercase eyebrow label above the page title (moodboard "// Typeface"
   treatment). Tertiary color, very light tracking. */
.page-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin: 0 0 6px 0;
}
.page-eyebrow::before {
  content: "// "; color: var(--accent-display); font-weight: 600;
}

/* Display headings use Bricolage Grotesque per moodboard. Bigger size +
   tighter tracking + slight optical-size axis hint via line-height. */
.page-title {
  font-family: var(--font-display);
  font-size: 36px; font-weight: 600;
  letter-spacing: -0.02em; line-height: 1.1;
  margin: 0;
}
.page-subtitle {
  font-size: 16px; color: var(--text-secondary); margin-top: 8px;
  max-width: 720px; line-height: 1.5;
}

/* Editorial italic accent. Use for short, deliberate callouts (e.g. an
   italic word inside a headline or subtitle). */
.editorial,
em.editorial,
.page-title em,
.page-subtitle em {
  font-family: var(--font-editorial);
  font-style: italic;
  font-weight: 400;
  color: var(--accent-display);
  letter-spacing: 0;
}
.page-subtitle em {
  /* Editorial serif tends to look smaller at the same px size as Inter.
     Bump up so the rhythm feels right next to the body. */
  font-size: 1.1em;
}

/* Coming-soon placeholder body */
.placeholder-body {
  padding: 48px 32px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-tertiary); font-size: 14px;
}
.placeholder-body .placeholder-tag {
  display: inline-flex; align-items: center;
  padding: 4px 10px; border-radius: 12px;
  background: var(--ant-warning-bg); border: 1px solid var(--ant-warning-border);
  color: #d48806; font-size: 12px; font-weight: 500;
  margin-top: 8px;
}

/* Editor layout */
.editor-shell {
  display: grid;
  grid-template-rows: 48px 1fr;
  height: 100%;
  background: var(--bg-container);
}
.editor-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 0 16px;
  background: var(--gray-1);
  border-bottom: 1px solid var(--border-secondary);
}
.editor-title {
  font-family: var(--font-display);
  font-size: 16px; font-weight: 600; color: var(--text-primary);
  letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 420px;
}
.editor-title .muted {
  font-family: var(--font-sans);
  color: var(--text-tertiary); font-weight: 400; letter-spacing: 0;
}
.editor-bar-spacer { flex: 1; }
.editor-canvas {
  position: relative;
  background: var(--gray-3);
  overflow: hidden;
}
.bpmn-host {
  width: 100%; height: 100%;
}
.editor-error-banner {
  position: absolute;
  top: 16px; left: 50%; transform: translateX(-50%);
  background: var(--ant-error-bg); border: 1px solid var(--ant-error-border);
  color: #cf1322;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 13px; box-shadow: var(--shadow-1);
  max-width: 80%;
}

/* Modal dialog (used for New diagram and Delete confirm) */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-card {
  background: var(--bg-container);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  width: 480px; max-width: calc(100vw - 32px);
  display: flex; flex-direction: column;
  max-height: calc(100vh - 64px);
}
.modal-title {
  font-size: 16px; font-weight: 600;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-secondary);
}
.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
}
.modal-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 24px;
  border-top: 1px solid var(--border-secondary);
}

/* Inline-editable editor title input */
.editor-title-input {
  font-family: inherit;
}

/* ============================================================
 * Multi-tab editor (ADR-0001)
 * ============================================================ */

.bpmn-editor-root {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.bpmn-tab-strip {
  display: flex;
  align-items: stretch;
  gap: 1px;
  padding: 6px 12px 0 12px;
  background: var(--bg-secondary, #fafafa);
  border-bottom: 1px solid var(--border-secondary, #e5e7eb);
  overflow-x: auto;
  scrollbar-width: thin;
  height: 38px;
  flex-shrink: 0;
}

.bpmn-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px 0 14px;
  height: 32px;
  min-width: 120px;
  max-width: 240px;
  background: var(--bg-elevated, #ffffff);
  border: 1px solid var(--border-secondary, #e5e7eb);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary, #6b7280);
  cursor: pointer;
  user-select: none;
  position: relative;
  margin-right: 2px;
  transition: background 120ms ease, color 120ms ease;
}

.bpmn-tab:hover {
  color: var(--text-primary, #111827);
  background: var(--bg-hover, #f5f5f5);
}

.bpmn-tab.is-active {
  color: var(--text-primary, #111827);
  background: var(--bg-canvas, #ffffff);
  border-color: var(--border-primary, #d1d5db);
  z-index: 2;
  box-shadow: 0 -2px 0 0 var(--accent-display, #c026d3) inset;
}

.bpmn-tab.is-active:hover {
  background: var(--bg-canvas, #ffffff);
}

.bpmn-tab-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bpmn-tab-dirty {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-display, #c026d3);
  flex-shrink: 0;
}

.bpmn-tab-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-tertiary, #9ca3af);
  cursor: pointer;
  flex-shrink: 0;
}

.bpmn-tab-close:hover {
  background: var(--bg-hover, #f5f5f5);
  color: var(--text-primary, #111827);
}

.bpmn-tab.is-active .bpmn-tab-close:hover {
  background: var(--bg-secondary, #f3f4f6);
}

.bpmn-tab-spacer { flex: 1; }

/* Container for the editor pane: when not the active tab, hidden but
 * mounted - keeps each tab's bpmn-js instance alive (ADR-0001 Tier 5 #3).
 * The active pane fills the remainder of .bpmn-editor-root after the
 * tab strip. */
.bpmn-tab-pane {
  display: none;
  flex: 1 1 auto;
  min-height: 0;
}
.bpmn-tab-pane.is-active {
  display: flex;
  flex-direction: column;
}

/* Per-title dirty marker (asterisk in the editor bar) */
.dirty-dot {
  color: var(--accent-display, #c026d3);
  font-weight: 700;
  margin-left: 4px;
}

/* ============================================================
 * Welcome / Recents landing
 * ============================================================ */

.welcome {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
}

.welcome-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  padding: 16px 32px 32px 32px;
}

@media (max-width: 1100px) {
  .welcome-grid { grid-template-columns: 1fr; }
}

.welcome-card {
  background: var(--bg-elevated, #ffffff);
  border: 1px solid var(--border-secondary, #e5e7eb);
  border-radius: 12px;
  padding: 20px 24px;
  min-height: 320px;
}

.welcome-card-muted {
  background: var(--bg-secondary, #fafafa);
}

.welcome-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display, "Bricolage Grotesque", system-ui);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 16px;
}

.welcome-empty-soft {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  color: var(--text-tertiary, #9ca3af);
}

.recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.recent-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 120ms ease;
}

.recent-item:hover {
  background: var(--bg-hover, #f5f5f5);
}

.recent-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-secondary, #fafafa);
  color: var(--text-tertiary, #9ca3af);
  font-size: 16px;
  flex-shrink: 0;
}

.recent-main { flex: 1; min-width: 0; }

.recent-name {
  font-weight: 600;
  color: var(--text-primary, #111827);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-tertiary, #9ca3af);
}

.recent-version {
  font-family: var(--font-mono, "JetBrains Mono", monospace);
}

.recent-time { font-style: italic; }

/* ============================================================
 * Properties panel (right rail)
 * Per design handoff 03_bpmn_editor.md §4.4: 360px default,
 * collapsible to a 40px stub.
 * ============================================================ */

.editor-body {
  display: flex;
  flex-direction: row;
  flex: 1 1 auto;
  min-height: 0;
}

.editor-body > .editor-canvas {
  flex: 1 1 auto;
  min-width: 0;
}

.bpmn-properties-panel {
  display: flex;
  flex-direction: column;
  width: 360px;
  flex-shrink: 0;
  background: var(--bg-elevated, #ffffff);
  border-left: 1px solid var(--border-secondary, #e5e7eb);
  overflow: hidden;
  transition: width 160ms ease;
}

.bpmn-properties-panel.is-collapsed {
  width: 40px;
}

.bpmn-properties-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 0 16px;
  height: 40px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-secondary, #e5e7eb);
  background: var(--bg-secondary, #fafafa);
}

.bpmn-properties-title {
  font-family: var(--font-display, "Bricolage Grotesque", system-ui);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #111827);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bpmn-properties-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary, #6b7280);
  cursor: pointer;
}

.bpmn-properties-toggle:hover {
  background: var(--bg-hover, #f5f5f5);
  color: var(--text-primary, #111827);
}

.bpmn-properties-toggle-stub {
  width: 100%;
  height: 40px;
  border-radius: 0;
  border-bottom: 1px solid var(--border-secondary, #e5e7eb);
}

.bpmn-properties-tabstrip {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  padding: 0 12px;
  height: 36px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-secondary, #e5e7eb);
  gap: 4px;
}

.bpmn-properties-tab {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary, #6b7280);
  cursor: default;
  user-select: none;
  border-bottom: 2px solid transparent;
}

.bpmn-properties-tab.is-active {
  color: var(--text-primary, #111827);
  border-bottom-color: var(--accent-display, #c026d3);
}

.bpmn-properties-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
}

.bpmn-properties-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bpmn-properties-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bpmn-properties-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary, #9ca3af);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bpmn-properties-typebadge {
  display: inline-block;
  align-self: flex-start;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--bg-secondary, #fafafa);
  border: 1px solid var(--border-secondary, #e5e7eb);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary, #111827);
}

.bpmn-properties-id {
  font-family: var(--font-mono, "JetBrains Mono", monospace);
  font-size: 12px;
  color: var(--text-secondary, #6b7280);
  word-break: break-all;
}

.bpmn-properties-status {
  font-size: 11px;
  color: var(--text-tertiary, #9ca3af);
  font-style: italic;
}

