@charset "UTF-8";

:root {
  color-scheme: light dark;
  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-soft: #eef2f1;
  --text: #1a2126;
  --text-muted: #5b6472;
  --border: #dde2e0;
  --accent: #0f766e;
  --accent-dark: #0b5952;
  --accent-soft: #ccfbf1;
  --accent-contrast: #ffffff;
  --danger: #b3261e;
  --shadow-sm: 0 1px 2px rgba(16, 24, 22, 0.05);
  --shadow-md: 0 6px 20px rgba(16, 24, 22, 0.06);
  --status-gesendet: #2563eb;
  --status-angerufen: #b45309;
  --status-abgelehnt: #b3261e;
  --status-warteliste: #7c3aed;
  --status-erfolg: #15803d;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10171a;
    --surface: #1b2326;
    --surface-soft: #212b2e;
    --text: #e7ecec;
    --text-muted: #9aa5a3;
    --border: #2c3739;
    --accent: #2dd4bf;
    --accent-dark: #5eead4;
    --accent-soft: #103c37;
    --accent-contrast: #05201d;
    --danger: #f2b8b5;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.35);
    --status-gesendet: #60a5fa;
    --status-angerufen: #fbbf24;
    --status-abgelehnt: #f2b8b5;
    --status-warteliste: #c4b5fd;
    --status-erfolg: #4ade80;
  }
}

* { box-sizing: border-box; }

html { overscroll-behavior-y: contain; }

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  margin: 0;
  overscroll-behavior-y: contain;
  background: var(--bg);
  background-image:
    radial-gradient(60rem 30rem at 15% -10%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 60%),
    radial-gradient(50rem 26rem at 100% 0%, color-mix(in srgb, var(--accent) 5%, transparent), transparent 60%);
  background-repeat: no-repeat;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  /* Must stay above the tour's spotlighted element (inline z-index: 60 in
     app.js) so the header never gets covered by that element's spotlight
     box-shadow while a tour step highlights a card below it. Still below the
     tour tooltip/backdrop itself (100/110). */
  z-index: 70;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  max-width: 1200px;
  margin-inline: auto;
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 0.75rem; }

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 11px;
  background: linear-gradient(155deg, var(--accent), var(--accent-dark));
  color: var(--accent-contrast);
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-size: 1.15rem;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.brand-name {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-size: 1.35rem;
  margin: 0;
  letter-spacing: 0.01em;
}

.brand-tagline {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.header-stats {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ---------- Layout ---------- */

.app-main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin-inline: auto;
  padding: 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.4rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

h1, h2 { margin-top: 0; font-family: "Fraunces", Georgia, serif; font-weight: 600; }
h2 { font-size: 1.1rem; letter-spacing: 0.01em; }

/* ---------- Upload ---------- */

.upload-drop {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 1.75rem 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.upload-drop::before {
  content: "📄";
  font-size: 1.3rem;
}

.upload-drop:hover {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-soft);
}
.upload-drop input[type="file"] { display: none; }

.export-row { margin-top: 0.9rem; display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.export-row .placeholder-help { margin: 0; }

/* ---------- Filter bar ---------- */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.filter-bar input[type="text"] { flex: 1 1 220px; }
.filter-bar select { flex: 0 0 auto; }

.checkbox-label, .rating-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ---------- Form controls ---------- */

input, select, textarea, button {
  font: inherit;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

button {
  cursor: pointer;
  background: var(--surface-soft);
  font-weight: 500;
  transition: border-color 0.15s ease, transform 0.05s ease;
}

button:hover:not(:disabled) { border-color: var(--accent); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.result-count { color: var(--text-muted); margin: 0 0 1rem; font-size: 0.9rem; }

/* ---------- Table ---------- */

.table-wrap { overflow-x: auto; }
.action-table-wrap { margin-top: 1rem; }
.action-table-wrap table { width: auto; min-width: 100%; }
.action-table-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.action-table-header h3 { margin: 0; }

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

th, td {
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 0.88rem;
  vertical-align: top;
}

thead th { background: var(--surface-soft); position: sticky; top: 0; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--accent); }
th.sortable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

tr.notes-row td { background: var(--surface-soft); white-space: pre-wrap; color: var(--text); }
tr.notes-row p { margin: 0.3rem 0; }

.own-note-label { display: block; margin-top: 0.5rem; }
.own-note-label strong { display: block; margin-bottom: 0.3rem; font-weight: 600; }
.own-note-label textarea { width: 100%; max-width: 480px; }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.empty-hint { color: var(--text-muted); padding: 0.75rem 0; }
.error { color: var(--danger); }

.placeholder-warning {
  color: var(--status-angerufen);
  font-size: 0.85rem;
  margin-left: 0.5rem;
}
p.placeholder-warning { margin: 0.5rem 0; }
button.placeholder-warning {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  white-space: nowrap;
}
button.placeholder-warning:hover { text-decoration: underline; }

.action-cell {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding-top: 0.9rem;
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* ---------- Lower grid ---------- */

.lower-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.lower-grid .card { margin-bottom: 0; }

.template-form input, .template-form textarea { width: 100%; }
.template-form > * + * { margin-top: 0.6rem; }

.template-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.template-actions button { font-size: 0.85rem; }

.sender-form { display: flex; flex-direction: column; gap: 0.6rem; }
.sender-field { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; color: var(--text-muted); }
.sender-field input, .sender-field textarea { color: var(--text); }

.placeholder-help { font-size: 0.8rem; color: var(--text-muted); }
.placeholder-help code { font-size: 0.76rem; background: var(--surface-soft); padding: 0.05rem 0.3rem; border-radius: 4px; }

/* ---------- Token autocomplete ---------- */

.token-field { position: relative; }
.token-field input, .token-field textarea { width: 100%; display: block; }

.token-suggestions {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  margin: 0.25rem 0 0;
  padding: 0.25rem;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
  max-height: 220px;
  overflow-y: auto;
}

.token-suggestions li {
  padding: 0.35rem 0.55rem;
  border-radius: 5px;
  font-size: 0.85rem;
  font-family: ui-monospace, monospace;
  cursor: pointer;
}

.token-suggestions li.active,
.token-suggestions li:hover {
  background: var(--accent-soft);
}

/* ---------- Preview ---------- */

.preview-nav {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
  font-size: 0.9rem;
}

.preview-body {
  white-space: pre-wrap;
  background: var(--surface-soft);
  color: var(--text);
  padding: 0.7rem;
  border-radius: 8px;
  font-family: inherit;
  margin: 0;
}

/* ---------- Status + mail action (in-table) ---------- */

.status-select { font-size: 0.85rem; }

.mail-btn {
  background: linear-gradient(155deg, var(--accent), var(--accent-dark));
  color: var(--accent-contrast);
  border-radius: 8px;
  padding: 0.4rem 0.8rem;
  text-decoration: none;
  white-space: nowrap;
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
  transition: opacity 0.15s ease;
}
.mail-btn:hover { opacity: 0.9; }

.mail-btn.disabled {
  background: var(--surface-soft);
  color: var(--text-muted);
  box-shadow: none;
  cursor: not-allowed;
  border: 1px solid var(--border);
}
.mail-btn.disabled:hover { opacity: 1; }

/* ---------- Footer ---------- */

.site-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}

.site-footer p { margin: 0.25rem 0; }
.site-footer a { color: var(--text-muted); text-decoration: underline; }
.site-footer a:hover { color: var(--accent); }

/* ---------- Header extras ---------- */

.header-right { display: flex; align-items: center; gap: 0.9rem; }
.tour-help-btn { font-size: 0.82rem; padding: 0.35rem 0.65rem; }

/* ---------- Guided tour ---------- */

.tour-dim {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(0, 0, 0, 0.45);
}

.tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 56;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

/* Applied to the element the current tour step points at. Outline + z-index
   only (no oversized box-shadow spotlight trick — that risked being counted
   in the page's scrollable-overflow in some browsers). Sits above .tour-dim
   (55) so it reads clearly against the dimmed background, below the sticky
   header (70) so the header is never covered, and below the tooltip (110). */
.tour-highlight {
  position: relative;
  z-index: 60;
  outline: 3px solid var(--accent);
  outline-offset: 4px;
  border-radius: 12px;
}

.tour-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.75rem;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-md);
}

.tour-card h2 { font-size: 1.15rem; margin-bottom: 0.5rem; }
.tour-card p { color: var(--text-muted); line-height: 1.5; }

.tour-skip {
  position: absolute;
  top: 1.1rem;
  right: 1.25rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.tour-nav {
  margin-top: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.tour-progress { color: var(--text-muted); font-size: 0.8rem; white-space: nowrap; }
.tour-nav-buttons { display: flex; gap: 0.5rem; align-items: center; }
.tour-waiting { color: var(--text-muted); font-size: 0.85rem; font-style: italic; }

.tour-tooltip {
  position: fixed;
  z-index: 110;
  max-width: none;
}

/* ---------- Legal pages ---------- */

.legal-main { max-width: 760px; }

.back-link {
  display: inline-block;
  margin-bottom: 1rem;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}
.back-link:hover { text-decoration: underline; }

.legal-card h1 { font-size: 1.8rem; margin-bottom: 1rem; }
.legal-card h2 { font-size: 1.05rem; margin-top: 1.5rem; margin-bottom: 0.4rem; }
.legal-card p { line-height: 1.6; color: var(--text-muted); }
.legal-card a { color: var(--accent); }
