/* پوستهٔ برنامه: منوی یکپارچه، نوار بالا و قاب صفحه. */

.skip-link { position: fixed; top: -80px; inset-inline-start: 16px; z-index: 1200; background: var(--surface); color: var(--ink); border: 2px solid var(--brand); border-radius: 8px; padding: 8px 14px; }
.skip-link:focus { top: 8px; }

.app { display: grid; grid-template-columns: 276px minmax(0, 1fr); align-items: stretch; min-height: 100vh; transition: grid-template-columns 120ms ease-out; }
html[data-authenticated=false] .app { grid-template-columns: minmax(0, 1fr); }
html[data-authenticated=true][data-sidebar-collapsed=true] .app { grid-template-columns: 0 minmax(0, 1fr); }
.main { min-width: 0; display: flex; flex-direction: column; }
.page { padding: 28px 36px 72px; width: 100%; max-width: 1240px; }
.page.wide { max-width: none; }
html[data-sidebar-collapsed=true] .page { max-width: none; }
.app-footer { padding: 0 36px 28px; color: var(--muted); font-size: .8125rem; }

/* ---------- منوی کناری ---------- */
.side { background: var(--surface); border-inline-end: 1px solid var(--border); display: flex; flex-direction: column; min-width: 0; overflow: hidden; transition: opacity 120ms ease-out, visibility 120ms; }
.side > * { width: 276px; flex-shrink: 0; }
html[data-sidebar-collapsed=true] .side { visibility: hidden; opacity: 0; pointer-events: none; }
.side-brand { display: flex; align-items: center; gap: 12px; padding: 18px 20px 14px; color: var(--ink); text-decoration: none; }
.side-brand:hover { text-decoration: none; color: var(--ink); }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; background: var(--brand); color: var(--on-brand); display: grid; place-items: center; flex: none; }
.brand-mark img { width: 38px; height: 38px; border-radius: 11px; object-fit: cover; }
.side-brand b { font-size: 1.15rem; display: block; line-height: 1.3; }
.side-brand span { font-size: .75rem; color: var(--muted); }
.side-cta { margin: 4px 16px 14px; display: flex; }
.nav-group { padding: 6px 12px 8px; }
.nav-h { display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: 0; padding: 8px 8px 6px; color: var(--muted); font-size: .78rem; font-weight: 700; cursor: pointer; text-align: start; }
.nav-h .i { margin-inline-start: auto; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; min-height: 44px; border-radius: 10px; color: var(--ink); font-weight: 500; text-decoration: none; }
.nav-item:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.nav-item[aria-current] { background: var(--brand-soft); color: var(--brand-ink); font-weight: 700; }
.nav-group.ai .nav-h { color: var(--ai-ink); }
.nav-group.ai .nav-item[aria-current] { background: var(--ai-soft); color: var(--ai-ink); }
.nav-n { margin-inline-start: auto; min-width: 24px; padding: 0 7px; text-align: center; border-radius: 999px; background: var(--brand); color: var(--on-brand); font-size: .75rem; font-weight: 700; line-height: 22px; }
.side nav { display: flex; flex-direction: column; flex: 1; }
.side-foot { margin-top: auto; padding-bottom: 20px; }
.side-foot .nav-item { color: var(--muted); }

/* ---------- نوار بالا ---------- */
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px 36px; min-height: 66px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 1000; }
.search { position: relative; flex: 1 1 320px; max-width: 520px; }
.search .i { position: absolute; inset-inline-start: 14px; top: 13px; color: var(--muted); }
.search .form-control { padding-inline-start: 44px; background: var(--surface-2); }
.tb-actions { display: flex; align-items: center; gap: 8px; margin-inline-start: auto; }
.icon-btn .dot { position: absolute; top: 8px; inset-inline-start: 9px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--bad); color: var(--surface); font-size: .68rem; font-weight: 700; line-height: 18px; text-align: center; }
.theme-sun, :root[data-theme=dark] .theme-moon { display: none; }
:root[data-theme=dark] .theme-sun { display: inline; }
.nav-dropdown { position: relative; }
.nav-dropdown > summary { list-style: none; cursor: pointer; }
.nav-dropdown > summary::-webkit-details-marker { display: none; }
.nav-dropdown-panel { position: absolute; inset-inline-end: 0; top: calc(100% + 10px); width: 280px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); z-index: 1100; overflow: hidden; }
.notifications-panel { width: 380px; max-width: calc(100vw - 24px); }
.nav-dropdown-panel .dropdown-heading { display: flex; justify-content: space-between; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.nav-dropdown-panel > a, .nav-dropdown-panel .user-logout button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 16px; color: var(--ink); background: none; border: 0; text-align: start; }
.nav-dropdown-panel > a:hover, .nav-dropdown-panel .user-logout button:hover { background: var(--surface-2); text-decoration: none; }
.user-logout { margin: 0; border-top: 1px solid var(--border); }
.user-logout button { color: var(--bad) !important; }
.who { display: flex; align-items: center; gap: 10px; padding: 5px 12px 5px 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--ink); }
.who small { display: block; color: var(--muted); font-size: .72rem; line-height: 1.4; }
.who b { display: block; font-size: .85rem; line-height: 1.4; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-ink); display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.sidebar-backdrop { position: fixed; inset: 0; background: #0008; border: 0; z-index: 1190; }
.toast-container { z-index: 1300; }

@media (max-width: 900px) {
  .app, html[data-authenticated=true][data-sidebar-collapsed=true] .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset-block: 0; inset-inline-start: 0; width: 276px; z-index: 1200; overflow-y: auto; visibility: hidden; opacity: 0; transform: translateX(100%); transition: transform 120ms ease-out, opacity 120ms ease-out, visibility 120ms; }
  html[data-sidebar-open=true] .side { visibility: visible; opacity: 1; pointer-events: auto; transform: translateX(0); overscroll-behavior: contain; }
  html[data-sidebar-open=true] { overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) {
  .app, .side { transition: none; }
}
@media (max-width: 640px) {
  .page { padding: 20px 16px 56px; }
  .topbar { padding: 10px 16px; flex-wrap: nowrap; gap: 8px; }
  .search { flex: 1 1 0; min-width: 0; max-width: none; }
  .tb-actions { gap: 4px; flex: none; }
  .tb-actions .tb-label, .who b, .who > .i { display: none; }
  .who { padding: 4px; }
  .nav-dropdown { position: static; }
  .nav-dropdown-panel, .notifications-panel { position: fixed; inset-inline: 12px; top: 68px; width: auto; max-width: none; }
  .app-footer { padding-inline: 16px; }
}
