/* =====================================================================
   Bausteine: Karten, Dialoge, Tabs, Listen, Badges, Hinweise,
   Personalverwaltung, Systemeinstellungen
   ===================================================================== */

/* ---------- Karten / Abschnitte ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 16px;
}
.panel h3 { font-size: 15px; margin-bottom: 12px; }
.kv {
  display: grid;
  grid-template-columns: minmax(130px, 30%) 1fr;
  gap: 10px 16px;
  margin: 0;
  font-size: 14px;
}
.kv dt { color: var(--text-dim); }
.kv dd { margin: 0; }
.app-empty { text-align: center; padding: 40px 10px 10px; }
.app-empty-icon { color: var(--text-dim); margin-bottom: 8px; }
.app-empty .alert { display: inline-block; margin-top: 6px; }
.btn-sm { padding: 6px 13px; font-size: 13px; }

/* Kleine runde Icon-Knöpfe (früher Fenster-Knöpfe) */
.win-btn {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  flex: none;
  background: transparent;
  border: none;
  border-radius: 999px;
  color: var(--text-dim);
  font: inherit;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.win-btn:hover { background: var(--hover); color: var(--text); }
.win-btn:disabled { opacity: .35; cursor: default; }

/* ---------- Buttons/Badges ---------- */
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); opacity: .88; }
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--text-dim);
}
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-ok { background: var(--ok-bg); color: var(--ok); }
.status-warn { background: var(--warn-bg); color: var(--warn); }
.status-bad { background: var(--danger-bg); color: var(--danger); }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace; font-size: .92em; }
code.secret {
  display: inline-block;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px dashed var(--line-strong);
  color: var(--text);
  font-size: 16px;
  letter-spacing: .05em;
  user-select: all;
}

/* ---------- Dialoge ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  animation: fade-in .15s ease-out;
}
.modal {
  width: 100%;
  max-width: 480px;
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  animation: pop-in .18s ease-out;
}
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.modal-wide { max-width: 680px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 0 24px; }
.modal-head h2 { font-size: 18px; margin: 0; }
.modal-body { padding: 16px 24px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 24px 22px; }

/* ---------- Hinweise (Toast) ---------- */
.toast-host {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 950;
  max-width: min(400px, calc(100vw - 32px));
}
.toast-item {
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-fg);
  box-shadow: var(--shadow);
  font-size: 13.5px;
  font-weight: 500;
  animation: pop-in .18s ease-out;
  transition: opacity .3s, transform .3s;
}
.toast-error { background: var(--danger); color: #fff; }
.toast-item.leaving { opacity: 0; transform: translateY(6px); }
.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 32px));
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 13.5px;
  box-shadow: var(--shadow);
  z-index: 1000;
}
.toast[hidden] { display: none; }

/* ---------- Tabs (Segment-Stil) ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin: 0 0 20px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab {
  position: relative;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); }
.tab.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--text); }

/* ---------- Formular-Extras ---------- */
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.action-row { display: flex; flex-wrap: wrap; gap: 8px; }
.row.align-end { align-items: flex-end; }
.row.align-end > .field:last-child { flex: none; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 16px; }
textarea { resize: vertical; min-height: 60px; }
input:disabled, select:disabled, textarea:disabled { opacity: .6; cursor: not-allowed; }

/* ---------- Liste/Detail (Split) ---------- */
.win-body.win-body-flush { padding: 0; overflow: hidden; }
.split { display: flex; height: 100%; }
.split-list {
  width: 340px;
  flex: none;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--bg-soft);
}
.split-detail { flex: 1; overflow-y: auto; padding: 24px 28px; min-width: 0; }
.toolbar { display: flex; gap: 8px; padding: 14px 14px 0; align-items: center; }
.split-detail .toolbar, .panel .toolbar { padding: 0 0 12px; }
.toolbar input, .toolbar select { padding: 8px 12px; font-size: 13.5px; }
.list-count { padding: 10px 16px 4px; }
.list { flex: 1; overflow-y: auto; padding: 4px 8px 14px; }
.list .empty { padding: 12px 8px; }
.list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 2px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.list-item:hover { background: var(--hover); }
.list-item.selected { background: var(--surface); border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.li-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.li-main strong, .li-main span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-main strong { font-weight: 600; }
.li-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

.detail-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.detail-head h2 { font-size: 22px; margin: 0; }
.detail-who { flex: 1; min-width: 0; }
.detail-badges { display: flex; gap: 6px; align-items: center; }
.back-btn { display: none; }

/* Zeitleiste der Personalhistorie */
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 1px solid var(--line-strong); }
.timeline li { position: relative; padding: 0 0 14px 14px; font-size: 13.5px; }
.timeline li::before {
  content: "";
  position: absolute;
  left: -20px;
  top: 5px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--text-faint);
}
.timeline .tl-promoted::before, .timeline .tl-hired::before, .timeline .tl-reactivated::before { border-color: var(--ok); }
.timeline .tl-demoted::before, .timeline .tl-suspended::before { border-color: var(--warn); }
.timeline .tl-terminated::before { border-color: var(--danger); }
.tl-note { margin: 2px 0; white-space: pre-wrap; }

/* ---------- Systemeinstellungen ---------- */
.court-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.court-row { display: flex; gap: 8px; align-items: center; }
.court-row .court-key { width: 110px; flex: none; }

.rank-head, .rank-row {
  display: grid;
  grid-template-columns: 46px minmax(140px, 1fr) 90px 52px 110px;
  gap: 8px;
  align-items: center;
}
.rank-head { font-size: 12px; color: var(--text-dim); padding: 0 4px 6px; }
.rank-list { display: flex; flex-direction: column; gap: 6px; }
.rank-row { padding: 8px 4px; border-bottom: 1px solid var(--line); }
.rank-row input[type="color"] { padding: 2px; height: 38px; cursor: pointer; }
.rank-level {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-2);
  font-weight: 700;
}
.rank-titles { grid-column: 2 / -1; font-size: 13px; }
.rank-titles summary { cursor: pointer; color: var(--text-dim); }
.title-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 12px; margin-top: 8px; }

.role-list { display: flex; flex-direction: column; gap: 10px; }
.role-row { display: grid; grid-template-columns: 170px 1fr 2fr; gap: 10px; align-items: center; }
.role-row .field { margin: 0; }

.upload-block { display: flex; gap: 20px; align-items: center; }
.upload-preview {
  flex: none;
  display: grid;
  place-items: center;
  color: var(--text-dim);
  font-size: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background-color: var(--surface-2);
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
}
.preview-seal { width: 110px; height: 110px; }
.preview-bg { width: 192px; height: 108px; background-size: cover; }

/* ---------- Schmale Bereiche (Container-Abfragen) ---------- */
.win-body { container-type: inline-size; }
@container (max-width: 680px) {
  .split-list { width: 100%; border-right: none; }
  .split-detail { display: none; padding: 16px 18px; }
  .split.show-detail .split-list { display: none; }
  .split.show-detail .split-detail { display: block; }
  .back-btn { display: inline-flex; }
  .detail-head { flex-wrap: wrap; }
  .row { flex-direction: column; gap: 0; }
}

/* ---------- Handy ---------- */
@media (max-width: 767px) {
  .rank-head { display: none; }
  .rank-row { grid-template-columns: 40px 1fr 80px; }
  .rank-row input[type="color"], .rank-row .rank-badge { grid-column: auto; }
  .role-row { grid-template-columns: 1fr; gap: 4px; }
  .upload-block { flex-direction: column; align-items: flex-start; }
  .modal-body .row { flex-direction: column; gap: 0; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 10px; }
  .panel { padding: 16px; }
}
