/* ═══════════════════════════════════════════════════════════
   SHELL — App-Shell, Sidebar, Topbar, Bottom-Nav
   GeniusHub v21 — Redesign

   Neue Struktur:
   - Desktop: #app = CSS-Grid mit .sidebar links + .main rechts
   - Mobile: Sidebar versteckt, Bottom-Nav fix unten
   - Topbar: ruhig, solide, kein Gradient

   Läuft PARALLEL zu layout.css. Styles hier haben Vorrang
   durch Reihenfolge der <link>-Tags in index.html.
   ═══════════════════════════════════════════════════════════ */

/* ── App-Grid ── */
#app {
  display: none;
  height: 100%;
  background: var(--bg-0);
  color: var(--fg);
  font-family: var(--f-sans);
}
#app.on {
  display: grid;
  grid-template-columns: 232px 1fr;
  grid-template-rows: 1fr;
}

/* Mobile: Sidebar raus, einspaltig */
@media (max-width: 820px) {
  #app.on { grid-template-columns: 1fr; }
}


/* ══════════ SIDEBAR (Desktop) ══════════ */
.side {
  display: flex;
  flex-direction: column;
  background: var(--bg-0);
  border-right: 1px solid var(--line);
  padding: 16px 12px calc(16px + var(--safe-b));
  gap: 14px;
  height: 100%;
  overflow-y: auto;
}
@media (max-width: 820px) {
  .side { display: none; }
}

.side::-webkit-scrollbar { width: 3px; }
.side::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 99px; }

/* Brand */
.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 12px;
  border-bottom: 1px solid var(--line);
}
.side-brand .mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--fg);
  color: var(--bg-0);
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 13px;
  font-family: var(--f-sans);
  letter-spacing: -.02em;
}
.side-brand .wm {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -.01em;
  color: var(--fg);
}

/* Nav-Gruppen */
.side-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.side-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 4px 10px 6px;
}

/* Sidebar Link */
.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  color: var(--fg-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: transparent;
  border: 0;
  text-align: left;
  width: 100%;
  min-height: 34px;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
  font-family: var(--f-sans);
}
.side-link:hover {
  background: var(--bg-2);
  color: var(--fg);
}
.side-link.on {
  background: var(--bg-2);
  color: var(--fg);
}
.side-link .ic {
  width: 16px; height: 16px;
  flex-shrink: 0;
  color: var(--fg-muted);
}
.side-link.on .ic { color: var(--accent); }

.side-link .badge {
  margin-left: auto;
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-3);
  color: var(--fg-muted);
  font-weight: 500;
  letter-spacing: .04em;
}

/* Sidebar Footer */
.side-foot {
  margin-top: auto;
  padding: 10px 10px 0;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}
.side-foot .av {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent-weak);
  color: var(--accent);
  display: grid; place-items: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}
.side-foot .info { min-width: 0; flex: 1; }
.side-foot .info .n {
  font-size: 12px;
  font-weight: 500;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-foot .info .m {
  font-size: 10px;
  color: var(--fg-dim);
  font-family: var(--f-mono);
}
.side-foot .btn-icon {
  width: 28px; height: 28px;
  border-radius: var(--r-md);
  background: transparent;
  border: 0;
  color: var(--fg-muted);
  display: grid; place-items: center;
  cursor: pointer;
  min-height: 28px;
}
.side-foot .btn-icon:hover { background: var(--bg-2); color: var(--fg); }


/* ══════════ MAIN ══════════ */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg-0);
}


/* ══════════ TOPBAR (neu, ruhig) ══════════ */
/* Override der alten .top */
.top {
  background: var(--bg-0) !important;
  border-bottom: 1px solid var(--line) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  min-height: 52px;
  padding: calc(10px + var(--safe-t)) calc(20px + var(--safe-r)) 10px calc(20px + var(--safe-l)) !important;
  gap: 10px !important;
}

.t-logo {
  font-family: var(--f-sans) !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  color: var(--fg) !important;
  background: none !important;
  -webkit-text-fill-color: var(--fg) !important;
  letter-spacing: -.01em !important;
}

.t-sep {
  background: var(--line) !important;
}

.t-user {
  background: var(--bg-1) !important;
  border: 1px solid var(--line) !important;
  padding: 4px 10px !important;
  border-radius: var(--r-md) !important;
}
.t-user > div div:first-child { font-size: 11px !important; color: var(--fg); }
.t-user > div div:last-child { font-size: 10px !important; color: var(--fg-dim); }
.t-av { font-size: 9px !important; }

.t-btn {
  background: transparent !important;
  border: 1px solid var(--line) !important;
  color: var(--fg-muted) !important;
  font-size: 11px !important;
  padding: 6px 10px !important;
  border-radius: var(--r-md) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  min-height: 32px;
}
.t-btn:hover {
  background: var(--bg-2) !important;
  color: var(--fg) !important;
  border-color: var(--line-2) !important;
}
.t-btn.lo { color: var(--fg-dim) !important; }
.t-btn.lo:hover { color: var(--err) !important; border-color: var(--err) !important; }

.news-badge {
  background: var(--accent) !important;
  color: #000 !important;
}


/* ══════════ NAV (horizontale Tab-Leiste in .main) ══════════ */
/* Wird auf Desktop weich unsichtbar, weil Sidebar aktiv ist.
   Auf Mobile übernimmt die Bottom-Nav. Falls User Nav trotzdem nutzt (z.B. für Tabs innerhalb einer Page), bleibt sie stylebar. */

.nav {
  background: var(--bg-0) !important;
  border-bottom: 1px solid var(--line) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  padding: 0 calc(20px + var(--safe-r)) 0 calc(20px + var(--safe-l)) !important;
  gap: 2px !important;
}

/* Auf Desktop die alte Tab-Leiste verstecken — Sidebar ersetzt sie */
@media (min-width: 821px) {
  .nav { display: none !important; }
}
/* Auf Mobile .nav bleibt sichtbar fuer volle Tab-Navigation
   (Bottom-Nav deckt nur die 5 wichtigsten Tabs ab) */

.nt {
  color: var(--fg-dim) !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  padding: 12px 10px !important;
  border-bottom: 2px solid transparent !important;
  /* Override inline color/border-color from index.html style attrs */
  border-color: transparent !important;
}
.nt:hover { color: var(--fg-muted) !important; }
.nt.on {
  color: var(--accent) !important;
  border-bottom-color: var(--accent) !important;
  font-weight: 600 !important;
  background: transparent !important;
}


/* ══════════ BOTTOM NAV (Mobile) ══════════ */
.bnav {
  display: none;
}

@media (max-width: 820px) {
  .bnav {
    display: grid;
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(10px + var(--safe-b));
    grid-template-columns: repeat(5, 1fr);
    padding: 5px;
    background: color-mix(in oklab, var(--bg-1) 94%, transparent);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-2);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    z-index: 9999; /* ueber Demo-Banner (9998) */
  }
  /* Wenn Demo-Banner aktiv: Bottom-Nav darueber positionieren */
  html.demo-mode .bnav {
    bottom: calc(60px + var(--safe-b));
  }
  .bnav a, .bnav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 2px;
    border-radius: 10px;
    color: var(--fg-muted);
    font-size: 9.5px;
    font-weight: 500;
    line-height: 1.1;
    background: transparent;
    border: 0;
    cursor: pointer;
    min-height: 44px;
    text-decoration: none;
  }
  .bnav a .ic, .bnav button .ic { width: 16px; height: 16px; }
  /* SVG Icons in bnav (ersetzt die Emoji-Glyphen) */
  .bnav .bn-icon {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
  }
  .bnav .bn-icon svg {
    width: 22px;
    height: 22px;
    display: block;
  }
  .bnav a.on, .bnav button.on {
    color: var(--fg);
    background: var(--bg-2);
  }
  .bnav a.on .ic, .bnav button.on .ic { color: var(--accent); }
  .bnav a.on .bn-icon svg,
  .bnav button.on .bn-icon svg { stroke-width: 2; color: var(--accent); }

  /* Page-Padding unten, damit Bottom-Nav nichts verdeckt */
  .pg { padding-bottom: calc(88px + var(--safe-b)) !important; }
  /* Wenn Demo-Banner aktiv: zusaetzlicher Platz fuer Bnav+Banner */
  html.demo-mode .pg { padding-bottom: calc(140px + var(--safe-b)) !important; }
}


/* ══════════ PAGE PADDING (Desktop) ══════════ */
@media (min-width: 821px) {
  .pg { padding: 28px 32px !important; }
}


/* ══════════ MEHR BOTTOM-SHEET (Mobile) ══════════ */
#bnavSheet {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10001;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  align-items: flex-end;
}
#bnavSheet.on { display: flex; }

.bs-sheet {
  width: 100%;
  background: var(--bg-1);
  border-radius: 20px 20px 0 0;
  padding: 12px 16px calc(24px + var(--safe-b));
  border-top: 1px solid var(--line);
  animation: sheetUp .22s var(--ease);
}
@keyframes sheetUp {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.bs-handle {
  width: 36px; height: 4px;
  background: var(--line-2);
  border-radius: 99px;
  margin: 0 auto 12px;
}

/* Sheet Header */
.bs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 2px;
}
.bs-h-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
}
.bs-h-sub {
  font-size: 11px;
  font-weight: 400;
  color: var(--fg-dim);
  margin-left: 4px;
}
.bs-edit-btn {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--fg-muted);
  padding: 4px 8px;
  font-size: 13px;
  cursor: pointer;
  min-height: 28px;
}
.bs-edit-btn:hover { background: var(--bg-2); color: var(--fg); }
.bs-done-btn {
  background: var(--accent);
  color: #000;
  border: 0;
  border-radius: var(--r-md);
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  min-height: 28px;
  font-family: var(--f-sans);
}

/* Edit mode: selected item (in bnav) */
.bs-grid button.bs-sel {
  background: var(--accent-weak);
  border-color: var(--accent);
  color: var(--fg);
}
.bs-chk {
  font-size: 10px;
  color: var(--accent);
  font-weight: 700;
  min-height: 12px;
  display: block;
}

.bs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.bs-grid button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  border-radius: 14px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--fg-muted);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  min-height: 72px;
  font-family: var(--f-sans);
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.bs-grid button .bs-ic {
  font-size: 22px;
  line-height: 1;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
}
.bs-grid button .bs-ic svg {
  width: 22px;
  height: 22px;
  display: block;
}
.bs-grid button:hover,
.bs-grid button.on {
  background: var(--bg-3);
  color: var(--fg);
}
.bs-grid button.on { border-color: var(--accent); }


/* ══════════ MOBILE CHROME (mob-header + cleanup) ══════════ */

/* Desktop: kein mob-header */
.mob-header { display: none; }

@media (max-width: 820px) {
  /* Alte Topbar + horizontale Tab-Nav komplett weg auf Mobile */
  #app.on .top { display: none !important; }
  #app.on .nav { display: none !important; }

  /* Neuer schlanker Mobile-Header (Titel + News + Settings + Logout) */
  .mob-header {
    display: flex;
    align-items: center;
    gap: 6px;
    position: sticky;
    top: 0;
    z-index: 500;
    padding: calc(10px + var(--safe-t)) calc(14px + var(--safe-r)) 10px calc(14px + var(--safe-l));
    min-height: 52px;
    background: var(--bg-0);
    border-bottom: 1px solid var(--line);
  }
  .mob-header .title {
    flex: 1;
    font-weight: 600;
    font-size: 15px;
    letter-spacing: -0.01em;
    color: var(--fg);
    font-family: var(--f-sans);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mob-header .mh-btn {
    width: 36px;
    height: 36px;
    min-height: 36px;
    border-radius: var(--r-md);
    background: transparent;
    border: 1px solid transparent;
    color: var(--fg-muted);
    display: grid;
    place-items: center;
    cursor: pointer;
    font-size: 15px;
    position: relative;
  }
  .mob-header .mh-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    display: block;
  }
  .mob-header .mh-btn:hover,
  .mob-header .mh-btn:active {
    background: var(--bg-2);
    color: var(--fg);
  }
  .mob-header .mh-btn.mh-logout { color: var(--fg-dim); }
  .mob-header .mh-btn.mh-logout:hover { color: var(--err); background: transparent; }
  .mob-header .mh-badge {
    position: absolute;
    top: 3px; right: 3px;
    min-width: 14px; height: 14px;
    padding: 0 3px;
    border-radius: 99px;
    background: var(--accent);
    color: #000;
    font-size: 9px;
    font-weight: 700;
    display: grid;
    place-items: center;
    line-height: 1;
  }
}


/* ══════════ LOADER ══════════ */
#ld { background: var(--bg-0) !important; }
#ld .logo {
  font-family: var(--f-sans) !important;
  font-weight: 700 !important;
  background: none !important;
  -webkit-text-fill-color: var(--fg) !important;
  color: var(--fg) !important;
  letter-spacing: -.02em;
}
