/* ============================================================
   EAB – components.css  |  Formulare, Tabellen, Karten, Buttons
   ============================================================ */

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .375rem;
  padding: .5rem 1rem;
  font-size: .9375rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  text-decoration: none;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--c-primary);
  color: #fff;
  border-color: var(--c-primary);
}
.btn-primary:hover:not(:disabled) { background: var(--c-primary-dark); border-color: var(--c-primary-dark); }

.btn-secondary {
  background: var(--c-surface);
  color: var(--c-text);
  border-color: var(--c-border);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover:not(:disabled) { background: var(--c-bg); }

.btn-danger {
  background: var(--c-expense);
  color: #fff;
  border-color: var(--c-expense);
}
.btn-danger:hover:not(:disabled) { background: #b91c1c; border-color: #b91c1c; }

.btn-ghost {
  background: transparent;
  color: var(--c-text-muted);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) { background: var(--c-bg); color: var(--c-text); }

.btn-sm { padding: .375rem .75rem; font-size: .875rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1.0625rem; }
.btn-full { width: 100%; }

/* ── Formulare ───────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: .375rem;
}

.form-row {
  display: grid;
  gap: var(--space-md);
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.form-label {
  font-size: .875rem;
  font-weight: 500;
  color: var(--c-text);
}

.form-label .required {
  color: var(--c-expense);
  margin-left: .25rem;
}

.form-input,
.form-select,
.form-textarea {
  padding: .5rem .75rem;
  font-size: .9375rem;
  font-family: inherit;
  color: var(--c-text);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px var(--c-primary-light);
}

.form-input::placeholder { color: var(--c-text-light); }

.form-input.is-error,
.form-select.is-error {
  border-color: var(--c-expense);
}

.form-textarea { resize: vertical; min-height: 100px; }

.form-hint {
  font-size: .8125rem;
  color: var(--c-text-muted);
}

.form-error {
  font-size: .8125rem;
  color: var(--c-expense);
  display: none;
}

.form-error.visible { display: block; }

.form-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  padding-top: var(--space-sm);
  border-top: 1px solid var(--c-border);
  margin-top: var(--space-md);
}

/* ── Karten ──────────────────────────────────────────────── */
.card {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--c-border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--c-border);
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--c-text);
}

.card-body { padding: var(--space-lg); }

.card-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--c-border);
  background: var(--c-bg);
}

/* ── Stat Cards (Dashboard) ──────────────────────────────── */
.stat-grid {
  display: grid;
  gap: var(--space-md);
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.stat-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: .8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-text-muted);
  margin-bottom: var(--space-sm);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  color: var(--c-text);
}

.stat-value.income { color: var(--c-income); }
.stat-value.expense { color: var(--c-expense); }

.stat-sub {
  font-size: .8125rem;
  color: var(--c-text-muted);
  margin-top: var(--space-xs);
}

/* ── Tabellen ────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--c-border);
  box-shadow: var(--shadow);
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--c-surface);
  font-size: .9375rem;
}

.table th {
  text-align: left;
  padding: .75rem var(--space-md);
  font-size: .8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--c-text-muted);
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}

.table td {
  padding: .75rem var(--space-md);
  border-bottom: 1px solid var(--c-border);
  color: var(--c-text);
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #f8fafc; }

.table td.amount { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.table td.amount.income { color: var(--c-income); }
.table td.amount.expense { color: var(--c-expense); }

.table-empty {
  text-align: center;
  color: var(--c-text-muted);
  padding: var(--space-xl) !important;
  font-style: italic;
}

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .6rem;
  font-size: .75rem;
  font-weight: 600;
  border-radius: 9999px;
  white-space: nowrap;
}

.badge-income  { background: #dcfce7; color: #15803d; }
.badge-expense { background: #fee2e2; color: #b91c1c; }
.badge-pending { background: #fef9c3; color: #a16207; }
.badge-active  { background: #dcfce7; color: #15803d; }
.badge-suspended { background: #f1f5f9; color: #64748b; }
.badge-business { background: var(--c-primary-light); color: var(--c-primary-dark); }
.badge-private  { background: #f1f5f9; color: #64748b; }

/* ── Page-Header ─────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xl);
  gap: var(--space-md);
  flex-wrap: wrap;
}

.page-heading {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--c-text);
}

.page-subheading {
  font-size: .9375rem;
  color: var(--c-text-muted);
  margin-top: var(--space-xs);
}

/* ── Alert / Hinweis ─────────────────────────────────────── */
.alert {
  padding: var(--space-md);
  border-radius: var(--radius);
  border: 1px solid;
  font-size: .9375rem;
  display: flex;
  gap: var(--space-sm);
  align-items: flex-start;
}

.alert-info    { background: #eff6ff; border-color: #93c5fd; color: #1e40af; }
.alert-success { background: #f0fdf4; border-color: #86efac; color: #15803d; }
.alert-warning { background: #fffbeb; border-color: #fcd34d; color: #92400e; }
.alert-error   { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }

/* ── Auth-Seiten ─────────────────────────────────────────── */
.auth-page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-bg);
  padding: var(--space-lg);
}

.auth-card {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--c-border);
  box-shadow: var(--shadow-lg);
  padding: var(--space-xl);
  width: 100%;
  max-width: 440px;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-xl);
}

.auth-logo-icon {
  width: 44px;
  height: 44px;
  background: var(--c-primary);
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
}

.auth-title {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--c-text);
  margin-bottom: .25rem;
}

.auth-subtitle {
  font-size: .9375rem;
  color: var(--c-text-muted);
  margin-bottom: var(--space-xl);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.auth-footer {
  margin-top: var(--space-lg);
  text-align: center;
  font-size: .9375rem;
  color: var(--c-text-muted);
}

/* ── Module Cards (Dashboard) ────────────────────────────── */
.module-grid {
  display: grid;
  gap: var(--space-md);
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  margin-top: var(--space-xl);
}

.module-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.module-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--c-primary);
  transform: translateY(-1px);
}

.module-card-icon {
  font-size: 2rem;
  line-height: 1;
}

.module-card-title {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--c-text);
}

.module-card-desc {
  font-size: .875rem;
  color: var(--c-text-muted);
  flex: 1;
}

.module-card-badge {
  align-self: flex-start;
  font-size: .75rem;
  font-weight: 600;
  padding: .2rem .6rem;
  border-radius: 9999px;
  background: var(--c-primary-light);
  color: var(--c-primary-dark);
}

/* ── Toast ───────────────────────────────────────────────── */
.toast {
  background: var(--c-text);
  color: #fff;
  padding: .75rem 1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: .9375rem;
  max-width: 360px;
  pointer-events: auto;
  animation: toast-in .2s ease forwards;
}

.toast.toast-success { background: var(--c-income); }
.toast.toast-error   { background: var(--c-expense); }
.toast.toast-warning { background: var(--c-warning); }

.toast.toast-out { animation: toast-out .2s ease forwards; }

@keyframes toast-in  { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(8px); } }

/* ── Utilities ───────────────────────────────────────────── */
.text-muted   { color: var(--c-text-muted); }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.text-sm      { font-size: .875rem; }
.text-lg      { font-size: 1.0625rem; }
.font-bold    { font-weight: 700; }
.mt-sm        { margin-top: var(--space-sm); }
.mt-md        { margin-top: var(--space-md); }
.mt-lg        { margin-top: var(--space-lg); }
.mb-md        { margin-bottom: var(--space-md); }
.gap-sm       { gap: var(--space-sm); }
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden       { display: none !important; }
.sr-only      { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  animation: fadeIn .15s ease;
}
.modal {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 640px;
  max-height: 90vh; overflow-y: auto;
  display: flex; flex-direction: column;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.5rem 0;
}
.modal-title { font-size: 1.125rem; font-weight: 600; }
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 1.5rem; line-height: 1; color: var(--c-text-muted);
  padding: .25rem .5rem; border-radius: var(--radius);
}
.modal-close:hover { background: var(--c-surface-raised); }
.modal-body  { padding: 1.25rem 1.5rem; flex: 1; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: .75rem;
  padding-top: 1rem; border-top: 1px solid var(--c-border); margin-top: 1rem;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

/* ── Tab-Bar ──────────────────────────────────────────────── */
.tab-bar {
  display: flex; gap: .25rem;
  border-bottom: 2px solid var(--c-border);
  margin-bottom: 1.5rem;
}
.tab-btn {
  background: none; border: none; cursor: pointer;
  padding: .625rem 1.25rem;
  font-size: .9375rem; font-weight: 500; color: var(--c-text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.tab-btn:hover  { color: var(--c-text); }
.tab-btn.active { color: var(--c-primary); border-bottom-color: var(--c-primary); }

/* ── Filter-Bar ───────────────────────────────────────────── */
.filter-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .75rem;
  margin-bottom: 1rem;
}

/* ── Summary-Bar ──────────────────────────────────────────── */
.summary-bar {
  display: flex; flex-wrap: wrap; gap: 1.5rem;
  padding: .875rem 1rem;
  background: var(--c-surface-raised);
  border-radius: var(--radius);
  margin-top: .75rem;
  font-size: .9375rem;
}

/* ── Summary-Table ────────────────────────────────────────── */
.summary-table td.positive, .summary-table th { color: inherit; }
.text-right { text-align: right; }
.positive   { color: var(--c-success) !important; }
.negative   { color: var(--c-danger)  !important; }

/* ── Kategorie-Liste ──────────────────────────────────────── */
.color-swatch {
  display: inline-block;
  width: .875rem; height: .875rem;
  border-radius: 50%; flex-shrink: 0;
  vertical-align: middle;
}
.color-picker {
  width: 2.25rem; height: 2.25rem;
  border: 1px solid var(--c-border); border-radius: var(--radius);
  padding: .125rem; cursor: pointer; background: none;
}
.kat-list  { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .5rem; }
.kat-item  { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; padding: .5rem 0; border-bottom: 1px solid var(--c-border); }
.kat-name  { flex: 1; font-weight: 500; }
.kat-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.kat-new-form { padding: .75rem; background: var(--c-surface-raised); border-radius: var(--radius); margin-bottom: 1rem; }

/* ── Form-Row ─────────────────────────────────────────────── */
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 10rem; }
