/* ====== Design tokens ====== */
:root{
  --sbw:260px;
  --bg-shell:#f3f4f6;
  --bg-surface:#fcfcfd;
  --bg-soft:#f7f7fb;
  --border-subtle:#e5e7eb;
  --border-strong:#d4d4dd;
  --text-main:#0f172a;
  --text-muted:#6b7280;
  --accent:#4f46e5;
  --accent-soft:#eef2ff;
  --accent-soft-2:#e0f2fe;
  --danger:#e11d48;
}

/* ===== Global look & feel ===== */
body.layout-sidebar{
  margin:0;
  background:radial-gradient(circle at top left,#f9fafb 0,#e5e7f5 35%,#f3f4f6 100%);
  color:var(--text-main);
  -webkit-font-smoothing:antialiased;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* ===== Layout grid (desktop) ===== */
body.layout-sidebar .page{
  display:grid;
  grid-template-columns: var(--sbw) 1fr;
  grid-template-areas: "sidebar content";
  min-height:100vh;
  overflow:hidden;
  padding:14px;
  box-sizing:border-box;
  gap:14px;
}

.sidebar {
  grid-area: sidebar;
  position:sticky;
  top:14px;
  height:calc(100vh - 28px);
  overflow-y:auto;
  background:
    linear-gradient(180deg,rgba(255,255,255,0.96),rgba(249,250,251,0.98));
  z-index:1001;
  border-radius:18px;
  box-shadow:
    0 18px 45px rgba(15,23,42,0.09),
    0 0 0 1px rgba(148,163,184,0.25);
  border:1px solid rgba(226,232,240,0.65);
}

.content {
  grid-area: content;
  display:grid;
  grid-template-rows:auto 1fr;
  min-width:0;
  min-height:calc(100vh - 28px);
  overflow:auto;
  background:var(--bg-surface);
  border-radius:22px;
  box-shadow:
    0 20px 50px rgba(15,23,42,0.06),
    0 0 0 1px rgba(209,213,219,0.65);
  position:relative;
}

/* ===== Sidebar base ===== */
.sidebar {
  color:var(--text-main);
}

.sidebar__brand{
  padding:16px 18px 14px;
  font-weight:700;
  font-size:18px;
  letter-spacing:0.03em;
  border-bottom:1px solid rgba(226,232,240,0.8);
  display:flex;
  align-items:center;
  gap:10px;
}

.sidebar__brand .brand-link{
  text-decoration:none;
  color:var(--text-main);
}

.sidebar__brand .brand-link:hover{
  opacity:0.9;
}

.sidebar__brand::before{
  content:"";
  width:32px;
  height:32px;
  border-radius:12px;
  background:radial-gradient(circle at 20% 0%,#e0f2fe 0,#eef2ff 50%,#ffffff 100%);
  box-shadow:0 0 0 1px rgba(191,219,254,0.7);
}

/* User block */
.sidebar__user{
  padding:12px 18px;
  border-top:1px solid rgba(229,231,235,0.8);
  border-bottom:1px solid rgba(229,231,235,0.8);
  position:relative;
  padding-right:56px;
  background:linear-gradient(90deg,rgba(248,250,252,0.9),rgba(239,246,255,0.9));
}

.sidebar__user .user-name{
  font-weight:600;
  font-size:14px;
}

.sidebar__user .user-role{
  font-size:12px;
  color:var(--text-muted);
}

/* ===== Nav (main menu) ===== */
.sidebar__nav{
  padding:14px 12px 16px;
  display:flex;
  flex-direction:column;
  gap:6px;
}

.nav-link{
  display:flex;
  align-items:center;
  gap:10px;
  padding:9px 11px;
  border-radius:999px;
  color:var(--text-main);
  text-decoration:none;
  background:transparent;
  border:none;
  cursor:pointer;
  width:100%;
  text-align:left;
  font-size:13px;
  transition:
    background .15s ease,
    color .15s ease,
    box-shadow .15s ease,
    transform .08s ease,
    opacity .15s ease;
}

.nav-link:hover{
  background:rgba(148,163,184,0.14);
}

.nav-link:active{
  transform:translateY(1px);
}

.nav-link.active{
  background:linear-gradient(90deg,var(--accent-soft),var(--accent-soft-2));
  color:var(--accent);
  font-weight:700;
  box-shadow:
    0 6px 16px rgba(79,70,229,0.18),
    0 0 0 1px rgba(129,140,248,0.35);
}

.nav-ico{
  width:26px;
  height:26px;
  flex:0 0 26px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius:999px;
  background:rgba(148,163,184,0.08);
  box-shadow:0 0 0 1px rgba(209,213,219,0.7);
  font-size:14px;
}

.nav-link.active .nav-ico{
  background:rgba(79,70,229,0.08);
  box-shadow:0 0 0 1px rgba(129,140,248,0.8);
}

/* Submenu toggle icon */
.nav-item.has-sub .chev{
  margin-left:auto;
  width:14px;
  height:14px;
  transition:transform .15s ease;
  opacity:.7;
}

.nav-link.open .chev{
  transform: rotate(90deg);
}

/* ===== Submenu (Groups) ===== */
.nav-sublist{
  display:flex;
  flex-direction:column;
  gap:4px;
  padding:6px 0 8px 26px;
  border-left: 2px dashed rgba(203,213,225,0.9);
  margin-left: 12px;
  max-height: 320px;
  overflow:auto;
}

.nav-sublist[hidden]{
  display:none !important;
}

/* group row container */
.nav-subitem{
  position:relative;
  display:flex;
  align-items:center;
  gap:6px;
  padding-right:34px;
}

.nav-sublink{
  display:flex;
  align-items:center;
  gap:8px;
  padding:7px 10px;
  border-radius:10px;
  color:#4b5563;
  text-decoration:none;
  flex:1 1 auto;
  min-width:0;
  transition:
    background .15s ease,
    color .15s ease,
    box-shadow .15s ease;
  font-size:12.5px;
}

.nav-sublink:hover{
  background:#f3f4ff;
  color:#111827;
}

.nav-sublink.active{
  background:linear-gradient(90deg,#eef2ff,#e0ebff);
  color:#1e3a8a;
  font-weight:600;
  box-shadow: inset 0 0 0 1px rgba(129,140,248,0.28);
}

.nav-sublink .dot{
  width:6px;
  height:6px;
  border-radius:999px;
  background:#cbd5e1;
  flex:0 0 6px;
}

.nav-subitem:hover .dot{
  background:#94a3b8;
}

.nav-subempty{
  color:#9ca3af;
  padding:8px 10px;
  font-size:12px;
  font-style:italic;
}

/* --- admin kebab (three-dots) --- */
.g-kebab-btn{
  position:absolute;
  right:6px;
  top:50%;
  transform: translateY(-50%);
  border:none;
  background:transparent;
  padding:5px;
  border-radius:999px;
  opacity:0;
  visibility:hidden;
  transition:
    opacity .15s ease,
    background .15s ease,
    box-shadow .15s ease;
  cursor:pointer;
  color:#6b7280;
  z-index:2;
  pointer-events:auto;
}

.nav-subitem:hover .g-kebab-btn,
.nav-subitem:focus-within .g-kebab-btn{
  opacity:1;
  visibility:visible;
}

.g-kebab-btn:hover{
  background:#e5edff;
  color:#111827;
  box-shadow:0 4px 10px rgba(15,23,42,0.12);
}

.g-kebab-btn svg{
  width:17px;
  height:17px;
  display:block;
}

/* ========= GLOBAL LAYER for groups menus ========= */
.g-layer{
  position:fixed;
  inset:0;
  z-index:4000;
  pointer-events:none;
}

.g-layer .g-menu,
.g-layer .g-pop{
  position:fixed;
  pointer-events:auto;
  min-width:190px;
  background:var(--bg-surface);
  border:1px solid rgba(210,214,227,0.95);
  border-radius:14px;
  box-shadow:
    0 18px 40px rgba(15,23,42,.18),
    0 0 0 1px rgba(226,232,240,0.9);
  padding:6px;
}

/* Context menu items */
.g-menu .g-item{
  width:100%;
  text-align:left;
  background:transparent;
  border:none;
  padding:8px 10px;
  border-radius:9px;
  cursor:pointer;
  color:var(--text-main);
  font-size:13px;
}

.g-menu .g-item:hover{
  background:#f4f6fb;
}

.g-menu .g-item.delete{
  color:var(--danger);
}

/* move / popover */
.g-pop{
  display:flex;
  gap:6px;
  align-items:center;
  min-width:260px;
}

.g-pop select{
  flex:1 1 auto;
  padding:6px 8px;
  border:1px solid #dde3f0;
  border-radius:9px;
  background:#f9fafb;
  font-size:13px;
}

.g-pop .btn{
  padding:7px 10px;
  border-radius:9px;
  border:1px solid #e2e8f0;
  background:#ffffff;
  cursor:pointer;
  font-size:12px;
}

.g-pop .btn.save{
  background:var(--accent-soft);
  border-color:#c7d2fe;
  color:#1e40af;
}

/* Badge in nav */
.badge{
  margin-left:auto;
  min-width:18px;
  height:18px;
  padding:0 6px;
  font-size:11px;
  border-radius:999px;
  background:var(--danger);
  color:#fff;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  line-height:1;
  font-weight:700;
  box-shadow:0 0 0 1px rgba(248,113,113,0.45);
}
.badge[hidden]{
  display:none !important;
}

/* ===== Sidebar footer ===== */
.sidebar__footer{
  padding:10px 12px 14px;
  border-top:1px solid rgba(229,231,235,0.9);
  background:rgba(248,250,252,0.97);
}

.btn.btn-logout{
  display:block;
  padding:9px 12px;
  border-radius:999px;
  color:#b91c1c;
  text-decoration:none;
  border:1px solid #fee2e2;
  background:#fff7f7;
  text-align:center;
  font-size:12.5px;
}

.btn.btn-logout:hover{
  background:#fee2e2;
}

/* ===== Overlay (mobile) ===== */
.overlay{
  position:fixed;
  inset:0;
  background:rgba(15, 23, 42, .35);
  z-index:1000;
  opacity:0;
  transition: opacity .2s ease;
}
.overlay[hidden]{
  display:none !important;
}
body.sidebar-open .overlay{
  opacity:1;
}

/* ===== Mobile layout ===== */
.topbar-mobile{
  display:none;
}

@media (max-width: 1023px){
  body.layout-sidebar .page{
    grid-template-columns: 1fr;
    grid-template-areas: "content";
    padding:0;
    gap:0;
  }
  .sidebar{
    position:fixed;
    left:0;
    top:0;
    width:var(--sbw);
    max-width:88vw;
    height:100vh;
    transform: translateX(-100%);
    transition:transform .22s ease;
    z-index:1001;
    will-change: transform;
    border-radius:0 18px 18px 0;
  }
  .sidebar.open{
    transform: translateX(0);
  }
  .content{
    border-radius:0;
    min-height:100vh;
    box-shadow:none;
  }
  .topbar-mobile{
    display:flex;
    align-items:center;
    gap:12px;
    position:sticky;
    top:0;
    z-index:30;
    padding:10px 14px;
    border-bottom:1px solid #e2e8f0;
    background:rgba(249,250,251,0.96);
    backdrop-filter:blur(12px);
  }
  .brand-mobile{
    text-decoration:none;
    color:var(--text-main);
    font-weight:700;
    font-size:15px;
  }
  .brand-mobile:hover{
    opacity:0.9;
  }
  .burger{
    width:38px;
    height:38px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    border-radius:12px;
    border:1px solid #e2e8f0;
    background:#ffffff;
  }
  .burger span{
    display:block;
    width:18px;
    height:2px;
    background:#0f172a;
    margin:3px 0;
    border-radius:2px;
  }
  body.sidebar-open{
    overflow:hidden;
  }
  body.sidebar-open #overlay{
    left: min(88vw, var(--sbw));
    right: 0;
    top:0;
    bottom:0;
  }
  .content > .container{
    margin-top:0 !important;
  }
}

/* ======== Notifications icon + popover ======== */
.n-notif-btn{
  position:absolute;
  right:16px;
  top:50%;
  transform:translateY(-50%);
  width:34px;
  height:34px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius:999px;
  border:1px solid #e2e8f0;
  background:#ffffff;
  cursor:pointer;
  box-shadow:0 4px 10px rgba(15,23,42,0.04);
}
.n-notif-btn:hover{
  background:#f8fafc;
}
.n-notif-btn:focus-visible{
  outline:2px solid rgba(37,99,235,.35);
  outline-offset:2px;
}
.n-notif-btn svg{
  width:18px;
  height:18px;
}
.n-badge{
  position:absolute;
  right:-3px;
  top:-3px;
  min-width:18px;
  height:18px;
  padding:0 6px;
  font-size:11px;
  border-radius:999px;
  background:var(--danger);
  color:#fff;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  line-height:1;
  font-weight:700;
}
.n-badge[hidden]{
  display:none !important;
}

/* Notifications layer separate from g-layer */
#n-layer{
  position:fixed;
  inset:0;
  z-index:4200;
  pointer-events:none;
}
#n-layer > *{
  pointer-events:auto;
}
.n-overlay{
  position:fixed;
  inset:0;
  background:transparent;
}

.n-pop{
  position:fixed;
  min-width:360px;
  max-width:520px;
  width:min(520px, calc(100vw - 24px));
  max-height:70vh;
  display:flex;
  flex-direction:column;
  background:#ffffff;
  border:1px solid #dde3f0;
  border-radius:16px;
  box-shadow:
    0 18px 44px rgba(15,23,42,.2),
    0 0 0 1px rgba(226,232,240,0.9);
}

.n-head{
  position:sticky;
  top:0;
  display:flex;
  align-items:center;
  gap:12px;
  padding:10px 12px;
  border-bottom:1px solid #e2e8f0;
  background:#ffffff;
  border-radius:16px 16px 0 0;
}
.n-title{
  font-weight:700;
  font-size:14px;
}
.n-actions{
  margin-left:auto;
  display:flex;
  gap:8px;
}

/* Buttons */
.n-btn{
  color:var(--text-main);
  background:#ffffff;
  border:1px solid #e2e8f0;
  border-radius:9px;
  padding:6px 10px;
  font-size:12px;
  cursor:pointer;
}
.n-btn:hover{
  background:#f8fafc;
}
.n-btn.primary{
  background:var(--accent-soft);
  border-color:#c7d2fe;
  color:#1e40af;
}

/* Tabs */
.n-tabs{
  display:flex;
  gap:8px;
  padding:8px 12px;
  border-bottom:1px solid #e2e8f0;
  background:#ffffff;
}
.n-tab{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:6px 10px;
  border-radius:999px;
  background:#f8fafc;
  border:1px solid #e2e8f0;
  cursor:pointer;
  user-select:none;
  color:#111827;
  font-size:13px;
  font-weight:600;
}
.n-tab:hover{
  background:#eef2ff;
  border-color:#c7d2fe;
}
.n-tab.active{
  background:var(--accent-soft);
  border-color:#c7d2fe;
  color:#1e40af;
}
.n-tab .count{
  min-width:18px;
  height:18px;
  padding:0 6px;
  border-radius:999px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  background:#e5edff;
  color:#1e40af;
  font-weight:700;
  font-size:11px;
}

/* JSON list mode */
.n-list{
  list-style:none;
  margin:0;
  padding:0;
  overflow:auto;
}
.n-item{
  display:flex;
  gap:10px;
  padding:10px 12px;
  border-bottom:1px solid #f3f4f6;
}
.n-item:last-child{
  border-bottom:none;
}
.n-item.unseen{
  background:#f8fbff;
}
.n-item .dot{
  width:8px;
  height:8px;
  border-radius:999px;
  margin-top:6px;
  background:#2563eb;
  flex:0 0 8px;
}
.n-main{
  min-width:0;
  flex:1 1 auto;
}
.n-ttl{
  font-weight:600;
  color:#0f172a;
  margin-bottom:2px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.n-body{
  color:#4b5563;
  font-size:13px;
  line-height:1.35;
  display:-webkit-box;
  -webkit-line-clamp:3;
  -webkit-box-orient:vertical;
  overflow:hidden;
}
.n-meta{
  display:flex;
  align-items:center;
  gap:8px;
  margin-top:6px;
  color:#6b7280;
  font-size:12px;
}
.n-meta a{
  color:#1d4ed8;
  text-decoration:none;
}
.n-meta a:hover{
  text-decoration:underline;
}
.n-ops{
  display:flex;
  align-items:center;
  gap:6px;
}
.n-ops .n-btn{
  padding:4px 8px;
}

/* Student tag */
.n-stu{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:2px 8px;
  border-radius:999px;
  background:#eef2ff;
  border:1px solid #c7d2fe;
  color:#1e40af;
  font-weight:600;
  font-size:12px;
}
.n-stu svg{
  width:14px;
  height:14px;
}

/* iFrame mode */
.n-frame-wrap{
  flex:1 1 auto;
  min-height:240px;
  display:none;
}
.n-frame{
  width:100%;
  height:100%;
  border:0;
  border-radius:0 0 16px 16px;
}

/* Reply box */
.n-reply {
  margin-top: 0.35rem;
  padding-top: 0.35rem;
  border-top: 1px solid rgba(148,163,184,0.25);
}
.n-reply-input {
  width: 100%;
  min-height: 2.2rem;
  resize: vertical;
  font-size: 0.78rem;
  line-height: 1.35;
  border-radius: 0.6rem;
  border: 1px solid rgba(148,163,184,0.7);
  padding: 0.35rem 0.55rem;
  background:#f9fafb;
}
.n-reply-input:focus{
  outline:none;
  border-color:#93c5fd;
  box-shadow:0 0 0 1px rgba(147,197,253,0.9);
  background:#ffffff;
}
.n-reply-actions {
  display:flex;
  justify-content:flex-end;
  gap:0.35rem;
  margin-top:0.25rem;
}
.n-reply-actions .n-btn{
  font-size:11px;
  padding:4px 9px;
}
.n-reply.sent .n-reply-input {
  border-color:#22c55e;
  background:rgba(34,197,94,0.04);
}
