/*
 * Design FP 11: Seitenaufbau .fp-page / .fp-section.
 * Masse aus tokens.css (--fp-page-*, --fp-section-*, --fp-title-*); Handy (<= 720 px) setzt tokens.css.
 * Spezielle Regeln für Seite, Kopf und Titel gehören hierher, nicht in die Bildschirm-Dateien.
 */

.fp-page {
  width: 100%;
  max-width: var(--fp-page-max);
  margin-inline: auto;
  padding: var(--fp-page-pad) var(--fp-page-pad) calc(var(--fp-page-pad) * 2);
}

.fp-page__body {
  display: flex;
  flex-direction: column;
  gap: var(--fp-section-gap);
}

/* Kopf: Titel links, Aktionen (Anlegen, Speichern) rechts. Ab 721 px klebt er am oberen Rand
   der Inhaltsspalte (die Spalte ist der Scrollbereich); auf dem Handy scrollt er mit. */
.fp-page__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-block: 12px;
  background: var(--bg);
  flex-shrink: 0;
}

@media (width > 720px) {
  .fp-page__head {
    position: sticky;
    top: 0;
    z-index: var(--z-panel);
  }
}

.fp-page__title {
  margin: 0;
  font-size: var(--fp-title-size);
  font-weight: var(--fp-title-weight);
  line-height: 1.2;
  color: var(--text);
  text-transform: none;
  letter-spacing: -0.01em;
}

.fp-page__actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  position: relative;
  flex: 0 0 auto;
}

/* Overflow menu of the title-row actions (Wasserbezugsorte […], Trello oV6qys3i). */
.fp-page__actions .fp-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 200px;
}

/* Fahrzeuge and Anhänger list heads (Trello 22djxDdP): title, «anlegen» and […] stay on one row
   (no wrap on the phone); Import sits in the […] menu, placed like the menu above. */
#section-fahrzeuge .fp-section__head,
#section-fahrzeuge .admin-section-actions {
  flex-wrap: nowrap;
}

#section-fahrzeuge .admin-section-actions {
  position: relative;
  flex: 0 0 auto;
}

#section-fahrzeuge .admin-section-actions .fp-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 200px;
}

/* Title and primary action on one row (Trello 1oh0RXEm, Trello oV6qys3i).
   The action sits at the right of the title, not in a loose corner of the
   head. With .fp-page__head--list the row is only as wide as the admin
   list column (same grid as .admin-split, above 1100 px), so the button
   lines up with the list instead of the far edge of the page. Screens
   without a detail column (Pikettplan) use the title-row without
   --list, so the button lines up with the full-width list. */
.fp-page__head--list {
  flex-direction: column;
  align-items: stretch;
}

.fp-page__title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: nowrap;
  width: 100%;
}

.fp-page__title-row .fp-page__title {
  margin: 0;
  min-width: 0;
  flex: 1 1 auto;
}

.fp-page__title-row .fp-page__actions {
  margin-left: auto;
}

.fp-page__head--list .admin-status {
  margin-top: 4px;
}

@media (width > 1100px) {
  .fp-page__head--list {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    gap: 16px;
    align-items: start;
  }

  .fp-page__head--list > * {
    grid-column: 1;
  }
}

.fp-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fp-section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.fp-section__title {
  margin: 0;
  font-size: var(--fp-section-title-size);
  font-weight: var(--fp-section-title-weight);
  line-height: 1.3;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
}

.fp-section__body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Administration (Steffen 12.11.2026): Menü und Inhalt linksbündig über die ganze Breite, nicht mehr
   mittig auf --fp-page-max. Die Galerie und der Layout-Editor brauchen den Platz. */
.fp-page:has(> #admin-shell) {
  max-width: none;
  margin-inline: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* Bottom padding matches the sides: the shell no longer scrolls as a page.
     When env(safe-area-inset-bottom) is set (iPhone-PWA, viewport-fit=cover) this pad is
     reduced so it does not stack with the same inset on .admin-content (Trello FXa40SKp). */
  padding-bottom: calc(var(--fp-page-pad) - min(var(--fp-page-pad), env(safe-area-inset-bottom, 0px)));
  padding-inline: max(var(--fp-page-pad), env(safe-area-inset-left, 0px)) max(var(--fp-page-pad), env(safe-area-inset-right, 0px));
}
