/* =====================================================================
   HLC OS - APPLICATION SHELL
   ---------------------------------------------------------------------
   The production shell for HLC OS - The HLC Business Operating System.
   Built entirely on the design system (design-system.css): every surface,
   color, radius, and shadow is a token, so the whole app themes together
   (Light primary · Dark · System). Sidebar + top nav + views inherit the
   same language Command Center established.
   ===================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ds-bg);
  color: var(--ds-text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* =====================================================================
   SHELL LAYOUT
   ===================================================================== */
.app-shell { display: grid; grid-template-columns: 272px 1fr; min-height: 100vh; }

/* ---- Sidebar ---- */
.sidebar {
  position: sticky; top: 0; align-self: start; height: 100vh;
  display: flex; flex-direction: column; gap: var(--sp-6);
  padding: var(--sp-6) var(--sp-5);
  background: var(--ds-surface-1); border-right: 1px solid var(--ds-hairline);
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: var(--sp-3); padding: 0 var(--sp-2); }
.brand__logo {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--ds-gold-500), var(--ds-gold-300));
  color: var(--ds-on-gold); font-family: var(--font-display); font-weight: 700; font-size: 1rem;
  box-shadow: var(--el-1);
}
.brand__text b { display: block; font-family: var(--font-display); font-size: var(--fs-lg); color: var(--ds-text-hi); line-height: 1.1; }
.brand__text span { font-size: var(--fs-xs); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ds-accent); font-weight: 700; }

.sidebar-nav { display: grid; gap: 2px; overflow-y: auto; }
.nav-link {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 9px var(--sp-3); border-radius: var(--r-md);
  color: var(--ds-text-lo); text-decoration: none; font-size: var(--fs-sm); font-weight: 500;
  cursor: pointer; border: none; background: transparent; width: 100%; text-align: left;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.nav-link::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: transparent; flex: none; transition: background var(--dur-1) var(--ease); }
.nav-link:hover { background: var(--ds-overlay); color: var(--ds-text-hi); }
.nav-link.active { background: var(--ds-overlay-2); color: var(--ds-text-hi); font-weight: 600; }
.nav-link.active::before { background: var(--ds-gold-500); box-shadow: 0 0 8px var(--ds-glow-strong); }
.nav-link.is-flagship.active { color: var(--ds-text-hi); }

.sidebar-foot { margin-top: auto; font-size: var(--fs-xs); color: var(--ds-text-mute); padding: 0 var(--sp-2); line-height: var(--lh-snug); }

/* ---- Workspace switcher ---- */
.ws-switcher { position: relative; }
.ws-badge { flex: none; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-size: var(--fs-xs); font-weight: 700; color: var(--ds-on-gold); background: linear-gradient(135deg, var(--ds-gold-500), var(--ds-gold-300)); }
.ws-current { display: flex; align-items: center; gap: var(--sp-3); width: 100%; padding: 8px var(--sp-3); border-radius: var(--r-md); border: 1px solid var(--ds-hairline); background: var(--ds-surface-2); cursor: pointer; text-align: left; transition: border-color var(--dur-1) var(--ease); }
.ws-current:hover { border-color: var(--ds-hairline-strong); }
.ws-current__text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ws-current__label { font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ds-text-mute); }
.ws-current__name { font-size: var(--fs-sm); font-weight: 600; color: var(--ds-text-hi); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-caret { color: var(--ds-text-lo); font-size: 0.7rem; }
.ws-menu { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 50; background: var(--ds-surface-2); border: 1px solid var(--ds-hairline-strong); border-radius: var(--r-md); box-shadow: var(--el-3); padding: var(--sp-2); display: none; }
.ws-menu.is-open { display: block; animation: ds-fade var(--dur-1) var(--ease) both; }
.ws-option { display: flex; align-items: center; gap: var(--sp-3); width: 100%; padding: 8px var(--sp-2); border-radius: var(--r-sm); border: none; background: transparent; cursor: pointer; text-align: left; color: var(--ds-text); transition: background var(--dur-1) var(--ease); }
.ws-option:hover { background: var(--ds-overlay); }
.ws-option.is-active { color: var(--ds-text-hi); }
.ws-option__name { flex: 1; font-size: var(--fs-sm); font-weight: 500; }
.ws-check { color: var(--ds-gold-500); font-weight: 700; }
.ws-menu__foot { padding: var(--sp-2) var(--sp-2) 4px; font-size: 0.62rem; color: var(--ds-text-mute); line-height: 1.4; border-top: 1px solid var(--ds-hairline); margin-top: 4px; }

/* ---- Integrations page ---- */
.int-list { display: grid; gap: 2px; }
.int-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-3) 0; border-bottom: 1px solid var(--ds-hairline); }
.int-row:last-child { border-bottom: none; }
.int-row__id { display: flex; flex-direction: column; gap: 1px; }
.int-name { font-size: var(--fs-base); color: var(--ds-text-hi); font-weight: 500; }
.int-acct { font-size: var(--fs-xs); color: var(--ds-text-mute); font-family: ui-monospace, monospace; }
.int-row__right { display: flex; align-items: center; gap: var(--sp-3); }

/* ---- Main ---- */
.app-main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-7);
  background: var(--ds-surface-glass); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--ds-hairline);
}
.topbar__left { display: flex; align-items: center; gap: var(--sp-4); min-width: 0; }
.crumb { font-size: var(--fs-xs); letter-spacing: 0.05em; text-transform: uppercase; color: var(--ds-text-mute); white-space: nowrap; }
.crumb b { color: var(--ds-text-lo); font-weight: 600; }
.topbar__right { display: flex; align-items: center; gap: var(--sp-3); }

.menu-toggle { display: none; }

.app-content { padding: var(--sp-7); }

/* =====================================================================
   VIEWS
   ===================================================================== */
.view-panel { display: none; }
.view-panel.active { display: block; animation: ds-fade var(--dur-2) var(--ease) both; }

/* ---- Placeholder / intro views (premium, reassuring) ---- */
.view-intro { max-width: 900px; }
.view-title { font-family: var(--font-display); font-size: var(--fs-3xl); font-weight: 700; color: var(--ds-text-hi); margin: var(--sp-2) 0 var(--sp-3); line-height: var(--lh-tight); }
.view-lead { font-size: var(--fs-md); color: var(--ds-text-lo); line-height: var(--lh-normal); margin: 0 0 var(--sp-6); max-width: 60ch; }

.placeholder-card { border: 1px solid var(--ds-hairline); border-radius: var(--r-lg); background: var(--ds-surface-2); box-shadow: var(--el-1); }
.placeholder-chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); justify-content: center; max-width: 640px; margin: var(--sp-3) auto var(--sp-5); }

/* ---- Settings ---- */
.settings-card { margin-bottom: var(--sp-5); max-width: 640px; }
.settings-card h3 { font-family: var(--font-display); font-size: var(--fs-xl); color: var(--ds-text-hi); margin: 0 0 var(--sp-2); }
.settings-card p { margin: 0 0 var(--sp-4); font-size: var(--fs-sm); color: var(--ds-text-lo); line-height: var(--lh-normal); }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; }
.settings-meta { display: grid; gap: 4px; font-size: var(--fs-sm); }
.settings-meta span { color: var(--ds-text-lo); }
.settings-meta strong { color: var(--ds-text-hi); font-weight: 600; }

/* =====================================================================
   MOBILE (drawer)
   ===================================================================== */
.sidebar-backdrop { display: none; }
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; width: 280px; height: 100vh;
    transform: translateX(-100%); transition: transform var(--dur-2) var(--ease); box-shadow: var(--el-3);
  }
  .app-shell.nav-open .sidebar { transform: translateX(0); }
  .menu-toggle { display: inline-flex; }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 35; opacity: 0; pointer-events: none; transition: opacity var(--dur-2) var(--ease); }
  .app-shell.nav-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .app-content { padding: var(--sp-5); }
  .topbar { padding: var(--sp-4) var(--sp-5); }
}
