/* deco Frames — peças do sabor Studio do design system da deco.
   Importe depois de tokens.css. Medidas de references/components (StudioShell, Sidebar,
   WorkspaceRail, Panel, Button, Badge, Form, DataTable). Só tokens: nada de cor fixa. */

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-size: 13px; line-height: 18px; }
:where(h1, h2, h3, p, figure) { margin: 0; }
:where(button) { font: inherit; color: inherit; letter-spacing: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
:where(input, select, textarea) { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
svg.icon { width: 16px; height: 16px; }
.icon-14 { width: 14px !important; height: 14px !important; }
.icon-12 { width: 12px !important; height: 12px !important; }
.headline { font-size: 24px; line-height: 1.3; font-weight: 500; letter-spacing: -0.02em; text-wrap: balance; }
.muted { color: var(--muted-foreground); }

/* Logo do workspace (marca do cliente). O fundo vem da marca: é a exceção de logo de terceiro. */
.ws-logo { --logo-bg: var(--card); display: grid; place-items: center; flex: none; overflow: hidden; background: var(--logo-bg); box-shadow: var(--shadow-edge); }
.ws-logo img { width: 84%; height: auto; display: block; }
.ws-logo.sm { width: 24px; height: 24px; border-radius: var(--radius-md); }
.ws-logo.md { width: 32px; height: 32px; border-radius: var(--radius-control); }
.ws-logo.lg { width: 48px; height: 48px; border-radius: var(--radius-panel); }
.ws-logo.wide { height: 40px; padding: 0 16px; border-radius: var(--radius-control); }
.ws-logo.wide img { width: auto; height: 13px; }
.ws-logo.wide.initial { width: 40px; padding: 0; font-size: 16px; }
.ws-logo.initial { background: var(--brand-purple-tint); color: var(--brand-purple-dark); font-weight: 500; box-shadow: none; }
.ws-logo.sm.initial { font-size: 11px; }
.ws-logo.lg.initial { font-size: 20px; }

/* Linha do produto no rodapé da sidebar: deixa claro que é uma ferramenta da deco */
.product { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 8px; border-radius: var(--radius-control); color: var(--muted-foreground); }
.product:hover { background: var(--sidebar-accent); }
.product .mk { width: 14px; height: 14px; }
.product b { font-weight: 500; color: var(--foreground); }
.product > span:first-of-type { flex: 1; min-width: 0; white-space: nowrap; }

/* Logo: deco-mark no claro, deco-mark-negative no escuro */
.mk { width: 20px; height: 20px; display: block; }
.mk-dark { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .mk-light { display: none; } :root:not([data-theme="light"]) .mk-dark { display: block; } }
:root[data-theme="dark"] .mk-light { display: none; }
:root[data-theme="dark"] .mk-dark { display: block; }

/* ---------- Moldura: trilho (opcional) + sidebar sem moldura + painel ---------- */
/* Studio deixa a sidebar redimensionável (192–400px); aqui ela abre em 232px para caber o nome das seções. */
:root { --studio-sidebar-width: 232px; }
.shell { display: grid; grid-template-columns: var(--studio-sidebar-width) minmax(0, 1fr); height: 100%; }
.shell.with-rail { grid-template-columns: var(--rail-width) var(--studio-sidebar-width) minmax(0, 1fr); }

.rail { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 8px 8px 12px; border-right: 1px solid var(--sidebar-border); overflow-y: auto; scrollbar-width: none; }
.rail-home .mk { width: 22px; height: 22px; }
.rail-home { width: 36px; height: 36px; border-radius: var(--radius-icon); display: grid; place-items: center; background: var(--card); box-shadow: var(--shadow-edge); position: relative; }
.rail-group { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 12px 4px; border-radius: 12px; background: color-mix(in oklab, var(--foreground) 4%, transparent); width: 52px; }
.rail-item { display: flex; flex-direction: column; align-items: center; gap: 4px; position: relative; width: 100%; }
.rail-name { font-size: 11px; line-height: 14px; color: var(--muted-foreground); max-width: 52px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-item.on .ws-logo { box-shadow: 0 0 0 1.5px var(--foreground); }
.rail-item.on .rail-name { color: var(--foreground); font-weight: 500; }
.rail-item.on::before, .rail-home.on::before { content: ""; position: absolute; left: -12px; top: 2px; width: 4px; height: 28px; border-radius: 0 4px 4px 0; background: var(--foreground); }

.side { display: flex; flex-direction: column; min-height: 0; padding: 0 8px 8px; }
.side-head { height: var(--topbar-height); display: flex; align-items: center; gap: 8px; padding: 0 8px; flex: none; }
.side-head .logo { width: 24px; height: 24px; border-radius: var(--radius-md); background: var(--card); box-shadow: var(--shadow-edge); display: grid; place-items: center; flex: none; }
.side-head .logo .mk { width: 15px; height: 15px; }
.side-head b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-scroll { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: none; display: flex; flex-direction: column; gap: 24px; padding-top: 4px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { height: 24px; display: flex; align-items: center; padding: 0 8px; font-size: 12px; font-weight: 500; color: var(--muted-foreground); }
.nav { height: 32px; display: flex; align-items: center; gap: 8px; padding: 0 8px; border-radius: var(--radius-control); color: var(--sidebar-foreground); }
.nav:hover { background: var(--sidebar-accent); }
.nav.on { background: var(--sidebar-accent); font-weight: 500; }
.nav svg.icon { color: var(--muted-foreground); }
.nav.on svg.icon { color: var(--foreground); }
.nav .txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav .count { font-size: 12px; color: var(--muted-foreground); font-weight: 400; font-variant-numeric: tabular-nums; }

.side-foot { flex: none; display: flex; flex-direction: column; gap: 8px; padding-top: 8px; }
.account { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--radius-control); min-width: 0; }
.avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--sidebar-accent); display: grid; place-items: center; font-size: 11px; font-weight: 500; flex: none; }
.account .who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.account .who b, .account .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account .who b { font-weight: 500; }
.account .who span { font-size: 12px; line-height: 16px; color: var(--muted-foreground); }

.panels { padding: var(--panel-gap) var(--panel-gap) var(--panel-gap) 0; min-width: 0; min-height: 0; display: flex; }
.panel { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--background); border-radius: var(--radius-panel); box-shadow: var(--shadow-edge); overflow: hidden; }
.panel-head { height: var(--topbar-height); flex: none; display: flex; align-items: center; gap: 8px; padding: 0 12px; border-bottom: 1px solid color-mix(in oklab, var(--border) 60%, transparent); }
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 140px; flex: 1 1 auto; padding-left: 4px; }
.crumbs a, .crumbs span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted-foreground); }
.crumbs a:hover { color: var(--foreground); }
.crumbs b { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.crumbs svg.icon { width: 12px; height: 12px; color: var(--subtle-foreground); }
.panel-body { flex: 1; min-height: 0; overflow-y: auto; }
.page { max-width: 1200px; margin: 0 auto; padding: 32px; display: flex; flex-direction: column; gap: 40px; }
.divider-v { width: 1px; height: 16px; background: var(--border); flex: none; }

/* ---------- Botões (pílula) ---------- */
.btn { height: 32px; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: var(--radius-pill); font-weight: 500; white-space: nowrap; background: var(--secondary); color: var(--foreground); }
.btn:hover { background: var(--secondary-hover); }
.btn:active { transform: translateY(1px); }
.btn-sm { height: 28px; padding: 0 12px; }
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: var(--card); box-shadow: var(--shadow-edge); }
.btn-outline:hover { background: var(--accent); }
.btn-ghost { background: transparent; color: var(--muted-foreground); }
.btn-ghost:hover { background: var(--accent); color: var(--foreground); }
.btn-danger:hover { color: var(--destructive); }
.btn svg.icon { width: 14px; height: 14px; }
.btn[disabled] { opacity: .4; pointer-events: none; }
.ibtn { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; color: color-mix(in oklab, var(--sidebar-foreground) 60%, transparent); flex: none; }
.ibtn:hover { background: var(--accent); color: var(--foreground); }
.ibtn-sm { width: 28px; height: 28px; }
.ibtn[disabled] { opacity: .4; pointer-events: none; }

/* ---------- Badges ---------- */
.status { height: 18px; display: inline-flex; align-items: center; gap: 5px; padding: 0 7px; border-radius: var(--radius-pill); background: var(--card); box-shadow: var(--shadow-edge); font-size: 11px; font-weight: 500; line-height: 1; white-space: nowrap; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c, var(--subtle-foreground)); flex: none; }
.chip { height: 20px; display: inline-flex; align-items: center; gap: 4px; padding: 0 8px; border-radius: var(--radius-pill); background: var(--muted); color: var(--muted-foreground); font-size: 12px; font-weight: 500; white-space: nowrap; }
.chip-dark { background: var(--primary); color: var(--primary-foreground); }
.chip-brand { background: var(--brand-lime-tint); color: var(--brand-foreground); }

/* ---------- Formulário ---------- */
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field > label { font-weight: 500; }
.input { height: var(--control-height); width: 100%; padding: 4px 12px; border-radius: var(--radius-control); border: 0; background: var(--input-background); box-shadow: var(--shadow-edge); outline-offset: 2px; }
.input:hover { background: var(--sidebar); }
.input::placeholder { color: var(--subtle-foreground); }
.input-sm { height: 32px; }
select.input { appearance: none; padding-right: 32px; background-image: none; }
.select { position: relative; }
.select svg.icon { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--muted-foreground); }
.search-box { position: relative; width: 220px; max-width: 100%; }
.search-box svg.icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted-foreground); pointer-events: none; }
.search-box .input { padding-left: 32px; }
.help { font-size: 12px; line-height: 16px; color: var(--muted-foreground); }
.help.err { color: var(--destructive); }
.alert { padding: 10px 12px; border-radius: var(--radius-control); background: color-mix(in oklab, var(--destructive) 10%, transparent); box-shadow: inset 0 0 0 1px var(--destructive); color: var(--destructive); }

/* Controle segmentado */
.seg { display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--radius-pill); background: var(--muted); }
.seg button { height: 28px; padding: 0 12px; border-radius: var(--radius-pill); font-weight: 500; color: var(--muted-foreground); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.seg button:hover { color: var(--foreground); }
.seg button.on { background: var(--card); color: var(--foreground); box-shadow: var(--shadow-edge); }
.seg.icons button { width: 28px; padding: 0; justify-content: center; }
.seg.icons svg.icon { width: 14px; height: 14px; }
.seg.wide { display: flex; }
.seg.wide button { flex: 1; justify-content: center; }

/* ---------- Tabela em card surface ---------- */
.table-card { overflow: hidden; }
.table-scroll { overflow-x: auto; }
table.dt { width: 100%; border-collapse: collapse; }
.dt th { height: 40px; text-align: left; font-weight: 400; color: var(--muted-foreground); padding: 0 8px; background: var(--card); position: sticky; top: 0; white-space: nowrap; }
.dt td { padding: 8px; border-top: 1px solid color-mix(in oklab, var(--border) 50%, transparent); vertical-align: middle; }
.dt th:first-child, .dt td:first-child { padding-left: 16px; }
.dt th:last-child, .dt td:last-child { padding-right: 16px; }
.dt tbody tr:hover { background: var(--muted); }
.dt .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Estado vazio */
.empty { padding: 64px 16px; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.empty b { font-size: 14px; line-height: 20px; font-weight: 500; }
.empty span { color: var(--muted-foreground); }

@media (max-width: 860px) {
  .shell, .shell.with-rail { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .rail { display: none; }
  .side { padding: 0 8px; }
  .side-scroll { flex-direction: row; overflow-x: auto; gap: 4px; padding: 0 0 8px; }
  .side-scroll .nav-group { flex-direction: row; gap: 4px; }
  .side-scroll .nav-label, .side-foot, .nav .count, .nav svg.icon { display: none; }
  .nav { flex: none; white-space: nowrap; }
  .panels { padding: 0 var(--panel-gap) var(--panel-gap); }
  .page { padding: 16px; gap: 24px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
