/* ═══════════════════════════════════════════════════════════
   Design-System — Spendenverwaltung
   ═══════════════════════════════════════════════════════════ */

:root {
  --primary:        #1a56a0;
  --primary-dark:   #0d3464;
  --primary-light:  #5b9bd5;
  --primary-bg:     #dbeafe;
  --accent:         #2563eb;

  --danger:         #dc3545;
  --danger-bg:      #f8d7da;
  --success:        #198754;
  --success-bg:     #d1e7dd;
  --warning:        #f0a500;
  --warning-bg:     #fff3cd;
  --info-bg:        #cfe2ff;

  --text:           #1a1a1a;
  --text-muted:     #6c757d;
  --text-light:     #adb5bd;

  --bg:             #f4f7f5;
  --bg-card:        #ffffff;
  --border:         #dee2e6;
  --border-light:   #f0f0f0;

  --radius:         8px;
  --radius-sm:      4px;
  --shadow:         0 1px 4px rgba(0,0,0,.08);
  --shadow-md:      0 4px 16px rgba(0,0,0,.12);

  --nav-w:          220px;
  --nav-h:          60px;
  --font:           -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ─── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow-x: hidden; max-width: 100%; }
body { font-family: var(--font); font-size: 15px; color: var(--text); background: var(--bg); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; }

/* ─── Layout ─────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar (Desktop) */
.sidebar {
  width: var(--nav-w);
  background: var(--primary-dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .2s;
}
.sidebar-brand {
  padding: 18px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-brand h1 {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}
.sidebar-brand .tenant-name {
  font-size: 11px;
  color: var(--primary-light);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar nav { flex: 1; padding: 8px 0; overflow-y: auto; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: rgba(255,255,255,.75);
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s;
  cursor: pointer;
}
.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,.1);
  color: #fff;
  border-left-color: var(--primary-light);
}
.nav-link .icon { width: 20px; text-align: center; font-size: 16px; }
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: 12px;
  color: rgba(255,255,255,.5);
}
.sidebar-footer strong { color: rgba(255,255,255,.8); display: block; margin-bottom: 2px; }
.btn-logout {
  margin-top: 6px;
  background: rgba(255,255,255,.1);
  border: none;
  color: rgba(255,255,255,.7);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.btn-logout:hover { background: rgba(255,255,255,.2); color: #fff; }

/* Main content area */
.main-content {
  flex: 1;
  margin-left: var(--nav-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar h2 { font-size: 18px; font-weight: 600; }
.content { padding: 24px; flex: 1; }

/* Bottom nav (Mobile) */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--primary-dark);
  height: var(--nav-h);
  z-index: 100;
  justify-content: space-around;
  align-items: center;
  border-top: 1px solid rgba(255,255,255,.1);
}
.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: rgba(255,255,255,.6);
  font-size: 11px;
  gap: 2px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-width: 48px;
}
.bottom-nav-item .icon { font-size: 20px; }
.bottom-nav-item.active { color: var(--primary-light); }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding-bottom: var(--nav-h); }
  .bottom-nav { display: flex; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
}

/* ─── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.card-header h3 { font-size: 15px; font-weight: 600; }
.card-body { padding: 18px; }

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity .15s, background .15s;
  white-space: nowrap;
  line-height: 1.4;
  font-family: var(--font);
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: #6c757d; color: #fff; }
.btn-secondary:hover:not(:disabled) { background: #5c636a; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #bb2d3b; }
.btn-ghost {
  background: transparent;
  color: var(--primary);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--primary-bg); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-icon { padding: 6px 8px; }

/* ─── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.form-control {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: var(--font);
  background: #fff;
  color: var(--text);
  transition: border-color .15s;
  min-width: 0;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45,106,79,.12);
}
.form-control:disabled { background: var(--bg); color: var(--text-muted); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .form-group { flex: 1 1 160px; min-width: 0; }
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }
.form-check label { font-size: 14px; cursor: pointer; margin: 0; font-weight: normal; color: var(--text); }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* ─── Tables ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  background: var(--bg);
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg); }
.td-actions { display: flex; gap: 6px; }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ─── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: #8a6600; }
.badge-danger  { background: var(--danger-bg);  color: var(--danger);  }
.badge-info    { background: var(--info-bg);    color: #0a58ca;        }
.badge-muted   { background: var(--border-light); color: var(--text-muted); }

/* ─── Modal ───────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); padding: 4px; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* ─── Alerts / Toast ──────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 12px;
}
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #a3cfbb; }
.alert-danger   { background: var(--danger-bg);  color: var(--danger);  border: 1px solid #f1aeb5; }
.alert-warning  { background: var(--warning-bg); color: #8a6600;        border: 1px solid #ffe69c; }

#toast-container {
  position: fixed;
  bottom: 80px;
  right: 16px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 340px;
}
.toast {
  background: var(--text);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  box-shadow: var(--shadow-md);
  animation: slideIn .2s ease;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
@keyframes slideIn { from { transform: translateX(100%); opacity:0; } to { transform: translateX(0); opacity:1; } }

/* ─── Misc ────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); font-size: 13px; }
.text-danger { color: var(--danger); }
.fw-bold { font-weight: 700; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 40px; margin-bottom: 8px; }
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading { text-align: center; padding: 32px; color: var(--text-muted); }

/* ─── Login Page ──────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
}
.login-card .logo {
  text-align: center;
  margin-bottom: 24px;
}
.login-card .logo h1 {
  font-size: 22px;
  color: var(--primary);
  font-weight: 700;
}
.login-card .logo p { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* ─── Stats / Dashboard ───────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.stat-card .stat-value { font-size: 26px; font-weight: 700; color: var(--primary); }
.stat-card .stat-sub { font-size: 12px; color: var(--text-muted); }

/* ─── Amount input ────────────────────────────────────────── */
.input-euro {
  position: relative;
}
.input-euro .form-control { padding-right: 36px; }
.input-euro::after {
  content: '€';
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* ─── Donation item row (für Artikelkauf) ────────────────── */
.item-row {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 8px;
  position: relative;
}
.item-row .remove-btn {
  position: absolute;
  top: 8px; right: 8px;
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

/* ─── Filter bar ──────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}
.filter-bar .form-control { flex: 1 1 180px; min-width: 0; max-width: 300px; }
.search-input { position: relative; flex: 1 1 200px; max-width: 340px; }
.search-input input { padding-left: 34px; }
.search-input::before { content: '🔍'; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 14px; pointer-events: none; }
