/* =========================================================
   AegisGate — layout.css
   App shell: sidebar, sticky header, workspace, responsive.
   ========================================================= */

.app { display: flex; min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
  width: 248px; flex: 0 0 248px;
  background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2));
  color: var(--sidebar-ink);
  border-right: 1px solid var(--sidebar-line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  z-index: 40;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--sidebar-line);
}
.brand-mark { width: 30px; height: 30px; color: var(--accent); }
.brand-name { display: block; color: var(--sidebar-ink-strong); font-weight: 700; font-size: 15px; letter-spacing: .01em; }
.brand-sub { display: block; font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--accent); }

.nav { flex: 1; overflow-y: auto; padding: 10px 10px 20px; }
.nav-section { margin-top: 14px; }
.nav-section:first-child { margin-top: 4px; }
.nav-section > .nav-section-label {
  padding: 4px 10px 6px;
  font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-3);
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  padding: 7px 10px; border-radius: 8px;
  color: var(--sidebar-ink); font-size: 13px;
  transition: background .12s, color .12s;
  position: relative;
}
.nav-item svg { width: 16px; height: 16px; flex: 0 0 16px; opacity: .85; }
.nav-item:hover { background: var(--accent-soft); color: var(--accent); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent); font-weight: 600;
}
.nav-item.active::before {
  content: ""; position: absolute; left: -10px; top: 6px; bottom: 6px; width: 3px;
  background: var(--accent); border-radius: 0 3px 3px 0;
}
.nav-badge {
  margin-left: auto; font-family: var(--mono); font-size: 10.5px;
  background: var(--block); color: #fff; border-radius: 999px; padding: 0 7px; line-height: 17px;
}
.sidebar-foot {
  padding: 10px 18px; font-size: 11.5px; color: var(--ink-3);
  border-top: 1px solid var(--sidebar-line);
  display: flex; align-items: center; gap: 7px;
}

/* ===== Main column ===== */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  height: 56px; padding: 0 20px;
  background: linear-gradient(90deg, var(--topbar-bg), var(--topbar-bg-2));
  color: var(--topbar-ink);
  border-bottom: 1px solid color-mix(in srgb, var(--topbar-bg) 70%, black);
  box-shadow: 0 1px 6px rgba(10,70,110,.25);
}
.topbar .icon-btn { color: rgba(255,255,255,.92); }
.topbar .icon-btn:hover { background: rgba(255,255,255,.16); color: #fff; }
.topbar .notif-dot { border-color: var(--topbar-bg-2); }
.crumbs { font-weight: 600; font-size: 14px; white-space: nowrap; }
.topbar-pulse { flex: 1; min-width: 60px; height: 30px; opacity: .85; }
.topbar-pulse svg { width: 100%; height: 100%; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.icon-btn {
  width: 32px; height: 32px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-2); position: relative;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 17px; height: 17px; }
.notif-dot {
  position: absolute; top: 5px; right: 5px; width: 7px; height: 7px;
  background: var(--block); border-radius: 50%; border: 2px solid var(--surface);
}

.org-switcher {
  background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.35);
  color: #fff; border-radius: 8px; padding: 5px 8px; font-size: 12.5px; max-width: 190px;
}
.org-switcher option { color: var(--ink); background: var(--surface); }

.global-search { position: relative; }
.global-search input {
  width: 250px; padding: 6px 10px 6px 30px;
  border: 1px solid rgba(255,255,255,.35); border-radius: 8px;
  color: #fff;
  background: rgba(255,255,255,.14) no-repeat 9px center / 14px
    url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%238b95ab" stroke-width="2"><circle cx="11" cy="11" r="7"/><path d="m21 21-4.3-4.3"/></svg>');
}
.global-search-results {
  display: none; position: absolute; top: 38px; right: 0; width: 340px; max-height: 380px; overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg);
}
.global-search-results.open { display: block; }
.gsr-group { padding: 8px 12px 2px; }
.gsr-item { display: block; width: 100%; text-align: left; padding: 7px 12px; font-size: 12.5px; }
.gsr-item:hover { background: var(--surface-2); }
.gsr-item .sub { color: var(--ink-3); font-size: 11.5px; }

.global-search input::placeholder { color: rgba(255,255,255,.75); }
.admin-chip { display: flex; align-items: center; gap: 8px; padding-left: 8px; border-left: 1px solid rgba(255,255,255,.3); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(255,255,255,.22); color: #fff; font-size: 11px; font-weight: 700;
  border: 1.5px solid rgba(255,255,255,.55);
  display: inline-flex; align-items: center; justify-content: center;
}
.admin-name { font-size: 12px; color: rgba(255,255,255,.92); white-space: nowrap; }

.content { padding: 22px 24px 48px; max-width: 1480px; width: 100%; margin: 0 auto; }

/* Page header row */
.page-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .grow { flex: 1; min-width: 220px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Grids */
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid.cols-6 { grid-template-columns: repeat(6, minmax(0,1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }

/* ===== Responsive ===== */
.burger { display: none; }
@media (max-width: 1180px) {
  .grid.cols-6 { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .admin-name { display: none; }
  .topbar-pulse { display: none; }
}
@media (max-width: 900px) {
  .burger { display: inline-flex; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%); transition: transform .18s ease;
  }
  .app.nav-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .grid.cols-6, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .span-2, .span-3, .span-4 { grid-column: auto; }
  .global-search input { width: 150px; }
  .content { padding: 16px 14px 40px; }
}

/* --- Crumbs detail + header pulse label (app.js) --- */
.topbar .crumb-root { color: rgba(255,255,255,.78); font-weight: 500; }
.topbar .crumb-sep { margin: 0 7px; color: rgba(255,255,255,.6); }
.topbar .crumb-cur { color: #fff; }
.topbar-pulse { display: flex; align-items: center; gap: 8px; justify-content: flex-end; padding-right: 6px; }
.topbar-pulse svg { width: 92px; height: 24px; flex: none; }
.pulse-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: rgba(255,255,255,.8); white-space: nowrap; }
@media (max-width: 1180px) { .pulse-label { display: none; } }
