/* kar.re 2 – Layout (7.4): Top-Leiste, Container, Tab-Leiste, Raster, Sprungleiste, KI-Panel-Plätze. */

/* Container 1280 px, Gutter je Breakpoint (tokens.css) */
.container {
  width: 100%;
  max-width: calc(var(--container) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.container-schmal {
  max-width: calc(var(--container-schmal) + 2 * var(--gutter));
}

/* Seite füllt den Viewport, Fußzeile bleibt unten */
body {
  display: flex;
  flex-direction: column;
}

main.container {
  flex: 1 0 auto;
  padding-top: var(--s-5);
  padding-bottom: var(--s-7);
}

main:focus {
  outline: none;
}

/* Platz für die Tab-Leiste auf dem Handy */
@media (max-width: 899.98px) {
  body {
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  }
}

/* ------------------------------------------------------------------ Top-Leiste */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}

.topbar-innen {
  height: 100%;
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.wortmarke {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: normal;
  line-height: 1;
  flex: 0 0 auto;
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
}

.wortmarke span {
  color: var(--brand);
}

.wortmarke:hover {
  text-decoration: none;
}

.nav-desktop {
  display: none;
  align-items: center;
  gap: var(--s-1);
  margin-left: var(--s-4);
}

.nav-desktop > a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 0 12px;
  border-radius: var(--radius-m);
  color: var(--text-2);
  font-weight: 500;
}

.nav-desktop > a:hover {
  color: var(--text);
  background: var(--surface-2);
  text-decoration: none;
}

.nav-desktop > a[aria-current="page"] {
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--brand);
  border-radius: var(--radius-s) var(--radius-s) 0 0;
}

.nav-desktop > a.btn {
  color: inherit;
  box-shadow: none;
}

.nav-desktop > a.btn-primary {
  color: var(--brand-ink);           /* gleiche Spezifität wie a.btn oben, steht danach → gewinnt (Kontrast 7.2) */
}

.topbar-aktionen {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--s-1);
}

/* Kopf-Suche: Desktop inline, Handy per Umschalter */
.kopf-suche {
  display: none;
  align-items: center;
  gap: var(--s-1);
}

.kopf-suche-feld {
  width: 220px;
  min-height: 40px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
}

.kopf-suche .btn-icon {
  min-width: 40px;
  min-height: 40px;
}

.topbar .suche-umschalter {
  display: inline-flex;
}

@media (min-width: 900px) {
  .nav-desktop { display: flex; }
  .kopf-suche { display: flex; }
  .topbar .suche-umschalter { display: none; }
  .anmelden-knopf span { display: inline; }
}

/* Mobil aufgeklappte Suche: eigene Zeile unter der Top-Leiste */
@media (max-width: 899.98px) {
  .kopf-suche.offen {
    display: flex;
    position: absolute;
    left: 0;
    right: 0;
    top: var(--topbar-h);
    padding: var(--s-2) var(--gutter);
    background: var(--surface-1);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-1);
  }
  .kopf-suche.offen .kopf-suche-feld {
    width: 100%;
    flex: 1 1 auto;
  }
  .anmelden-knopf span { display: none; }
  .anmelden-knopf { min-width: var(--tap); padding-inline: 0; justify-content: center; }
  .nav-neu { display: none; }
}

/* Theme-Icon: zeigt die Alternative */
.theme-icon-hell { display: none; }
.theme-icon-dunkel { display: inline-block; }
:root[data-theme="hell"] .theme-icon-hell { display: inline-block; }
:root[data-theme="hell"] .theme-icon-dunkel { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dunkel"]) .theme-icon-hell { display: inline-block; }
  :root:not([data-theme="dunkel"]) .theme-icon-dunkel { display: none; }
}

/* ------------------------------------------------------------------ Tab-Leiste (Handy) */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  align-items: stretch;
  background: var(--surface-1);
  border-top: 1px solid var(--border);
}

.tabbar .tab {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-2);
  font-size: .72rem;
  font-weight: 500;
  padding: 4px 2px;
  border-radius: 0;
}

.tabbar .tab:hover {
  text-decoration: none;
  color: var(--text);
}

.tabbar .tab .icon {
  width: 24px;
  height: 24px;
}

.tabbar .tab[aria-current="page"] {
  color: var(--brand);
}

.tabbar .tab span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.tab-neu .tab-neu-kreis {
  width: 48px;
  height: 48px;
  margin-top: -22px;
  border-radius: 50%;
  background: var(--brand);
  color: var(--brand-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-1);
  border: 3px solid var(--bg);
}

.tab-neu .tab-neu-kreis .icon {
  width: 26px;
  height: 26px;
  stroke-width: 2.5;
}

.tab-neu[aria-current="page"] .tab-neu-kreis {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

@media (min-width: 900px) {
  .tabbar { display: none; }
}

/* ------------------------------------------------------------------ Fußzeile */
.fuss {
  border-top: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-3);
  font-size: var(--fs-0);
  margin-top: auto;
}

.fuss-innen {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-5);
  align-items: center;
  padding-block: var(--s-4);
}

.fuss-links {
  display: flex;
  gap: var(--s-4);
}

.fuss-links a {
  color: var(--text-2);
  min-height: 32px;
  display: inline-flex;
  align-items: center;
}

.fuss-hinweis {
  flex: 1 1 100%;
}

@media (min-width: 900px) {
  .fuss-hinweis {
    flex: 1 1 auto;
    text-align: right;
  }
}

/* ------------------------------------------------------------------ Raster */
.karten-raster {
  display: grid;
  gap: var(--s-4);
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* Fuhrpark-Kacheln: 1 Spalte < 360, 2 Spalten ab 360, dann auto-fill 240 */
.kachel-raster {
  display: grid;
  gap: var(--s-3);
  grid-template-columns: 1fr;
}

@media (min-width: 360px) {
  .kachel-raster { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 600px) {
  .kachel-raster { gap: var(--s-4); grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
}

/* Zweispaltig ab 900 (Hero Fahrzeugseite, Editor mit Seitenleiste) */
.zweispaltig {
  display: grid;
  gap: var(--s-5);
  grid-template-columns: 1fr;
}

@media (min-width: 900px) {
  .zweispaltig { grid-template-columns: 3fr 2fr; align-items: start; }
}

/* Inhalt + KI-Seitenpanel (Desktop sticky rechts, 380 px) */
.mit-ki-panel {
  display: grid;
  gap: var(--s-5);
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 900px) {
  .mit-ki-panel { grid-template-columns: minmax(0, 1fr) var(--ki-panel); }
  .ki-panel-desktop {
    position: sticky;
    top: calc(var(--topbar-h) + var(--s-4));
    max-height: calc(100vh - var(--topbar-h) - 2 * var(--s-4));
    overflow: auto;
  }
}

/* Sticky Suchfeld unter der Top-Leiste (Fuhrpark) */
.sticky-unter-kopf {
  position: sticky;
  top: var(--topbar-h);
  z-index: 40;
  background: var(--bg);
  padding-block: var(--s-3);
}

/* Sprungleiste (Fahrzeugseite): sticky, horizontal scrollbar */
.sprungleiste {
  position: sticky;
  top: var(--topbar-h);
  z-index: 40;
  display: flex;
  gap: var(--s-1);
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding-block: var(--s-2);
  margin-inline: calc(-1 * var(--gutter));
  padding-inline: var(--gutter);
  scroll-snap-type: x proximity;
}

.sprungleiste::-webkit-scrollbar {
  display: none;
}

.sprungleiste a {
  flex: 0 0 auto;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  color: var(--text-2);
  font-size: var(--fs-0);
  font-weight: 500;
  white-space: nowrap;
  scroll-snap-align: start;
}

.sprungleiste a:hover {
  text-decoration: none;
  background: var(--surface-2);
  color: var(--text);
}

.sprungleiste a[aria-current="true"],
.sprungleiste a.aktiv {
  background: var(--surface-3);
  color: var(--text);
}

/* Abschnitte mit Anker-Versatz */
.abschnitt {
  margin-top: var(--s-6);
  scroll-margin-top: calc(var(--topbar-h) + 60px);
}

.abschnitt-kopf {
  display: flex;
  flex-wrap: wrap;            /* Hinweistext rutscht unter die Überschrift statt sie zu quetschen („Notize/n“ auf der Kundenseite) */
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-3);
}

.abschnitt-kopf h2 {
  margin: 0;
}

/* Floating-Button „Fragen“ auf dem Handy (oberhalb der Tab-Leiste) */
.fab {
  position: fixed;
  right: var(--s-4);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + var(--s-4));
  z-index: 45;
  min-width: 56px;
  height: 56px;
  padding: 0 18px;
  border-radius: var(--radius-pill);
  background: var(--ki);
  color: var(--bg);           /* dunkel: fast schwarz auf Hellblau, hell: fast weiß auf Blau (vorher 3,4:1) */
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-2);
}

@media (min-width: 900px) {
  .fab { display: none; }
}

/* Formular-Aktionen: Handy volle Breite, Desktop nebeneinander */
.form-aktionen {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-top: var(--s-4);
}

@media (max-width: 599.98px) {
  .form-aktionen > .btn { flex: 1 1 100%; }
}

/* Formular-Zeilen: einspaltig unter 600, sonst zwei Spalten */
.form-zeile {
  display: grid;
  gap: var(--s-3);
  grid-template-columns: 1fr;
}

@media (min-width: 600px) {
  .form-zeile { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
}

/* Leer-/Fehlerzustände */
.leer, .fehler {
  text-align: center;
  padding: var(--s-6) var(--s-4);
}

.leer-bild {
  width: 240px;
  margin: 0 auto var(--s-4);
  border-radius: var(--radius-l);
  opacity: .9;
}

.leer .form-aktionen, .fehler .form-aktionen {
  justify-content: center;
}

.fehler-code {
  font-family: var(--mono);
  font-size: var(--fs-4);
  color: var(--text-3);
  margin: 0;
}

.fehler-text {
  color: var(--text-2);
}

/* Rechtstexte */
.rechtstext {
  max-width: 760px;
}

.rechtstext h2 {
  margin-top: var(--s-5);
  font-size: var(--fs-1);
}

/* Login/Setup */
.login-karte, .setup-karte {
  margin-top: var(--s-5);
}

.login-titel {
  margin-bottom: var(--s-4);
}

.login-hinweis-cookie {
  margin-top: var(--s-4);
}

/* Tap-Ziele ≥ 44 px auf Handy/Touch (7.4): Fußzeilen-Links und Sprungleiste */
@media (max-width: 899.98px), (pointer: coarse) {
  .fuss-links a,
  .sprungleiste a {
    min-height: var(--tap);
  }

  .sprungleiste {
    padding-block: var(--s-1);
  }
}
