/* AG-Wunschliste – gemeinsames UI (mobil-first) */

:root {
  --bg: #f0f4f3;
  --surface: #ffffff;
  --text: #1c1917;
  --muted: #57534e;
  --border: #d6d3d1;
  --accent: #0f766e;
  --accent-hover: #115e59;
  --accent-soft: #ccfbf1;
  --secondary: #44403c;
  --secondary-hover: #292524;
  --danger: #b91c1c;
  --danger-hover: #991b1b;
  --ok-bg: #ecfdf5;
  --ok-border: #6ee7b7;
  --err-bg: #fef2f2;
  --err-border: #fca5a5;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(28, 25, 23, 0.08);
  --shadow-lg: 0 4px 24px rgba(28, 25, 23, 0.08);
  --font: "DM Sans", system-ui, -apple-system, sans-serif;
  --tap-min: 2.75rem;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0.75rem 1rem 2rem;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
}

.app--narrow {
  max-width: 52rem;
}

/* ——— Typo ——— */

h1 {
  font-size: clamp(1.35rem, 4vw, 1.6rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.35rem;
  color: var(--text);
}

h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 1.25rem 0 0.5rem;
}

h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 1rem 0 0.5rem;
}

.lead,
.hint {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 1rem;
  line-height: 1.45;
}

.hint a,
.lead a {
  color: var(--accent);
  font-weight: 500;
}

.hint a:hover,
.lead a:hover {
  text-decoration: underline;
}

/* ——— Navigation / Links oben ——— */

.nav-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.nav-top a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  padding: 0.35rem 0;
}

.nav-top a:hover {
  text-decoration: underline;
}

.nav-top span {
  color: var(--border);
  user-select: none;
}

/* ——— Meldungen ——— */

.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.flash.ok {
  background: var(--ok-bg);
  border: 1px solid var(--ok-border);
  color: #065f46;
}

.flash.err {
  background: var(--err-bg);
  border: 1px solid var(--err-border);
  color: #991b1b;
}

/* ——— Toolbar (Filter) ——— */

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.toolbar form.row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  align-items: end;
}

@media (min-width: 640px) {
  .toolbar form.row {
    grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  }
}

@media (min-width: 900px) {
  .toolbar form.row {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.7fr) minmax(0, 1fr) auto;
  }
}

.toolbar label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  display: block;
  margin-bottom: 0.25rem;
}

.toolbar input,
.toolbar select {
  width: 100%;
  min-height: var(--tap-min);
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  background: #fafaf9;
}

.toolbar input:focus,
.toolbar select:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.toolbar .toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* ——— Buttons ——— */

button,
a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-min);
  padding: 0.5rem 1rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

a.button {
  background: var(--accent);
  color: #fff !important;
}

a.button:hover {
  background: var(--accent-hover);
}

a.button.secondary {
  background: var(--secondary);
}

a.button.secondary:hover {
  background: var(--secondary-hover);
}

button.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

button.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

button:not(.primary):not(.danger) {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

button:not(.primary):not(.danger):hover {
  background: #f5f5f4;
}

button.danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

button.danger:hover {
  background: var(--danger-hover);
}

/* ——— Formulare ——— */

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin: 1.25rem 0 0;
  background: var(--surface);
  box-shadow: var(--shadow);
}

legend {
  font-weight: 700;
  padding: 0 0.35rem;
  font-size: 0.95rem;
}

label {
  display: block;
  margin-top: 0.75rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: #44403c;
}

label:first-of-type {
  margin-top: 0;
}

input[type="text"],
input[type="number"],
input[type="file"],
select {
  width: 100%;
  max-width: 32rem;
  min-height: var(--tap-min);
  margin-top: 0.25rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  background: #fafaf9;
}

input:focus,
select:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.row2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 560px) {
  .row2 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.form-actions {
  margin-top: 1.1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.form-actions a {
  color: var(--accent);
  font-weight: 500;
  font-size: 0.9rem;
}

.form-actions a:hover {
  text-decoration: underline;
}

/* Schuljahr-Select oben im Formular */
.form-block {
  margin-bottom: 0.5rem;
}

/* ——— Tabellen ——— */

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0.5rem 0 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: min(100%, 640px);
}

/* Schmale Tabellen (z. B. nur 2 Spalten): kein erzwungenes Scrollen */
.table-wrap--compact table {
  min-width: 0;
}

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

thead th {
  background: #f5f5f4;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:nth-child(even) {
  background: #fafaf9;
}

th a {
  color: var(--accent);
  text-decoration: none;
}

th a:hover {
  text-decoration: underline;
}

.num {
  text-align: center;
  width: 3rem;
}

.actions {
  white-space: nowrap;
  width: 1%;
}

.actions .button {
  padding: 0.35rem 0.65rem;
  min-height: auto;
  font-size: 0.8rem;
}

/* Tabellen mit Inputs (AGs bearbeiten) */
td input[type="text"],
td input[type="number"] {
  min-height: 2.5rem;
  max-width: none;
  width: 100%;
}

@media (max-width: 639px) {
  table {
    font-size: 0.82rem;
  }

  th,
  td {
    padding: 0.45rem 0.5rem;
  }
}

/* ——— Zuordnung Tabs ——— */

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0 1rem;
}

.tabs a {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.88rem;
  text-decoration: none;
  color: var(--muted);
  background: #e7e5e4;
}

.tabs a:hover {
  background: #d6d3d1;
  color: var(--text);
}

.tabs a.is-active {
  background: var(--accent);
  color: #fff;
}

/* ——— AGs: Select oben ——— */

.form-select-block {
  margin: 1rem 0;
}

.form-select-block label {
  margin-top: 0;
}

.form-select-block select {
  max-width: 100%;
}

/* ——— Löschen-Block unter Formular ——— */

form.form-delete {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* ——— Checkbox / Touch ——— */

label.checkbox-row,
label:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: var(--tap-min);
  font-weight: 500;
  cursor: pointer;
}

label.checkbox-row input {
  width: auto;
  min-height: auto;
  margin: 0;
}

button,
a.button,
input[type="submit"] {
  touch-action: manipulation;
}

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

/* ——— Print ——— */

@media print {
  .no-print {
    display: none !important;
  }

  body {
    background: #fff;
    padding: 0;
  }

  .app {
    max-width: none;
  }

  .table-wrap {
    border: none;
    overflow: visible;
  }

  table {
    min-width: 0;
    font-size: 0.82rem;
  }

  a.button {
    color: #000 !important;
    background: none !important;
    border: 1px solid #999;
    text-decoration: none;
  }

  thead th {
    background: #eee !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
