/* LLOGARITES shell UI (index) */
:root{
  --sidebar-width:260px;
  --header-height:68px;
  --actions-height:56px;
  --transition:.2s ease;
  --safe-area-top:env(safe-area-inset-top,0px);
  --safe-area-right:env(safe-area-inset-right,0px);
  --safe-area-bottom:env(safe-area-inset-bottom,0px);
  --safe-area-left:env(safe-area-inset-left,0px);
}

body{
  margin:0;
  background:var(--ui-bg);
  color:var(--ui-text);
  min-height:100vh;
  min-height:100dvh;
  display:flex;
  flex-direction:column;
  overflow:hidden;
  overscroll-behavior:none;
}

.app-shell{
  width:min(1120px,100%);
  height:calc(100vh - 28px);
  height:calc(100dvh - 28px);
  margin:14px auto;
  background:var(--ui-surface);
  border:1px solid var(--ui-border);
  border-radius:var(--ui-radius-lg);
  box-shadow:var(--ui-shadow);
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

header{
  background:var(--ui-surface);
  height:var(--header-height);
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap:12px;
  padding:0 calc(18px + var(--safe-area-right)) 0 calc(18px + var(--safe-area-left));
  border-bottom:1px solid var(--ui-border);
  position:sticky;
  top:0;
  z-index:100;
  cursor:pointer;
}

.header-logo-full{
  height:40px;
  max-width:220px;
  object-fit:contain;
}

.header-actions{
  display:grid;
  grid-template-columns:var(--sidebar-width) 1fr;
  align-items:center;
  gap:10px;
  padding:8px calc(18px + var(--safe-area-right)) 8px calc(18px + var(--safe-area-left));
  border-bottom:1px solid var(--ui-border);
  background:var(--ui-surface);
  position:sticky;
  top:var(--header-height);
  z-index:95;
  height:var(--actions-height);
}

.header-left{
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap:10px;
  cursor:pointer;
  background:transparent;
  padding:0;
}

.header-right{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}

.header-logo-container{
  position:static;
  transform:none;
  cursor:pointer;
  display:flex;
  align-items:center;
}

.menu-btn{
  background:none;
  border:none;
  color:var(--ui-primary);
  cursor:pointer;
  padding:0;
  display:flex;
  align-items:center;
  border-radius:8px;
  transition:var(--transition);
  width:44px;
  height:44px;
  justify-content:center;
  flex:0 0 auto;
}

.menu-btn:hover{
  background:var(--ui-hover);
}

.menu-label{
  font-size:1.12rem;
  font-weight:600;
  letter-spacing:.2px;
  color:var(--ui-text);
  line-height:1;
}

.menu-btn svg{
  width:18px;
  height:18px;
  stroke-width:2;
}

.header-left.active .menu-label,
.header-left.active .menu-btn{
  color:var(--ui-primary);
}

.menu-btn:focus-visible,
.nav-btn:focus-visible,
.menu-item:focus-visible{
  outline:2px solid var(--ui-primary);
  outline-offset:2px;
}

/* TOP NAV */
.top-nav{
  display:flex;
  justify-content:flex-start;
  gap:6px;
  background:transparent;
  height:auto;
  align-items:center;
  padding:0;
}

.nav-btn{
  background:none;
  border:none;
  font-size:1.12rem;
  font-weight:600;
  color:var(--ui-muted);
  cursor:pointer;
  position:relative;
  letter-spacing:.2px;
  padding:10px 16px;
  border-radius:8px;
  transition:var(--transition);
  min-height:44px;
}

.nav-btn.active{
  color:var(--ui-primary);
  font-weight:600;
}

.nav-btn:hover{
  background:var(--ui-hover);
}

.nav-btn.active::after{
  content:"";
  position:absolute;
  left:10px;
  right:10px;
  bottom:2px;
  height:2px;
  background:var(--ui-primary);
  border-radius:2px;
}


/* SIDEBAR */
.sidebar{
  position:fixed;
  top:calc(var(--header-height) + var(--actions-height));
  left:0;
  width:var(--sidebar-width);
  height:calc(100% - var(--header-height) - var(--actions-height));
  background:var(--ui-surface);
  z-index:200;
  display:flex;
  flex-direction:column;
  border-right:1px solid var(--ui-border);
  box-shadow:none;
  padding-bottom:var(--safe-area-bottom);
}

.sidebar-header{
  padding:24px 20px 14px;
  border-bottom:1px solid var(--ui-border);
  color:var(--ui-muted);
  font-size:12px;
  letter-spacing:.18em;
  text-transform:uppercase;
}

.sidebar-menu{
  flex:1;
  padding:12px 14px;
  overflow-y:auto;
  transition:transform .2s ease, opacity .2s ease;
}

.sidebar:not(.active) .sidebar-menu{
  transform:translateY(-10px);
  opacity:0;
  pointer-events:none;
}

.sidebar.active .sidebar-menu{
  transform:translateY(0);
  opacity:1;
  pointer-events:auto;
}

.menu-group{
  background:transparent;
  border-radius:6px;
  margin-bottom:12px;
  overflow:hidden;
  border:none;
  box-shadow:none;
}

.menu-item{
  display:flex;
  align-items:center;
  width:100%;
  min-height:44px;
  padding:11px 12px;
  border:none;
  background:none;
  font-size:14px;
  cursor:pointer;
  gap:12px;
  border-bottom:1px solid var(--ui-border);
  transition:var(--transition);
  color:var(--ui-text);
  border-radius:8px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.menu-item i{
  color:var(--ui-text);
  width:20px;
}

.submenu{
  display:none;
  padding:4px 6px 8px 6px;
}

.submenu.open{
  display:block;
}

.submenu .menu-item{
  font-size:13px;
  min-height:44px;
  padding:10px 10px;
  border-bottom:none;
  color:var(--ui-text);
  border-radius:8px;
}

.submenu .menu-item i{
  color:var(--ui-text);
}

.submenu-chevron{
  margin-left:auto;
  color:var(--ui-text);
}

.menu-item:hover{
  background:var(--ui-hover);
}

.menu-item.active{
  background:rgba(11,95,255,0.10);
  color:var(--ui-primary);
  font-weight:600;
}

.menu-item.active i{
  color:var(--ui-primary);
}

.overlay{
  position:fixed;
  top:0;
  left:0;
  width:100%;
  height:100%;
  background:var(--ui-overlay);
  opacity:0;
  visibility:hidden;
  z-index:150;
  transition:.3s;
  touch-action:none;
}

.overlay.active{
  opacity:1;
  visibility:visible;
}

/* MAIN */
main{
  flex:1;
  background:var(--ui-surface);
  overflow:auto;
  position:relative;
  border-top:1px solid var(--ui-border);
  margin:0;
  -webkit-overflow-scrolling:touch;
}

.main-layout{
  display:flex;
  min-height:100%;
  gap:16px;
}

.content-area{
  flex:1;
  min-width:0;
  min-height:100%;
}

.page{
  display:none;
  width:100%;
  min-height:100%;
}

.page.active{
  display:block;
}

iframe{
  width:100%;
  height:100%;
  border:none;
  border-radius:0;
  display:block;
  overflow:hidden;
}

.sidebar-footer{
  padding:20px;
  font-size:11px;
  color:var(--ui-muted);
  border-top:1px solid var(--ui-border);
}

body.menu-open-mobile{
  overflow:hidden;
  overscroll-behavior:none;
  touch-action:none;
}

body.menu-open-mobile main,
body.menu-open-mobile .content-area{
  pointer-events:none;
}

body.menu-open-mobile .sidebar,
body.menu-open-mobile .overlay{
  pointer-events:auto;
}

@media (prefers-reduced-motion: reduce){
  *{
    transition:none !important;
    animation:none !important;
  }
}

@media (max-width:720px){
  .app-shell{
    width:100%;
    height:100dvh;
    margin:0;
    border-radius:0;
    border-left:none;
    border-right:none;
  }
  header{
    height:calc(64px + var(--safe-area-top));
    flex-wrap:wrap;
    gap:8px;
    padding-top:var(--safe-area-top);
    padding-right:calc(18px + var(--safe-area-right));
    padding-left:calc(18px + var(--safe-area-left));
  }
  :root{--actions-height:52px;}
  .header-actions{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    flex-wrap:nowrap;
    padding:8px calc(14px + var(--safe-area-right)) 8px calc(14px + var(--safe-area-left));
  }
  .header-left{flex:0 0 auto;order:2;}
  .header-right{flex:1 1 auto;order:1;}
  .top-nav{justify-content:flex-start;flex:1 1 auto;}
  .theme-switch--compact{margin-left:0;}
  .sidebar{
    top:calc(64px + var(--safe-area-top) + var(--actions-height));
    height:calc(100% - 64px - var(--safe-area-top) - var(--actions-height));
  }
  .nav-btn{font-size:1.08rem;padding:10px 12px;}
  .menu-btn{width:44px;height:44px;}
  .menu-label{font-size:1.08rem;}
  .sidebar-menu{
    padding-top:12px;
    padding-bottom:calc(12px + var(--safe-area-bottom));
  }
  .sidebar-footer{
    padding:20px 20px calc(20px + var(--safe-area-bottom));
  }
  main{margin:10px calc(10px + var(--safe-area-right)) 0 calc(10px + var(--safe-area-left));}
}

@media (min-width:980px){
  main{margin:16px 16px 0 16px;}
}

@media (min-width:900px){
  .overlay{display:none;}
  main{
    margin-left:var(--sidebar-width);
    width:calc(100% - var(--sidebar-width));
  }
}

@media (max-width:899px){
  main{
    overflow:hidden;
  }
  .sidebar{
    left:auto;
    right:0;
    width:min(340px,55vw);
    border-right:none;
    border-left:1px solid var(--ui-border);
    border-top:1px solid var(--ui-border);
    transition:transform .28s cubic-bezier(.22,1,.36,1), opacity .2s ease;
    transform:translateX(100%);
    opacity:0;
    pointer-events:none;
    border-radius:16px 0 0 16px;
    box-shadow:0 18px 40px rgba(15,23,42,0.18);
    background:var(--ui-surface);
  }
  .sidebar.active{
    transform:translateX(0);
    opacity:1;
    pointer-events:auto;
  }
  .sidebar-menu{
    transform:none;
    opacity:1;
    pointer-events:auto;
    padding:10px 12px;
  }
  .sidebar:not(.active) .sidebar-menu{
    transform:none;
    opacity:1;
    pointer-events:auto;
  }
  .menu-btn{
    margin-left:0;
  }
  .menu-item{
    min-height:48px;
    padding:12px 12px;
    border-radius:10px;
    font-size:0.93rem;
  }
  .menu-item i{
    width:18px;
  }
  .overlay{
    background:var(--ui-overlay);
  }
  .main-layout{
    display:block;
  }
}
