/* OCAP Workspace shell — chrome only. Tokens mirror the CRM (oc-crm/web) so
   the workspace and its apps feel like one product. */
:root {
  --background: 0 0% 100%;
  --foreground: 0 0% 12%;
  --card: 0 0% 100%;
  --muted: 0 0% 96%;
  --muted-foreground: 0 0% 40%;
  --accent: 152 55% 94%;
  --accent-foreground: 160 84% 22%;
  --primary: 160 84% 30%;
  --primary-foreground: 0 0% 100%;
  --border: 0 0% 90%;
  --ok: 152 60% 42%;
  --down: 0 72% 50%;
  --radius: 0.5rem;
}
html.dark {
  --background: 0 0% 7%;
  --foreground: 0 0% 83%;
  --card: 0 0% 10%;
  --muted: 0 0% 14%;
  --muted-foreground: 0 0% 56%;
  --accent: 0 0% 17%;
  --accent-foreground: 0 0% 92%;
  --primary: 152 76% 67%;
  --primary-foreground: 0 0% 7%;
  --border: 0 0% 18%;
  --ok: 152 60% 55%;
  --down: 0 70% 60%;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ── Left rail ─────────────────────────────────────────────────────────── */
.rail {
  display: flex;
  flex-direction: column;
  width: 224px;
  flex-shrink: 0;
  border-right: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / 0.4);
  padding: 6px;
  transition: width 0.16s ease;
}
.ws-header {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-bottom: 2px;
  padding: 8px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.ws-header:hover { background: hsl(var(--accent) / 0.6); }
.ws-chevron { width: 15px; height: 15px; margin-left: auto; color: hsl(var(--muted-foreground)); }
.ws-logo {
  display: grid;
  place-items: center;
  height: 28px;
  width: 28px;
}
/* Oakvale leaf at full size (no ring), tinted to the theme's foreground via CSS
   mask — dark leaf in light mode, light leaf in dark mode. */
.ws-leaf {
  height: 20px;
  width: 20px;
  background: hsl(var(--foreground));
  -webkit-mask: url(/oakvale-leaf.png) center / contain no-repeat;
  mask: url(/oakvale-leaf.png) center / contain no-repeat;
}
.ws-name { font-weight: 600; }

/* ── Collapsed rail (click the header to toggle) ───────────────────────── */
body.collapsed .rail { width: 56px; }
body.collapsed .ws-name,
body.collapsed .ws-chevron,
body.collapsed .nav-item .label,
body.collapsed .rail-section-label,
body.collapsed .subnav,
body.collapsed .dot,
body.collapsed #theme-toggle .label { display: none; }
body.collapsed .ws-header,
body.collapsed .nav-item,
body.collapsed #theme-toggle { justify-content: center; padding-left: 0; padding-right: 0; gap: 0; }
.rail-section-label {
  padding: 8px 10px 4px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: hsl(var(--muted-foreground));
}
.rail-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: hsl(var(--muted-foreground));
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.nav-item:hover { background: hsl(var(--accent) / 0.6); color: hsl(var(--foreground)); }
.nav-item.active { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); font-weight: 500; }
.nav-item .icon { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item.active .icon { color: hsl(var(--primary)); }
.nav-item .label { flex: 1; }
.nav-item.soon { opacity: 0.55; cursor: default; }
.nav-item.soon:hover { background: transparent; color: hsl(var(--muted-foreground)); }
.soon-tag { font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; color: hsl(var(--muted-foreground)); border: 1px solid hsl(var(--border)); border-radius: 999px; padding: 1px 6px; }
body.collapsed .soon-tag { display: none; }
.dot { width: 7px; height: 7px; border-radius: 999px; background: hsl(var(--muted-foreground) / 0.5); }
.dot.ok { background: hsl(var(--ok)); }
.dot.down { background: hsl(var(--down)); }
/* active app's own sections, nested under it */
.subnav { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 4px; padding-left: 14px; border-left: 1px solid hsl(var(--border)); margin-left: 12px; }
.sub-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 7px 10px; border: 0; border-radius: var(--radius); background: transparent;
  color: hsl(var(--muted-foreground)); font: inherit; font-size: 13px; text-align: left; cursor: pointer;
}
.sub-item:hover { background: hsl(var(--accent) / 0.6); color: hsl(var(--foreground)); }
.sub-item.active { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); font-weight: 500; }
.sub-item .icon { width: 15px; height: 15px; flex-shrink: 0; }
.sub-item.active .icon { color: hsl(var(--primary)); }
.sub-accent {
  display: flex; align-items: center; gap: 10px; width: 100%; margin-top: 4px;
  padding: 7px 10px; border: 0; border-radius: var(--radius);
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
  font: inherit; font-size: 13px; font-weight: 500; text-align: left; cursor: pointer;
}
.sub-accent:hover { background: hsl(var(--primary) / 0.9); }
.sub-accent .icon { width: 15px; height: 15px; flex-shrink: 0; }

.rail-spacer { flex: 1; }
.rail-foot { border-top: 1px solid hsl(var(--border)); padding-top: 4px; }

/* ── Content ───────────────────────────────────────────────────────────── */
.content { position: relative; flex: 1; min-width: 0; }
.view, .pane { position: absolute; inset: 0; display: none; }
.view.active, .pane.active { display: block; }

/* Home */
.home { max-width: 720px; margin: 0 auto; padding: 72px 32px; }
.home-title { font-size: 28px; font-weight: 600; margin: 0 0 6px; }
.home-sub { color: hsl(var(--muted-foreground)); margin: 0 0 28px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.card {
  display: flex; flex-direction: column; gap: 8px;
  padding: 18px; border: 1px solid hsl(var(--border)); border-radius: var(--radius);
  background: hsl(var(--card)); cursor: pointer; text-align: left; font: inherit; color: inherit;
}
.card:hover { border-color: hsl(var(--primary) / 0.5); }
.card.soon { cursor: default; opacity: 0.6; }
.card-top { display: flex; align-items: center; gap: 10px; }
.card-icon { display: grid; place-items: center; height: 32px; width: 32px; border-radius: var(--radius); background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.card-name { font-weight: 600; }
.card-desc { font-size: 13px; color: hsl(var(--muted-foreground)); }

/* App panes (iframes) */
.pane iframe { width: 100%; height: 100%; border: 0; display: block; }
.pane-fallback {
  position: absolute; inset: 0; display: none; place-items: center;
  background: hsl(var(--background));
}
.pane-fallback.show { display: grid; }
.fallback-box { text-align: center; color: hsl(var(--muted-foreground)); }
.fallback-box h2 { color: hsl(var(--foreground)); font-weight: 600; margin: 0 0 6px; }
.fallback-box > div:first-of-type { max-width: 360px; margin: 0 auto; }
.fallback-actions { display: flex; gap: 8px; justify-content: center; margin-top: 14px; }
.signin, .retry {
  padding: 8px 16px; border-radius: var(--radius); font: inherit; font-weight: 500; cursor: pointer;
}
.signin { border: 0; background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.retry { border: 1px solid hsl(var(--border)); background: transparent; color: hsl(var(--foreground)); }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: hsl(var(--muted-foreground)); }
.loading.hide { display: none; }
