/* base.css - Grundgeruest: Reset, globale Token (Radius, Typografie,
   Abstaende), Layout (Topbar, Seiteninhalt), Utilities.
   Farbwerte kommen AUSSCHLIESSLICH aus den Theme-Dateien (CSS-Variablen);
   die Bedienelemente selbst liegen in components.css. */

/* ---------- Reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ---------- Globale, themenunabhaengige Token ---------- */
:root {
  /* Radius-System (CI der Plattform) */
  --radius-sm: 0.5rem;
  --radius: 0.625rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  --radius-full: 999px;

  /* Typografie: Outfit (CI); Font-Dateien koennen spaeter lokal unter
     /public/fonts abgelegt werden - bis dahin greift der System-Fallback. */
  --font-sans: "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.5rem;

  --topbar-h: 4rem;
  --container: 80rem;
}

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

body {
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: 1.55;
  color: var(--text);
  background-color: var(--bg);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  min-height: 100vh;
  /* Sticky Footer (M6-Feedback): der App-Footer sitzt bei kurzem Inhalt
     immer am unteren Fensterrand (margin-top:auto auf .app-foot) */
  display: flex;
  flex-direction: column;
}
body > main { width: 100%; }

img,
svg {
  max-width: 100%;
  display: block;
}

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

h1 { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.015em; }
h2 { font-size: var(--fs-lg); font-weight: 650; }
h3 { font-size: var(--fs-md); font-weight: 650; }

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.1em 0.4em;
}

/* Fokus sichtbar, aber nur bei Tastatur-Navigation */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Dezente Scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.topbar-logo:hover { color: var(--text); }
.topbar-logo .logo-mark {
  width: 1.9rem;
  height: 1.9rem;
  color: var(--accent);
  flex: none;
}
.topbar-logo .logo-sub {
  color: var(--text-muted);
  font-weight: 500;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.topbar-nav::-webkit-scrollbar { display: none; }

.nav-link {
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 550;
  white-space: nowrap;
}
.nav-link:hover {
  color: var(--text);
  background: var(--surface-hover);
}
.nav-link.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.topbar-spacer { flex: 1; }

.topbar-tools {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex: none;
}

/* Mail-Status-Badge (Ampel + letzter Abruf + "Jetzt abrufen") */
.mail-badge {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface-2);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  white-space: nowrap;
}
.mail-badge .dot { flex: none; }
.mail-badge .mail-last { color: var(--text-faint); }
.mail-badge .btn { padding: 0.2rem 0.6rem; font-size: var(--fs-xs); }

/* ---------- Seiteninhalt ---------- */
.page {
  max-width: var(--container);
  margin: 0 auto;
  padding: 1.75rem 1.25rem 4rem;
}

.page-head {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  flex-wrap: wrap;
  margin-bottom: 1.4rem;
}
.page-head .sub {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

/* ---------- Karten ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem 1.4rem;
  /* Karten duerfen die Seite nie horizontal sprengen (M6-Feedback);
     breite Tabellen scrollen in ihrem .table-scroll, Overlays sind
     position:fixed und bleiben unbeschnitten */
  overflow-x: clip;
}
.card + .card { margin-top: 1.1rem; }
.card-title {
  font-size: var(--fs-md);
  font-weight: 650;
  margin-bottom: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.card-title .hint {
  font-size: var(--fs-xs);
  color: var(--text-faint);
  font-weight: 450;
}

.grid {
  display: grid;
  gap: 1.1rem;
}
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* ---------- Login-Layout ---------- */
.auth-wrap {
  flex: 1; /* fuellt den Raum bis zum Footer (Sticky-Footer-Layout) */
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.auth-card {
  width: 100%;
  max-width: 25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  padding: 2.2rem 2rem;
}
.auth-logo {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  justify-content: center;
  margin-bottom: 0.5rem;
  font-weight: 700;
  font-size: var(--fs-lg);
}
.auth-logo .logo-mark {
  width: 2.4rem;
  height: 2.4rem;
  color: var(--accent);
}
.auth-intro {
  text-align: center;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  margin-bottom: 1.6rem;
}

/* ---------- Utilities ---------- */
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: var(--fs-sm); }
.xs { font-size: var(--fs-xs); }
.mono { font-family: var(--font-mono); }
.row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.row.between { justify-content: space-between; }
/* Formular-Zeilen (M6-Feedback): .fields richtet Felder an der OBERKANTE
   aus (einzeilige Labels -> Inputs in Linie, Hints stoeren nicht);
   .end richtet Buttons/Schalter an der Input-GRUNDLINIE aus. */
.row.fields { align-items: flex-start; }
.row.end { align-items: flex-end; }
.stack > * + * { margin-top: 0.9rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }

/* Hamburger-Umschalter der Navigation (nur schmale Fenster) */
.nav-toggle {
  display: none;
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
}
.nav-toggle:hover { background: var(--surface-hover); }
.nav-toggle svg { width: 1.3rem; height: 1.3rem; }

/* ---------- Responsive ---------- */
@media (max-width: 1550px) {
  .mail-badge .mail-last { display: none; }
}
@media (max-width: 1450px) {
  .mail-badge .mail-label { display: none; }
}
/* Schmale Fenster (M6-Feedback): Navigation hinter dem Hamburger-Umschalter
   als aufklappbares Panel unter der Topbar. Beim Vergroessern gilt die
   Media Query nicht mehr - die Navigation ist automatisch wieder normal. */
@media (max-width: 1280px) {
  .nav-toggle { display: inline-flex; }
  .topbar-nav {
    display: none;
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    right: 0;
    z-index: 49;
    flex-direction: column;
    align-items: stretch;
    gap: 0.15rem;
    padding: 0.6rem 0.75rem 0.8rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border-strong);
    box-shadow: var(--shadow-md);
    overflow-x: visible;
  }
  .topbar.nav-open .topbar-nav { display: flex; }
  .topbar-nav .nav-link { padding: 0.65rem 0.85rem; }
}
@media (max-width: 900px) {
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
  .topbar { gap: 0.5rem; padding: 0 0.6rem; }
  .topbar-logo .logo-text { display: none; }
  .topbar-tools { gap: 0.35rem; }
  .mail-badge #mail-fetch-now .fetch-label { display: none; }
  .page { padding: 1.25rem 0.85rem 3rem; }
  .row.fields > .field,
  .row.end > .field { flex-basis: 100%; }
  .ticket-row .t-meta { flex-wrap: wrap; row-gap: 0.3rem; }
  .tabs { flex-wrap: wrap; }
}

/* App-Footer (M6-Feedback, Muster Statistik): Name + Version auf jeder Seite */
.app-foot {
  margin-top: auto; /* bei kurzem Inhalt an den unteren Fensterrand */
  text-align: center;
  padding: 1.2rem 1rem 1.5rem;
  color: var(--text-faint);
  font-size: var(--fs-xs);
}
