/* ============================================================================
   Phase 6 Step 2 — App shell (FlyWP IA): top app-bar + More menu + avatar menu
   + mobile bottom-nav + resource-scoped sidebar.
   ADDITIVE & ISOLATED: nothing here applies until dashboard.html opts in by
   rendering .appbar / .bottomnav. Old .sb/.topbar styles remain untouched in
   layout.css until the swap is verified. All colors via base.css tokens.
   ============================================================================ */

/* ---- top app bar -------------------------------------------------------- */
.appbar{
  position:fixed;top:0;left:0;right:0;height:var(--th,58px);z-index:40;
  display:flex;align-items:center;gap:var(--s-4,16px);
  padding:0 var(--s-5,20px);
  background:var(--w);border-bottom:1px solid var(--b1);
}
.appbar-brand{display:flex;align-items:center;gap:var(--s-2,8px);flex-shrink:0;text-decoration:none;}
.appbar-brand .logo{
  width:30px;height:30px;border-radius:var(--radius-sm,6px);
  background:var(--a);color:#fff;display:flex;align-items:center;justify-content:center;
  font-weight:700;font-size:14px;letter-spacing:.5px;
}
.appbar-brand .name{font-weight:700;font-size:15px;color:var(--t1);white-space:nowrap;}
.appbar-brand .name em{font-style:normal;color:var(--a);}

/* primary nav */
.appbar-nav{display:flex;align-items:center;gap:2px;height:100%;}
/* Mockup topnav: pill nav items (rounded highlight), not an underline. */
.appbar-nav a,.appbar-nav .navlink{
  position:relative;display:inline-flex;align-items:center;gap:6px;
  padding:7px 12px;border-radius:var(--radius-sm,6px);font-size:14px;font-weight:500;color:var(--t2);
  text-decoration:none;cursor:pointer;border:0;background:none;
  transition:background .12s,color .12s;white-space:nowrap;
}
.appbar-nav a:hover,.appbar-nav .navlink:hover{background:var(--bg2);color:var(--t1);}
.appbar-nav a.on,.appbar-nav .navlink.on{background:var(--ab);color:var(--a);}
.appbar-nav svg{width:16px;height:16px;flex-shrink:0;}
.appbar-nav .nb{
  min-width:16px;height:16px;padding:0 4px;border-radius:8px;font-size:10px;font-weight:700;
  display:inline-flex;align-items:center;justify-content:center;background:var(--y);color:#fff;
}
.appbar-nav .nb.r{background:var(--r);}

.appbar-spacer{flex:1;}

/* right cluster */
.appbar-right{display:flex;align-items:center;gap:var(--s-2,8px);flex-shrink:0;}
.appbar-search{
  display:flex;align-items:center;gap:8px;height:34px;width:230px;max-width:30vw;
  padding:0 10px;border-radius:var(--radius-sm,6px);border:1px solid var(--b1);
  background:var(--bg2);color:var(--t3);font-size:14px;cursor:text;transition:border-color .12s;
}
.appbar-search:focus-within{border-color:var(--a);background:var(--w);}
.appbar-search svg{width:15px;height:15px;color:var(--t3);flex-shrink:0;}
.appbar-search input{border:0;background:none;outline:0;flex:1;font:inherit;color:var(--t1);min-width:0;}
.appbar-search kbd{
  font-family:var(--mono);font-size:10px;color:var(--t4);border:1px solid var(--b1);
  border-radius:4px;padding:1px 5px;background:var(--w);
}
/* Mockup .tb-btn: bordered white square icon buttons. */
.appbar-ic{
  width:34px;height:34px;border-radius:var(--radius-sm,6px);border:1px solid var(--b1);
  display:flex;align-items:center;justify-content:center;color:var(--t2);cursor:pointer;
  background:var(--w);position:relative;transition:background .12s,color .12s,border-color .12s;
}
.appbar-ic:hover{background:var(--bg2);color:var(--t1);}
.appbar-ic svg{width:18px;height:18px;}
.appbar-ic .nd{position:absolute;top:7px;right:8px;width:7px;height:7px;border-radius:50%;background:var(--r);border:1.5px solid var(--w);}

/* avatar + dropdown */
.appbar-avatar{
  width:34px;height:34px;border-radius:50%;background:var(--a);color:#fff;
  display:flex;align-items:center;justify-content:center;font-weight:600;font-size:14px;
  cursor:pointer;border:0;flex-shrink:0;
}
.menu-pop{
  position:absolute;top:calc(100% + 8px);right:0;min-width:230px;z-index:60;
  background:var(--w);border:1px solid var(--b1);border-radius:var(--radius,8px);
  box-shadow:var(--shadow-lg);padding:6px;
  opacity:0;visibility:hidden;transform:translateY(-4px);transition:opacity .14s,transform .14s,visibility .14s;
}
.menu-pop.open{opacity:1;visibility:visible;transform:translateY(0);}
.menu-pop .mh{padding:10px 10px 8px;border-bottom:1px solid var(--b1);margin-bottom:6px;}
.menu-pop .mh .nm{font-weight:600;font-size:13.5px;color:var(--t1);}
.menu-pop .mh .rl{font-size:11.5px;color:var(--t3);margin-top:1px;}
.menu-item{
  display:flex;align-items:center;gap:10px;width:100%;padding:8px 10px;border:0;background:none;
  border-radius:var(--radius-sm,6px);font-size:14px;color:var(--t2);cursor:pointer;text-align:left;
  text-decoration:none;transition:background .1s,color .1s;
}
.menu-item:hover{background:var(--bg2);color:var(--t1);}
.menu-item svg{width:16px;height:16px;flex-shrink:0;color:var(--t3);}
.menu-item.danger{color:var(--r);}
.menu-item.danger svg{color:var(--r);}
.menu-item.danger:hover{background:var(--rb);}
.menu-item .nb{margin-left:auto;min-width:16px;height:16px;padding:0 5px;border-radius:8px;font-size:10px;font-weight:700;display:inline-flex;align-items:center;justify-content:center;background:var(--y);color:#fff;}
.menu-sep{height:1px;background:var(--b1);margin:6px 0;}
.menu-pop .menu-grp{font-size:10px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:var(--t3);padding:9px 10px 3px;}
.menu-pop.menu-pop-more{min-width:248px;padding:7px;}
.menu-pop.menu-pop-more .menu-item{padding:9px 10px;font-size:14px;border-radius:9px;}
.menu-pop.menu-pop-more .menu-item svg{width:17px;height:17px;}
.menu-pop.menu-pop-more .mh{padding:9px 10px 9px;margin-bottom:3px;}
.menu-status{display:flex;align-items:center;gap:7px;padding:8px 10px;font-size:11.5px;color:var(--t3);}
.menu-status .dot{width:7px;height:7px;border-radius:50%;background:var(--g);box-shadow:0 0 0 3px var(--gb);}

/* "More" wrapper so the popup anchors under the trigger */
.appbar-more{position:relative;height:100%;display:flex;align-items:center;}
.appbar-more .menu-pop{min-width:200px;}

/* the avatar wrapper anchors its menu */
.appbar-acct{position:relative;}

/* ---- body offset when appbar shell is active --------------------------- */
body.shell-appbar{display:block;padding-top:var(--th,58px);}
/* hide the legacy left sidebar + top bar; their nodes stay in the DOM so any
   JS that reads their ids/badges keeps working — we only hide the frame. */
body.shell-appbar > aside.sb{display:none!important;}
body.shell-appbar > header.topbar{display:none!important;}
/* The old mobile ☰ FAB toggled the now-hidden .sb sidebar — dead in the appbar
   shell. Hide it (and its backdrop); mobile nav is the bottom-nav + More sheet. */
body.shell-appbar .mob-toggle,
body.shell-appbar .mob-backdrop{display:none!important;}
/* body already pads top by --th to clear the fixed appbar; .main must NOT pad
   top again (that double-counted the appbar height → big gap under the topbar). */
body.shell-appbar .main{margin-left:0!important;width:100%;padding-top:0;}
body.shell-appbar .content{max-width:1320px;margin:0 auto;padding:var(--s-6,24px) var(--s-6,24px) 80px;}

/* ---- mobile bottom nav -------------------------------------------------- */
.bottomnav{
  display:none;position:fixed;left:0;right:0;bottom:0;z-index:45;height:58px;
  background:var(--w);border-top:1px solid var(--b1);
  padding-bottom:env(safe-area-inset-bottom,0);
}
.bottomnav a,.bottomnav .navlink{
  flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;
  font-size:10.5px;font-weight:500;color:var(--t3);text-decoration:none;cursor:pointer;
  border:0;background:none;position:relative;
}
.bottomnav a.on,.bottomnav .navlink.on{color:var(--a);}
.bottomnav svg{width:21px;height:21px;}
.bottomnav .nb{position:absolute;top:6px;left:50%;margin-left:4px;min-width:15px;height:15px;padding:0 4px;border-radius:8px;font-size:9px;font-weight:700;display:inline-flex;align-items:center;justify-content:center;background:var(--y);color:#fff;}

/* mobile "More" sheet */
.sheet-overlay{position:fixed;inset:0;z-index:70;background:rgba(0,0,0,.4);opacity:0;visibility:hidden;transition:opacity .2s,visibility .2s;}
.sheet-overlay.open{opacity:1;visibility:visible;}
.sheet{
  position:fixed;left:0;right:0;bottom:0;z-index:71;background:var(--w);
  border-radius:16px 16px 0 0;padding:8px 12px calc(16px + env(safe-area-inset-bottom,0));
  transform:translateY(100%);transition:transform .24s cubic-bezier(.32,.72,0,1);max-height:80vh;overflow-y:auto;
}
.sheet.open{transform:translateY(0);}
.sheet .grip{width:36px;height:4px;border-radius:2px;background:var(--b2);margin:8px auto 12px;}
.sheet .sgrid{display:grid;grid-template-columns:repeat(4,1fr);gap:4px;}
.sheet .sitem{display:flex;flex-direction:column;align-items:center;gap:6px;padding:14px 6px;border-radius:var(--radius,8px);font-size:11px;color:var(--t2);text-decoration:none;cursor:pointer;border:0;background:none;text-align:center;}
.sheet .sitem:hover,.sheet .sitem:active{background:var(--bg2);}
.sheet .sitem svg{width:22px;height:22px;color:var(--t2);}
.sheet .ssep{grid-column:1/-1;height:1px;background:var(--b1);margin:6px 0;}

/* ---- responsive --------------------------------------------------------- */
@media(max-width:1100px){
  .appbar-nav .navlabel{display:none;}      /* icon-only primary nav on tablet */
  .appbar-search{width:160px;}
}
@media(max-width:760px){
  body.shell-appbar{padding-bottom:58px;}
  .appbar-nav,.appbar-more{display:none;}    /* primary nav moves to bottom-nav */
  .appbar-search{display:none;}
  .appbar-ic.opt-hide{display:none;}
  .bottomnav{display:flex;}
  body.shell-appbar .content{padding:24px var(--s-4,16px) 76px;}
  /* Above the bottom nav, not on it: at 24px it covered "More". */
  .scroll-top{bottom:calc(58px + 16px + env(safe-area-inset-bottom,0px));right:16px;width:44px;height:44px;}
}
