/* =============================================================
   Prozess – Stylesheet
   Design angelehnt an marketing.arthurweber.ch/marketingplan/
   Hausfarbe Arthur Weber: #005AA0
============================================================= */

:root {
  --aw-blue: #005AA0;
  --aw-blue-dark: #004478;
  --aw-blue-light: #e6effa;

  --bg: #ffffff;
  --bg-2: #f5f5f5;
  --bg-3: #ececec;
  --bg-page: #fafafa;

  --text: #1f1f1f;
  --text-2: #5a5a5a;
  --text-3: #8a8a8a;

  --border: #e3e3e3;
  --border-2: #cfcfcf;

  --success: #2e7d32;
  --warning: #ed6c02;
  --danger:  #c62828;

  --radius: 4px;
  --shadow-card: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-modal: 0 10px 40px rgba(0,0,0,0.18);
}

* { box-sizing: border-box; }

/* HTML hidden-Attribut absolut erzwingen — manche Browser/Setups
   respektieren das sonst nicht zuverlässig. */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-page);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
a { color: var(--aw-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============= LOGIN ============= */
.login-screen {
  position: fixed; inset: 0;
  background: var(--bg-page);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  z-index: 1000;
}
.login-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px 32px;
  width: 100%; max-width: 380px;
  box-shadow: var(--shadow-card);
}
.login-logo { text-align: center; margin-bottom: 16px; }
.login-logo img { height: 30px; }
.login-card h1 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 600;
  color: var(--aw-blue);
  text-align: center;
}
.login-sub {
  margin: 0 0 22px;
  color: var(--text-2);
  font-size: 13px;
  text-align: center;
}
.login-card label {
  display: block;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 5px;
  margin-top: 12px;
}
.login-card input[type=text],
.login-card input[type=password] {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--bg);
}
.login-card input:focus { outline: 2px solid var(--aw-blue-light); border-color: var(--aw-blue); }
.login-btn { width: 100%; margin-top: 22px; padding: 10px 14px; font-size: 14px; }
.login-error {
  background: #fdecea;
  color: var(--danger);
  border: 1px solid #f5c0bb;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-top: 14px;
}

/* ============= TOP-BAR ============= */
.app-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo { display: flex; align-items: center; transition: opacity 0.15s; }
.brand-logo:hover { opacity: 0.75; }
.brand-logo img { display: block; height: 28px; }
.brand-divider {
  width: 1px; height: 22px;
  background: var(--border-2);
  margin: 0 4px;
}
.brand-title {
  font-size: 17px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.01em;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.user-chip {
  font-size: 12px;
  color: var(--text-2);
  padding: 0 8px;
  border-left: 1px solid var(--border);
  margin-left: 4px;
}

/* ============= SUCH-BOX ============= */
.search-box {
  display: flex;
  align-items: center;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 0 10px;
  width: 360px;
  max-width: 100%;
  position: relative;
}
.search-box:focus-within {
  border-color: var(--aw-blue);
  background: var(--bg);
  box-shadow: 0 0 0 3px var(--aw-blue-light);
}
.search-box svg { color: var(--text-3); flex: none; }
.search-box input {
  border: none; background: transparent;
  flex: 1;
  padding: 7px 8px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
  min-width: 0;
}
.search-clear {
  background: transparent;
  border: none;
  color: var(--text-3);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.search-clear:hover { color: var(--text); }

/* ============= BUTTONS ============= */
.btn {
  background: var(--bg);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 7px 14px;
  font-size: 13px;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
  font-family: inherit;
}
.btn:hover { background: var(--bg-2); border-color: var(--text-3); text-decoration: none; }
.btn:active { background: var(--bg-3); }
.btn-primary {
  background: var(--aw-blue);
  color: #fff;
  border-color: var(--aw-blue);
}
.btn-primary:hover { background: var(--aw-blue-dark); border-color: var(--aw-blue-dark); color: #fff; }
.btn-icon { padding: 7px 9px; }
.btn svg { width: 14px; height: 14px; flex: none; }
.btn-danger-text { color: var(--danger); border-color: transparent; background: transparent; }
.btn-danger-text:hover { background: #fdecea; border-color: transparent; color: var(--danger); }
.btn-mini {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-3);
  padding: 4px;
  border-radius: 3px;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-mini:hover { background: var(--bg-2); color: var(--text); }
.btn-mini svg { width: 14px; height: 14px; }

/* ============= LAYOUT ============= */
.prozess-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: calc(100vh - 60px);
  gap: 0;
}
.prozess-sidebar {
  background: var(--bg);
  border-right: 1px solid var(--border);
  padding: 16px 0 24px;
  overflow-y: auto;
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
}
.sidebar-head {
  padding: 0 18px 10px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.prozess-main {
  padding: 24px 32px 48px;
  max-width: 1100px;
  width: 100%;
}

/* ============= BAUM ============= */
.tree { display: block; padding: 4px 0; }
.tree-node { display: block; }
.tree-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 10px;
  cursor: pointer;
  border-left: 3px solid transparent;
  user-select: none;
  position: relative;
  border-radius: 0 3px 3px 0;
  transition: background 0.1s;
}
.tree-row:hover { background: var(--bg-2); }
.tree-row.active {
  background: var(--aw-blue-light);
  border-left-color: var(--aw-blue);
}
.tree-row.active .tree-label { color: var(--aw-blue); font-weight: 500; }

.tree-caret {
  width: 14px; height: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-3);
  flex: none;
  font-size: 9px;
  transition: transform 0.15s ease;
}
.tree-caret.empty { visibility: hidden; }
.tree-node.open > .tree-row > .tree-caret { transform: rotate(90deg); }

/* Pfeil als reines Text-Dreieck (▶) – schlanker und ruhiger als ein SVG */
.tree-caret::before { content: '▶'; line-height: 1; }
.tree-caret.empty::before { content: ''; }

.tree-icon {
  width: 13px; height: 13px;
  color: var(--text-3);
  flex: none;
  opacity: 0.7;
}
.tree-row.active .tree-icon { color: var(--aw-blue); opacity: 1; }
.tree-row.is-category .tree-icon { color: var(--aw-blue); opacity: 0.55; }

.tree-label {
  font-size: 13px;
  color: var(--text);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}
.tree-row.is-category .tree-label { font-weight: 500; }
.tree-row.is-process .tree-label { color: var(--text-2); font-weight: 400; }
.tree-row.is-process.active .tree-label { color: var(--aw-blue); font-weight: 500; }

/* Stift-Symbol zum Bearbeiten (erscheint bei Hover) */
.tree-edit {
  opacity: 0;
  background: transparent;
  border: none;
  padding: 2px 4px;
  border-radius: 3px;
  color: var(--text-3);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  flex: none;
  transition: opacity 0.1s, background 0.1s, color 0.1s;
}
.tree-row:hover .tree-edit { opacity: 1; }
.tree-edit:hover { background: var(--bg-3); color: var(--aw-blue); }
.tree-edit svg { width: 12px; height: 12px; }

.tree-children { display: none; padding-left: 8px; }
.tree-node.open > .tree-children { display: block; }
.tree-children .tree-children { padding-left: 14px; }

/* ============= WELCOME ============= */
.welcome {
  padding: 64px 24px;
  text-align: center;
  color: var(--text-2);
}
.welcome h2 { color: var(--text); font-size: 20px; margin-bottom: 6px; }
.welcome p { max-width: 480px; margin: 0 auto; }

/* ============= PROZESS-DETAIL ============= */
.proc-detail { animation: fade-in 0.15s; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.proc-breadcrumb {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.proc-breadcrumb a { color: var(--text-3); }
.proc-breadcrumb a:hover { color: var(--aw-blue); }
.proc-breadcrumb .sep { color: var(--border-2); }

.proc-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.proc-head h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  letter-spacing: -0.01em;
}
.proc-head-actions { display: flex; gap: 6px; flex: none; }

.proc-meta {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 4px;
}

.proc-body {
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--text);
}
.proc-body h1, .proc-body h2, .proc-body h3, .proc-body h4 {
  color: var(--text);
  margin-top: 24px;
  margin-bottom: 10px;
  font-weight: 600;
}
.proc-body h2 { font-size: 18px; }
.proc-body h3 { font-size: 16px; color: var(--aw-blue); }
.proc-body p { margin: 0 0 12px; }
.proc-body ul, .proc-body ol { margin: 0 0 12px; padding-left: 24px; }
.proc-body li { margin-bottom: 4px; }
.proc-body code {
  background: var(--bg-2);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.92em;
  font-family: 'SFMono-Regular', Consolas, monospace;
}
.proc-body pre {
  background: var(--bg-2);
  padding: 12px 14px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 13px;
}
.proc-body blockquote {
  border-left: 3px solid var(--aw-blue);
  margin: 12px 0;
  padding: 4px 0 4px 14px;
  color: var(--text-2);
  background: var(--aw-blue-light);
}
.proc-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 13.5px;
  background: var(--bg);
  box-shadow: var(--shadow-card);
  border-radius: var(--radius);
  overflow: hidden;
}
.proc-body table th {
  background: var(--bg-2);
  text-align: left;
  font-weight: 600;
  padding: 9px 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
}
.proc-body table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.proc-body table tr:last-child td { border-bottom: none; }
.proc-body table tr:nth-child(2n) td { background: #fafafa; }
.proc-body a {
  color: var(--aw-blue);
  text-decoration: underline;
  text-decoration-color: rgba(0, 90, 160, 0.3);
  text-underline-offset: 2px;
}
.proc-body a:hover { text-decoration-color: var(--aw-blue); }
.proc-body img { max-width: 100%; height: auto; }

/* ============= SUCH-ERGEBNISSE ============= */
.search-results { animation: fade-in 0.15s; }
.search-results-head {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 16px;
}
.search-results-head strong { color: var(--text); }
.search-result {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.05s;
}
.search-result:hover {
  border-color: var(--aw-blue);
  background: var(--bg);
  box-shadow: var(--shadow-card);
}
.search-result-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--aw-blue);
  margin-bottom: 2px;
}
.search-result-cat {
  font-size: 11px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.search-result-snippet {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.55;
}
.search-result mark {
  background: #fff4a3;
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}
.search-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-3);
}

/* ============= MODALS ============= */
.modal {
  position: fixed; inset: 0;
  background: rgba(31,31,31,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  padding: 24px;
  overflow-y: auto;
  animation: fade-in 0.15s;
}
.modal-card {
  background: var(--bg);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  margin: auto;
}
.modal-card-large { max-width: 900px; }
.modal-card-small { max-width: 420px; }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.modal-close {
  background: transparent;
  border: none;
  font-size: 26px;
  line-height: 1;
  color: var(--text-3);
  padding: 0 4px;
  cursor: pointer;
}
.modal-close:hover { color: var(--text); }

.modal-body { padding: 18px 20px 20px; }
.modal-body label {
  display: block;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 5px;
  margin-top: 14px;
}
.modal-body label:first-of-type { margin-top: 0; }
.modal-body input[type=text],
.modal-body select,
.modal-body textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--bg);
  font-family: inherit;
}
.modal-body input:focus, .modal-body select:focus, .modal-body textarea:focus, .editor:focus {
  outline: 2px solid var(--aw-blue-light);
  border-color: var(--aw-blue);
}
.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
}

/* ============= EDITOR ============= */
.editor-toolbar {
  display: flex;
  gap: 2px;
  padding: 6px 8px;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  flex-wrap: wrap;
}
.editor-toolbar button {
  background: transparent;
  border: 1px solid transparent;
  padding: 4px 9px;
  font-size: 13px;
  border-radius: 3px;
  color: var(--text);
  font-family: inherit;
  min-width: 28px;
}
.editor-toolbar button:hover { background: var(--bg); border-color: var(--border-2); }
.editor-toolbar .sep {
  width: 1px;
  background: var(--border);
  margin: 4px 4px;
}
.editor {
  border: 1px solid var(--border-2);
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 14px 16px;
  min-height: 280px;
  max-height: 50vh;
  overflow-y: auto;
  background: var(--bg);
  font-size: 14px;
  line-height: 1.6;
  outline: none;
}
.editor:empty::before {
  content: 'Inhalt eingeben…';
  color: var(--text-3);
}
.editor h2 { font-size: 18px; margin: 16px 0 8px; }
.editor h3 { font-size: 16px; margin: 14px 0 6px; color: var(--aw-blue); }
.editor p { margin: 0 0 10px; }
.editor ul, .editor ol { margin: 0 0 10px; padding-left: 24px; }
.editor table { border-collapse: collapse; margin: 10px 0; width: 100%; }
.editor table td, .editor table th {
  border: 1px solid var(--border-2);
  padding: 6px 9px;
  vertical-align: top;
}
.editor table th { background: var(--bg-2); }
.editor a { color: var(--aw-blue); text-decoration: underline; }

/* Aktive Tabellenzelle hervorheben (beim Klick im Editor) */
.editor table td.tbl-active,
.editor table th.tbl-active {
  outline: 2px solid var(--aw-blue);
  outline-offset: -2px;
  background: var(--aw-blue-light);
}

/* Tabellen-Werkzeuge die erscheinen wenn man in einer Zelle steht */
.tbl-tools {
  position: absolute;
  display: flex;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border-2);
  border-radius: 4px;
  padding: 3px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  z-index: 10;
  font-size: 11px;
  white-space: nowrap;
}
.tbl-tools button {
  background: transparent;
  border: none;
  padding: 4px 7px;
  font-size: 12px;
  cursor: pointer;
  border-radius: 3px;
  color: var(--text-2);
  font-family: inherit;
  line-height: 1;
  white-space: nowrap;
}
.tbl-tools button:hover { background: var(--bg-2); color: var(--aw-blue); }
.tbl-tools .sep { width: 1px; background: var(--border); margin: 2px 2px; }
.tbl-tools .danger:hover { background: #fdecea; color: var(--danger); }

/* ============= TOASTS ============= */
.toast-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1500;
  pointer-events: none;
}
.toast {
  background: var(--text);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  box-shadow: var(--shadow-modal);
  animation: toast-in 0.18s;
  max-width: 360px;
}
.toast.ok { background: var(--success); }
.toast.err { background: var(--danger); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ============= MOBIL ============= */
@media (max-width: 900px) {
  .prozess-layout {
    grid-template-columns: 1fr;
  }
  .prozess-sidebar {
    position: static;
    height: auto;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .prozess-main { padding: 18px 16px 32px; }
  .app-header { padding: 10px 14px; gap: 12px; flex-wrap: wrap; }
  .brand-title { font-size: 15px; }
  .search-box { width: 100%; order: 99; }
  .header-controls { width: 100%; }
  .user-chip { display: none; }
  .proc-head h1 { font-size: 20px; }
}
