/* ========== Global ========== */
body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0;
}

h1 {
  text-align: center;
  color: #333;
  padding: 20px;
}

/* ========== Tree Container & Panels ========== */
.tree-container {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  height: 100%;
  overflow-x: auto;
  padding: 10px 0;
  border: 1px solid #1f2937;
  border-radius: 12px;
  box-sizing: border-box;
}

.tree-panel {
  border: 2px solid #ccc;
  padding: 10px;
  position: relative;
  background: #cbd5e1;
  box-sizing: border-box;
  min-width: 250px;
  overflow: visible;
  display: flex;
  flex-direction: column;
}

.tree-panel ul {
  list-style: none;
  padding: 0;
  margin: 0;
  flex-grow: 1;
}

/* ========== Tree Rows ========== */
.tree-panel li {
  display: flex;
  align-items: center;
  padding: 5px 8px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 1px solid #ddd;
  box-sizing: border-box;
  transition: padding-left 120ms ease, background-color 120ms ease;
}
.tree-panel li:last-child { border-bottom: none; }

/* Text in Zeile */
.tree-panel li span {
  text-align: left;
  flex-grow: 1;
  color: black;
}

/* Hover */
.tree-panel li:hover { background-color: #f0f0f0; }

/* Kategorien: fixer Einzug, keine horizontale Verschiebung beim Selektieren */
.tree-panel li:not([data-type="exercise-package"]) { padding-left: 8px; }
.tree-panel li:not([data-type="exercise-package"]).selected { padding-left: 8px; }

/* Pakete: klarer Hintergrund + konstanter Einzug */
.tree-panel li[data-type="exercise-package"] {
  background-color: #e0f7fa;
  display: flex;
  align-items: center;
  padding-left: 30px;
}
.tree-panel li[data-type="exercise-package"]:hover { background-color: #b2ebf2; }

/* Einheitlicher Selected-State (Kategorien & Pakete) */
.tree-panel li.selected {
  background-color: #007BFF;
  color: #fff;
  font-weight: 600;
  outline: 2px solid #888;
  outline-offset: -2px;
  border-color: transparent;
  border-radius: 4px;
}

/* Icons im Selected-State */
.tree-panel li.selected .knowledge-icon {
  filter: brightness(0) invert(1);
}

/* Vorfahr (Kategorie) dezent markieren, wenn ein Paket selektiert ist */
.tree-panel li.is-ancestor > div {
  background: rgba(0, 123, 255, .12);
  border-radius: 4px;
  box-shadow: inset 3px 0 0 #007BFF;
}

/* ========== Icons & Meta rechts ========== */
.knowledge-icon {
  width: 20px;
  height: 20px;
  margin-right: 8px;
  flex-shrink: 0;
}

/* Rechtsleiste (Badge + Pfeil) */
.row-meta {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

/* Pfeil normal im Flow */
.expand-icon {
  position: static;
  transform: none;
  color: #007BFF;
  font-weight: bold;
  line-height: 1;
}

/* Badge (einheitlich) */
.pkg-badge {
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 10px;
  background: #eef;
  color: #333;
  white-space: nowrap;
}

/* ========== Resize Handle ========== */
.resize-handle {
  position: absolute;
  right: -8px;
  top: -2px;
  width: 16px;
  height: calc(100% + 2px);
  cursor: ew-resize;
  background-color: rgba(0, 123, 255, 0.5);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}
.resize-handle::after {
  content: '↔';
  font-size: 18px;
  color: #007BFF;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ========== Detail Panel (unter dem Tree) ========== */
.detail-panel {
  position: relative;
  border-top: 2px solid #ccc;
  border-bottom: 2px solid #ccc;
  background-color: rgb(20, 44, 92);
  min-width: 300px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px;
}

/* Lesbare Card-Optik im Ausgabebereich */
#package-details { padding: 12px 0; }

#package-details .detail-panel {
  background: #ffffff;
  color: #111111;
  border: 1px solid #d0d7de;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  padding: 14px 16px;
}

#package-details .detail-content {
  font-size: 15px;
  line-height: 1.55;
}

#package-details .detail-content h2 {
  margin: 0 0 8px 0;
  font-size: 20px;
  line-height: 1.3;
  color: #111111;
}

#package-details .detail-content h3.package-title {
  margin: 2px 0 8px 0;
  font-size: 18px;
  line-height: 1.35;
  color: inherit;
}

#package-details .description {
  margin: 6px 0 12px 0;
  color: #222222;
}

#package-details .divider {
  height: 1px;
  background: #e6e8eb;
  margin: 10px 0 12px 0;
  border: 0;
}

#package-details .info-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  align-items: start;
}

#package-details .date-label {
  margin: 0;
  color: #444444;
  font-weight: 600;
}
#package-details .date-value {
  margin: 0;
  color: #111111;
}

#package-details a { color: #0b57d0; text-decoration: none; }
#package-details a:hover { text-decoration: underline; }

/* Typo-Glättung */
#package-details, #package-details * {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========== Formular-Grid & Inputs ========== */
.kt-form-grid {
  display: grid;
  grid-template-columns: 160px 1fr;
  column-gap: 16px;
  row-gap: 10px;
  align-items: start;
  margin-top: 6px;
}
.kt-form-grid label {
  font-weight: 600;
  color: #444;
  line-height: 1.3;
}

/* Im Details-Bereich harte Ausrichtung erzwingen */
#package-details .kt-form-grid {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  column-gap: 16px;
  row-gap: 10px;
  align-items: start;
}
#package-details .kt-form-grid > label {
  grid-column: 1 / 2;
  justify-self: start;
  align-self: start;
  display: block;
  margin: 0;
}
#package-details .kt-form-grid > input.kt-input,
#package-details .kt-form-grid > .kt-output,
#package-details .kt-form-grid > textarea.kt-input {
  grid-column: 2 / 3;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
}

/* Spacer-Zeile */
.kt-form-grid .kt-spacer,
#package-details .kt-form-grid .kt-spacer {
  grid-column: 1 / -1;
  height: 12px;
}

.kt-input {
  width: 100%;
  padding: 8px;
  box-sizing: border-box;
  border: 1px solid #d0d7de;
  border-radius: 8px;
  background: #fff;
  color: #111;
}
.kt-input--readonly {
  background: #f6f8fa;
  color: #444;
  border: 1px solid #d0d7de;
}

/* Editierbare Inputs immer hell (auch im Dark Mode) */
.kt-input--editable {
  background: #ffffff !important;
  color: #111111 !important;
  border: 1px solid #d0d7de;
}

/* Textarea-Grundhöhe & Resize */
.kt-form-grid textarea.kt-input,
#package-details .kt-form-grid > textarea.kt-input {
  min-height: 120px;
  resize: vertical;
}

/* Reines Ausgabefeld (optisch wie Input) */
.kt-output {
  background: #f6f8fa;
  color: #111;
  border: 1px solid #d0d7de;
  border-radius: 8px;
  padding: 8px;
  line-height: 1.4;
  min-height: 38px;
  box-sizing: border-box;
  pointer-events: none;
  user-select: none;
  cursor: default;
}

/* ========== Actions & Buttons ========== */
.kt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}

.kt-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font: inherit;
  line-height: 1.2;
  border-radius: 10px;
  border: 1px solid #d0d7de;
  background: #ffffff;
  color: #111;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(0,0,0,.04);
  transition: background 120ms ease, border-color 120ms ease,
              box-shadow 120ms ease, transform 60ms ease;
}
.kt-btn:hover {
  background: #f3f4f6;
  border-color: #c9d2da;
}
.kt-btn:active { transform: translateY(1px); }
.kt-btn:focus-visible { outline: 2px solid #0b57d0; outline-offset: 2px; }

.kt-btn--primary {
  background: #0b57d0;
  border-color: #0b57d0;
  color: #fff;
}
.kt-btn--primary:hover { filter: brightness(0.98); }

.kt-btn--danger {
  background: #fee2e2;
  border-color: #fecaca;
  color: #7f1d1d;
}
.kt-btn--danger:hover { background: #fecaca; }

/* Kleine Symbolchen per data-action (optional) */
.kt-btn[data-action="insert-before"]::before { content: "＋"; }
.kt-btn[data-action="insert-after"]::before  { content: "＋"; }
.kt-btn[data-action="update"]::before        { content: "✎"; }
.kt-btn[data-action="delete"]::before        { content: "🗑"; }

/* ========== Dark Mode Tweaks ========== */
@media (prefers-color-scheme: dark) {
  .tree-panel li.selected { outline-color: #9aa4b2; }
  .tree-panel li.is-ancestor > div {
    background: rgba(88, 166, 255, 0.18);
    box-shadow: inset 3px 0 0 #58a6ff;
  }

  #package-details .detail-panel {
    background: #161b22;
    color: #e6edf3;
    border-color: #30363d;
    box-shadow: none;
  }
  #package-details .detail-content h2 { color: #e6edf3; }
  #package-details .description { color: #d0d7de; }
  #package-details .divider { background: #30363d; }
  #package-details .date-label { color: #c9d1d9; }
  #package-details .date-value { color: #f0f6fc; }
  #package-details a { color: #58a6ff; }

  .kt-form-grid label { color: #c9d1d9; }
  .kt-input {
    background: #0d1117;
    color: #e6edf3;
    border-color: #30363d;
  }
  .kt-input--readonly { background: #161b22; }

  .kt-actions {
    background: #0d1117;
    border-color: #30363d;
    box-shadow: none;
  }
  .kt-btn {
    background: #161b22;
    border-color: #30363d;
    color: #e6edf3;
    box-shadow: none;
  }
  .kt-btn:hover { background: #1f2733; border-color: #3a4250; }
  .kt-btn--primary { background: #2563eb; border-color: #2563eb; color: #fff; }
  .kt-btn--danger  { background: rgba(190,18,60,.18); border-color: rgba(248,113,113,.5); color: #fecaca; }

  /* Editierbare Inputs bleiben hell, wie oben erzwungen */
}
/* ---- Pfad-Markierung im Baum ---- */
.tree-panel li.is-ancestor > div {
  background: rgba(0, 123, 255, 0.12);
  border-radius: 4px;
  box-shadow: inset 3px 0 0 #0b57d0;
}

/* Noch deutlicheres „Band“ für alle Vorfahren des aktuell selektierten Knotens */
.tree-panel li.path-ancestor > div {
  background: rgba(0, 123, 255, 0.18);
  box-shadow: inset 4px 0 0 #2563eb;
}

/* ---- Breadcrumb oben unter der Überschrift ---- */
#kt-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  margin: 4px 0 8px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #f8fafc;
  font-size: 14px;
}

.kt-crumb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid #d0d7de;
  color: #111;
}

.kt-crumb-sep { opacity: .6; }
.kt-crumb--leaf { background: #0b57d0; color: #fff; border-color: #0b57d0; }

/* Der Listeneintrag selbst */
.tree-panel li { position: relative; }

/* Overlay (falls du sowas hast) muss UNTER dem Inhalt liegen */
.tree-panel li::before {
  z-index: 0;               /* wichtig */
}

/* Inhalt über das Overlay heben */
.tree-panel li > div {
  position: relative;
  z-index: 1;
}
/* Grundzustand der Icons */
.tree-panel li .knowledge-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-right: 8px;
  filter: none !important;
  opacity: 1 !important;
  mix-blend-mode: normal;
}

/* (optional) wenn du standardmäßig abdunkelst, dann nur bei :not(.selected) */
.tree-panel li:not(.selected) .knowledge-icon {
  opacity: 0.85;           /* dezente Entsättigung für unselektiert */
  filter: none;
}
.tree-panel li.selected .knowledge-icon {
  filter: brightness(0) invert(1);
  opacity: 1;
}

#pkg-assign { width: 100%; }

/* sanftes Grün + kleine Markierung links */
/* sanfte Kennzeichnung für zugeordnete Pakete */
.tree-panel li.is-assigned > div,
.tree-panel li.is-assigned.selected > div,
.tree-panel li > div.assigned-row {
  background-color: mediumseagreen !important;
  border-left: 3px solid #3cb371;
  border-radius: 8px;
}
