/* ── CSS Variables ──────────────────────────────────────────────────────────── */
:root {
  --bg:        #1a1a2e;
  --bg2:       #151528;
  --bg3:       #0f0f20;
  --surface:   #1e2244;
  --surface2:  #252850;
  --border:    #2e3260;
  --text:      #e2e8f0;
  --text2:     #94a3b8;
  --text3:     #64748b;
  --accent:    #5b9cf6;
  --accent-h:  #3b82f6;
  --shadow:    0 4px 24px rgba(0,0,0,0.45);
  --shadow-lg: 0 12px 48px rgba(0,0,0,0.6);

  /* board dot grid */
  --dot-color: rgba(255,255,255,0.045);
}

[data-theme="light"] {
  --bg:        #f0f4fa;
  --bg2:       #e8edf7;
  --bg3:       #dce3f0;
  --surface:   #ffffff;
  --surface2:  #f5f7fc;
  --border:    #d0d7e8;
  --text:      #1a202c;
  --text2:     #4a5568;
  --text3:     #718096;
  --accent:    #3b82f6;
  --accent-h:  #2563eb;
  --shadow:    0 4px 24px rgba(0,0,0,0.10);
  --shadow-lg: 0 12px 48px rgba(0,0,0,0.18);
  --dot-color: rgba(0,0,0,0.06);
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}

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

/* ── App Layout ───────────────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 54px;
  padding: 0 20px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 50;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-mark {
  width: 34px;
  height: 34px;
  background: var(--accent);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 13px;
  color: #fff;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.header-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.3px;
}

.header-title-dim {
  color: var(--text2);
  font-weight: 400;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px 5px 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.user-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

/* ── Toolbar ──────────────────────────────────────────────────────────────── */
#toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 20px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
  overflow-x: auto;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.filter-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 6px;
  flex-shrink: 0;
}

.filter-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.filter-btn:hover {
  background: var(--surface);
  color: var(--text);
  border-color: var(--text3);
}

.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.person-btn {
  border-color: var(--pcolor, var(--border)) !important;
}
.person-btn.active {
  background: var(--pcolor, var(--accent)) !important;
  border-color: var(--pcolor, var(--accent)) !important;
  color: #fff !important;
}

.sdot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Board ────────────────────────────────────────────────────────────────── */
#board-container {
  flex: 1;
  overflow: auto;
  background-color: var(--bg);
  background-image: radial-gradient(circle, var(--dot-color) 1px, transparent 1px);
  background-size: 28px 28px;
  position: relative;
}

#board {
  position: relative;
  width: 2400px;
  height: 1400px;
  min-width: 100%;
  min-height: 100%;
}

/* ── SVG Arrows ───────────────────────────────────────────────────────────── */
#arrows-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.arrow-path {
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  transition: opacity 0.2s, stroke 0.2s;
}

/* Dark mode arrow colors */
[data-theme="dark"] .arrow-path        { stroke: #3d4575; }
[data-theme="dark"] .arrow-path.arrow-dim { stroke: #282c50; opacity: 0.5; }
[data-theme="dark"] .arrow-head        { fill: #3d4575; }

/* Light mode arrow colors */
[data-theme="light"] .arrow-path        { stroke: #b0bcd6; }
[data-theme="light"] .arrow-path.arrow-dim { stroke: #d5dcee; opacity: 0.5; }
[data-theme="light"] .arrow-head        { fill: #b0bcd6; }

/* ── Tasks Layer ──────────────────────────────────────────────────────────── */
#tasks-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ── Task Card ────────────────────────────────────────────────────────────── */
.task-card {
  position: absolute;
  width: 214px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow 0.2s, opacity 0.2s, transform 0.12s;
  user-select: none;
}

.task-card:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--text3);
}

.task-card.dimmed {
  opacity: 0.22;
}

.task-card.is-dragging {
  box-shadow: 0 20px 60px rgba(0,0,0,0.55);
  transform: scale(1.03) rotate(0.5deg);
  z-index: 999 !important;
}

.card-stripe {
  height: 4px;
  width: 100%;
  transition: background 0.2s;
}

.card-inner {
  padding: 10px 12px 12px;
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  cursor: grab;
  margin-bottom: 10px;
}

.card-top:active { cursor: grabbing; }

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  flex: 1;
  word-break: break-word;
}

.card-edit-btn {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: var(--text3);
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
  padding: 0;
}

.card-edit-btn:hover {
  color: var(--text);
  background: var(--surface2);
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.card-assignee-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.assignee-name {
  font-size: 12px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.no-assignee {
  font-size: 12px;
  color: var(--text3);
}

.status-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 12px;
  border: 1px solid;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  flex-shrink: 0;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}
.btn-icon:hover { background: var(--surface2); }

.logout-btn {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
}
.logout-btn:hover { background: var(--surface2); color: var(--text); }

.btn-new {
  padding: 6px 16px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s;
}
.btn-new:hover { background: var(--accent-h); }

.btn-prim {
  padding: 8px 20px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s;
}
.btn-prim:hover { background: var(--accent-h); }

.btn-sec {
  padding: 8px 20px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  font-size: 13px;
  transition: background 0.15s;
}
.btn-sec:hover { background: var(--surface2); }

.btn-danger {
  padding: 8px 20px;
  border-radius: 8px;
  border: 1px solid rgba(231,76,60,0.35);
  background: rgba(231,76,60,0.12);
  color: #e74c3c;
  font-size: 13px;
  transition: background 0.15s;
}
.btn-danger:hover { background: rgba(231,76,60,0.22); }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.modal.hidden { display: none !important; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 30px;
  width: 500px;
  max-width: 96vw;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-box h2 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 22px;
  color: var(--text);
}

/* ── Form ─────────────────────────────────────────────────────────────────── */
.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text2);
  margin-bottom: 6px;
}

.required { color: #e74c3c; }
.label-hint { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text3); font-size: 11px; }

.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91,156,246,0.18);
}

.field textarea {
  resize: vertical;
  min-height: 72px;
}

.field select option {
  background: var(--surface);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* ── Dependency list ──────────────────────────────────────────────────────── */
.dep-list {
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  background: var(--bg);
}

.dep-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text2);
  transition: background 0.12s;
}

.dep-item:hover { background: var(--surface); color: var(--text); }
.dep-item input[type="checkbox"] { cursor: pointer; accent-color: var(--accent); }

.dep-list:empty::after {
  content: 'Keine anderen Aufgaben vorhanden';
  display: block;
  padding: 8px;
  font-size: 12px;
  color: var(--text3);
}

/* ── Modal Footer ─────────────────────────────────────────────────────────── */
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.modal-footer-right {
  display: flex;
  gap: 8px;
}

/* ── Login Page ───────────────────────────────────────────────────────────── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
  padding: 20px;
}

.login-page {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 42px 40px 36px;
  width: 380px;
  max-width: 100%;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
}

.logo-icon {
  width: 50px;
  height: 50px;
  background: var(--accent);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 15px;
  color: #fff;
  letter-spacing: 0.5px;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(91,156,246,0.4);
}

.login-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.login-subtitle {
  font-size: 13px;
  color: var(--text2);
  margin-top: 2px;
}

.login-submit-btn {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  margin-top: 6px;
}

.login-error {
  background: rgba(231,76,60,0.12);
  border: 1px solid rgba(231,76,60,0.35);
  color: #e74c3c;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
}

.login-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
  font-size: 12px;
  color: var(--text3);
}

.hint-sep { color: var(--border); }

/* ── Utilities ────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Scrollbars ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ── Transitions ──────────────────────────────────────────────────────────── */
#header, #toolbar, #board-container, .task-card, .modal-box, .field input,
.field textarea, .field select, .filter-btn, .btn-new, .btn-prim, .btn-sec,
.btn-danger, .btn-icon, .logout-btn {
  transition-property: background, border-color, color, box-shadow;
  transition-duration: 0.2s;
}
