/* Shared app chrome: mobile drawer nav + scroll helpers */

/*
 * Lock the signed-in shell so the sidebar / mobile topbar stay put while the
 * page content scrolls. Page-level CSS is inconsistent (some sidebars sticky,
 * some not; some .main overflow, some grow the document) — this is the single
 * source of truth once body.app-shell is applied by app-shell.js.
 */
/* Prefer class set by app-shell.js; :has() is a no-JS-wait fallback */
html.app-shell-lock,
html:has(body.app-shell){
  height:100%;
  overflow:hidden;
}
body.app-shell{
  display:flex;
  height:100%;
  max-height:100%;
  min-height:0;
  overflow:hidden;
  margin:0;
}
/* Desktop: pin sidebar; only main column scrolls */
@media (min-width:901px){
  body.app-shell .sidebar{
    position:sticky !important;
    top:0 !important;
    align-self:flex-start;
    height:100vh !important;
    max-height:100vh !important;
    overflow-x:hidden;
    overflow-y:auto;
    flex-shrink:0;
    -webkit-overflow-scrolling:touch;
  }
  body.app-shell .main,
  body.app-shell .main-wrap{
    flex:1 1 auto;
    min-width:0;
    min-height:0;
    height:100%;
    max-height:100vh;
    overflow-x:hidden;
    overflow-y:auto !important;
    -webkit-overflow-scrolling:touch;
  }
}

.nav-topbar{
  display:none;align-items:center;gap:12px;
  position:sticky;top:0;z-index:200;
  padding:10px 14px;background:#11161f;
  border-bottom:1px solid #2e3d4e;
  flex-shrink:0;
}
.nav-topbar .brand-mini img{
  height:26px;width:auto;max-height:26px;display:block;object-fit:contain;
}
.nav-toggle{
  display:inline-flex;align-items:center;justify-content:center;
  width:42px;height:42px;padding:0;border-radius:10px;cursor:pointer;
  background:#1a202c;border:1px solid #2e3d4e;color:#e8eef4;font-size:20px;line-height:1;
}
.nav-toggle:hover{border-color:#f0a844;color:#f0a844}
.sidebar-backdrop{
  display:none;position:fixed;inset:0;z-index:250;
  background:rgba(0,0,0,.55);backdrop-filter:blur(2px);
}
.sidebar-backdrop.show{display:block}

@media (max-width:900px){
  body.app-shell{
    flex-direction:column;
    height:100%;
    max-height:100%;
    overflow:hidden;
  }
  .nav-topbar{
    display:flex;
    position:sticky;
    top:0;
    z-index:200;
    flex-shrink:0;
  }
  .sidebar{
    position:fixed !important;top:0;left:0;bottom:0;
    width:min(280px,86vw) !important;height:100vh !important;max-height:100vh !important;
    z-index:300;transform:translateX(-105%);
    transition:transform .22s ease;
    border-right:1px solid #2e3d4e !important;
    border-bottom:0 !important;
    overflow-y:auto !important;
    box-shadow:8px 0 32px rgba(0,0,0,.45);
  }
  .sidebar.open{transform:translateX(0)}
  .sidebar nav{
    display:flex !important;flex-direction:column !important;flex-wrap:nowrap !important;gap:2px !important;
  }
  .sidebar nav a{
    padding:12px 14px !important;font-size:15px !important;min-height:44px;
    display:flex !important;align-items:center;
  }
  body.app-shell .main,
  body.app-shell .main-wrap{
    width:100%;
    max-width:100%;
    flex:1 1 auto;
    min-height:0;
    height:auto;
    overflow-y:auto !important;
    -webkit-overflow-scrolling:touch;
    padding-left:16px;
    padding-right:16px;
  }
  body.app-shell.nav-open{overflow:hidden}
  /* Dashboard / grids that use 12-col spans */
  .grid .span-7,.grid .span-5,.grid .span-4,.grid .span-8,.grid .span-12,
  .span-7,.span-5,.span-4,.span-8,.span-12{grid-column:1 / -1 !important}
  .field-row{grid-template-columns:1fr !important}
  button,.btn,select,input,textarea{min-height:42px}
}

/* Tablet: denser chrome, still room for sidebar */
@media (min-width:901px) and (max-width:1100px){
  .sidebar{width:200px !important;padding:16px 12px !important}
  .sidebar nav a{padding:9px 10px !important;font-size:13px !important}
  .main,.main-wrap{padding-left:20px;padding-right:18px}
}

@media (min-width:901px){
  .nav-topbar{display:none !important}
  .sidebar-backdrop{display:none !important}
}

/* Safe area for notched phones */
@supports (padding: env(safe-area-inset-bottom)){
  .nav-topbar{padding-left:max(14px,env(safe-area-inset-left));padding-right:max(14px,env(safe-area-inset-right))}
  body.app-shell .sidebar{padding-bottom:max(16px,env(safe-area-inset-bottom))}
}

/* —— Profile switcher (all pages) —— */
.nav-profile-slot{margin:10px 0 14px;position:relative;z-index:50}
.nav-profile-slot.sidebar-slot{display:block}
.nav-topbar .nav-profile-slot{margin:0 0 0 auto;flex-shrink:0}
.profile-switch{position:relative;width:100%}
.profile-chip{
  display:flex;align-items:center;gap:10px;width:100%;
  padding:10px 12px;border-radius:12px;cursor:pointer;
  background:linear-gradient(180deg,#1e2633,#171d28);
  border:1px solid #3d4d62;color:#e8eef4;
  font:600 13px 'Sora',system-ui,sans-serif;text-align:left;
  transition:border-color .12s,box-shadow .12s;
  box-shadow:0 2px 8px rgba(0,0,0,.25);
  text-decoration:none;
}
.profile-chip:hover{border-color:#f0a844;box-shadow:0 0 0 1px rgba(240,168,68,.25)}
.profile-chip:disabled{opacity:.7;cursor:wait}
.profile-chip .p-av{
  width:34px;height:34px;border-radius:50%;flex-shrink:0;
  display:flex;align-items:center;justify-content:center;font-size:16px;
  border:2px solid rgba(255,255,255,.12);
}
.profile-chip .p-av.sm,.profile-opt .p-av.sm{width:28px;height:28px;font-size:13px;border-width:0}
.profile-chip .p-meta{display:flex;flex-direction:column;min-width:0;flex:1}
.profile-chip .p-label{font-size:10px;text-transform:uppercase;letter-spacing:.07em;color:#93a5b8;font-weight:600}
.profile-chip .p-name{font-size:13.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#e8eef4}
.profile-chip .p-caret{color:#f0a844;font-size:12px;flex-shrink:0}
/* Mobile top bar: compact chip with icon + caret */
.nav-topbar .profile-chip{width:auto;max-width:none;padding:6px 10px 6px 6px;gap:6px}
.nav-topbar .profile-chip .p-meta{display:none}
.nav-topbar .profile-chip .p-av{width:30px;height:30px}

.profile-menu{
  position:absolute;top:calc(100% + 6px);left:0;right:0;z-index:500;
  background:#1f2937;border:1px solid #3d4d62;border-radius:12px;
  box-shadow:0 16px 48px rgba(0,0,0,.55);padding:6px;max-height:min(60vh,380px);overflow-y:auto;
}
.profile-menu-title{
  font:600 10px 'Sora',system-ui,sans-serif;text-transform:uppercase;letter-spacing:.08em;
  color:#93a5b8;padding:8px 10px 6px;
}
.nav-topbar .profile-menu{left:auto;right:0;min-width:240px}
.profile-opt{
  display:flex;align-items:center;gap:10px;width:100%;
  padding:10px 10px;border-radius:9px;border:none;background:transparent;
  color:#e8eef4;font:600 13px 'Sora',system-ui,sans-serif;cursor:pointer;text-align:left;
  text-decoration:none;
}
.profile-opt:hover{background:#2a3342}
.profile-opt.active{background:rgba(240,168,68,.14)}
.profile-opt .p-opt-name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.profile-opt .p-check{color:#f0a844;font-size:14px}
.profile-opt.manage{
  margin-top:4px;border-top:1px solid #2e3d4e;border-radius:0 0 8px 8px;
  color:#f0a844;justify-content:center;font-size:12.5px;padding-top:12px;
}

/* Ensure page-level mobile sidebar CSS doesn't hide the slot */
@media (max-width:900px){
  .nav-profile-slot.sidebar-slot{display:block;margin:8px 0 12px}
}

/* —— Sidebar foot (signed-in + sign out) + Discord on every page —— */
.sidebar.shell-sidebar{
  display:flex !important;
  flex-direction:column !important;
}
.sidebar.shell-sidebar > div:first-child{
  flex:1 1 auto;
  min-height:0;
}
.shell-foot,
.sidebar .foot[data-shell-foot]{
  margin-top:auto !important;
  padding-top:16px !important;
  border-top:1px solid #2e3d4e;
  display:flex !important;
  flex-direction:column;
  gap:10px;
  flex-shrink:0;
}
.shell-who,
.sidebar .foot .who{
  font-size:13px;
  color:#93a5b8;
  margin:0;
}
.shell-who b,
.sidebar .foot .who b{
  color:#f0a844;
  font-weight:600;
}
.shell-logout,
.sidebar .foot button,
.sidebar .foot [data-shell-logout]{
  font:600 13px 'Sora',system-ui,sans-serif;
  padding:9px 12px;
  border-radius:8px;
  cursor:pointer;
  background:#1a202c;
  border:1px solid #2e3d4e;
  color:#e8eef4;
  width:100%;
  text-align:center;
}
.shell-logout:hover,
.sidebar .foot button:hover{
  border-color:#f0a844;
  color:#f0a844;
}
.shell-discord{
  display:flex !important;
  align-items:center;
  gap:8px;
  margin-top:8px !important;
  padding:10px 12px !important;
  border-radius:10px;
  background:#5865F2;
  color:#fff !important;
  font:600 13.5px 'Sora',system-ui,sans-serif !important;
}
.shell-discord:hover{
  background:#4752c4;
  color:#fff !important;
}
.shell-discord svg{
  width:16px;
  height:16px;
  flex-shrink:0;
}

@media (max-width:900px){
  .sidebar.shell-sidebar{
    /* drawer already flexes; keep foot visible at bottom of drawer */
  }
  .shell-foot,
  .sidebar .foot[data-shell-foot]{
    margin-top:20px !important;
  }
}

/* —— What's New: nav entry + popup —— */
.shell-whatsnew{
  position:relative;
  display:flex !important;
  align-items:center;
  gap:9px;
}
.wn-nav-ico{font-size:14px;line-height:1;flex-shrink:0}
.wn-nav-dot{
  width:7px;height:7px;border-radius:50%;
  background:#f0a844;flex-shrink:0;margin-left:2px;
  box-shadow:0 0 0 3px rgba(240,168,68,.18);
}

.wn-overlay{
  position:fixed;inset:0;z-index:900;
  display:flex;align-items:center;justify-content:center;
  padding:20px;
  background:rgba(10,13,18,.62);
  backdrop-filter:blur(4px);-webkit-backdrop-filter:blur(4px);
  animation:wn-fade .16s ease;
}
.wn-overlay[hidden]{display:none}
@keyframes wn-fade{from{opacity:0}to{opacity:1}}
@keyframes wn-pop{from{opacity:0;transform:translateY(8px) scale(.98)}to{opacity:1;transform:none}}

.wn-modal{
  width:100%;max-width:440px;max-height:min(84vh,640px);
  display:flex;flex-direction:column;
  background:linear-gradient(180deg,#232f3e,#1a2330);
  border:1px solid #34455a;border-radius:18px;
  box-shadow:0 24px 64px -20px rgba(0,0,0,.65);
  padding:22px 22px 18px;
  position:relative;
  animation:wn-pop .18s cubic-bezier(.2,.9,.3,1.2);
}
.wn-close{
  position:absolute;top:14px;right:14px;
  width:30px;height:30px;border-radius:9px;
  display:flex;align-items:center;justify-content:center;
  background:#1a202c;border:1px solid #2e3d4e;color:#93a5b8;
  cursor:pointer;font-size:13px;line-height:1;
}
.wn-close:hover{border-color:#f0a844;color:#f0a844}
.wn-head{display:flex;align-items:center;gap:13px;margin:0 26px 14px 0}
.wn-badge{
  width:42px;height:42px;border-radius:12px;flex-shrink:0;
  display:flex;align-items:center;justify-content:center;font-size:19px;
  background:radial-gradient(circle at 30% 30%,rgba(240,168,68,.35),rgba(240,168,68,.08));
  border:1px solid rgba(240,168,68,.4);
}
.wn-head h2{margin:0;font:700 17px 'Sora',system-ui,sans-serif;color:#e8eef4;letter-spacing:-.01em}
.wn-sub{margin:2px 0 0;font-size:12.5px;color:#93a5b8}
.wn-body{overflow-y:auto;margin:0 -4px;padding:0 4px;flex:1 1 auto;min-height:40px}
.wn-loading{color:#93a5b8;font-size:13.5px;margin:8px 0}
.wn-entry{
  padding:14px 0;
  border-top:1px solid #2e3d4e;
}
.wn-entry:first-child{border-top:0;padding-top:0}
.wn-entry-top{display:flex;align-items:center;gap:9px;margin-bottom:5px}
.wn-ver{font:700 11px 'JetBrains Mono',ui-monospace,monospace;color:#f0a844;letter-spacing:.03em}
.wn-date{font-size:11.5px;color:#6b7d90}
.wn-entry h3{margin:0 0 6px;font:600 14.5px 'Sora',system-ui,sans-serif;color:#e8eef4}
.wn-entry ul{margin:0;padding-left:18px;color:#93a5b8;font-size:13px;line-height:1.65}
.wn-entry li{margin-bottom:2px}
.wn-footer-link{
  display:block;text-align:center;margin-top:14px;padding-top:14px;
  border-top:1px solid #2e3d4e;
  color:#f0a844;text-decoration:none;font:600 12.5px 'Sora',system-ui,sans-serif;
}
.wn-footer-link:hover{text-decoration:underline}
body.wn-open{overflow:hidden}

@media (max-width:480px){
  .wn-modal{padding:18px 16px 14px;border-radius:14px}
}
