/* LLOGARITES shell UI (index) */
:root{
  --sidebar-width:260px;
  --header-height:86px;
  --safe-area-top:env(safe-area-inset-top, 0px);
  --safe-area-bottom:env(safe-area-inset-bottom, 0px);
  --header-safe-height:calc(var(--header-height) + var(--safe-area-top));
  --transition:.2s ease;
  --shell-header-padding:0 22px;
  --shell-header-pad-top:0px;
  --shell-header-pad-bottom:0px;
  --shell-header-gap:18px;
  --shell-header-align:center;
  --shell-logo-height:54px;
  --shell-logo-max-width:297px;
  --shell-logo-offset:0;
  --shell-header-right-gap:14px;
  --shell-menu-gap:10px;
  --shell-menu-btn-size:36px;
  --shell-menu-icon-size:22px;
  --shell-menu-label-size:1.42rem;
  --shell-nav-gap:8px;
  --shell-nav-size:1.4rem;
  --shell-nav-pad-y:12px;
  --shell-nav-pad-x:18px;
}

/* App shell */
body{
  margin:0;
  background:var(--ui-bg);
  color:var(--ui-text);
  min-height:100vh;
  min-height:100dvh;
  height:100vh;
  height:100dvh;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

.app-shell{
  width:min(1120px,100%);
  height:calc(100vh - 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-safe-height);
  display:flex;
  align-items:var(--shell-header-align);
  justify-content:space-between;
  gap:var(--shell-header-gap);
  padding:var(--shell-header-padding);
  padding-top:calc(var(--safe-area-top) + var(--shell-header-pad-top));
  padding-bottom:var(--shell-header-pad-bottom);
  border-bottom:1px solid var(--ui-border);
  position:sticky;
  top:0;
  z-index:100;
}

.header-logo-full{
  height:var(--shell-logo-height);
  max-width:var(--shell-logo-max-width);
  object-fit:contain;
}

.header-left{
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap:var(--shell-menu-gap);
  cursor:pointer;
  background:transparent;
  padding:0;
}

.header-right{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:var(--shell-header-right-gap);
  flex:1 1 auto;
  min-width:0;
}

.header-logo-container{
  position:static;
  transform:none;
  cursor:pointer;
  display:flex;
  align-items:center;
  padding-bottom:var(--shell-logo-offset);
}

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

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

.menu-label{
  font-family:var(--font-ui);
  font-size:var(--shell-menu-label-size);
  font-weight:900;
  letter-spacing:.01em;
  color:var(--ui-text);
  line-height:1;
}

.menu-btn svg{
  width:var(--shell-menu-icon-size);
  height:var(--shell-menu-icon-size);
  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 navigation */
.top-nav{
  display:flex;
  justify-content:flex-start;
  gap:var(--shell-nav-gap);
  background:transparent;
  height:auto;
  align-items:center;
  padding:0;
}

.nav-btn{
  background:none;
  border:none;
  font-family:var(--font-ui);
  font-size:var(--shell-nav-size);
  font-weight:900;
  color:var(--ui-muted);
  cursor:pointer;
  position:relative;
  letter-spacing:.01em;
  padding:var(--shell-nav-pad-y) var(--shell-nav-pad-x);
  border-radius:8px;
  transition:var(--transition);
}

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

.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:var(--header-safe-height);
  left:0;
  width:var(--sidebar-width);
  height:calc(100vh - var(--header-safe-height));
  height:calc(100dvh - var(--header-safe-height));
  background:var(--ui-surface);
  z-index:200;
  display:flex;
  flex-direction:column;
  border-right:1px solid var(--ui-border);
  box-shadow:none;
}

.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%;
  padding:10px 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;
  padding:8px 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;
}

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

/* Main area */
main{
  flex:1;
  background:var(--ui-surface);
  overflow:hidden;
  position:relative;
  border-top:1px solid var(--ui-border);
  margin:0;
}

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

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

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

.page.active{
  display:block;
}

iframe{
  width:100%;
  height:100%;
  border:none;
  border-radius:0;
}

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

.sidebar-tools{
  padding:0 14px 14px;
  border-top:1px solid var(--ui-border);
  background:var(--ui-surface);
}

.sidebar-theme-row{
  width:100%;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  margin-top:14px;
  padding:12px 12px;
  border:1px solid var(--ui-border);
  border-radius:12px;
  background:var(--ui-surface-2);
  color:var(--ui-text);
  cursor:pointer;
  transition:var(--transition);
  text-align:left;
}

.sidebar-theme-row:hover{
  background:var(--ui-hover);
  border-color:rgba(11,95,255,0.18);
}

.sidebar-theme-row:focus-visible{
  outline:2px solid var(--ui-primary);
  outline-offset:2px;
}

.sidebar-theme-copy{
  min-width:0;
  display:flex;
  flex-direction:column;
  gap:3px;
}

.sidebar-theme-title{
  font-size:0.95rem;
  font-weight:600;
  color:var(--ui-text);
}

.sidebar-theme-subtitle{
  font-size:0.78rem;
  color:var(--ui-muted);
}

.theme-switch--menu{
  pointer-events:none;
  flex:0 0 auto;
}

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

/* Compact mobile shell */
@media (max-width:720px){
  :root{
    --header-height:72px;
    --shell-header-padding:8px 12px 10px;
    --shell-header-pad-top:8px;
    --shell-header-pad-bottom:10px;
    --shell-header-gap:8px;
    --shell-header-align:flex-end;
    --shell-logo-height:41px;
    --shell-logo-max-width:198px;
    --shell-logo-offset:2px;
    --shell-header-right-gap:8px;
    --shell-menu-gap:4px;
    --shell-menu-btn-size:36px;
    --shell-menu-icon-size:24px;
    --shell-nav-gap:6px;
    --shell-nav-size:1.3rem;
    --shell-nav-pad-y:10px;
    --shell-nav-pad-x:11px;
  }
  header{
    flex-wrap:nowrap;
  }
  .header-left{
    flex:0 0 auto;
    order:2;
    align-self:flex-end;
  }
  .header-right{
    display:grid;
    grid-template-columns:minmax(0,1fr) auto;
    align-items:end;
    align-self:flex-end;
    padding-bottom:1px;
  }
  .top-nav{
    justify-content:center;
    flex:0 1 auto;
    min-width:0;
  }
  .sidebar{top:var(--header-safe-height);height:calc(100vh - var(--header-safe-height));height:calc(100dvh - var(--header-safe-height));}
  .nav-btn{
    display:flex;
    align-items:center;
    line-height:1;
    min-height:42px;
  }
  .menu-label{
    display:none;
  }
  main{margin:8px 8px 0 8px;}
}

/* Wide desktop shell */
@media (min-width:980px){
  main{margin:16px 16px 0 16px;}
}

/* Desktop shell */
@media (min-width:900px){
  .overlay{display:none;}
  .sidebar{
    left:auto;
    right:0;
    border-right:none;
    border-left:1px solid var(--ui-border);
  }
  main{
    margin-left:0;
    margin-right:var(--sidebar-width);
    width:calc(100% - var(--sidebar-width));
  }
}

/* Tablet and mobile sidebar */
@media (max-width:899px){
  .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{
    padding:12px 12px;
    border-radius:10px;
    font-size:0.93rem;
  }
  .sidebar-tools{
    padding:0 12px 12px;
  }
  .sidebar-theme-row{
    margin-top:12px;
    padding:11px 12px;
    border-radius:12px;
  }
  .sidebar-theme-title{
    font-size:0.92rem;
  }
  .sidebar-theme-subtitle{
    font-size:0.76rem;
  }
  .menu-item i{
    width:18px;
  }
  .overlay{
    background:var(--ui-overlay);
  }
  .main-layout{
    display:block;
  }
}
