/* =========================================================================
   Komponenten
   ========================================================================= */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 22px;
  border-radius: var(--r-md);
  font-size: 15px;
  font-weight: 600;
  border: none;
  white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease, opacity .15s ease;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--c-primary-600); color: #fff; }
.btn-primary:hover { background: var(--c-primary-700); color: #fff; }
.btn-secondary { background: #fff; color: var(--c-primary-600); border: 1.5px solid var(--c-primary-600); }
.btn-secondary:hover { background: var(--c-primary-50); }
.btn-ghost { background: transparent; color: var(--c-ink-600); }
.btn-ghost:hover { background: var(--c-surface-100); color: var(--c-ink-950); }
.btn-danger { background: var(--c-danger-600); color: #fff; }
.btn-danger:hover { background: oklch(42% 0.13 25); color: #fff; }
.btn:disabled { background: var(--c-line-200); color: var(--c-ink-400); cursor: not-allowed; }
.btn-lg { height: 52px; padding: 0 26px; font-size: 16px; }
.btn-sm { height: 36px; padding: 0 16px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-icon { width: 44px; height: 44px; padding: 0; border-radius: var(--r-md); background: transparent; color: var(--c-ink-600); }
.btn-icon:hover { background: var(--c-surface-100); color: var(--c-ink-950); }

/* ---------- Formulare ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-6); }
.form-grid--single { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; }
.field--full { grid-column: 1 / -1; }
.field label {
  display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: var(--c-ink-950);
}
.field .req { color: var(--c-danger-600); }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 0 14px;
  border: 1.5px solid var(--c-line-200);
  border-radius: var(--r-md);
  font-size: 15px;
  background: #fff;
  min-height: var(--touch-min);
}
.field input, .field select { height: 44px; }
.field textarea { padding: 12px 14px; min-height: 96px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--c-primary-600);
}
.field input.has-error, .field select.has-error, .field textarea.has-error { border-color: var(--c-danger-600); }
.field-error { font-size: 13px; color: var(--c-danger-600); margin-top: 6px; }
.field-hint { font-size: 13px; color: var(--c-ink-400); margin-top: 6px; }

.checkbox, .radio {
  display: flex; align-items: center; gap: 10px; font-size: 15px; cursor: pointer; min-height: var(--touch-min);
}
.checkbox input, .radio input { position: absolute; opacity: 0; width: 22px; height: 22px; }
.checkbox__box {
  width: 22px; height: 22px; border-radius: 4px; border: 2px solid var(--c-line-300); flex: none;
  display: flex; align-items: center; justify-content: center;
}
.checkbox input:checked ~ .checkbox__box {
  background: var(--c-primary-600); border-color: var(--c-primary-600);
}
.checkbox input:checked ~ .checkbox__box::after {
  content: ""; width: 9px; height: 6px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg) translate(1px,-1px);
}
.radio__box { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--c-line-300); flex: none; display:flex; align-items:center; justify-content:center; }
.radio input:checked ~ .radio__box { border-color: var(--c-primary-600); }
.radio input:checked ~ .radio__box::after { content:""; width: 11px; height: 11px; border-radius: 50%; background: var(--c-primary-600); }

.dropzone {
  border: 1.5px dashed var(--c-line-300);
  border-radius: var(--r-lg);
  padding: 28px;
  text-align: center;
  color: var(--c-ink-600);
  font-size: 14px;
  background: var(--c-surface-50);
}

.autosave-hint { margin-top: 16px; font-size: 13px; color: var(--c-ink-400); display: flex; align-items: center; gap: 6px; }
.autosave-hint svg { width: 14px; height: 14px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 13px; border-radius: var(--r-pill);
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-neutral   { background: var(--c-surface-100); color: var(--c-ink-600); }
.badge-info      { background: var(--c-primary-100); color: var(--c-primary-700); }
.badge-success   { background: var(--c-success-100); color: var(--c-success-600); }
.badge-warning   { background: var(--c-warning-100); color: var(--c-warning-600); }
.badge-danger    { background: var(--c-danger-100);  color: var(--c-danger-600); }

/* ---------- Karten & KPI ---------- */
.card {
  background: #fff;
  border: 1px solid var(--c-line-200);
  border-radius: var(--r-lg);
  padding: 20px;
}
.card-hover:hover { border-color: var(--c-line-300); box-shadow: var(--shadow-md); }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.kpi-card {
  background: #fff; border: 1px solid var(--c-line-200); border-radius: var(--r-lg); padding: 20px;
  display: flex; flex-direction: column; gap: 8px;
}
.kpi-card__top { display: flex; align-items: flex-start; justify-content: space-between; }
.kpi-card__label { font-size: 13px; color: var(--c-ink-600); }
.kpi-card__icon { width: 34px; height: 34px; border-radius: var(--r-md); display: flex; align-items: center; justify-content: center; background: var(--c-primary-50); color: var(--c-primary-600); flex: none; }
.kpi-card__icon svg { width: 18px; height: 18px; }
.kpi-card__value { font-family: var(--font-display); font-weight: 700; font-size: 36px; line-height: 1; color: var(--c-primary-900); }
.kpi-card__trend { font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 4px; }
.kpi-card__trend.up { color: var(--c-success-600); }
.kpi-card__trend.down { color: var(--c-danger-600); }
.kpi-card__trend.flat { color: var(--c-ink-400); }

.section-title {
  display: flex; align-items: center; justify-content: space-between;
  margin: 36px 0 16px;
}
.section-title h2 { font-size: 20px; }
.section-title a { font-size: 13.5px; font-weight: 600; }

.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* ---------- Tabellen ---------- */
.table-card {
  background: #fff;
  border: 1px solid var(--c-line-200);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.table-toolbar {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  padding: 14px 20px;
  border-bottom: 1px solid var(--c-line-200);
}
.table-toolbar__search { position: relative; flex: 1; min-width: 200px; max-width: 320px; }
.table-toolbar__search input {
  width: 100%; height: 40px; padding: 0 14px 0 38px; border: 1.5px solid var(--c-line-200); border-radius: var(--r-md); font-size: 14px;
}
.table-toolbar__search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--c-ink-400); }
.table-toolbar select {
  height: 40px; padding: 0 12px; border: 1.5px solid var(--c-line-200); border-radius: var(--r-md); font-size: 14px; background: #fff; color: var(--c-ink-600);
}
.table-toolbar__spacer { flex: 1; }

.table-scroll { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table thead tr { background: var(--c-surface-50); }
.data-table th {
  text-align: left; padding: 12px 20px; font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--c-ink-400);
  border-bottom: 1px solid var(--c-line-200); white-space: nowrap;
  position: sticky; top: 0; background: var(--c-surface-50); z-index: 1;
}
.data-table td { padding: 14px 20px; border-bottom: 1px solid var(--c-surface-100); vertical-align: middle; }
.data-table tbody tr { min-height: 56px; transition: background-color .1s ease; }
.data-table tbody tr:hover { background: var(--c-surface-50); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr.row-link { cursor: pointer; }
.data-table td.cell-strong { font-weight: 600; color: var(--c-ink-950); }
.data-table td.cell-muted { color: var(--c-ink-600); }
.data-table td.cell-actions { text-align: right; }

.progress-bar { width: 92px; height: 6px; border-radius: 3px; background: var(--c-line-200); overflow: hidden; }
.progress-bar__fill { height: 100%; background: var(--c-primary-600); border-radius: 3px; }
.progress-bar__fill.success { background: var(--c-success-600); }
.progress-bar__fill.warning { background: var(--c-warning-600); }

.table-pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-top: 1px solid var(--c-line-200); font-size: 13px; color: var(--c-ink-400);
}
.pagination { display: flex; gap: 6px; }
.pagination a, .pagination span {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: var(--r-md); font-size: 13px; color: var(--c-ink-600);
}
.pagination a:hover { background: var(--c-surface-100); }
.pagination .is-active { background: var(--c-primary-600); color: #fff; font-weight: 600; }

.empty-state {
  padding: 56px 24px; text-align: center; color: var(--c-ink-400);
}
.empty-state svg { width: 40px; height: 40px; margin: 0 auto 12px; opacity: .5; }
.empty-state strong { display: block; color: var(--c-ink-600); font-size: 15px; margin-bottom: 4px; }

/* ---------- Avatare & Initialen-Kacheln ---------- */
.avatar-sm { width: 28px; height: 28px; border-radius: 50%; background: var(--c-primary-600); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; flex: none; }
.avatar-lg { width: 64px; height: 64px; border-radius: 50%; background: var(--c-primary-600); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 600; flex: none; }
.avatar-group { display: flex; }
.avatar-group .avatar-sm { margin-left: -8px; border: 2px solid #fff; }
.avatar-group .avatar-sm:first-child { margin-left: 0; }

/* ---------- Zeitachse / Timeline ---------- */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content:""; position:absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--c-line-200); }
.timeline-item { position: relative; padding-bottom: 24px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content:""; position:absolute; left:-26px; top: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: 3px solid var(--c-primary-600);
}
.timeline-item.is-done::before { background: var(--c-primary-600); }
.timeline-item__date { font-size: 12.5px; color: var(--c-ink-400); font-weight: 600; margin-bottom: 2px; }
.timeline-item__title { font-weight: 600; font-size: 14.5px; margin-bottom: 2px; }
.timeline-item__desc { font-size: 13.5px; color: var(--c-ink-600); }

/* ---------- Dialoge & Toasts ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: oklch(17% 0.012 235 / 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 200; padding: 20px;
}
.modal {
  width: 100%; max-width: 420px; background: #fff; border-radius: var(--r-xl); box-shadow: var(--shadow-lg); padding: 24px;
}
.modal h3 { font-family: var(--font-display); font-size: 19px; margin-bottom: 10px; }
.modal p { font-size: 14px; color: var(--c-ink-600); line-height: 1.5; margin-bottom: 20px; }
.modal__actions { display: flex; gap: 10px; justify-content: flex-end; }

.toast-stack { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 300; width: 320px; max-width: calc(100vw - 32px); }
.toast {
  display: flex; gap: 10px; align-items: flex-start; background: #fff; border-left: 4px solid var(--c-primary-600);
  border-radius: var(--r-md); box-shadow: var(--shadow-md); padding: 14px 16px; font-size: 14px;
}
.toast.success { border-color: var(--c-success-600); }
.toast.danger { border-color: var(--c-danger-600); }

/* ---------- Kanban (Aufgaben) ---------- */
.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; align-items: start; }
.kanban-col { background: var(--c-surface-100); border-radius: var(--r-lg); padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.kanban-col__head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 2px; }
.kanban-col__head h3 { font-size: 14.5px; }
.kanban-col__count { font-size: 12px; font-weight: 700; color: var(--c-ink-400); background: #fff; border-radius: var(--r-pill); padding: 2px 9px; }
.kanban-card { background: #fff; border: 1px solid var(--c-line-200); border-radius: var(--r-md); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.kanban-card__title { font-size: 14px; font-weight: 600; line-height: 1.35; }
.kanban-card__meta { display: flex; align-items: center; justify-content: space-between; }

/* ---------- Chat / Mitteilungen ---------- */
.chat-layout { display: grid; grid-template-columns: 300px 1fr; gap: 0; border: 1px solid var(--c-line-200); border-radius: var(--r-lg); background: #fff; overflow: hidden; min-height: 620px; }
.chat-list { border-right: 1px solid var(--c-line-200); overflow-y: auto; max-height: 720px; }
.chat-list__search { padding: 14px; border-bottom: 1px solid var(--c-line-200); }
.chat-list__item { display: flex; gap: 12px; padding: 14px; border-bottom: 1px solid var(--c-surface-100); }
.chat-list__item:hover, .chat-list__item.is-active { background: var(--c-surface-50); }
.chat-list__item.is-active { border-left: 3px solid var(--c-primary-600); padding-left: 11px; }
.chat-list__meta { min-width: 0; flex: 1; }
.chat-list__name { font-size: 14px; font-weight: 600; display: flex; justify-content: space-between; gap: 6px; }
.chat-list__preview { font-size: 13px; color: var(--c-ink-600); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-list__time { font-size: 11.5px; color: var(--c-ink-400); font-weight: 400; flex: none; }

.chat-thread { display: flex; flex-direction: column; height: 100%; }
.chat-thread__header { padding: 16px 20px; border-bottom: 1px solid var(--c-line-200); display: flex; align-items: center; gap: 12px; }
.chat-thread__body { flex: 1; padding: 20px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; max-height: 560px; }
.chat-bubble { max-width: 68%; padding: 11px 15px; border-radius: var(--r-lg); font-size: 14.5px; line-height: 1.45; }
.chat-bubble.is-mine { align-self: flex-end; background: var(--c-primary-600); color: #fff; border-bottom-right-radius: 2px; }
.chat-bubble.is-theirs { align-self: flex-start; background: var(--c-surface-100); border-bottom-left-radius: 2px; }
.chat-bubble__meta { font-size: 11px; margin-top: 6px; opacity: .7; }
.chat-bubble__attachment { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.15); border-radius: var(--r-sm); padding: 8px 10px; margin-top: 6px; font-size: 13px; }
.chat-bubble.is-theirs .chat-bubble__attachment { background: #fff; border: 1px solid var(--c-line-200); }
.chat-thread__composer { display: flex; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--c-line-200); align-items: center; }
.chat-thread__composer input { flex: 1; height: 44px; border: 1.5px solid var(--c-line-200); border-radius: var(--r-pill); padding: 0 18px; font-size: 14.5px; }

/* ---------- Signatur-Pad ---------- */
.signature-pad {
  border: 1.5px dashed var(--c-line-300); border-radius: var(--r-lg); background: var(--c-surface-50);
  height: 160px; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.signature-pad canvas { width: 100%; height: 100%; touch-action: none; }
.signature-pad__placeholder { color: var(--c-ink-400); font-size: 13.5px; position: absolute; pointer-events: none; }
.signature-pad__line { position: absolute; left: 24px; right: 24px; bottom: 34px; height: 1px; background: var(--c-line-300); }

/* ---------- Foto-Grid ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.photo-grid__item { position: relative; aspect-ratio: 1; border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--c-line-200); background: var(--c-surface-100); }
.photo-grid__item img { width: 100%; height: 100%; object-fit: cover; }
.photo-grid__add {
  aspect-ratio: 1; border-radius: var(--r-md); border: 1.5px dashed var(--c-line-300);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--c-ink-400); font-size: 12px; font-weight: 600; background: var(--c-surface-50);
}
.photo-grid__add svg { width: 22px; height: 22px; }

/* ---------- Step-Indikator (Rapport mobil) ---------- */
.step-indicator { display: flex; align-items: center; gap: 6px; margin-bottom: 22px; }
.step-indicator__dot { flex: 1; height: 4px; border-radius: 2px; background: var(--c-line-200); }
.step-indicator__dot.is-done { background: var(--c-primary-600); }
.step-indicator__dot.is-active { background: var(--c-primary-400); }

/* ---------- Utility ---------- */
.text-right { text-align: right; }
.d-flex { display: flex; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-0 { margin-top: 0; }
.flex-wrap { flex-wrap: wrap; }
