/* ═══════════════════════════════════════════════════════════
   BURJ LUMEN — App Shell / Layout
═══════════════════════════════════════════════════════════ */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  transition: grid-template-columns var(--t) var(--ease);
}
.app.is-collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

/* Explicit grid placement — never rely on auto-placement (which mis-assigns
   columns under RTL once the sidebar leaves the flow). The content column is
   pinned by name so the main panel is always full-width and visible. */
.sidebar { grid-column: 1; }
.main { grid-column: 2; }

/* ════════════════ SIDEBAR ════════════════ */
.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-inline-end: 1px solid var(--hairline);
  min-height: 0;
  position: relative;
  z-index: 30;
}

.sb-brand {
  display: flex; align-items: center; gap: 11px;
  height: var(--topbar-h);
  padding-inline: 18px;
  border-bottom: 1px solid var(--hairline);
  flex-shrink: 0;
}
.sb-logo {
  width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--brand) 0%, var(--brand-strong) 100%);
  color: #fff; font-weight: 800; font-size: 18px;
  box-shadow: var(--shadow-brand);
}
.sb-brand-text { min-width: 0; line-height: 1.2; }
.sb-brand-text b { display: block; font-size: 15px; font-weight: 800; letter-spacing: -0.01em; }
.sb-brand-text span { display: block; font-size: 10.5px; color: var(--ink-muted); font-weight: 500; }
.is-collapsed .sb-brand { justify-content: center; padding-inline: 0; }
.is-collapsed .sb-brand-text { display: none; }

/* Search */
.sb-search {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 14px 6px;
}
.is-collapsed .sb-search { padding-inline: 14px; }
.sb-search-field {
  display: flex; align-items: center; gap: 9px;
  width: 100%; height: 38px; padding-inline: 12px;
  background: var(--tint); border: 1px solid transparent;
  border-radius: var(--r-sm); color: var(--ink-faint);
  font-size: 13px; transition: all var(--t-fast);
}
.sb-search-field:hover { border-color: var(--hairline-strong); }
.sb-search-field kbd {
  margin-inline-start: auto; font-family: var(--font-num);
  font-size: 10px; background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 5px; padding: 1px 5px; color: var(--ink-faint);
}
.is-collapsed .sb-search-field kbd,
.is-collapsed .sb-search-field span { display: none; }
.is-collapsed .sb-search-field { justify-content: center; padding-inline: 0; }

/* Nav */
.sb-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 6px 10px 10px; min-height: 0; }
.sb-section + .sb-section { margin-top: 6px; }
.sb-section-label {
  display: block; font-size: 10px; font-weight: 800; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-faint);
  padding: 12px 10px 6px;
}
.is-collapsed .sb-section-label { text-align: center; height: 1px; padding: 0; margin: 12px auto; width: 28px; background: var(--hairline); color: transparent; overflow: hidden; }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  width: 100%; padding: 8px 10px; border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 600; color: var(--ink-muted);
  position: relative; transition: background var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}
.nav-item:hover { background: var(--tint); color: var(--ink); }
.nav-item .ico { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item.active { background: var(--brand-soft); color: var(--brand-strong); }
.nav-item.active::before {
  content: ''; position: absolute; inset-inline-start: -10px; top: 50%;
  transform: translateY(-50%); width: 3px; height: 20px;
  background: var(--brand); border-radius: 999px;
}
.nav-item .badge {
  margin-inline-start: auto; font-size: 9.5px; font-weight: 800;
  background: var(--brand); color: #fff; border-radius: 999px; padding: 1px 7px;
}
.nav-item .chev { margin-inline-start: auto; width: 14px; height: 14px; transition: transform var(--t-fast); color: var(--ink-faint); }
.nav-item[aria-expanded="true"] .chev { transform: rotate(180deg); }
/* ── "New" pill (جديد) — refined soft-emerald with a live pulsing dot ── */
.nav-item .nav-badge {
  margin-inline-start: auto;
  display: inline-flex; align-items: center; gap: 4px; line-height: 1;
  font-size: 9px; font-weight: 700;
  color: #15A34A;
  background: color-mix(in srgb, #22C55E 13%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #22C55E 26%, transparent);
  border-radius: 999px; padding: 3px 8px 3px 7px; flex-shrink: 0;
  transition: background var(--t-fast);
}
.nav-item .nav-badge::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0;
  background: #22C55E;
  box-shadow: 0 0 0 0 color-mix(in srgb, #22C55E 55%, transparent);
  animation: navNewPulse 2s ease-out infinite;
}
@keyframes navNewPulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, #22C55E 55%, transparent); }
  70%  { box-shadow: 0 0 0 4px color-mix(in srgb, #22C55E 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, #22C55E 0%, transparent); }
}
.nav-item:hover .nav-badge { background: color-mix(in srgb, #22C55E 18%, transparent); }
[dir="ltr"] .nav-item .nav-badge { letter-spacing: .05em; text-transform: uppercase; }
/* When a badge precedes the chevron, the chevron sits right after it (no auto-push) */
.nav-item .nav-badge + .chev { margin-inline-start: 7px; }

/* ── "Coming soon" placeholder items (قريباً) — muted & inert ── */
.nav-item.nav-soon { color: var(--ink-faint); cursor: default; }
.nav-item.nav-soon:hover { background: transparent; color: var(--ink-faint); }
.nav-item.nav-soon .ico { opacity: .65; }
.nav-soon-sub { padding-inline-start: 26px; }
/* ── "Soon" pill (قريباً) — elegant neutral ghost with a dim dot ── */
.nav-item .nav-tag-soon {
  margin-inline-start: auto;
  display: inline-flex; align-items: center; gap: 4px; line-height: 1;
  font-size: 9px; font-weight: 600;
  color: var(--ink-faint);
  background: color-mix(in srgb, var(--ink) 5%, transparent);
  box-shadow: inset 0 0 0 1px var(--hairline);
  border-radius: 999px; padding: 3px 8px 3px 7px; flex-shrink: 0;
}
.nav-item .nav-tag-soon::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0;
  background: currentColor; opacity: .5;
}
[dir="ltr"] .nav-item .nav-tag-soon { letter-spacing: .04em; text-transform: uppercase; }
@media (prefers-reduced-motion: reduce) { .nav-item .nav-badge::before { animation: none; } }
.is-collapsed .nav-item { justify-content: center; padding-inline: 0; }
.is-collapsed .nav-item .label,
.is-collapsed .nav-item .badge,
.is-collapsed .nav-item .nav-badge,
.is-collapsed .nav-item .nav-tag-soon,
.is-collapsed .nav-item.nav-soon,
.is-collapsed .nav-item .chev { display: none; }

.nav-sub {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows var(--t) var(--ease);
  margin-inline-start: 18px;
}
.nav-sub.open { grid-template-rows: 1fr; }
.nav-sub-inner { overflow: hidden; border-inline-start: 1px solid var(--hairline); padding-inline-start: 12px; }
.nav-subitem {
  display: block; padding: 6px 10px; border-radius: 8px;
  font-size: 12.5px; font-weight: 500; color: var(--ink-muted);
  transition: background var(--t-fast), color var(--t-fast);
}
.nav-subitem:hover { background: var(--tint); color: var(--ink); }
.nav-subitem.active { color: var(--brand-strong); font-weight: 700; }
.is-collapsed .nav-sub { display: none; }

/* Collapse / expand toggle — floating edge pull-tab (outside menu flow) */
.sb-edge-toggle {
  position: absolute; top: 74px; inset-inline-end: -13px; z-index: 40;
  width: 26px; height: 26px; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--hairline-strong);
  color: var(--ink-muted); box-shadow: var(--shadow);
  cursor: pointer;
  opacity: 0; transform: scale(0.8);
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}
.sidebar:hover .sb-edge-toggle,
.sb-edge-toggle:focus-visible { opacity: 1; transform: none; }
.sb-edge-toggle:hover { color: #fff; background: var(--brand); border-color: var(--brand); }
.sb-edge-toggle .ico { width: 14px; height: 14px; }

/* Sidebar footer */
.sb-foot { border-top: 1px solid var(--hairline); padding: 10px; flex-shrink: 0; }
.sb-user {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px; border-radius: var(--r-sm); width: 100%;
  transition: background var(--t-fast);
}
.sb-user:hover { background: var(--tint); }
.avatar {
  width: 36px; height: 36px; border-radius: 999px; flex-shrink: 0;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px;
  background: linear-gradient(145deg, var(--brand), var(--brand-strong));
}
.sb-user-text { min-width: 0; text-align: start; line-height: 1.25; }
.sb-user-text b { display: block; font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-text span { display: block; font-size: 11px; color: var(--ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.is-collapsed .sb-user { justify-content: center; }
.is-collapsed .sb-user-text { display: none; }

/* ════════════════ MAIN ════════════════ */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  height: var(--topbar-h); padding-inline: 18px;
  background: var(--surface); border-bottom: 1px solid var(--hairline);
  flex-shrink: 0; z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.crumbs { display: flex; align-items: center; gap: 7px; font-size: 13.5px; min-width: 0; }
.crumbs a { color: var(--ink-faint); font-weight: 600; transition: color var(--t-fast); }
.crumbs a:hover { color: var(--ink-muted); }
.crumbs .sep { width: 14px; height: 14px; color: var(--hairline-strong); flex-shrink: 0; }
.crumbs .here { font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-actions { flex: 1; display: flex; align-items: center; justify-content: flex-end; gap: 4px; }

.icon-btn {
  width: 38px; height: 38px; border-radius: var(--r-sm);
  display: grid; place-items: center; color: var(--ink-muted);
  transition: background var(--t-fast), color var(--t-fast);
  position: relative;
}
.icon-btn:hover { background: var(--tint); color: var(--ink); }
.icon-btn .ico { width: 18px; height: 18px; }
.icon-btn .dot {
  position: absolute; top: 8px; inset-inline-end: 9px;
  width: 8px; height: 8px; border-radius: 999px; background: var(--bad);
  border: 2px solid var(--surface);
}
.topbar-sep { width: 1px; height: 22px; background: var(--hairline); margin-inline: 4px; }

/* Content scroll area */
.content {
  flex: 1; overflow-y: auto; min-height: 0;
  background: var(--canvas);
}

/* ════════════════ STATUS BAR (footer) ════════════════ */
.statusbar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  height: 30px; padding-inline: 16px; flex-shrink: 0;
  background: var(--surface); border-top: 1px solid var(--hairline);
  font-size: 11.5px; color: var(--ink-muted); z-index: 15;
}
.sbar-crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; white-space: nowrap; }
.sbar-link { color: var(--ink-muted); font-weight: 600; transition: color var(--t-fast); }
.sbar-link:hover { color: var(--brand); }
.sbar-here { color: var(--ink); font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sbar-chevron { display: inline-flex; color: var(--ink-faint); flex-shrink: 0; }
.sbar-chevron .ico { width: 12px; height: 12px; }
.sbar-info { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.sbar-chip { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.sbar-chip .ico { width: 13px; height: 13px; color: var(--ink-faint); }
.sbar-status { color: var(--ok); font-weight: 700; }
.dot-live { width: 7px; height: 7px; border-radius: 999px; background: var(--ok); box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); animation: pulse 2s infinite; }
.sbar-sep { width: 1px; height: 13px; background: var(--hairline); }
.sbar-ver { color: var(--ink-faint); }
@media (max-width: 760px) { .sbar-info .sbar-chip:not(.sbar-status), .sbar-info .sbar-sep { display: none; } }
.content-inner {
  max-width: var(--content-max); margin-inline: auto;
  padding: 26px 28px 40px;
}

@media (max-width: 1100px) {
  .content-inner { padding: 20px 16px 32px; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { grid-column: 1; position: fixed; inset-block: 0; inset-inline-start: 0; width: var(--sidebar-w); transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  .main { grid-column: 1; }      /* sidebar is out of flow → main owns the only column */
  .app.mobile-open .sidebar { transform: none; }
}
