/* ============================================================
 * BIMeTUI — Layout (App-Shell, Grid, Subgrid)
 *
 * Drei-Zonen-Grid: Header (volle Breite), Sidebar, Content.
 * Seiten-Divs im Content erben das Grid via Subgrid.
 * ============================================================ */

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: var(--font);
  font-size: var(--fs-base);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* ── App-Shell (Haupt-Grid) ────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--header-height) 1fr;
  grid-template-areas:
    "header  header"
    "sidebar content";
  min-height: 100vh;
}

/* ── Header ────────────────────────────────────────────────── */
.header {
  grid-area: header;
  background: linear-gradient(135deg, #1a5276, var(--accent));
  color: white;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  padding: 0 var(--sp-5);
  gap: var(--gap);
}
.header__title { font-size: var(--fs-xl); font-weight: 600; }
.header__user  { font-size: var(--fs-sm); opacity: 0.8; }
.header__status {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  cursor: pointer;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  grid-area: sidebar;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: var(--gap) 0;
  overflow-y: auto;
}
.sidebar__link {
  display: block;
  padding: var(--sp-2) var(--sp-5);
  color: var(--text);
  text-decoration: none;
  font-size: var(--fs-base);
  border-left: 3px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}
.sidebar__link:hover { background: var(--bg); }
.sidebar__link--active {
  border-left-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* ── Content ───────────────────────────────────────────────── */
.content {
  grid-area: content;
  padding: var(--sp-6);
  overflow-y: auto;
}

/* ── Page-Container (Seiten im Content) ────────────────────── */
.page { display: none; }
.page--active { display: block; }

/* ── Seiten-Layouts (Subgrid fuer Spalten) ─────────────────── */

/* Zwei Spalten (z.B. Projekte, Dashboard Details) */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
  align-items: start;
}

/* Drei Spalten (z.B. Regelwerk-Editor) */
.grid-3 {
  display: grid;
  grid-template-columns: 220px 1fr 320px;
  gap: var(--gap);
  align-items: start;
}

/* Chat-Layout: Content + Sidebar (z.B. Wissen) */
.grid-chat {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--gap);
  align-items: start;
  height: calc(100vh - var(--header-height) - 2 * var(--sp-6));
}

/* Vertikales Stack-Layout */
.grid-stack {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100%;
  gap: 0;
}

/* Flex-Row fuer Inline-Gruppen */
.flex-row {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
}
.flex-row--between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.flex-row--end {
  display: flex;
  gap: var(--sp-2);
  justify-content: flex-end;
}

/* ── Utilities ─────────────────────────────────────────────── */
.hidden  { display: none !important; }
.mono    { font-family: var(--mono); font-size: var(--fs-xs); }
.muted   { color: var(--muted); }
.text-xs { font-size: var(--fs-xs); }
.text-sm { font-size: var(--fs-sm); }
.text-center { text-align: center; }
.mt-1 { margin-top: var(--sp-2); }
.mt-2 { margin-top: var(--sp-4); }
.mt-3 { margin-top: var(--gap); }
.mb-1 { margin-bottom: var(--sp-2); }
.mb-2 { margin-bottom: var(--sp-4); }
.gap-sm { gap: var(--sp-2); }
.gap-md { gap: var(--sp-4); }
.sticky { position: sticky; top: var(--sp-6); }
