/* Shared application shell. Record/page components live in workspace-records.css.
   Legacy shell selectors explicitly exclude .workspace-shell in app.css. */
:root {
  --workspace-navy:#142735;
  --workspace-cyan:#00c9df;
  --workspace-head:#d2e5f2;
  --workspace-bg:#edf3f6;
  --workspace-border:#dbe5ed;
  --workspace-surface:#fff;
  --workspace-text:#213547;
  --workspace-muted:#64798a;
  --workspace-sidebar-width:264px;
  --workspace-header-height:52px;
  --workspace-submenu:#fff;
  --workspace-submenu-active:#d3edf5;
}
html[data-theme="dark"] {
  --workspace-bg:#0d1b27;
  --workspace-surface:#132635;
  --workspace-head:#284759;
  --workspace-border:#304859;
  --workspace-text:#e8f0f5;
  --workspace-muted:#abc0ce;
  --workspace-submenu:#1b3242;
  --workspace-submenu-active:#245168;
}
body.workspace-shell {
  margin:0;
  background:var(--workspace-bg);
  color:var(--workspace-text);
  font-family:"Tajawal","Cairo","Segoe UI",Tahoma,Arial,sans-serif;
  font-size:14px;
  font-weight:500;
  line-height:1.55;
  --sidebar-w:var(--workspace-sidebar-width);
}
.workspace-shell .app {
  display:grid;
  grid-template-columns:var(--sidebar-w) minmax(0,1fr);
  align-items:start;
  min-height:100vh;
  width:100%;
  min-width:0;
}
.workspace-shell .app-main-shell { min-width:0; width:100%; }
.workspace-shell .app-main-shell > main {
  width:100%;
  min-width:0;
  max-width:100%;
  padding:14px;
  background:var(--workspace-bg);
}
.workspace-shell :is(button,a,input,select):focus-visible {
  outline:2px solid #1594b9;
  outline-offset:3px;
}
.workspace-shell .app-sidebar {
  position:sticky;
  inset-block-start:0;
  display:flex;
  flex-direction:column;
  width:100%;
  min-width:0;
  height:100vh;
  height:100dvh;
  padding:0;
  overflow:hidden;
  border:0;
  border-inline-end:1px solid #213b4d;
  background:var(--workspace-navy);
  color:#f4f8fb;
  z-index:25;
}
.workspace-shell .sidebar-top {
  display:grid;
  grid-template-columns:minmax(0,1fr) 32px;
  align-items:start;
  gap:10px;
  padding:15px 12px 12px;
  margin:0;
  min-height:90px;
  border:0;
  border-bottom:1px solid #38505f;
  border-radius:0;
  background:#10212e;
  flex:0 0 auto;
}
.workspace-shell .sidebar-top .brand-mark { display:none; }
.workspace-shell .brand-copy,
.workspace-shell .brand-copy-text {
  display:flex;
  flex-direction:column;
  align-items:stretch;
  gap:3px;
  min-width:0;
  margin:0;
  padding:0;
  text-decoration:none;
  color:#f4f8fb;
  background:transparent;
}
.workspace-shell .brand-kicker {
  color:#9db4c3;
  font-size:10px;
  font-weight:500;
  letter-spacing:0;
}
.workspace-shell .brand-title {
  font-size:15px;
  line-height:1.5;
  font-weight:700;
  white-space:normal;
  overflow-wrap:anywhere;
  color:#fff;
}
.workspace-shell .brand-subtitle { color:#b7c7d2; font-size:11px; line-height:1.6; }
.workspace-shell .brand-meta { display:flex; flex-wrap:wrap; gap:3px 8px; margin-top:4px; }
.workspace-shell .brand-meta-chip {
  display:inline;
  padding:0;
  border:0;
  border-radius:0;
  background:transparent;
  color:#a5bac8;
  font-size:10px;
  font-weight:500;
  line-height:1.7;
  overflow-wrap:anywhere;
}
.workspace-shell .brand-meta-chip-renew { cursor:pointer; }
.workspace-shell .brand-meta-chip-renew:hover { color:var(--workspace-cyan); text-decoration:underline; }
.workspace-shell :is(.collapse-btn,.workspace-menu-toggle) {
  display:inline-flex;
  justify-content:center;
  align-items:center;
  flex:0 0 auto;
  width:32px;
  height:32px;
  margin:0;
  padding:6px;
  border:1px solid #436072;
  border-radius:4px;
  background:transparent;
  color:#e8f5ff;
  cursor:pointer;
}
.workspace-shell :is(.collapse-btn,.workspace-menu-toggle):hover { border-color:var(--workspace-cyan); background:#203f52; }
.workspace-shell :is(.collapse-btn,.workspace-menu-toggle,.workspace-shortcut,.side-link-icon,.side-group-icon) svg {
  width:20px;
  height:20px;
  flex:0 0 auto;
  fill:none;
  stroke:currentColor;
  stroke-width:1.8;
  stroke-linecap:round;
  stroke-linejoin:round;
}
.workspace-shell .side-nav {
  display:flex;
  flex-direction:column;
  flex:1 1 auto;
  min-height:0;
  gap:0;
  padding:0 0 16px;
  overflow-y:auto;
  overflow-x:hidden;
  scrollbar-width:thin;
  scrollbar-color:#547082 transparent;
}
.workspace-shell .side-group { display:block; margin:0; border:0; background:transparent; }
.workspace-shell :is(.side-link,.side-group-toggle) {
  position:relative;
  display:flex;
  align-items:center;
  width:100%;
  min-width:0;
  min-height:42px;
  gap:10px;
  margin:0;
  padding:9px 14px;
  border:0;
  border-bottom:1px solid #354a59;
  border-radius:0;
  background:transparent;
  color:#f4f8fb;
  text-align:start;
  text-decoration:none;
  cursor:pointer;
  box-shadow:none;
  transform:none;
}
.workspace-shell :is(.side-link,.side-group-toggle):hover { background:#1e394c; }
.workspace-shell :is(.side-link.active,.side-group-toggle.active),
.workspace-shell .side-group.is-open > .side-group-toggle { background:#1d3b4e; }
.workspace-shell :is(.side-link-icon,.side-group-icon) {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  flex:0 0 22px;
  width:22px;
  height:22px;
  border:0;
  border-radius:0;
  background:transparent;
  color:var(--workspace-cyan);
  box-shadow:none;
}
.workspace-shell :is(.side-link-label,.side-group-label) {
  flex:1 1 auto;
  min-width:0;
  color:inherit;
  font-size:14px;
  font-weight:600;
  line-height:1.5;
  white-space:normal;
  overflow-wrap:anywhere;
}
.workspace-shell .side-group-caret {
  flex:0 0 auto;
  margin-inline-start:auto;
  font-size:11px;
  color:#a6bece;
  transition:transform .16s ease;
}
.workspace-shell .side-group.is-open > .side-group-toggle .side-group-caret { transform:rotate(180deg); }
.workspace-shell .side-submenu {
  display:none;
  width:100%;
  margin:0;
  padding:0;
  gap:0;
  border:0;
  border-radius:0;
  background:var(--workspace-submenu);
}
.workspace-shell .side-group.is-open > .side-submenu { display:block; }
.workspace-shell .side-submenu .side-submenu-link {
  min-height:40px;
  padding:8px 14px;
  border-bottom:1px solid var(--workspace-border);
  background:var(--workspace-submenu);
  color:var(--workspace-text);
}
.workspace-shell .side-submenu .side-link-icon { color:#62849c; }
.workspace-shell .side-submenu :is(.side-submenu-link:hover,.side-submenu-link.active) {
  background:var(--workspace-submenu-active);
  color:var(--workspace-text);
}
.workspace-shell .side-submenu .side-submenu-link.active {
  box-shadow:inset -3px 0 0 #00a7c5;
  font-weight:700;
}
.workspace-shell .side-nav-badge {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  flex:0 0 auto;
  min-width:18px;
  height:18px;
  padding:0 5px;
  border:0;
  border-radius:3px;
  background:#da4054;
  color:#fff;
  font-size:11px;
  font-weight:700;
  line-height:1;
  opacity:0;
}
.workspace-shell .app-header {
  display:block;
  position:sticky;
  inset-block-start:0;
  z-index:20;
  min-height:var(--workspace-header-height);
  margin:0;
  padding:0;
  border:0;
  border-bottom:1px solid #3b5263;
  background:var(--workspace-navy);
  color:#f4f8fb;
  box-shadow:none;
  backdrop-filter:none;
}
.workspace-shell .app-header .topbar-row {
  display:flex;
  align-items:stretch;
  justify-content:flex-start;
  flex-wrap:nowrap;
  width:100%;
  min-width:0;
  min-height:var(--workspace-header-height);
  gap:0;
}
.workspace-shell .header-main {
  display:flex;
  align-items:center;
  flex:1 1 auto;
  gap:10px;
  min-width:0;
  padding:0 14px;
}
.workspace-shell #btn-sidebar-top { display:none; }
.workspace-shell .workspace-system-name {
  min-width:0;
  max-width:280px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  color:#f4f8fb;
  text-decoration:none;
  font-size:14px;
  font-weight:700;
}
.workspace-shell .page-heading { display:flex; flex:0 0 auto; }
.workspace-shell .page-context-badge {
  display:inline-flex;
  align-items:center;
  padding:3px 7px;
  border:1px solid #527083;
  border-radius:3px;
  background:transparent;
  color:#bad2e1;
  font-size:10px;
  font-weight:500;
  white-space:nowrap;
}
.workspace-shell .page-context-badge.is-alert { color:#ffd5ba; border-color:#ba754c; }
.workspace-shell :is(.header-controls,.header-meta-row,.header-tools,.topbar-left-actions,.header-switcher) {
  display:flex;
  align-items:stretch;
  flex:0 0 auto;
  flex-wrap:nowrap;
  gap:0;
  min-width:0;
  margin:0;
  padding:0;
  border:0;
  background:transparent;
}
.workspace-shell .header-controls { overflow:visible; max-height:none; opacity:1; }
.workspace-shell .header-switcher { align-items:center; padding-inline:6px; }
.workspace-shell .header-switcher label { color:#c4d6e1; font-size:11px; white-space:nowrap; }
.workspace-shell .header-switcher #tenant-switch { max-width:155px; }
.workspace-shell .app-header :is(.workspace-shortcut,.header-select,.btn,.header-toggle,.app-profile-trigger,.btn-logout) {
  position:relative;
  inset:auto;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  flex:0 0 auto;
  gap:7px;
  width:auto;
  min-width:46px;
  height:var(--workspace-header-height);
  margin:0;
  padding:0 13px;
  border:0;
  border-inline-start:1px solid #3b5263;
  border-radius:0;
  background:transparent;
  color:#dce9f2;
  box-shadow:none;
  text-decoration:none;
  font-size:12px;
  font-weight:500;
  line-height:1.2;
  cursor:pointer;
}
.workspace-shell .app-header :is(button,a,select):hover { background:#224154; color:#fff; transform:none; }
.workspace-shell .app-header .workspace-system-name:hover { background:transparent; }
.workspace-shell .app-header .header-select { color:#c7dbe8; max-width:100px; padding-inline:9px; }
.workspace-shell .header-select option { color:var(--workspace-text); background:var(--workspace-surface); }
.workspace-shell .app-header .workspace-expiry { color:#c9dde9; font-size:11px; }
.workspace-shell .workspace-expiry svg { color:var(--workspace-cyan); width:16px; height:16px; }
.workspace-shell .app-header #btn-theme { font-size:20px; color:#f4d775; }
.workspace-shell .app-header .btn-logout { color:#f0b4b7; }
.workspace-shell .app-header .chat-top-badge { top:6px; inset-inline-start:6px; min-width:15px; height:15px; padding:0 4px; border-radius:3px; font-size:10px; }
.workspace-shell #btn-chat-reset { min-width:38px; padding-inline:9px; }
.workspace-shell .workspace-sidebar-tools { display:flex; flex:0 0 auto; border-top:1px solid #38505f; padding:8px; gap:8px; }
.workspace-shell .workspace-sidebar-tool { display:inline-flex; align-items:center; justify-content:center; flex:1 1 auto; gap:6px; min-height:32px; padding:4px 6px; border:1px solid #38505f; border-radius:3px; background:transparent; color:#c4d6e1; font-size:11px; text-decoration:none; cursor:pointer; }
.workspace-shell .workspace-sidebar-tool:hover { background:#224154; color:#fff; }
.workspace-shell .workspace-sidebar-tool svg { width:16px; height:16px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.workspace-shell :is(.mobile-top-actions,.app-profile-mobile-fallback,#bn-overlay) { display:none; }
.workspace-shell .workspace-sidebar-backdrop { display:none; }

@media (min-width:801px) {
  html.sidebar-collapsed .workspace-shell { --sidebar-w:64px; }
  html.sidebar-collapsed .workspace-shell .app { grid-template-columns:64px minmax(0,1fr); }
  html.sidebar-collapsed .workspace-shell .sidebar-top { display:flex; justify-content:center; min-height:var(--workspace-header-height); padding:10px 0; }
  html.sidebar-collapsed .workspace-shell :is(.brand-copy,.side-link-label,.side-group-label,.side-group-caret,.side-submenu) { display:none; }
  html.sidebar-collapsed .workspace-shell .workspace-sidebar-tools { display:none; }
  html.sidebar-collapsed .workspace-shell :is(.side-link,.side-group-toggle) { justify-content:center; min-height:48px; padding:12px 0; }
  html.sidebar-collapsed .workspace-shell .side-nav-badge { position:absolute; top:3px; inset-inline-end:3px; height:14px; min-width:14px; font-size:9px; }
}
@media (max-width:1250px) and (min-width:801px) {
  .workspace-shell .app-header .workspace-expiry { display:none; }
  .workspace-shell .workspace-system-name { max-width:200px; }
  .workspace-shell .page-heading { display:none; }
  .workspace-shell .app-header :is(.workspace-shortcut,.header-select,.btn,.header-toggle,.app-profile-trigger,.btn-logout) { padding-inline:10px; }
}
@media (max-width:1000px) and (min-width:801px) {
  .workspace-shell .workspace-shortcut-label { display:none; }
  .workspace-shell .app-header .header-select#palette-select { display:none; }
  .workspace-shell .workspace-system-name { max-width:150px; }
}
@media (max-width:800px) {
  html.workspace-menu-open, html.workspace-menu-open body.workspace-shell { overflow:hidden; }
  .workspace-shell .app { display:block; width:100%; }
  .workspace-shell .app-main-shell > main { padding:10px; }
  .workspace-shell.mobile-top-controls .app-main-shell > main,
  .workspace-shell.has-profile-action .app-main-shell > main { padding-top:10px; }
  .workspace-shell .app-sidebar {
    position:fixed;
    inset-block:0;
    inset-inline-start:0;
    width:min(300px,88vw);
    height:100vh;
    height:100dvh;
    visibility:hidden;
    pointer-events:none;
    transform:translateX(105%);
    z-index:10031;
    transition:transform .18s ease,visibility .18s;
  }
  html.workspace-menu-open .workspace-shell .app-sidebar { visibility:visible; pointer-events:auto; transform:none; box-shadow:-12px 0 36px #00111b55; }
  .workspace-shell .workspace-sidebar-backdrop:not([hidden]) {
    display:block;
    position:fixed;
    inset:0;
    width:100%;
    height:100%;
    margin:0;
    padding:0;
    border:0;
    border-radius:0;
    background:#06152188;
    z-index:10030;
  }
  .workspace-shell .app-header { display:block; }
  .workspace-shell #btn-sidebar-top { display:inline-flex; }
  .workspace-shell .header-main { padding-inline:10px; gap:8px; }
  .workspace-shell .workspace-system-name { font-size:13px; max-width:none; }
  .workspace-shell .app-header :is(.page-heading,.workspace-expiry,.workspace-shortcut-label,.header-meta-row),
  .workspace-shell .app-header #palette-select,
  .workspace-shell .app-header #btn-chat-reset { display:none; }
  .workspace-shell .header-controls { display:flex; max-height:none!important; opacity:1!important; }
  .workspace-shell .app-header :is(.workspace-shortcut,.header-select,.btn,.header-toggle,.app-profile-trigger,.btn-logout) { min-width:40px; padding-inline:9px; }
  .workspace-shell .topbar-left-actions { flex:0 0 auto; }
  .workspace-shell .app-header .btn-logout { display:none; }
}
@media (prefers-reduced-motion:reduce) {
  .workspace-shell :is(.app-sidebar,.side-group-caret) { transition:none; }
}
@media print {
  .workspace-shell :is(.app-sidebar,.app-header,.workspace-sidebar-backdrop) { display:none!important; }
  .workspace-shell .app { display:block!important; }
  .workspace-shell .app-main-shell > main { padding:0; background:#fff; }
}
