/* WhatsApp-Web style shell shared by the inbox, the dashboard and the admin panel: a fixed
   sidebar menu plus a top app bar. The base palette stays in app.css; this file only adds the
   shell tokens and layout. Page-specific styles live in dashboard.css and admin.css. */
:root {
  --page: #f0f2f5;
  --side-bg: #ffffff;
  --active-bg: #f5f6f6;
  --active-text: #111b21;
  --head-bg: #f9fafb;
  --avatar-bg: #1f766d;
  --avatar-text: #ffffff;
  --shadow: 0 1px 3px rgba(11, 20, 26, 0.08);
  --ico-bg: #e9edef; --ico-fg: #54656f; --ico-active-bg: #d1f4ee; --ico-active-fg: #0f766e;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #111b21;
    --side-bg: #202c33;
    --active-bg: #2a3942;
    --active-text: #e9edef;
    --head-bg: #202c33;
    --avatar-bg: #14b8a6;
    --avatar-text: #111b21;
    --shadow: none;
    --ico-bg: #2a3942; --ico-fg: #aebac1; --ico-active-bg: #0f766e; --ico-active-fg: #5eead4;
  }
}
:root[data-theme="dark"] {
  --page: #111b21;
  --side-bg: #202c33;
  --active-bg: #2a3942;
  --active-text: #e9edef;
  --head-bg: #202c33;
  --avatar-bg: #14b8a6;
  --avatar-text: #111b21;
  --shadow: none;
  --ico-bg: #2a3942; --ico-fg: #aebac1; --ico-active-bg: #0f766e; --ico-active-fg: #5eead4;
}

.page-admin, .page-dash, .page-inbox { background: var(--page); }

/* ---- shell ---------------------------------------------------------------------- */
.shell {
  display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: 100vh;
  background: var(--page);
}

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
  background: var(--side-bg); border-right: 1px solid var(--border);
}
.brand-block {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
  color: var(--text); text-decoration: none;
}
.brand-mark {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px;
  background: var(--accent); color: var(--accent-text); flex: none;
}
.brand-text { display: grid; line-height: 1.2; }
.brand-name { font-size: 17px; font-weight: 700; }
.brand-sub { font-size: 13px; color: var(--muted); }
.side-tenant { margin: 16px 20px 4px; font-size: 14px; color: var(--muted); }

.side-nav { padding: 4px 12px 16px; flex: 1; }
.side-label {
  margin: 18px 8px 6px; font-size: 12px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
}
.sections { display: grid; gap: 2px; }
.sections button, .side-link {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 9px 12px; border: 0; border-radius: 7px; background: none;
  color: var(--text); font: inherit; font-size: 15px; text-align: left; text-decoration: none;
  cursor: pointer;
  transition: background .15s ease;
}
.sections button:hover, .side-link:hover { background: rgba(0,0,0,0.03); }
.sections button[aria-current="true"], .side-link[aria-current="page"] {
  background: var(--active-bg); color: var(--active-text); font-weight: 500;
}
.sections button:focus-visible, .side-link:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; }
.ico {
  width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor;
  stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; opacity: 0.85;
}
.side-foot { margin: 0; padding: 14px 20px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }
.appbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  min-height: 59px; padding: 8px 24px;
  background: var(--side-bg); border-bottom: 1px solid var(--border);
}
.page-title { margin: 0; flex: 1; min-width: 0; font-size: 19px; font-weight: 700; color: var(--text); }
.icon-btn {
  display: none; place-items: center; width: 38px; height: 38px; padding: 0;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); cursor: pointer;
}
.user-pill {
  display: flex; align-items: center; gap: 10px; padding: 6px 14px 6px 6px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
}
.avatar {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--avatar-bg); color: var(--avatar-text); font-size: 13px; font-weight: 700;
}
.user-text { display: grid; line-height: 1.2; }
.user-name { font-size: 14px; font-weight: 600; }
.user-role { font-size: 12px; color: var(--muted); }

.content { flex: 1; width: 100%; max-width: 1320px; padding: 20px 24px 40px; }
.footer {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 24px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted);
}

/* ---- WhatsApp-like sidebar icons ------------------------------------------------ */
.sections button .ico, .side-link .ico {
  width: 36px; height: 36px; padding: 8px; border-radius: 50%;
  background: var(--ico-bg); color: var(--ico-fg); opacity: 1;
}
.sections button[aria-current="true"] .ico { background: var(--ico-active-bg); color: var(--ico-active-fg); }
.sections button:hover .ico { color: var(--text); }

/* ---- per-page body sizing ------------------------------------------------------- */
/* The dashboard is a normal scrolling page inside the shell. */
.page-dash .main > .dash { flex: 1; }
/* The inbox fills the viewport and scrolls inside its panes. */
.page-inbox { height: 100vh; overflow: hidden; }
.page-inbox .shell { min-height: 0; height: 100vh; }
.page-inbox .main { min-height: 0; }
/* The connection pill now sits on the white app bar, not on the old dark header. */
.page-inbox .live { color: var(--muted); }
.page-inbox .live.on { color: var(--accent); }

/* ---- responsive ------------------------------------------------------------------ */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; background: none; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 20;
    transform: translateX(-100%); transition: transform 0.2s ease;
  }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, 0.25); }
  .scrim { position: fixed; inset: 0; z-index: 15; background: rgba(4, 32, 28, 0.45); }
  .icon-btn { display: grid; }
  .appbar, .content, .footer { padding-left: 16px; padding-right: 16px; }
  .user-text { display: none; }
  .user-pill { padding: 4px; }
}
