/* ============================================
   TraumGmbH – Admin: Departments
   Tree diagram + modal
   ============================================ */

/* === TREE CONTAINER === */
.dept-tree {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* === ROOT BLOCK (eine Card pro Root) === */
.dept-root-block {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}

/* === NODE BASE === */
.dept-node {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 18px;
  gap: 12px;
  transition: background 0.1s;
  position: relative;
}
.dept-node:not(:last-child) {
  border-bottom: 1px solid var(--border);
}
.dept-node:hover { background: var(--bg); }

/* === ROOT NODE === */
.dept-node-depth-0 {
  background: var(--accent-pale);
  border-bottom: 2px solid var(--border) !important;
}
.dept-node-depth-0:hover { background: #fce8e6; }
.dept-node-depth-0 .dept-node-name {
  font-size: 15px;
  font-weight: 800;
  color: var(--accent);
}

/* === CHILD NODES === */
.dept-node-depth-1 {
  padding-left: 44px;
}
.dept-node-depth-2 {
  padding-left: 72px;
  background: #fafafa;
}

/* === VERTICAL + HORIZONTAL LINES === */
.dept-node-depth-1::before,
.dept-node-depth-2::before {
  content: '';
  position: absolute;
  left: 24px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}
.dept-node-depth-1::after,
.dept-node-depth-2::after {
  content: '';
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 2px;
  background: var(--border);
}
.dept-node-depth-1::after {
  left: 24px;
  width: 12px;
}
.dept-node-depth-2::after {
  left: 52px;
  width: 12px;
}

/* Letzte Node: vertikale Linie nur bis zur Mitte */
.dept-node-last::before {
  bottom: 50%;
}

/* === NODE INNER === */
.dept-node-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.dept-node-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid currentColor;
}
.dept-node-depth-0 .dept-node-dot { color: var(--accent); background: var(--accent); }
.dept-node-depth-1 .dept-node-dot { color: var(--info); background: white; }
.dept-node-depth-2 .dept-node-dot { color: var(--success); background: var(--success); }

.dept-node-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dept-node-badge {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-input);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

/* === EDIT BUTTON === */
.dept-node-actions { display: flex; gap: 6px; flex-shrink: 0; }
.dept-btn-edit {
  width: 30px; height: 30px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: all 0.1s;
}
.dept-btn-edit:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-pale); }

/* === ADD CHILD BUTTON === */
.dept-add-child {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-top: 1px dashed var(--border);
  background: var(--bg);
  transition: color 0.1s, background 0.1s;
}
.dept-add-child:hover { color: var(--accent); background: var(--accent-pale); }
.dept-add-child-depth-1 { padding-left: 44px; }
.dept-add-child-depth-2 { padding-left: 72px; }

/* === MODAL === */
.dept-modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 60;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.dept-modal-bg.show { display: flex; }

.dept-modal {
  background: var(--bg-white);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 500px;
  padding: 24px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

.dept-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.dept-modal-title { font-size: 17px; font-weight: 800; }
.dept-modal-close {
  width: 32px; height: 32px;
  background: var(--bg-input);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-sec);
  transition: background 0.1s;
}
.dept-modal-close:hover { background: var(--border); }

.dept-modal-footer {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

.dept-btn-danger {
  color: var(--accent) !important;
  border-color: var(--accent) !important;
}
.dept-btn-danger:hover {
  background: var(--accent-pale) !important;
}

/* === DESKTOP === */
@media (min-width: 768px) {
  .dept-modal-bg { align-items: center; }
  .dept-modal {
    border-radius: var(--r);
    max-width: 440px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.12);
  }
  .dept-tree { padding: 0; }
}