/* PAGE FRAME: the single source of truth for page width, page background, page spacing and the footer.
   Every page (company and admin) is drawn inside .wt-main > .main-content by layouts/admin/app_bs.blade.php.
   Change --wt-content-width in tokens/space.css and every page follows.
   Page CSS must not set its own max-width / outer margin / outer padding / background on its root element;
   the rules below force the frame on every known page root so older page files cannot drift.
   The chat pages and the automation (flows) pages keep their own style: body.chat-page-mode, body.ws-page and body.wt-own-style (set in app_bs.blade.php by route) are left alone. */

/* 1. Background: one colour behind every page, nothing painted by page roots */
html:has(body.wt-skin),body.wt-skin{background:var(--wt-color-page) !important}
.wt-skin .wt-main,.wt-skin .wt-main > .main-content{background:var(--wt-color-page)}

/* 2. Width, background and spacing: EVERY block that sits directly in .main-content is a page root, whatever its class.
   (Nothing is listed by name, so a new page cannot be missed.) Excluded: the page-title hero, overlays/modals/menus/loaders,
   and the chat and automation pages (they have their own style, see CLAUDE.md). */
:root{--wt-frame-pad-top:var(--wt-space-6);--wt-frame-pad-bottom:var(--wt-space-8)}
.wt-skin:not(.chat-page-mode):not(.ws-page):not(.wt-own-style) .main-content > :is(div,section,main,article,form):not(.header,.modal,.ca-modal,.tp-modal,.ca-menu,.template-loader,.wt-drawer-scrim,.wt-scrim,.chat-page-shell,.chat-app,[hidden],[style*="position:fixed"],[style*="position: fixed"]){
  width:var(--wt-content-width) !important;max-width:none !important;min-height:0 !important;
  margin:0 auto !important;padding:var(--wt-frame-pad-top) 0 var(--wt-frame-pad-bottom) !important;
  background:transparent !important;box-sizing:border-box}
/* a wrapper whose only job is to hold the .wt-content page adds no spacing of its own (same specificity as the rule above, so it wins by order) */
.wt-skin:not(.chat-page-mode):not(.ws-page):not(.wt-own-style) .main-content > :is(.wt-scope,div):has(> .wt-content):not(.header,.modal,.ca-modal,.tp-modal,.ca-menu,.template-loader,.wt-drawer-scrim,.wt-scrim,.chat-page-shell,.chat-app,[hidden]){padding-block:0 !important}
.wt-skin:not(.chat-page-mode):not(.ws-page):not(.wt-own-style) .main-content > :is(.wt-scope,div):has(> .wt-content) > .wt-content{padding-block:var(--wt-frame-pad-top) var(--wt-frame-pad-bottom) !important}

/* 3. Page roots nested inside another page wrapper fill it: never narrower or wider. Their side padding is a page margin and is removed,
   except on elements that are also cards (.wa-capacity: border, radius, own padding) which must keep it. */
.wt-skin:not(.chat-page-mode):not(.ws-page):not(.wt-own-style) .main-content > * :is(.wt-content,.wt-apps,.cs,.wa-limits-page,.wz-page,.ws-alay,.wtc .page,.mc .shell,.tpl,.wa-client-directory,.wa-cs,.wa-bk,.wa-bd,.elog-shell,.ops-shell,.odoo-ops .ops-shell,.ns-page,.wa-onboarding-inner,.wa-conn-inner){width:100% !important;max-width:none !important;margin-inline:0 !important;box-sizing:border-box}
.wt-skin:not(.chat-page-mode):not(.ws-page):not(.wt-own-style) .main-content > * :is(.wt-content,.wt-apps,.cs,.wa-limits-page,.wz-page,.ws-alay,.wtc .page,.mc .shell,.tpl,.wa-client-directory,.wa-cs,.wa-bk,.wa-bd,.elog-shell,.ops-shell,.odoo-ops .ops-shell,.ns-page,.wa-onboarding-inner,.wa-conn-inner):not(.wa-capacity){padding-inline:0 !important}
.wt-skin:not(.chat-page-mode):not(.ws-page):not(.wt-own-style) .main-content > .container-fluid{padding-inline:0 !important}
/* Plain page-title blocks (.header): a populated one is the page top and gets the same top space as every root (some pages pull their title up with a negative margin and rely on it); an empty spacer gets none */
.wt-skin .main-content > .header:not(:is([style*="background"],.recovery-header,.campaign-builder-hero,.crm-import-header,.wt-hero)){padding-block:0 !important;min-height:0}
.wt-skin:not(.chat-page-mode):not(.ws-page):not(.wt-own-style) .main-content > .header:not(:is([style*="background"],.recovery-header,.campaign-builder-hero,.crm-import-header,.wt-hero)):has(*){padding-top:var(--wt-frame-pad-top) !important}
.wt-skin:not(.chat-page-mode):not(.ws-page):not(.wt-own-style) .main-content > .header:not(:is([style*="background"],.recovery-header,.campaign-builder-hero,.crm-import-header,.wt-hero)):has(*):last-child{padding-bottom:var(--wt-frame-pad-bottom) !important}

/* 4. Footer: one footer, same width and background everywhere */
.wt-skin .wt-foot{width:var(--wt-content-width);margin-inline:auto;box-sizing:border-box;padding-inline:0;background:transparent}

@media (max-width:900px){
  .wt-skin:not(.chat-page-mode):not(.ws-page):not(.wt-own-style) .main-content > :is(div,section,main,article,form):not(.header,.modal,.ca-modal,.tp-modal,.ca-menu,.template-loader,.wt-drawer-scrim,.wt-scrim,.chat-page-shell,.chat-app,[hidden],[style*="position:fixed"],[style*="position: fixed"]){width:calc(100% - 2 * var(--wt-space-4)) !important}
  .wt-skin .wt-foot{width:calc(100% - 2 * var(--wt-space-4))}
}

/* Chat and automation pages keep their own width (not the capped frame width) */
body.wt-own-style,body.chat-page-mode,body.ws-page{--wt-content-width:96%}
