/* ============================================================
   MOBILE NAV — Drawer + Bottom Tab Bar + Mobile UI
   ============================================================ */

/* ---------- Hamburger ---------- */
.hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px; height: 42px;
  border-radius: 12px;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.18);
  color: rgba(255,255,255,.92);
  font-size: 22px;
  cursor: pointer; padding: 0;
  transition: background .14s;
  flex: 0 0 auto;
  font-family: inherit; line-height: 1;
}
.hamburger:hover { background: rgba(255,255,255,.17); }

/* ---------- Overlay ---------- */
.mobileOverlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.58);
  z-index: 1199;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.mobileOverlay.open { display: block; animation: overlayIn .22s ease both; }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Drawer ---------- */
.mobileDrawer {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 290px; max-width: 90vw;
  z-index: 1200;
  background: #0d0a17;
  border-right: 1px solid rgba(255,255,255,.10);
  display: flex; flex-direction: column;
  overscroll-behavior: contain;
  -webkit-transform: translate3d(-100%, 0, 0);
  transform: translate3d(-100%, 0, 0);
  transition: transform .28s cubic-bezier(.4, 0, .2, 1);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.mobileDrawer.open {
  -webkit-transform: translate3d(0, 0, 0);
  transform: translate3d(0, 0, 0);
  box-shadow: 12px 0 40px rgba(0,0,0,.60);
}

.drawerHeader {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 16px 14px;
  padding-top: calc(20px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex: 0 0 auto;
}
.drawerLogo { display: flex; align-items: center; gap: 10px; }
.drawerLogoImg { width: 34px; height: 34px; border-radius: 9px; object-fit: cover; }
.drawerAppName { font-size: 15px; font-weight: 700; color: rgba(255,255,255,.92); }
.drawerClose {
  width: 36px; height: 36px; border-radius: 10px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12);
  color: rgba(255,255,255,.60); font-size: 18px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  padding: 0; font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.drawerClose:active { background: rgba(255,255,255,.15); }

.drawerUser {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex: 0 0 auto;
}
.drawerUserInner {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 13px; border-radius: 14px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08);
}
.drawerAvatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800; color: rgba(255,255,255,.9);
  flex: 0 0 auto; background: rgba(168,85,247,.35);
}
.drawerUserInfo { min-width: 0; }
.drawerUserName {
  font-size: 14px; font-weight: 600; color: rgba(255,255,255,.92);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.drawerUserRole { font-size: 11px; color: rgba(255,255,255,.42); margin-top: 2px; }

.drawerLinks {
  flex: 1; overflow-y: auto; padding: 10px;
  display: flex; flex-direction: column; gap: 2px;
  -webkit-overflow-scrolling: touch;
}
.drawerLinks::-webkit-scrollbar { width: 3px; }
.drawerLinks::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 2px; }

.drawerLink {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px; border-radius: 13px;
  text-decoration: none; font-size: 15px; font-weight: 500;
  color: rgba(255,255,255,.70); border: 1px solid transparent;
  min-height: 50px; -webkit-tap-highlight-color: transparent;
}
.drawerLink:active { background: rgba(255,255,255,.08); }
.drawerLink.active {
  background: linear-gradient(135deg, rgba(249,115,22,.18), rgba(168,85,247,.14));
  border-color: rgba(249,115,22,.25); color: rgba(255,255,255,.97); font-weight: 600;
}

.drawerFooter {
  padding: 12px 10px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(255,255,255,.06); flex: 0 0 auto;
}
.drawerLogout {
  width: 100%; padding: 14px; border-radius: 13px;
  background: rgba(239,68,68,.10); border: 1px solid rgba(239,68,68,.20);
  color: rgba(252,165,165,.85); font-size: 15px; font-weight: 600;
  cursor: pointer; text-align: center; font-family: inherit; min-height: 50px;
  -webkit-tap-highlight-color: transparent;
}
.drawerLogout:active { background: rgba(239,68,68,.22); }

/* ============================================================
   BOTTOM TAB BAR — Floating Pill Nav
   Schwebende Kapsel, nicht randlos — klar sichtbar & modern.
   ============================================================ */
.bottomTabBar {
  display: none;
  position: fixed;
  /* Floating: Seitenabstand + Abstand zum Bildschirmrand */
  left: 12px; right: 12px;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  z-index: 1100;

  /* Sichtbares dunkles Glas — klare Trennung vom Seiteninhalt */
  background: rgba(20, 13, 38, 0.92);
  -webkit-backdrop-filter: blur(36px) saturate(180%);
  backdrop-filter: blur(36px) saturate(180%);

  /* Kapsel-Form */
  border-radius: 26px;
  border: 1px solid rgba(255,255,255,.14);
  box-shadow:
    inset 0 1px 0   rgba(255,255,255,.20),   /* oberer Specular  */
    0 10px 40px     rgba(0,0,0,.55),          /* Tiefenschatten   */
    0 2px 10px      rgba(0,0,0,.30),          /* Nah-Schatten     */
    0 0 0 1px       rgba(255,255,255,.04);    /* äußerer Rim      */

  padding: 0 4px;
  overflow: hidden;
  align-items: stretch;

  /* Bar fliegt von unten rein */
  animation: lgBarUp .45s cubic-bezier(.34,1.15,.64,1) both;
}

/* ── Aktiv-Kapsel (Position + Breite via JS) ── */
.liquidPill {
  position: absolute;
  /* 5 px Abstand oben/unten → füllt den Bar besser aus, wirkt mittig */
  top: 5px; bottom: 5px;
  left: 0; width: 0;
  opacity: 0;
  border-radius: 18px;
  pointer-events: none;
  z-index: 1;
  /* JS schreibt transition direkt auf das Element */
  will-change: left, width, opacity;

  background: linear-gradient(
    140deg,
    rgba(249,115,22,.32) 0%,
    rgba(168,85,247,.24) 100%
  );
  border: 1px solid rgba(249,115,22,.38);
  box-shadow:
    inset 0 1px 0  rgba(255,255,255,.30),
    0 0 24px       rgba(249,115,22,.34),
    0 3px 14px     rgba(0,0,0,.30);

  animation: lgGlow 3.5s ease-in-out 2s infinite;
}

/* ── Tab-Item ── */
.tabItem {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px; padding: 10px 4px; min-height: 58px;
  text-decoration: none; border: none; background: none;
  cursor: pointer; font-family: inherit;
  color: rgba(255,255,255,.48);
  -webkit-tap-highlight-color: transparent;
  position: relative; -webkit-user-select: none; user-select: none;
  transition: color .15s ease, transform .10s ease;
  z-index: 2;
}
/* Ins Glas drücken */
.tabItem:active {
  transform: scale(0.84);
  transition: transform .05s ease;
}

/* Aktiver Tab: leuchtendes Orange */
.tabItem.active { color: #fb923c; }
.tabItem.active .tabIcon  { animation: lgIconPop .42s cubic-bezier(.34,1.56,.64,1) both; }
.tabItem.active .tabLabel { animation: lgLabelIn .26s ease .08s both; }

.tabIcon  { font-size: 22px; line-height: 1; display: block; }
.tabLabel { font-size: 10px; font-weight: 700; letter-spacing: .2px; white-space: nowrap; }

/* ════════════════════════════════════════════════════════════
   Keyframes
   ════════════════════════════════════════════════════════════ */
@keyframes lgBarUp {
  from { transform: translateY(calc(100% + 24px)); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
@keyframes lgGlow {
  0%, 100% {
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,.28),
      0 0 22px rgba(249,115,22,.30),
      0 3px 14px rgba(0,0,0,.28);
  }
  50% {
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,.34),
      0 0 34px rgba(249,115,22,.46),
      0 3px 18px rgba(0,0,0,.34);
  }
}
@keyframes lgIconPop {
  0%   { transform: scale(1)    translateY(0);   }
  36%  { transform: scale(1.32) translateY(-3px); }
  68%  { transform: scale(0.90) translateY(0);   }
  100% { transform: scale(1)    translateY(0);   }
}
@keyframes lgLabelIn {
  from { opacity: 0; transform: translateY(3px); }
  to   { opacity: 1; transform: translateY(0);   }
}

/* ============================================================
   APP-SHELL LAYOUT  (body.mobileShell)
   ─────────────────────────────────────────────────────────
   Kein position:fixed für die Tab Bar mehr!
   Body = flex column mit fixer Höhe.
   .mobileScrollWrap scrollt, Tab Bar bleibt unten.
   → Kein Springen, keine Viewport-Recalculation-Bugs.
   ============================================================ */
.mobileShell {
  display: flex !important;
  flex-direction: column !important;
  /* 100dvh = dynamic viewport, schrumpft NICHT wenn URL-Bar sichtbar */
  height: 100dvh !important;
  height: 100vh !important; /* Fallback für ältere Browser */
  height: 100dvh !important;
  overflow: hidden !important;
  padding: 0 !important;
}

.mobileShell .mobileScrollWrap {
  flex: 1 1 0;
  min-height: 0;           /* Pflicht: sonst kein Scroll in flex-Child */
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  /* Padding übernimmt was früher auf body war */
  padding: max(14px, env(safe-area-inset-top, 14px)) 14px 20px;
}

/* Tab Bar im App-Shell: kein fixed mehr, einfacher flex-Child.
   Floating-Pill bleibt sichtbar — Seitenabstand + Bodenabstand via margin */
.mobileShell .bottomTabBar {
  display: flex;
  position: static !important;
  flex: 0 0 auto;
  width: calc(100% - 24px);
  margin: 0 12px calc(10px + env(safe-area-inset-bottom, 0px));
  padding-bottom: 0;
}

/* ============================================================
   MOBILE OVERRIDES  (≤ 768px)
   ============================================================ */
@media (max-width: 768px) {

  /* Tab Bar anzeigen (wenn kein App-Shell, z.B. JS deaktiviert) */
  .bottomTabBar { display: flex; }

  /* Desktop-Nav verstecken */
  .navWrap   { display: none !important; }
  .hamburger { display: none !important; }
  .authFloating { display: none !important; }
  .brandRight   { display: none !important; }

  /* Header kompakt */
  .top {
    flex-direction: row !important; align-items: center !important;
    gap: 10px !important; margin-bottom: 14px !important; flex-wrap: nowrap !important;
  }
  h1        { font-size: 19px !important; letter-spacing: .1px !important; }
  .subtitle { font-size: 11px !important; margin-top: 2px !important; }
  .brandLogo {
    width: 36px !important; height: 36px !important;
    border-radius: 10px !important; padding: 4px !important;
  }

  /* Tap-Targets */
  .btn-primary, .btn-secondary, .btn-danger, .iconBtn, button { min-height: 44px; }

  /* Body-Padding (Fallback wenn kein App-Shell) */
  body {
    padding-top:    max(14px, env(safe-area-inset-top, 14px)) !important;
    padding-left:   14px !important;
    padding-right:  14px !important;
    /* Floating bar: 10px gap + ~58px Höhe + 16px extra */
    padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Cards */
  .card  { padding: 14px !important; border-radius: 18px !important; }
  .glass { border-radius: 18px !important; }

  /* KPI-Grid */
  .grid    { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  .kpi     { grid-column: span 1 !important; padding: 13px !important; }
  .kpiBig  { grid-column: span 1 !important; }
  .kpiFull { grid-column: 1 / -1 !important; }
  .kpiValue { font-size: 22px !important; }

  /* Tabellen */
  .tableWrap { border-radius: 14px !important; overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
  table { min-width: 580px; }
  th, td { padding: 10px !important; font-size: 13px !important; }

  /* Formular */
  input, select, textarea { font-size: 16px !important; min-height: 44px; }
  textarea { min-height: unset !important; }

  /* Modals */
  .modalCard { border-radius: 20px !important; max-height: 90dvh !important; }
}

@media (max-width: 390px) {
  .grid    { grid-template-columns: 1fr !important; }
  .kpiFull { grid-column: span 1 !important; }
  h1       { font-size: 17px !important; }
  .tabIcon { font-size: 20px !important; }
  .tabLabel { font-size: 9px !important; }
}
