/* 8.2 Processes – Styles */
:root {
  --c-primary: #1a56db;
  --c-primary-dark: #1240a8;
  --c-logo: #ff7800;
  --c-bg: #f5f7fa;
  --c-surface: #ffffff;
  --c-border: #dde3ec;
  --c-text: #1f2937;
  --c-text-dim: #6b7280;
  --c-danger: #dc2626;
  --c-ok: #059669;
  --radius: 8px;
  --shadow: 0 4px 16px rgba(15, 30, 60, .12);
}

* { box-sizing: border-box; }
/* Muss vor den display:flex-Regeln stehen: das hidden-Attribut soll immer gewinnen. */
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--c-text);
  background: var(--c-bg);
  display: flex;
  flex-direction: column;
}

button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }

/* ---------- Login ---------- */
.login-body { align-items: center; justify-content: center; }
.login-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 36px 40px;
  width: 360px;
}
.login-logo { display: flex; align-items: center; gap: 10px; }
.login-logo h1 { margin: 0; font-size: 26px; }
.login-subtitle { color: var(--c-text-dim); margin: 6px 0 24px; }
.login-card label { display: block; margin: 14px 0 4px; font-weight: 600; }
.login-card input {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--c-border); border-radius: var(--radius);
}
.login-card input:focus { outline: 2px solid var(--c-primary); border-color: transparent; }
.login-error { color: var(--c-danger); margin-top: 12px; }

.logo-badge {
  background: var(--c-logo); color: #fff;
  border-radius: 8px; padding: 4px 8px;
  font-family: 'Tienne', Georgia, serif;
  font-weight: 700; font-size: 15px; letter-spacing: .5px;
}
.logo-text { font-weight: 700; font-size: 16px; }

/* ---------- Buttons ---------- */
.btn {
  background: var(--c-surface); color: var(--c-text);
  border: 1px solid var(--c-border); border-radius: var(--radius);
  padding: 7px 14px;
}
.btn:hover { background: #eef2f8; }
.btn-primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-dark); }
.btn-danger { background: var(--c-danger); border-color: var(--c-danger); color: #fff; }
.btn-block { width: 100%; margin-top: 20px; padding: 10px; }
.btn-small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn {
  background: none; border: none; color: var(--c-text-dim);
  border-radius: 6px; padding: 3px 8px;
}
.icon-btn:hover { background: #e6ebf3; color: var(--c-text); }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  background: var(--c-surface); border-bottom: 1px solid var(--c-border);
  padding: 8px 16px; flex: 0 0 auto;
}
.topbar-left { display: flex; align-items: center; gap: 8px; }
.topbar-center { flex: 1; display: flex; justify-content: center; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.search-wrap { position: relative; width: min(480px, 100%); }
.search-wrap input {
  width: 100%; padding: 8px 14px;
  border: 1px solid var(--c-border); border-radius: 20px; background: var(--c-bg);
}
.search-wrap input:focus { outline: 2px solid var(--c-primary); background: #fff; }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 60;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  max-height: 320px; overflow: auto;
}
.search-results .sr-item {
  display: block; width: 100%; text-align: left; background: none; border: none;
  padding: 8px 14px; border-bottom: 1px solid #f0f3f8;
}
.search-results .sr-item:hover { background: #eef2f8; }
.search-results .sr-path { color: var(--c-text-dim); font-size: 12px; }

.user-menu { position: relative; }
.user-dropdown {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius); box-shadow: var(--shadow); min-width: 180px;
}
.user-dropdown button {
  display: block; width: 100%; text-align: left;
  background: none; border: none; padding: 9px 14px;
}
.user-dropdown button:hover { background: #eef2f8; }

/* ---------- Layout ---------- */
.layout { flex: 1; display: flex; min-height: 0; }
.sidebar {
  width: 300px; flex: 0 0 auto; display: flex; flex-direction: column;
  background: var(--c-surface); border-right: 1px solid var(--c-border);
}
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; font-weight: 700; border-bottom: 1px solid var(--c-border);
}
.tree { flex: 1; overflow: auto; padding: 8px 4px; }

.tree-node { user-select: none; }
.tree-row {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px; border-radius: 6px; cursor: pointer;
  white-space: nowrap;
}
.tree-row:hover { background: #eef2f8; }
.tree-row.selected { background: #dbe6fb; }
.tree-row .caret { width: 14px; flex: 0 0 auto; color: var(--c-text-dim); font-size: 11px; }
.tree-row .t-icon { flex: 0 0 auto; }
/* Der Name weicht als Erstes, damit das Status-Badge lesbar bleibt. */
.tree-row .t-name { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tree-children { margin-left: 16px; }
.tree-status { margin-left: auto; flex: 0 0 auto; }

.status-badge {
  font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 600;
  background: #e5e7eb; color: #374151;
}
.status-draft { background: #fef3c7; color: #92400e; }
.status-review { background: #dbeafe; color: #1e40af; }
.status-published { background: #d1fae5; color: #065f46; }
.status-archived { background: #e5e7eb; color: #4b5563; }

/* ---------- Editor ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.empty-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; color: var(--c-text-dim);
  text-align: center; padding: 24px;
}
.empty-icon { font-size: 52px; margin-bottom: 8px; color: #c3cddd; }

.editor-area { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.editor-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--c-surface); border-bottom: 1px solid var(--c-border); padding: 8px 14px;
}
.editor-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex-wrap: wrap; }
.process-path { color: var(--c-text-dim); font-size: 12px; }
.version-info { color: var(--c-text-dim); font-size: 12px; }
.dirty-flag { color: #b45309; font-size: 12px; font-weight: 600; }
.editor-actions { display: flex; gap: 8px; flex: 0 0 auto; }

.editor-body { flex: 1; display: flex; min-height: 0; position: relative; }
.canvas { flex: 1; background: #fdfdfe; }

.prop-panel {
  width: 280px; flex: 0 0 auto; overflow: auto;
  background: var(--c-surface); border-left: 1px solid var(--c-border); padding: 12px;
}
.prop-head { font-weight: 700; margin-bottom: 8px; }
.prop-row { display: flex; gap: 8px; margin-bottom: 6px; }
.prop-row label { color: var(--c-text-dim); width: 46px; flex: 0 0 auto; }
.prop-row span { word-break: break-all; }
.prop-link-section { margin-top: 18px; border-top: 1px solid var(--c-border); padding-top: 12px; }
.prop-hint { color: var(--c-text-dim); font-size: 12px; }
.prop-link-section select {
  width: 100%; padding: 7px 8px;
  border: 1px solid var(--c-border); border-radius: var(--radius);
}
.prop-link-actions { margin-top: 8px; }

.incoming-bar {
  flex: 0 0 auto; background: #f0f5ff; border-top: 1px solid var(--c-border);
  padding: 6px 14px; font-size: 13px; color: var(--c-text-dim);
}
.incoming-bar a { color: var(--c-primary); cursor: pointer; text-decoration: underline; }

/* Verknüpfungs-Badge im Diagramm */
.link-badge {
  background: var(--c-primary); color: #fff; border-radius: 50%;
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
  font-size: 13px; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.link-badge:hover { background: var(--c-primary-dark); transform: scale(1.1); }

/* ---------- Dropdown / Kontextmenü ---------- */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius); box-shadow: var(--shadow); min-width: 180px;
}
.dropdown-menu button {
  display: block; width: 100%; text-align: left;
  background: none; border: none; padding: 9px 14px; white-space: nowrap;
}
.dropdown-menu button:hover { background: #eef2f8; }

.ctx-menu {
  position: fixed; z-index: 100;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius); box-shadow: var(--shadow); min-width: 200px; padding: 4px 0;
}
.ctx-menu button {
  display: block; width: 100%; text-align: left;
  background: none; border: none; padding: 8px 16px; white-space: nowrap;
}
.ctx-menu button:hover { background: #eef2f8; }
.ctx-menu .ctx-sep { border-top: 1px solid var(--c-border); margin: 4px 0; }
.ctx-menu .ctx-danger { color: var(--c-danger); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(15, 25, 45, .45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: var(--c-surface); border-radius: 12px; box-shadow: var(--shadow);
  width: min(640px, 100%); max-height: 85vh; display: flex; flex-direction: column;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--c-border); font-weight: 700; font-size: 16px;
}
.modal-body { padding: 18px; overflow: auto; }
.modal-body label { display: block; font-weight: 600; margin: 12px 0 4px; }
.modal-body label:first-child { margin-top: 0; }
.modal-body input[type="text"], .modal-body input[type="password"],
.modal-body select, .modal-body textarea {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--c-border); border-radius: var(--radius);
}
.modal-body textarea { min-height: 70px; resize: vertical; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.modal-error { color: var(--c-danger); margin-top: 10px; }

.modal-table { width: 100%; border-collapse: collapse; }
.modal-table th, .modal-table td {
  text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--c-border);
  font-size: 13px; vertical-align: middle;
}
.modal-table th { color: var(--c-text-dim); font-weight: 600; }
.modal-table .row-actions { display: flex; gap: 6px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 300;
  background: #111827; color: #fff; padding: 10px 20px; border-radius: 24px;
  box-shadow: var(--shadow); font-size: 14px;
}
.toast.toast-error { background: var(--c-danger); }

/* bpmn-js: Wasserzeichen-Link dezent lassen */
.bjs-powered-by { opacity: .4; }
