/* ==========================================================================
   Mine platform console shell (topbar + page container)
   --------------------------------------------------------------------------
   Depends on console-ui.css for tokens and components. All colours come from
   var(--c-*); this file contains no palette definitions.
   Mount with ConsoleShell.mount({active, variant}).
   ========================================================================== */

.c-shell{
  display:flex;
  flex-direction:column;
  min-height:100dvh;
  background:var(--c-paper);
  color:var(--c-ink);
  font-family:var(--c-font);
}
.c-shell-main{
  flex:1;
  width:100%;
  min-width:0;
}

/* ==========================================================================
   Topbar
   ========================================================================== */

.c-topbar{
  position:sticky;
  top:0;
  z-index:40;
  border-bottom:1px solid var(--c-line);
  background:var(--c-topbar-bg);
  -webkit-backdrop-filter:blur(12px) saturate(1.1);
  backdrop-filter:blur(12px) saturate(1.1);
  box-sizing:border-box;
}
.c-topbar-inner{
  display:flex;
  align-items:center;
  gap:14px;
  width:100%;
  max-width:var(--c-page-max);
  min-height:var(--c-topbar-h);
  margin-inline:auto;
  padding:10px 32px;
  box-sizing:border-box;
}

.c-brand{
  display:inline-flex;
  align-items:center;
  gap:10px;
  flex:none;
  min-width:0;
  color:var(--c-ink);
  text-decoration:none;
}
.c-brand:hover{color:var(--c-ink)}
.c-brand-mark{
  display:inline-grid;
  grid-template-columns:repeat(2,7px);
  grid-template-rows:repeat(2,7px);
  gap:4px;
  place-content:center;
  width:38px;
  height:38px;
  flex:none;
  border:1px solid var(--c-brand-mark-border);
  border-radius:var(--c-radius);
  background:var(--c-brand-mark-bg);
  box-sizing:border-box;
}
.c-brand-mark i{
  display:block;
  background:var(--c-brand-dot);
  border-radius:1px;
}
.c-brand-mark i:last-child{background:var(--c-brand-dot-accent)}
.c-brand-text{
  display:flex;
  flex-direction:column;
  min-width:0;
  line-height:1.2;
}
.c-brand-name{
  color:var(--c-ink);
  font-size:14px;
  font-weight:650;
  letter-spacing:0;
  line-height:1.2;
  white-space:nowrap;
}
.c-brand-sub{
  margin-top:1px;
  color:var(--c-muted);
  font-size:10px;
  font-weight:600;
  letter-spacing:.08em;
  line-height:1.2;
  text-transform:uppercase;
  white-space:nowrap;
}

.c-topbar-nav{
  display:flex;
  align-items:center;
  gap:2px;
  min-width:0;
  overflow-x:auto;
  scrollbar-width:none;
}
.c-topbar-nav::-webkit-scrollbar{display:none}
.c-topbar-link{
  display:inline-flex;
  align-items:center;
  gap:6px;
  min-height:34px;
  padding:7px 12px;
  border:1px solid transparent;
  border-radius:var(--c-radius-sm);
  color:var(--c-muted);
  font-size:var(--c-text-md);
  font-weight:600;
  line-height:1.2;
  text-decoration:none;
  white-space:nowrap;
  transition:background-color .15s,color .15s,border-color .15s;
  box-sizing:border-box;
}
.c-topbar-link:hover{
  background:var(--c-surface-muted);
  color:var(--c-ink);
  text-decoration:none;
}
.c-topbar-link.is-active,
.c-topbar-link[aria-current="page"]{
  background:var(--c-accent-soft);
  border-color:var(--c-accent-line);
  color:var(--c-accent-strong);
}

.c-topbar-actions{
  display:flex;
  align-items:center;
  gap:8px;
  flex:none;
  margin-left:auto;
  min-width:0;
}
.c-topbar-actions-slot{
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
  min-width:0;
}
.c-topbar-actions-slot:empty{display:none}
.c-topbar-user-slot{display:flex;align-items:center;min-width:0}
.c-topbar-user-slot:empty{display:none}

.c-topbar-user{
  display:flex;
  align-items:center;
  min-width:0;
}
.c-topbar-user-avatar{
  display:grid;
  place-items:center;
  width:32px;
  height:32px;
  flex:none;
  border-radius:50%;
  background:var(--c-accent-soft);
  color:var(--c-accent-strong);
  font-size:var(--c-text-md);
  font-weight:700;
  line-height:1;
}
.c-topbar-user-text{
  display:flex;
  flex-direction:column;
  min-width:0;
  margin-left:8px;
  line-height:1.2;
}
.c-topbar-user-name{
  max-width:160px;
  overflow:hidden;
  color:var(--c-ink);
  font-size:var(--c-text-sm);
  font-weight:650;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.c-topbar-user-role{
  margin-top:1px;
  color:var(--c-muted);
  font-size:10px;
  font-weight:600;
  line-height:1.2;
  white-space:nowrap;
}

/* Native <details> account menu: no Bootstrap JS dependency. */
.c-user-menu{position:relative}
.c-user-menu-summary{
  display:flex;
  align-items:center;
  gap:8px;
  min-height:38px;
  padding:3px 8px 3px 4px;
  border:1px solid transparent;
  border-radius:var(--c-radius-pill);
  color:var(--c-ink);
  list-style:none;
  cursor:pointer;
  box-sizing:border-box;
}
.c-user-menu-summary::-webkit-details-marker{display:none}
.c-user-menu-summary::marker{content:""}
.c-user-menu-summary:hover{background:var(--c-surface-muted)}
.c-user-menu[open] .c-user-menu-summary{
  border-color:var(--c-line);
  background:var(--c-surface-muted);
}
.c-user-menu-caret{
  width:6px;
  height:6px;
  flex:none;
  margin-left:2px;
  border-right:1.5px solid var(--c-muted);
  border-bottom:1.5px solid var(--c-muted);
  transform:rotate(45deg);
}
.c-user-menu[open] .c-user-menu-caret{transform:rotate(-135deg)}
.c-user-menu-panel{
  position:absolute;
  right:0;
  top:calc(100% + 6px);
  z-index:60;
  min-width:210px;
  padding:6px;
  border:1px solid var(--c-line);
  border-radius:var(--c-radius);
  background:var(--c-surface);
  box-shadow:var(--c-shadow-lg);
  box-sizing:border-box;
}
.c-user-menu-link{
  display:flex;
  align-items:center;
  gap:8px;
  width:100%;
  padding:8px 10px;
  border:0;
  border-radius:var(--c-radius-sm);
  background:transparent;
  color:var(--c-ink);
  font-family:inherit;
  font-size:var(--c-text-md);
  line-height:1.4;
  text-align:left;
  text-decoration:none;
  cursor:pointer;
  box-sizing:border-box;
}
.c-user-menu-link:hover{
  background:var(--c-surface-muted);
  color:var(--c-accent-strong);
  text-decoration:none;
}
.c-user-menu-divider{
  height:1px;
  margin:5px 4px;
  background:var(--c-line);
}

.c-topbar-toggle{
  display:none;
  align-items:center;
  justify-content:center;
  width:38px;
  height:38px;
  flex:none;
  padding:0;
  border:1px solid var(--c-line-strong);
  border-radius:var(--c-radius);
  background:var(--c-surface);
  color:var(--c-muted);
  cursor:pointer;
  box-sizing:border-box;
}
.c-topbar-toggle:hover{
  background:var(--c-surface-muted);
  color:var(--c-ink);
}
.c-topbar-toggle-bars{
  display:flex;
  flex-direction:column;
  gap:3px;
  width:16px;
}
.c-topbar-toggle-bars i{
  display:block;
  width:100%;
  height:2px;
  border-radius:1px;
  background:currentColor;
  transition:transform .16s,opacity .16s;
}
.c-shell.is-nav-open .c-topbar-toggle-bars i:nth-child(1){transform:translateY(5px) rotate(45deg)}
.c-shell.is-nav-open .c-topbar-toggle-bars i:nth-child(2){opacity:0}
.c-shell.is-nav-open .c-topbar-toggle-bars i:nth-child(3){transform:translateY(-5px) rotate(-45deg)}

.c-topbar-link:focus-visible,
.c-brand:focus-visible,
.c-user-menu-summary:focus-visible,
.c-user-menu-link:focus-visible,
.c-topbar-toggle:focus-visible{
  outline:3px solid var(--c-focus-color);
  outline-offset:2px;
}

/* ==========================================================================
   Variants
   ========================================================================== */

.c-shell--public .c-page{max-width:1240px}

.c-shell--auth{background:var(--c-paper)}
.c-shell--auth .c-topbar{
  position:static;
  border-bottom:0;
  background:transparent;
  -webkit-backdrop-filter:none;
  backdrop-filter:none;
}
.c-shell--auth .c-topbar-inner{
  justify-content:center;
  min-height:0;
  padding:26px 16px 6px;
}
.c-shell--auth .c-brand-mark{
  grid-template-columns:repeat(2,7px);
  grid-template-rows:repeat(2,7px);
  gap:4px;
  width:42px;
  height:42px;
}
.c-shell--auth .c-brand-name{font-size:var(--c-text-lg)}
.c-shell--auth .c-brand-sub{display:block;font-size:var(--c-text-xs)}
.c-shell--auth .c-shell-main{
  display:grid;
  place-items:center;
  flex:1;
  padding:16px 16px 48px;
}
.c-shell--auth .c-page{
  width:100%;
  max-width:440px;
  padding:0;
}

/* When a page hides the topbar entirely, keep the same vertical rhythm. */
.c-shell--auth.c-shell--no-topbar .c-shell-main{padding-top:48px}

/* ==========================================================================
   Responsive topbar
   ========================================================================== */

@media(max-width:991.98px){
  .c-topbar-inner{
    flex-wrap:wrap;
    gap:8px 12px;
    min-height:0;
    padding:9px 18px;
  }
  .c-topbar-nav{
    display:none;
    order:3;
    flex-basis:100%;
    flex-direction:column;
    align-items:stretch;
    gap:2px;
    margin-top:2px;
    padding:6px 0 8px;
    border-top:1px solid var(--c-line);
    overflow:visible;
  }
  .c-shell.is-nav-open .c-topbar-nav{display:flex}
  .c-topbar-link{justify-content:flex-start;padding:10px 12px}
  .c-topbar-toggle{display:inline-flex}
  .c-topbar-actions{margin-left:auto}
}
@media(max-width:767.98px){
  .c-topbar-inner{padding:8px 14px}
  .c-brand-mark{
    grid-template-columns:repeat(2,6px);
    grid-template-rows:repeat(2,6px);
    gap:3px;
    width:34px;
    height:34px;
  }
  .c-brand-name{font-size:var(--c-text-md)}
  .c-brand-sub{display:none}
  .c-topbar-user-name{max-width:110px}
  .c-user-menu-summary{padding-right:6px}
  .c-shell--auth .c-topbar-inner{padding-top:22px}
}
@media(max-width:575.98px){
  .c-topbar-inner{padding:8px 12px}
  .c-topbar-user-text{display:none}
  .c-topbar-user-avatar{width:30px;height:30px}
  .c-user-menu-summary{min-height:34px;padding:2px 6px 2px 2px}
  .c-topbar-toggle{width:34px;height:34px}
  .c-user-menu-panel{
    position:fixed;
    top:60px;
    right:12px;
    left:auto;
    min-width:min(220px,calc(100vw - 24px));
  }
  .c-topbar-actions-slot .c-btn{
    min-height:34px;
    padding:6px 9px;
    font-size:var(--c-text-sm);
  }
  .c-shell--auth .c-topbar-inner{padding-top:20px}
  .c-shell--auth .c-shell-main{padding:12px 12px 40px}
}

@media(prefers-reduced-motion:reduce){
  .c-topbar-toggle-bars i,
  .c-topbar-link{transition:none}
}

/* ==========================================================================
   App shell — Tabler-style vertical sidebar is the single primary nav.
   Topbar only carries the current section, actions and the account menu.
   ========================================================================== */

.c-shell--sidebar{
  display:grid;
  grid-template-columns:248px minmax(0,1fr);
  align-items:start;
}
.c-shell-body{
  display:flex;
  flex-direction:column;
  min-width:0;
  min-height:100dvh;
}

.c-sidebar{
  position:sticky;
  top:0;
  z-index:50;
  display:flex;
  flex-direction:column;
  width:248px;
  height:100dvh;
  padding:18px 12px 12px;
  border-right:1px solid var(--c-line);
  background:var(--c-surface);
  box-sizing:border-box;
  overflow:hidden;
}
.c-sidebar-head{
  flex:none;
  padding:2px 8px 16px;
}
.c-sidebar-head .c-brand{gap:10px}
.c-sidebar-head .c-brand-mark{width:36px;height:36px}
.c-sidebar-head .c-brand-name{font-size:var(--c-text-md)}
.c-sidebar-head .c-brand-sub{font-size:9px}

.c-sidebar-nav{
  display:flex;
  flex-direction:column;
  gap:2px;
  min-height:0;
  padding:0 2px 12px;
  overflow-y:auto;
  scrollbar-width:thin;
}
.c-sidebar-section{
  margin:14px 10px 5px;
  color:var(--c-muted);
  font-size:10px;
  font-weight:700;
  letter-spacing:.1em;
  line-height:1.4;
  text-transform:uppercase;
}
.c-sidebar-link{
  display:flex;
  align-items:center;
  gap:10px;
  min-height:38px;
  padding:8px 10px;
  border:1px solid transparent;
  border-radius:var(--c-radius-sm);
  color:var(--c-muted);
  font-size:var(--c-text-md);
  font-weight:600;
  line-height:1.3;
  text-decoration:none;
  box-sizing:border-box;
  transition:background-color .15s,color .15s,border-color .15s;
}
.c-sidebar-link:hover{
  background:var(--c-surface-muted);
  color:var(--c-ink);
  text-decoration:none;
}
.c-sidebar-link.is-active,
.c-sidebar-link[aria-current="page"]{
  border-color:var(--c-accent-line);
  background:var(--c-accent-soft);
  color:var(--c-accent-strong);
}
.c-sidebar-link:focus-visible{
  outline:3px solid var(--c-focus-color);
  outline-offset:2px;
}
.c-sidebar-icon{
  display:inline-flex;
  flex:none;
  width:18px;
  height:18px;
  align-items:center;
  justify-content:center;
  color:currentColor;
}
.c-sidebar-icon svg{width:18px;height:18px;display:block}
.c-sidebar-label{
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.c-sidebar-foot{
  display:flex;
  align-items:center;
  gap:7px;
  flex:none;
  margin-top:auto;
  padding:12px 10px 2px;
  border-top:1px solid var(--c-line);
  color:var(--c-muted);
  font-size:var(--c-text-xs);
  line-height:1.4;
}
.c-sidebar-foot-dot{
  width:7px;
  height:7px;
  flex:none;
  border-radius:50%;
  background:var(--c-online);
  box-shadow:0 0 0 3px var(--c-online-soft);
}

.c-topbar-context{
  display:flex;
  align-items:center;
  gap:8px;
  min-width:0;
  margin-right:auto;
}
.c-topbar-kicker{
  color:var(--c-muted);
  font-size:var(--c-text-xs);
  font-weight:650;
  letter-spacing:.06em;
  line-height:1.3;
  text-transform:uppercase;
  white-space:nowrap;
}
.c-topbar-sep{
  color:var(--c-line-strong);
  font-size:var(--c-text-sm);
  line-height:1;
}
.c-topbar-title{
  min-width:0;
  overflow:hidden;
  color:var(--c-ink);
  font-size:var(--c-text-lg);
  font-weight:650;
  line-height:1.3;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.c-topbar-toggle--sidebar{display:none}
.c-sidebar-backdrop{display:none}

.c-shell--app .c-page{
  max-width:1600px;
  padding-inline:32px;
}

body.c-nav-locked{overflow:hidden}

@media(max-width:991.98px){
  .c-shell--sidebar{
    display:block;
  }
  .c-sidebar{
    position:fixed;
    top:0;
    bottom:0;
    left:0;
    width:min(290px,86vw);
    height:100dvh;
    z-index:100;
    transform:translateX(-100%);
    transition:transform .2s ease;
    box-shadow:var(--c-shadow-lg);
  }
  .c-shell.is-sidebar-open .c-sidebar{transform:none}
  .c-sidebar-backdrop{
    display:block;
    position:fixed;
    inset:0;
    z-index:90;
    background:rgba(20,35,33,.42);
    opacity:0;
    pointer-events:none;
    transition:opacity .2s ease;
  }
  .c-shell.is-sidebar-open .c-sidebar-backdrop{
    opacity:1;
    pointer-events:auto;
  }
  .c-topbar-toggle--sidebar{display:inline-flex}
  .c-shell--app .c-page{padding:20px 16px 40px}
  .c-topbar-title{font-size:var(--c-text-md)}
}

@media(prefers-reduced-motion:reduce){
  .c-sidebar,
  .c-sidebar-backdrop,
  .c-sidebar-link{transition:none}
}
