/* =========================================================
   Mandatswerk – Auftragsportal
   Farb- und Schriftsystem wie die Website
   ========================================================= */

:root {
  --ground: #F2F4F4;
  --surface: #FFFFFF;
  --surface-2: #E9EDED;
  --ink: #0E181E;
  --muted: #5A6B72;
  --line: #D3DBDB;
  --line-strong: #B4C0C1;
  --accent: #0B5E75;
  --accent-ink: #FFFFFF;
  --accent-soft: #DCEBEF;
  --highlight: #E0731A;
  --highlight-soft: #FBE9DB;
  --danger: #B3261E;
  --shadow: 0 1px 0 rgba(14, 24, 30, 0.04), 0 12px 32px rgba(14, 24, 30, 0.08);

  --display: "Bricolage Grotesque", "Helvetica Neue", Arial, sans-serif;
  --body: "IBM Plex Sans", "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "IBM Plex Mono", "SFMono-Regular", Menlo, Consolas, monospace;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0D171C;
    --surface: #142229;
    --surface-2: #1A2B33;
    --ink: #E6EDEE;
    --muted: #97A7AD;
    --line: #253740;
    --line-strong: #344953;
    --accent: #5EB9CF;
    --accent-ink: #0D171C;
    --accent-soft: #163540;
    --highlight: #F2944A;
    --highlight-soft: #3A2415;
    --danger: #F2877F;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

/* ---------- Grundlagen ---------- */

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2 {
  font-family: var(--display);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0;
}

button, input, textarea { font: inherit; color: inherit; }

.wrap {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding-inline: 20px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  padding: 0.7em 1.15em;
  border-radius: 4px;
  font-weight: 500;
  font-size: 0.95rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease;
  white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.6; cursor: default; transform: none; }

.btn-primary { background: var(--accent); color: var(--accent-ink); }

.btn-secondary {
  background: transparent;
  border-color: var(--line-strong);
}
.btn-secondary:hover { border-color: var(--ink); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  padding: 0.5em 0.8em;
}
.btn-ghost:hover { color: var(--ink); background: var(--surface-2); transform: none; }

.btn-block { width: 100%; }

.link-btn {
  background: none;
  border: 0;
  padding: 0.35em 0;
  font-size: 0.88rem;
  color: var(--muted);
  cursor: pointer;
}
.link-btn:hover { color: var(--ink); text-decoration: underline; }
.link-btn.danger:hover { color: var(--danger); }

/* ---------- Formularfelder ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > span {
  font-size: 0.85rem;
  font-weight: 500;
}

.field small {
  font-weight: 400;
  color: var(--muted);
  margin-left: 4px;
}

.field input,
.field textarea {
  width: 100%;
  padding: 0.65em 0.8em;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
}

.field textarea { resize: vertical; min-height: 4.5em; }

.field input[type="file"] {
  padding: 0.5em;
  border-style: dashed;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
}

.field input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 0.4em 0.8em;
  font: inherit;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-soft);
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.9rem;
}

/* ---------- Login ---------- */

.login {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 40px 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.login-card .brand-name,
.login-card .brand-sub { margin: 0; }
.login-card .brand-sub { margin-top: -16px; }
.login-card h1 { font-size: 1.6rem; margin-top: 8px; }

/* ---------- Kopfzeile ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--ground) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
}

.brand {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Hauptbereich ---------- */

.main { padding-block: 28px 80px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.new-task {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow);
}

.new-task h2 { font-size: 1.25rem; }

.new-task-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.field-date { width: 190px; max-width: 100%; }

/* ---------- Tabs ---------- */

.tabs {
  display: flex;
  gap: 4px;
  margin: 32px 0 14px;
  border-bottom: 1px solid var(--line);
}

.tab {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 10px 14px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.tab:hover { color: var(--ink); }

.tab[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.count {
  font-family: var(--mono);
  font-size: 0.75rem;
  min-width: 1.6em;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  text-align: center;
}

.tab[aria-selected="true"] .count { background: var(--accent-soft); color: var(--accent); }

/* ---------- Aufgabenliste ---------- */

.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
}

.task {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  padding: 16px 18px;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.task.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.check {
  appearance: none;
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  margin: 2px 0 0;
  border: 2px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.check:hover { border-color: var(--accent); }

.check:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.check:checked::after {
  content: "";
  width: 6px;
  height: 11px;
  border: solid var(--accent-ink);
  border-width: 0 2.5px 2.5px 0;
  transform: translateY(-1px) rotate(45deg);
}

.task-body { min-width: 0; }

.task-title {
  margin: 0;
  font-weight: 500;
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

.task.is-done .task-title {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: var(--line-strong);
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--muted);
}

.due {
  font-family: var(--mono);
  font-size: 0.78rem;
}

.due.soon { color: var(--highlight); }

.due.overdue {
  color: var(--highlight);
  background: var(--highlight-soft);
  padding: 0 6px;
  border-radius: 3px;
}

.task-desc {
  margin: 10px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.95rem;
}

/* ---------- Anhänge ---------- */

.files {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px 7px 10px;
  background: var(--surface-2);
  border-radius: 5px;
  font-size: 0.9rem;
}

.file-ext {
  flex: none;
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  min-width: 3.4em;
  padding: 2px 5px;
  border-radius: 3px;
  background: var(--accent);
  color: var(--accent-ink);
  text-align: center;
}

.file a {
  flex: 1;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file a:hover { text-decoration: underline; }

.file-size {
  flex: none;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.file-remove {
  flex: none;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.file-remove:hover { background: var(--surface); color: var(--danger); }

.progress {
  margin-top: 12px;
  height: 6px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 150ms linear;
}

.progress-label {
  margin: 6px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.task-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 18px;
  margin-top: 12px;
}

.attach-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.4em 0.8em;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-soft);
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}

.attach-btn:hover { filter: brightness(0.97); }

.drop-hint {
  font-size: 0.8rem;
  color: var(--muted);
}

@media (hover: none) {
  .drop-hint { display: none; }
}

/* ---------- Bearbeiten ---------- */

.edit-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  grid-column: 1 / -1;
}

.edit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

/* ---------- Hinweis ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--ground);
  box-shadow: var(--shadow);
  font-size: 0.92rem;
  z-index: 50;
}

.toast.error { background: var(--danger); color: #fff; }

@media (max-width: 520px) {
  .new-task { padding: 18px 16px; }
  .new-task-row .btn { width: 100%; }
  .field-date { width: 100%; }
  .task { padding: 14px; gap: 4px 12px; }
}
