/* ProzessPilot. Farben und Grundformen aus bpmndesk übernommen (DESK Suite). */

:root {
  --teal: #0e97ad;
  --sky: #0284c7;
  --sky-dark: #0369a1;
  --deep: #0b162a;
  --bg: #eef4fa;
  --surface: #ffffff;
  --surface-2: #f5f9fd;
  --text: #0f1c2e;
  --text-muted: #4e6680;
  --border: rgba(14, 97, 150, 0.14);
  --accent: #0a7d94;
  --rot: #dc2626;
  --rot-bg: rgba(220, 38, 38, 0.07);
  --orange: #c2410c;
  --orange-bg: rgba(234, 88, 12, 0.08);
  --gruen: #15803d;
  --gruen-bg: rgba(22, 163, 74, 0.08);
  --shadow: 0 4px 24px rgba(14, 60, 120, 0.10);
  --shadow-sm: 0 2px 10px rgba(14, 60, 120, 0.08);
  --grid-color: rgba(14, 97, 173, 0.045);
  --header-height: 56px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.app-shell {
  position: relative;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0 16px 16px;
}

/* Kopfzeile */
.site-header {
  height: var(--header-height);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 4px;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.brand-dark { color: var(--text); }
.brand-accent { color: var(--sky); }
.brand-badge {
  margin-left: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--accent);
  background: rgba(14, 151, 173, 0.10);
}

.toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  background: transparent;
  color: var(--text);
  transition: all 0.15s ease;
}
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; flex-shrink: 0; }
.btn:disabled { opacity: 0.6; cursor: wait; transform: none !important; }
.btn-primary { background: var(--sky); color: #fff; box-shadow: 0 1px 2px rgba(2,132,199,.15), 0 2px 4px rgba(2,132,199,.12); }
.btn-primary:hover { background: var(--sky-dark); transform: translateY(-1px); }
.btn-secondary { background: var(--surface); box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 1px 3px rgba(15,23,42,.06); }
.btn-secondary svg { color: var(--text-muted); }
.btn-secondary:hover { transform: translateY(-1px); box-shadow: 0 2px 4px rgba(15,23,42,.06), 0 4px 8px rgba(15,23,42,.08); }
.btn-secondary:hover svg { color: var(--accent); }
.btn-ghost { color: var(--text-muted); }
.btn-ghost:hover { color: var(--teal); }
.btn-icon { padding: 4px; min-height: 28px; }
.btn-big { width: 100%; min-height: 44px; font-size: 15px; font-weight: 600; }
.btn-danger:hover { color: var(--rot); }

/* Hauptbereich */
.app-main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
  position: relative;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  min-height: 0;
}
.panel-block { display: flex; flex-direction: column; gap: 6px; }
.panel-block.grow { flex: 1; min-height: 160px; }

.field-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: none; }
.muted { color: var(--text-muted); font-weight: 400; }
.klein { font-size: 11.5px; margin: 0; }

.input {
  width: 100%;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus { border-color: var(--sky); box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.14); background: #fff; }
.textarea { flex: 1; min-height: 140px; resize: vertical; line-height: 1.5; }
.textarea-klein { min-height: 160px; flex: none; }

/* Mikrofon */
.mic-block { align-items: center; text-align: center; gap: 8px; }
.mic-button {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 12px 26px 12px 14px;
  border-radius: 999px;
  border: none;
  background: var(--deep);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(11, 22, 42, 0.22);
  transition: transform 0.15s ease, background 0.15s ease;
}
.mic-button:hover { transform: translateY(-1px); }
.mic-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--sky);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.mic-icon svg { width: 20px; height: 20px; stroke: #fff; fill: none; stroke-width: 2; }
.mic-button.is-aktiv { background: var(--rot); }
.mic-button.is-aktiv .mic-icon { background: #fff; animation: puls 1.4s ease-in-out infinite; }
.mic-button.is-aktiv .mic-icon svg { stroke: var(--rot); }
.mic-button:disabled { opacity: 0.5; cursor: not-allowed; }
.mic-status { margin: 0; font-size: 12.5px; color: var(--text-muted); min-height: 18px; }
.mic-status.zwischen { color: var(--text); font-style: italic; }
@keyframes puls { 0%, 100% { box-shadow: 0 0 0 0 rgba(255,255,255,.7); } 50% { box-shadow: 0 0 0 8px rgba(255,255,255,0); } }

.progress { margin: 4px 0 0; font-size: 12.5px; color: var(--text-muted); text-align: center; }

/* Ergebnis */
.ergebnis { border-top: 1px solid var(--border); padding-top: 12px; gap: 8px; }
.ergebnis-titel { margin: 0; font-size: 14px; }
.ergebnis-untertitel { margin: 8px 0 2px; font-size: 12.5px; color: var(--text-muted); }
.ergebnis-zusammenfassung { margin: 0; font-size: 13px; }
.befund-liste { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.befund-liste:empty { display: none; }
.befund {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.45;
  background: var(--surface-2);
}
.befund[data-art="fehler"] { background: var(--rot-bg); color: #7f1d1d; }
.befund[data-art="hinweis"] { background: var(--orange-bg); color: #7c2d12; }
.befund[data-art="frage"] { background: rgba(2, 132, 199, 0.07); }
.befund[data-element] { cursor: pointer; }
.befund[data-element]:hover { outline: 1px solid currentColor; }
.befund .regel { font-weight: 600; margin-right: 4px; opacity: 0.8; }
.ok-badge { color: var(--gruen); font-weight: 600; }

.leitsatz { margin: auto 0 0; font-size: 12px; color: var(--text-muted); text-align: center; }

/* Editor */
.editor { display: flex; flex-direction: column; min-width: 0; min-height: 0; gap: 8px; }
.editor-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.mode-toggle { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.mode-toggle .btn.is-active { background: var(--sky); color: #fff; }
.editor-status { font-size: 12px; color: var(--text-muted); }
.canvas-wrap { position: relative; flex: 1; min-height: 0; }

#canvas {
  position: absolute;
  inset: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
#canvas .djs-container, #canvas .djs-palette, #canvas .djs-popup, #canvas .djs-context-pad { font-family: "Inter", system-ui, sans-serif; }
#canvas .djs-palette { margin-top: 12px; margin-left: 12px; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-sm); background: #fff; }
#canvas .djs-palette .entry:hover, #canvas .djs-palette .highlighted-entry { background: rgba(14, 165, 233, 0.08); }

/* Markierungen aus dem Regelcheck */
.djs-element.pp-fehler .djs-visual > :first-child { stroke: var(--rot) !important; stroke-width: 3px !important; }
.djs-element.pp-hinweis .djs-visual > :first-child { stroke: #ea580c !important; stroke-width: 2.5px !important; }

.leer-hinweis {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 5;
}
.leer-karte {
  pointer-events: auto;
  max-width: 360px;
  text-align: center;
  padding: 24px 28px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px dashed rgba(2, 132, 199, 0.35);
  color: var(--text-muted);
}
.leer-karte p { margin: 0 0 8px; }
.leer-titel { font-size: 16px; font-weight: 600; color: var(--text); }

.panel-element {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 300px;
  max-height: calc(100% - 24px);
  overflow-y: auto;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.panel-element-kopf { display: flex; align-items: center; justify-content: space-between; }
.element-typ { font-size: 12px; font-weight: 600; color: var(--accent); }

/* Dialoge */
.dialog {
  border: none;
  border-radius: 14px;
  padding: 18px;
  width: min(560px, calc(100vw - 32px));
  box-shadow: 0 20px 60px rgba(11, 22, 42, 0.25);
  color: var(--text);
}
.dialog::backdrop { background: rgba(11, 22, 42, 0.35); }
.dialog-kopf { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.dialog-kopf h2 { margin: 0; font-size: 17px; }
.prozess-liste { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow-y: auto; }
.prozess-eintrag {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid transparent;
}
.prozess-eintrag:hover { border-color: var(--border); }
.prozess-eintrag button.prozess-oeffnen { flex: 1; text-align: left; background: none; border: none; padding: 0; color: var(--text); }
.prozess-name { display: block; font-weight: 600; }
.prozess-meta { display: block; font-size: 12px; color: var(--text-muted); }
.prozess-leer { color: var(--text-muted); padding: 10px 0; }

.dialog-login { width: min(360px, calc(100vw - 32px)); padding: 26px; }
.dialog-login form { display: flex; flex-direction: column; gap: 10px; }
.brand-login { justify-content: center; font-size: 24px; margin-bottom: 8px; }
.login-fehler { margin: 0; color: var(--rot); font-size: 13px; }

/* Hinweise */
#toast-container { position: fixed; top: calc(var(--header-height) + 12px); right: 24px; z-index: 40; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast {
  min-width: 260px;
  max-width: min(380px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  box-shadow: var(--shadow-sm);
  background: #fff;
  border: 1px solid rgba(14, 165, 233, 0.3);
  animation: toast-in 0.2s ease forwards;
}
.toast[data-type="error"] { border-color: rgba(220, 38, 38, 0.35); color: var(--rot); }
.toast[data-type="ok"] { border-color: rgba(22, 163, 74, 0.35); color: var(--gruen); }
.toast.is-leaving { animation: toast-out 0.2s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; transform: translateY(-8px); } }

/* Schmale Bildschirme */
@media (max-width: 980px) {
  .app-shell { height: auto; min-height: 100vh; }
  .site-header { height: auto; flex-wrap: wrap; padding: 10px 0; }
  .app-main { grid-template-columns: 1fr; }
  .panel { overflow: visible; }
  .editor { min-height: 70vh; }
  .btn-label { display: none; }
  .panel-element { width: auto; left: 12px; }
}
