/* =========================================================================
   Schulden-Tracker – "Ledger" Design
   Token-System:
   Farbe   : --ink (Marke/Text), --paid (grün), --open (Bernstein),
             --bg (kühles Hellgrau), --surface (Weiß)
   Type    : Fraunces (Display/Marke), Inter (UI-Text), IBM Plex Mono (Zahlen)
   Signatur: schmaler "Tilgungsfaden" – eine 4px-Linie unter jedem Schulden-
             Namen, die den bezahlten Anteil farbig einfärbt.
   ========================================================================= */

:root {
  --ink: #16233d;
  --ink-soft: #5b6472;
  --ink-faint: #9aa3b2;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --line: #e3e7ee;

  --paid: #2e7d63;
  --paid-bg: #e7f3ee;
  --open: #c2742d;
  --open-bg: #fbeee1;

  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(22, 35, 61, 0.06);
  --shadow-md: 0 8px 24px rgba(22, 35, 61, 0.08);

  --font-display: "Fraunces", "Iowan Old Style", serif;
  --font-body: "Inter", -apple-system, Segoe UI, sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
}

/* ---------- Topbar ---------- */
.app-topbar {
  background: var(--ink);
  color: #fff;
  padding: 0.85rem 0;
  margin-bottom: 2rem;
}

.app-topbar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.25rem;
}

.app-header-actions {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.8rem;
}

.dropdown-menu {
  border: 1px solid rgba(22, 35, 61, 0.08);
  box-shadow: 0 14px 30px rgba(22, 35, 61, 0.12);
  border-radius: 0.85rem;
  padding: 0.35rem 0;
  min-width: 12rem;
  max-width: min(16rem, calc(100vw - 1.5rem));
  margin-top: 0.45rem;
}

.dropdown-item {
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
}

.user-menu-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.75rem 0.25rem;
}

.user-menu-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ink), #35507a);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.user-menu-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.user-menu-role {
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.menu-icon {
  display: inline-flex;
  width: 1.1rem;
  justify-content: center;
}

.menu-trigger-icon {
  display: inline-flex;
  margin: 0;
  font-size: 1rem;
}

.user-menu-trigger {
  width: 2.7rem;
  height: 2.7rem;
  padding: 0;
  font-size: 1rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255,255,255,0.16);
  transition: background 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}
.user-menu-trigger.dropdown-toggle::after {
  display: none;
}
.user-menu-trigger:hover, .user-menu-trigger:focus {
  background: #f2f4f9;
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.12);
}

.user-menu-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ink), #35507a);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.app-user-pill {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.85rem;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.app-brand {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #fff;
}

.app-brand-eyebrow {
  display: block;
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #9aa9c9;
  margin-bottom: 0.15rem;
}

/* ---------- Summary cards ---------- */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.3rem;
  height: 100%;
  box-shadow: var(--shadow-sm);
  border-left: 3px solid var(--ink);
}

.stat-card.is-paid { border-left-color: var(--paid); }
.stat-card.is-open { border-left-color: var(--open); }

.stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 0.35rem;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.65rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.stat-sub {
  font-size: 0.78rem;
  color: var(--ink-faint);
  margin-top: 0.2rem;
}

/* ---------- Section heading ---------- */
.section-heading {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
}

/* ---------- Ledger table ---------- */
.ledger-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

table.ledger {
  width: 100%;
  border-collapse: collapse;
}

table.ledger thead th {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: #fafbfc;
  border-bottom: 1px solid var(--line);
  padding: 0.7rem 1rem;
  white-space: nowrap;
}

table.ledger td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

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

.debt-name {
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}
.debt-name:hover { text-decoration: underline; }

.debt-desc {
  font-size: 0.78rem;
  color: var(--ink-faint);
}

/* Signature element: schmaler Tilgungsfaden unter dem Namen */
.thread-track {
  position: relative;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  margin-top: 0.45rem;
  width: 100%;
  min-width: 90px;
}
.thread-fill {
  position: absolute;
  inset: 0;
  width: 0%;
  background: var(--paid);
  border-radius: 2px;
  transition: width 0.4s ease;
}

.amount {
  font-family: var(--font-mono);
  font-weight: 500;
  text-align: right;
  white-space: nowrap;
}

.amount.is-paid { color: var(--paid); }
.amount.is-open { color: var(--open); }

.status-badge {
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
}
.status-badge.bezahlt { background: var(--paid-bg); color: var(--paid); }
.status-badge.offen   { background: var(--open-bg); color: var(--open); }

.row-actions .btn { --bs-btn-padding-y: 0.25rem; --bs-btn-padding-x: 0.55rem; font-size: 0.8rem; }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--ink-soft);
}
.empty-state h5 { font-family: var(--font-display); color: var(--ink); }

/* ---------- Responsive adjustments ---------- */
@media (max-width: 768px) {
  .app-topbar {
    padding: 0.95rem 0;
    margin-bottom: 1.25rem;
  }

  .app-topbar .container {
    flex-direction: column;
    align-items: flex-start;
  }

  .app-header-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .app-brand {
    font-size: 1.3rem;
  }

  .stat-card {
    padding: 0.95rem 1rem;
  }

  .stat-value {
    font-size: 1.35rem;
  }

  .ledger-card {
    border-radius: 8px;
  }

  table.ledger th,
  table.ledger td {
    padding: 0.7rem 0.75rem;
  }

  .row-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.35rem;
  }

  .row-actions .btn {
    font-size: 0.75rem;
    padding: 0.25rem 0.45rem;
  }
}

@media (max-width: 576px) {
  body {
    font-size: 14px;
  }

  .app-brand-eyebrow {
    font-size: 0.62rem;
  }

  .app-header-actions {
    gap: 0.4rem;
  }

  .app-user-pill {
    width: 100%;
    padding-top: 0.15rem;
  }

  .section-heading {
    font-size: 1.1rem;
  }

  .stat-card {
    min-height: 100px;
  }

  .modal-dialog {
    margin: 0.5rem;
  }

  .modal-footer {
    flex-wrap: wrap;
    gap: 0.35rem;
  }

  #toast-container {
    left: 0.5rem;
    right: 0.5rem;
    bottom: 0.5rem;
  }
}

/* ---------- Misc ---------- */
.btn-ink {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.btn-ink:hover { background: #0e1830; border-color: #0e1830; color: #fff; }

.modal-header { border-bottom: 1px solid var(--line); }
.modal-title { font-family: var(--font-display); font-weight: 600; }

.payment-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
}
.payment-row:last-child { border-bottom: none; }

/* Toast container: bottom-left by default (admin.php uses bootstrap helper classes too) */
#toast-container {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  z-index: 2000;
  pointer-events: none;
}

/* Toast visual tweaks */
.toast {
  border-radius: 0.6rem;
  box-shadow: var(--shadow-md);
  pointer-events: auto;
}
.toast .btn-close {
  opacity: 0.9;
}

/* Access badges (view/edit) — keep Bootstrap colors but tune size */
.badge {
  font-size: 0.75rem;
  padding: 0.28rem 0.55rem;
  border-radius: 0.6rem;
  font-weight: 600;
}

.badge.bg-success { background-color: var(--paid) !important; color: #fff !important; }
.badge.bg-secondary { background-color: #6c757d !important; color: #fff !important; opacity: 0.95; }

/* Small form controls consistency for admin modals */
.form-control-sm, .form-select-sm {
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
}
