/* ============================================================
 * BIMeTUI — Komponenten
 *
 * Wiederverwendbare UI-Bausteine. Alle erben von variables.css.
 * Reihenfolge: Section → Cards → Buttons → Tags → Tables →
 *              Forms → Upload → Chat → Statusbar
 * ============================================================ */

/* ── Section (Container fuer Content-Bloecke) ──────────────── */
.section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: var(--sp-6);
  margin-bottom: var(--sp-6);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.section--compact  { padding: var(--sp-3); }
.section--flush    { padding: 0; margin-bottom: 0; }
.section--no-mb    { margin-bottom: 0; }

.section__title {
  font-size: var(--fs-lg);
  margin-bottom: var(--gap);
  padding-bottom: var(--sp-2);
  border-bottom: 2px solid var(--border);
}
.section__subtitle {
  font-size: var(--fs-sm);
  font-weight: 600;
  margin-bottom: var(--sp-2);
}

/* ── Cards (Dashboard-Statistik) ───────────────────────────── */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--gap);
  margin-bottom: var(--sp-6);
}
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: var(--sp-5);
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.card__number { font-size: 32px; font-weight: 700; }
.card__label  { font-size: var(--fs-xs); color: var(--muted); margin-top: var(--sp-1); }
.card--ok      .card__number { color: var(--ok); }
.card--error   .card__number { color: var(--error); }
.card--warning .card__number { color: var(--warning); }
.card--info    .card__number { color: var(--info); }
.card--bordered { border-left: 3px solid var(--border); }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 24px;
  border-radius: var(--radius);
  font-size: var(--fs-base);
  cursor: pointer;
  font-weight: 500;
  transition: opacity 0.15s;
}
.btn:hover    { opacity: 0.9; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--sm      { font-size: var(--fs-xs); padding: var(--sp-1) 10px; }
.btn--md      { font-size: var(--fs-sm); padding: 5px 12px; }
.btn--muted   { background: var(--muted); }
.btn--ok      { background: var(--ok); }
.btn--error   { background: var(--error); }
.btn--outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn--outline:hover { border-color: var(--accent); background: var(--bg); }
.btn--icon {
  border: none;
  background: none;
  cursor: pointer;
  padding: 2px;
  font-size: var(--fs-base);
}
.btn--icon-error { color: var(--error); }

/* ── Tags (Status, Schwere, Kategorien) ────────────────────── */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-lg);
  font-size: var(--fs-xs);
  font-weight: 600;
}
.tag--ok      { background: #d4efdf; color: #1e8449; }
.tag--error   { background: #fadbd8; color: #c0392b; }
.tag--warning { background: #fef9e7; color: #b7950b; }
.tag--offen   { background: #fadbd8; color: #c0392b; }
.tag--geloest { background: #d4efdf; color: #1e8449; }
.tag--accent  { background: color-mix(in srgb, var(--accent) 15%, white); color: var(--accent); }
.tag--sm      { font-size: 9px; }
.tag--xs      { font-size: 8px; }

/* ── Tables ────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th {
  background: #f1f3f5;
  padding: var(--sp-2) 10px;
  text-align: left;
  font-weight: 600;
}
td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--bg); }

/* ── Forms ─────────────────────────────────────────────────── */
.input {
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  font-family: var(--font);
  width: 100%;
}
.input:focus { outline: none; border-color: var(--accent); }
.input--mono { font-family: var(--mono); font-size: var(--fs-xs); }
.input--lg   { padding: 10px 14px; font-size: var(--fs-base); border-radius: var(--radius); }
.select { composes: input; }
.textarea {
  composes: input;
  resize: vertical;
  min-height: 60px;
}
.form-grid {
  display: grid;
  gap: var(--sp-2);
}
.form-grid--2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2);
}
.form-label {
  font-size: 10px;
  color: var(--muted);
  display: block;
}

/* ── Upload Area ───────────────────────────────────────────── */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
}
.upload-area:hover { border-color: var(--accent); }
.upload-area--active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}
.upload-area input[type="file"] { display: none; }

/* ── Chat (Wissen / RAG) ──────────────────────────────────── */
.chat-messages {
  overflow-y: auto;
  padding: var(--gap);
  background: var(--bg);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.chat-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  font-size: var(--fs-sm);
  line-height: 1.5;
  white-space: pre-wrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.chat-bubble--user {
  background: var(--accent);
  color: white;
  margin-left: auto;
}
.chat-bubble--assistant {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.chat-input-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--sp-2);
  padding: var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
}
.chat-quellen {
  margin-top: var(--sp-2);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--muted);
}

/* ── Progress / Gauge ──────────────────────────────────────── */
.gauge {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  margin: 0 auto var(--sp-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 700;
  color: white;
}
.progress-bar {
  background: #ecf0f1;
  border-radius: var(--radius-sm);
  height: 18px;
  width: 100px;
  position: relative;
}
.progress-bar__fill {
  background: var(--ok);
  height: 100%;
  border-radius: var(--radius-sm);
}
.progress-bar__label {
  position: absolute;
  left: var(--sp-1);
  top: 1px;
  font-size: 10px;
  font-weight: 600;
}

/* ── Accordion (Regelwerk, Termin-Liste) ───────────────────── */
.accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: var(--sp-2);
  overflow: hidden;
}
.accordion__header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: var(--sp-2) var(--sp-3);
  cursor: pointer;
  background: var(--bg);
}
.accordion__header:hover { background: #eef1f4; }
.accordion__body {
  display: none;
  padding: var(--sp-3);
  border-top: 1px solid var(--border);
}
.accordion__body--open { display: block; }
.accordion__chevron {
  font-size: var(--fs-base);
  color: var(--muted);
  transition: transform 0.2s;
}
.accordion__chevron--open { transform: rotate(90deg); }

/* ── Kategorie-Liste (Wissen-Dokumente) ────────────────────── */
.kat-group {
  border-left: 3px solid var(--border);
  margin-bottom: 6px;
  padding: var(--sp-1) var(--sp-2);
}
.kat-group--ok     { border-left-color: var(--ok); }
.kat-group--error  { border-left-color: var(--error); }
.kat-group__title  { font-weight: 600; font-size: var(--fs-xs); }
.kat-group__desc   { font-size: 10px; color: var(--muted); }
.kat-group__item {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: var(--sp-1);
  align-items: center;
  padding: 2px 0;
  margin-left: var(--sp-2);
}

/* ── Termin-Karte ──────────────────────────────────────────── */
.termin {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--sp-3);
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
}
.termin--erledigt { opacity: 0.5; }
.termin--ueberfaellig { background: #fff5f5; }
.termin__titel { font-weight: 600; font-size: var(--fs-sm); }
.termin__titel--done { text-decoration: line-through; }
.termin__meta { font-size: var(--fs-xs); color: var(--muted); }

/* ── Workflow-Button (API Explorer) ────────────────────────── */
.wf-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  font-size: var(--fs-xs);
  line-height: 1.3;
  transition: background 0.15s;
}
.wf-btn:hover { background: var(--bg); border-color: var(--accent); }
.wf-btn__desc { display: block; font-size: 10px; color: var(--muted); margin-top: 2px; }

/* ── Status-Bar (Footer) ───────────────────────────────────── */
.status-bar {
  padding: var(--sp-3) var(--sp-5);
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--muted);
}

/* ── Wizard (Gefuehrte Workflows) ──────────────────────── */
.wizard-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg);
  z-index: 10;
  padding: var(--sp-6);
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: var(--gap);
}
.wizard-title { font-size: var(--fs-xl); font-weight: 700; }
.wizard-steps {
  display: flex;
  gap: var(--sp-4);
}
.wizard-step {
  font-size: var(--fs-xs);
  color: var(--muted);
  padding-bottom: var(--sp-2);
  border-bottom: 2px solid transparent;
}
.wizard-step--active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.wizard-step--done { color: var(--ok); }
.wizard-content { overflow-y: auto; }
.wizard-actions {
  display: flex;
  justify-content: space-between;
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
}
