/* ---------- Grundlagen ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #faf6ef;
  --card: #ffffff;
  --ink: #2d2a24;
  --muted: #7a7469;
  --line: #e8e1d4;
  --accent: #2f6b4f;
  --accent-dark: #24543e;
  --accent-soft: #e7f1ec;
  --amber: #b97d10;
  --amber-soft: #fdf3df;
  --red: #b23a3a;
  --red-soft: #fbe9e9;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(60, 50, 30, 0.08), 0 4px 14px rgba(60, 50, 30, 0.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, .brand { font-family: Georgia, "Times New Roman", serif; }
h1 { font-size: 1.7rem; margin-bottom: 0.6rem; }
h2 { font-size: 1.2rem; margin: 1.6rem 0 0.7rem; }
a { color: var(--accent); }

/* ---------- Kopfzeile ---------- */
.topbar {
  background: var(--accent-dark);
  color: #fff;
  box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 0.7rem 1rem;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem;
}
.brand { color: #fff; text-decoration: none; font-size: 1.15rem; font-weight: bold; }
.topbar nav { display: flex; align-items: center; gap: 0.2rem; flex-wrap: wrap; }
.topbar nav a, .topbar .link-btn {
  color: #e4efe9; text-decoration: none; padding: 0.35rem 0.7rem; border-radius: 8px; font-size: 0.95rem;
}
.topbar nav a:hover, .topbar .link-btn:hover { background: rgba(255,255,255,0.12); }
.topbar nav a.active { background: rgba(255,255,255,0.18); color: #fff; font-weight: 600; }

/* ---------- Layout ---------- */
.container { max-width: 1080px; margin: 0 auto; padding: 1.4rem 1rem 3rem; width: 100%; flex: 1; }
.footer { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 1.2rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: 0.92rem; }
.center { text-align: center; }
.spacer { flex: 1; }

/* ---------- Meldungen ---------- */
.flash { padding: 0.7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 0.95rem; }
.flash-success { background: var(--accent-soft); color: var(--accent-dark); border: 1px solid #c4dccf; }
.flash-error { background: var(--red-soft); color: var(--red); border: 1px solid #eccaca; }

/* ---------- Buttons & Formulare ---------- */
.btn {
  display: inline-block; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 0.45rem 0.95rem; border-radius: 9px; font-size: 0.95rem; cursor: pointer;
  text-decoration: none; transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: #f4efe5; border-color: #d8cfbc; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-small { padding: 0.25rem 0.65rem; font-size: 0.85rem; }
.btn-block { width: 100%; padding: 0.6rem; font-size: 1rem; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: #f0eade; }
.link-btn { background: none; border: none; cursor: pointer; font: inherit; }
.link-btn.danger { color: var(--red); font-size: 0.88rem; text-decoration: underline; }
.inline-form { display: inline; }

label { display: block; font-size: 0.92rem; font-weight: 600; margin-bottom: 0.9rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="number"], select {
  display: block; width: 100%; margin-top: 0.25rem; padding: 0.55rem 0.7rem;
  border: 1px solid var(--line); border-radius: 9px; font-size: 0.98rem; background: var(--card); color: var(--ink);
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.check { display: flex; align-items: center; gap: 0.4rem; font-weight: normal; margin: 0; white-space: nowrap; }
.check input { width: auto; margin: 0; }

/* ---------- Anmelde-Karten & Formulare ---------- */
.auth-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.8rem; max-width: 420px; margin: 2.5rem auto;
}
.auth-card.wide { max-width: 620px; margin-top: 1rem; }
.auth-card h1 { margin-bottom: 0.3rem; }
.auth-card form { margin-top: 1.2rem; }
.auth-card p.muted { margin-top: 0.8rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.form-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 0.4rem; }
.danger-zone { margin-top: 1.4rem; padding-top: 1rem; border-top: 1px dashed var(--line); text-align: center; }

/* ---------- Filterleiste ---------- */
.filterbar {
  display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.7rem; margin: 1rem 0 0.6rem; box-shadow: var(--shadow);
}
.filterbar input[type="search"] { flex: 2; min-width: 180px; margin: 0; }
.filterbar input[type="number"] { margin: 0; }
.filterbar select { flex: 1; min-width: 150px; width: auto; margin: 0; }

/* ---------- Kategorien & Bücherkarten ---------- */
.category h2 {
  border-bottom: 2px solid var(--line); padding-bottom: 0.3rem; margin-top: 2rem;
  display: flex; align-items: baseline; gap: 0.5rem;
}
.count {
  font-family: -apple-system, sans-serif; font-size: 0.78rem; font-weight: 600;
  background: var(--accent-soft); color: var(--accent-dark);
  border-radius: 99px; padding: 0.1rem 0.55rem;
}
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 0.9rem; }
.book-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 0.95rem 1rem;
  display: flex; flex-direction: column; gap: 0.55rem;
  border-left: 4px solid var(--accent);
}
.book-card.is-loaned { border-left-color: var(--amber); background: #fffdf8; }
.book-top { display: flex; justify-content: space-between; gap: 0.6rem; align-items: flex-start; }
.book-title { font-size: 1.02rem; line-height: 1.3; }
.book-author { color: var(--muted); font-size: 0.88rem; }
.book-series { color: var(--accent-dark); font-size: 0.82rem; margin-top: 0.15rem; font-style: italic; }
.loan-info { font-size: 0.82rem; color: var(--muted); background: var(--bg); border-radius: 8px; padding: 0.4rem 0.6rem; }
.book-actions { display: flex; align-items: center; gap: 0.4rem; margin-top: auto; }
.chip {
  font-size: 0.75rem; background: var(--bg); border: 1px solid var(--line);
  border-radius: 99px; padding: 0.1rem 0.55rem; color: var(--muted); white-space: nowrap;
}

/* ---------- Badges ---------- */
.badge {
  font-size: 0.74rem; font-weight: 600; border-radius: 99px; padding: 0.15rem 0.6rem; white-space: nowrap;
}
.badge-green { background: var(--accent-soft); color: var(--accent-dark); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-red { background: var(--red-soft); color: var(--red); }

/* ---------- Tabellen ---------- */
.table-wrap {
  overflow-x: auto; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
th, td { text-align: left; padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: #fbf8f2; }
tbody tr:last-child td { border-bottom: none; }
.row-overdue td { background: var(--red-soft); }

/* ---------- Verwaltung ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0.8rem; margin: 1rem 0; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 0.8rem 1rem; color: var(--muted); font-size: 0.88rem;
}
.stat-num { display: block; font-size: 1.7rem; font-weight: 700; color: var(--ink); font-family: Georgia, serif; }
.stat-alert { border-color: #eccaca; background: var(--red-soft); }
.stat-alert .stat-num { color: var(--red); }
.admin-columns { display: grid; grid-template-columns: 1fr 1.4fr; gap: 1.6rem; align-items: start; }
.stacked label { margin-bottom: 0.7rem; }
.stacked .btn { margin-top: 0.3rem; }

/* ---------- Leerzustand ---------- */
.empty {
  background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 1.6rem; text-align: center; color: var(--muted);
}

/* ---------- Cover ---------- */
.book-body { display: flex; gap: 0.8rem; }
.book-main { flex: 1; min-width: 0; }
.cover-link { flex-shrink: 0; text-decoration: none; }
.cover-thumb {
  width: 62px; height: 92px; object-fit: cover; border-radius: 6px;
  border: 1px solid var(--line); background: #fff; box-shadow: var(--shadow);
}
.cover-placeholder {
  width: 62px; height: 92px; border-radius: 6px; overflow: hidden;
  background: linear-gradient(160deg, var(--accent-soft), #d9e8df);
  border: 1px solid var(--line); display: flex; align-items: center; justify-content: center;
  padding: 4px; text-align: center;
}
.cover-placeholder span {
  font-family: Georgia, serif; font-size: 0.55rem; color: var(--accent-dark); line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden;
}
.cover-placeholder.large { width: 180px; height: 266px; }
.cover-placeholder.large span { font-size: 0.95rem; }
.book-title a { color: inherit; text-decoration: none; }
.book-title a:hover { text-decoration: underline; }

/* ---------- Detailseite ---------- */
.detail-grid { display: flex; gap: 1.6rem; margin-top: 1rem; align-items: flex-start; flex-wrap: wrap; }
.detail-cover img {
  width: 180px; border-radius: 10px; border: 1px solid var(--line); box-shadow: var(--shadow);
}
.detail-info { flex: 1; min-width: 260px; }
.detail-info .book-actions { margin-top: 1rem; }

/* ---------- Sterne & Bewertungen ---------- */
.stars { color: #d99a1b; letter-spacing: 0.08em; font-size: 1.05rem; }
.stars-line { display: flex; align-items: center; gap: 0.45rem; margin: 0.5rem 0; }
.stars-line.small { margin: 0.25rem 0 0; }
.stars-line.small .stars { font-size: 0.85rem; }

.rating-form {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1rem; max-width: 560px;
  display: flex; flex-direction: column; gap: 0.7rem;
}
.rating-form textarea {
  width: 100%; padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: 9px;
  font: inherit; font-size: 0.95rem; resize: vertical;
}
.star-input { display: inline-flex; flex-direction: row-reverse; justify-content: flex-end; gap: 0.1rem; }
.star-input input { position: absolute; opacity: 0; pointer-events: none; }
.star-input label { font-size: 1.9rem; color: #d8d2c5; cursor: pointer; margin: 0; transition: color 0.1s; }
.star-input label:hover, .star-input label:hover ~ label,
.star-input input:checked ~ label { color: #d99a1b; }

.rating-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.8rem 1rem; margin-bottom: 0.7rem; max-width: 720px;
}
.rating-head { display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; }
.rating-comment { margin-top: 0.4rem; white-space: pre-line; }

/* ---------- QR-Druckseite ---------- */
.qr-sheet { display: flex; gap: 1.5rem; flex-wrap: wrap; margin-top: 1.5rem; }
.qr-poster {
  background: #fff; border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 1.6rem; text-align: center; width: 340px;
}
.qr-poster h2 { margin: 0 0 0.4rem; }
.qr-svg { margin: 1rem auto; width: 260px; }
.qr-url { font-size: 0.85rem; color: var(--muted); word-break: break-all; }
.qr-code-text { font-size: 1.1rem; letter-spacing: 0.2em; }

@media print {
  .no-print, .topbar, .footer, .flash { display: none !important; }
  body { background: #fff; }
  .qr-poster { border-color: #999; page-break-inside: avoid; }
}

/* ---------- Mobil ---------- */
@media (max-width: 720px) {
  .admin-columns, .form-row { grid-template-columns: 1fr; }
  .book-grid { grid-template-columns: 1fr; }
  h1 { font-size: 1.45rem; }
}
