/*
  Fyro Ensemble (admin) — app-specific styles only.
  Everything generic comes from the Fyro design system (https://design.fyroadv.com):
  fyro-tokens.css + fyro.css, loaded first. Rules here:
    - colours only from tokens: hsl(var(--token)), never HEX/rgb
    - reuse fy- components; add a class here only for what the system has no piece for
    - page-only styles go in assets/css/pages/<page>.css (loaded via $page_css)
*/

/* Icons (inline Lucide SVG from icon()) ----------------------------------- */
.icon { width: 16px; height: 16px; flex: none; display: inline-block; vertical-align: -0.2em; }
.fy-btn .icon { width: 15px; height: 15px; }
.icon--sm { width: 13px; height: 13px; }
.icon--lg { width: 20px; height: 20px; }

/* Shell ------------------------------------------------------------------- */
.fy-nav-item .nav-count {
  margin-left: auto;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: hsl(var(--warning) / 0.16);
  color: hsl(var(--warning));
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
}
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 4px 2px 0 6px; min-width: 0; }
.sidebar-user__text { flex: 1; min-width: 0; line-height: 1.3; }
.sidebar-user__name { font-size: 13px; font-weight: 600; color: hsl(var(--sidebar-accent-foreground)); }
.sidebar-user__email { font-size: 11px; color: hsl(var(--muted-foreground)); }
.theme-switch > button { padding: 4px 7px; }
.theme-switch .icon { width: 14px; height: 14px; }

/* Avatars: photo, or initial on the agent's categorical colour (agentAvatar()) */
.avatar {
  --size: 28px;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  object-fit: cover;
  color: hsl(0 0% 100%);
  font-size: calc(var(--size) * 0.42);
  font-weight: 600;
  line-height: 1;
}
.avatar--sm { --size: 22px; }
.avatar--lg { --size: 40px; }
.avatar--xl { --size: 56px; }

/* Page header inside .fy-page (title lives in the top bar; this is the intro line + actions) */
.page-intro { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.page-intro__text { font-size: 13px; color: hsl(var(--muted-foreground)); max-width: 720px; }

/* Section label above a block */
.section-label { margin-bottom: 8px; }

/* Tab counts (pageTabs()) */
.fy-tabs .tab-count {
  display: inline-block;
  min-width: 18px;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 999px;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  line-height: 17px;
  text-align: center;
}
.fy-tabs .is-active .tab-count { background: hsl(var(--primary-subtle)); color: hsl(var(--primary)); }

/* Row list: a card of clickable rows (dashboard lists, task list, activity) */
.row-list { display: flex; flex-direction: column; }
.row-list > .row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 10px 16px;
  border-bottom: 1px solid hsl(var(--border));
  color: inherit;
  font-weight: 400;
  text-decoration: none;
}
.row-list > .row:last-child { border-bottom: 0; }
a.row:hover { background: hsl(var(--accent) / 0.6); text-decoration: none; }
.row__main { flex: 1; min-width: 0; }
.row__title { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__sub { font-size: 12px; color: hsl(var(--muted-foreground)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__meta { flex: none; font-size: 12px; color: hsl(var(--muted-foreground)); white-space: nowrap; }
.row__time { flex: none; min-width: 56px; text-align: right; font-size: 12px; color: hsl(var(--muted-foreground)); white-space: nowrap; }
.row__icon { flex: none; display: inline-grid; place-items: center; width: 24px; }
.row .icon-chevron { flex: none; color: hsl(var(--muted-foreground)); opacity: .6; }

/* Live dot for running work */
.live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: hsl(var(--cc-rest)); flex: none; }
.live-dot--on { background: hsl(var(--positive)); box-shadow: 0 0 0 3px hsl(var(--positive) / 0.18); animation: live-pulse 2s ease-in-out infinite; }
@keyframes live-pulse { 50% { box-shadow: 0 0 0 5px hsl(var(--positive) / 0.05); } }

/* Key/value meta grid (task, agent details) */
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.meta-grid__label { margin-bottom: 4px; }
.meta-grid__value { font-size: 13px; font-weight: 500; overflow-wrap: anywhere; }

/* Plain-text agent output, prompts, payloads */
.prose-pre {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-md);
  background: hsl(var(--muted));
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 480px;
  overflow: auto;
}

/* Charts (server-rendered, no library) ------------------------------------ */
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: hsl(var(--muted-foreground)); }
.chart-legend > span { display: inline-flex; align-items: center; gap: 6px; }

/* Vertical stacked bars: .vbars > .vbar[title] > .vbar__stack > .vbar__seg[style=height] */
.vbars { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding-bottom: 18px; position: relative; }
.vbar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; position: relative; min-width: 0; }
.vbar__stack { display: flex; flex-direction: column-reverse; height: 100%; justify-content: flex-start; border-radius: 3px 3px 0 0; overflow: hidden; background: hsl(var(--muted)); }
.vbar__seg { width: 100%; flex: none; }
.vbar__label { position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%); font-size: 10px; color: hsl(var(--muted-foreground)); white-space: nowrap; }

/* Horizontal bars: .hbars > .hbar > label / track > fill / value */
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(70px, 30%) 1fr auto; align-items: center; gap: 10px; font-size: 12px; }
.hbar__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar__track { height: 8px; border-radius: 999px; background: hsl(var(--muted)); overflow: hidden; }
.hbar__fill { height: 100%; border-radius: 999px; min-width: 2px; }
.hbar__value { font-family: var(--font-mono); font-size: 12px; font-weight: 500; text-align: right; min-width: 3ch; }

/* Ring gauge */
.ring { position: relative; width: 112px; height: 112px; margin: 4px auto 0; }
.ring svg { width: 100%; height: 100%; }
.ring__track { stroke: hsl(var(--muted)); }
.ring__value { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-mono); font-size: 22px; font-weight: 600; }

/* Timeline (task events) -------------------------------------------------- */
.timeline { position: relative; display: flex; flex-direction: column; }
.timeline__item { position: relative; display: grid; grid-template-columns: 28px 1fr; gap: 12px; padding-bottom: 18px; }
.timeline__item::before { content: ""; position: absolute; left: 13px; top: 26px; bottom: 0; width: 1px; background: hsl(var(--border)); }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__item:last-child::before { display: none; }
.timeline__icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 1px solid hsl(var(--border)); background: hsl(var(--card)); }
.timeline__icon .icon { width: 14px; height: 14px; }
.timeline__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; min-height: 28px; padding-top: 4px; }
.timeline__title { font-size: 13px; font-weight: 600; }
.timeline__time { font-size: 12px; color: hsl(var(--muted-foreground)); white-space: nowrap; }
.timeline__body { margin-top: 6px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }

/* Auth pages (login, SSO errors): centred card on the app background ------- */
.auth-page { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-box { width: 100%; max-width: 380px; display: flex; flex-direction: column; align-items: center; gap: 24px; }
.auth-box > .fy-card { width: 100%; }
.auth-divider { display: flex; align-items: center; gap: 12px; color: hsl(var(--muted-foreground)); font-size: 12px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: hsl(var(--border)); }

@media (max-width: 768px) {
  .hbar { grid-template-columns: minmax(60px, 34%) 1fr auto; }
  .row-list > .row { padding: 10px 14px; }
  .theme-switch > button { min-height: 32px !important; }
}

/* KPI cards two-up on phones instead of a tall single column */
@media (max-width: 640px) {
  .fy-kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .fy-kpi-card { padding: 12px; }
  .fy-kpi-card__value { font-size: 22px; }
}

/* Theme switch lives in the top bar on desktop, in the sidebar drawer on phones */
.theme-switch--drawer { display: none; width: 100%; margin-bottom: 10px; }
@media (max-width: 640px) {
  .fy-topbar .theme-switch { display: none; }
  .theme-switch--drawer { display: flex; }
  .fy-topbar__actions .fy-btn { padding: 0 10px; }
}
