/* ============================================================================
   VEERHA — SCREENS
   Shell composition.

   The design system defines the shell's *parts* (.v-rail, .v-topbar,
   .v-sidenav, .v-crumb, .v-pagehead). This file assembles them into the app
   frame, and wraps each screen in the labelled frame the deliverable presents
   them in.

   Layout only. No colours, no radii, no type sizes that aren't tokens —
   anything visual belongs in the design system, not here.
   ============================================================================ */


/* --- THE FRAME -----------------------------------------------------------
   One screen = one frame. Label above, the app inside. The equivalent of an
   artboard, and the reason this folder reads like a design file rather than
   a website. */

.vs-frame { margin-top: var(--s-12); scroll-margin-top: 76px; }
.vs-frame:first-of-type { margin-top: var(--s-8); }

.vs-frame__hd {
  display: flex; align-items: baseline; gap: var(--s-3);
  margin-bottom: var(--s-3); flex-wrap: wrap;
}
.vs-frame__n {
  font-family: var(--num); font-size: var(--t-meta-s); color: var(--text-muted);
  border: 1px solid var(--border); border-radius: var(--r-chip);
  padding: 1px 6px; background: var(--surface);
}
.vs-frame__name { font-size: var(--t-card-s); font-weight: 600; letter-spacing: -.008em; }
.vs-frame__route {
  font-family: var(--num); font-size: var(--t-meta-s); color: var(--brand-700);
  background: var(--brand-50); padding: 1px 6px; border-radius: var(--r-xs);
}
.vs-frame__note {
  font-size: var(--t-small-s); color: var(--text-muted);
  max-width: 86ch; margin-bottom: var(--s-3);
}
.vs-frame__box {
  border: 1px solid var(--border-strong); border-radius: var(--r-card);
  overflow: hidden; background: var(--canvas); box-shadow: var(--e1);
}

/* A frame that has to show a fixed viewport — the three-pane inbox, anything
   whose panes only make sense at a real height. */
.vs-frame--h720 .vs-app { height: 720px; }
.vs-frame--h620 .vs-app { height: 620px; }
.vs-frame--h520 .vs-app { height: 520px; }
.vs-frame--h420 .vs-app { height: 420px; }


/* --- THE APP -------------------------------------------------------------
   Rail on the left, everything else in a column beside it. The rail stretches
   to the full height of whatever the screen contains. */

.vs-app {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
}
/* Same rule for the frame shell: the rail is expanded by default, so the
   grid column has to be --rail-open or the page slides under it. */
.vs-app:has(> .v-rail.is-expanded) {
  grid-template-columns: var(--rail-open) minmax(0, 1fr);
  background: var(--canvas);
  position: relative;
}
.vs-app > .v-rail { height: 100%; }

.vs-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }


/* The scrolling region. On a fixed-height frame it scrolls; on an auto frame
   it simply grows. */
.vs-body { flex: 1; min-height: 0; overflow: auto; display: flex; min-width: 0; }

/* The page canvas — where a screen's content lives. */
.vs-canvas { flex: 1; min-width: 0; padding: var(--s-6) var(--s-8) var(--s-12); }
.vs-canvas--flush { padding: 0; }
.vs-canvas--narrow { max-width: 900px; }

/* A screen with a second-level nav (Settings, Marketing, Catalog, AI). */
.vs-body--sectioned > .v-sidenav { flex: none; }

/* Full-bleed screens: the inbox, the builders — they manage their own columns
   and must not get canvas padding. */
.vs-body--panes { overflow: hidden; }
/* A bar above the panes (Mail and Chat views): the body stacks, panes fill. A
   class, not an inline style, because the walkthrough copies classes only. */
.vs-body--stack { flex-direction: column; }
.vs-body--stack > .vs-panes { flex: 1; min-height: 0; }


/* --- TOP BAR EXTRAS ------------------------------------------------------
   The design system's .v-topbar is the bar; these are the things that sit in
   it on a real screen. */

.vs-topbar__menu {
  width: 32px; height: 32px; border-radius: var(--r-sm); flex: none;
  display: grid; place-items: center; color: var(--text-muted);
  background: none; border: 0; cursor: pointer;
}
.vs-topbar__menu:hover { background: var(--surface-subtle); color: var(--text-secondary); }
.vs-topbar__search { flex: 1; max-width: 420px; }
.vs-topbar__acts { display: flex; align-items: center; gap: var(--s-2); margin-left: auto; }


/* --- SECOND-LEVEL NAV EXTRAS --------------------------------------------- */

/* The section nav carries the module name only — the top bar already shows
   the full path, and the two sitting 40px apart was the same information
   twice. */
.vs-sidenav__head { padding-bottom: var(--s-3); border-bottom: 1px solid var(--border); }
.vs-sidenav__search { margin-top: var(--s-2); }


/* --- TAB STRIP UNDER THE TOP BAR -----------------------------------------
   A third navigation form the product uses: Today | Analytics,
   WhatsApp | Customer Mail | Callbacks. It sits flush under the topbar and
   spans the content column. */

.vs-tabstrip {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0 var(--s-8); flex: none;
}
.vs-tabstrip .v-tabs { border-bottom: 0; }
/* Generated by tools/shell.py for the rows with top tabs (Dashboard,
   Conversations, Customers). Sits between the top bar and the body, so it works
   above a canvas, a sectioned body or a full-bleed pane layout. */


/* --- PAGE-LEVEL LAYOUT HELPERS -------------------------------------------
   Used by the archetype recipes. Grid only. */

.vs-filterbar {
  display: flex; align-items: center; gap: var(--s-3);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-tile); padding: var(--s-3) var(--s-4);
  margin-bottom: var(--s-4); flex-wrap: wrap;
}
.vs-filterbar__search { flex: 1; min-width: 220px; }

/* Two columns, main + rail. The drawer body and several detail screens. */
.vs-split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--s-5); align-items: start; }
.vs-split--wide { grid-template-columns: minmax(0, 1fr) 380px; }

/* Three panes — inbox, mail, the builders. */
.vs-panes { display: grid; min-height: 0; width: 100%; }
.vs-panes--inbox { grid-template-columns: 320px minmax(0, 1fr) 320px; }
.vs-panes--builder { grid-template-columns: 200px minmax(0, 1fr) 300px; }
.vs-pane { min-width: 0; min-height: 0; overflow: auto; border-right: 1px solid var(--border); background: var(--surface); }
.vs-pane:last-child { border-right: 0; }
.vs-pane--canvas { background: var(--canvas); }
.vs-pane__back { display: none; }   /* phone only: the inbox's way back to the list */
.vs-pane__hd {
  padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border);
  background: var(--surface); position: sticky; top: 0; z-index: var(--z-sticky);
}

/* A drawer sitting over the screen behind it. Drawn, not animated. */
.vs-overlay { position: absolute; inset: 0; display: flex; justify-content: flex-end; z-index: var(--z-overlay); }
/* The point of a drawer over a modal is that the list stays readable behind
   it. At 78% it was a sliver; 62% keeps enough of the table to see where you
   are and what is next. */
.vs-overlay .v-drawer { position: relative; z-index: var(--z-raised); width: 980px; max-width: 62%; }
.vs-overlay--modal { align-items: center; justify-content: center; }
.vs-overlay .v-modal { position: relative; z-index: var(--z-raised); max-height: calc(100% - 2 * var(--s-6)); overflow: auto; }

/* Card grids used by A6 and the dashboard. */
.vs-cards { display: grid; gap: var(--s-4); }
.vs-cards--2 { grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); }
.vs-cards--3 { grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); }


/* --- THE ORG TREE --------------------------------------------------------
   Connectors only — the nodes themselves are .v-card from the design system.
   Lines are 1px borders in token colours; nothing here is a new component,
   it is the same reason .vs-panes exists: composition the system doesn't own.

   Structure:  .vs-tree__node  +  .vs-tree__kids > .vs-tree__cell*
   Each cell drops a stem into its node and contributes its half of the
   horizontal bar, so the bar spans first-centre to last-centre automatically
   however many children there are. */

.vs-tree { display: flex; flex-direction: column; align-items: center;
  width: max-content; margin: 0 auto; }
.vs-tree__node { width: 188px; flex: none; }

.vs-tree__kids {
  display: flex; align-items: flex-start; justify-content: center;
  gap: var(--s-3); position: relative; margin-top: var(--s-6);
}
/* stem down out of the parent, landing exactly on the bar */
.vs-tree__kids::before {
  content: ''; position: absolute; top: calc(-1 * var(--s-6)); left: 50%;
  width: 1px; height: var(--s-6); background: var(--border-strong);
}

.vs-tree__cell {
  position: relative; padding-top: var(--s-6);
  display: flex; flex-direction: column; align-items: center;
}
.vs-tree__cell::after {                       /* the shared horizontal bar */
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 1px; background: var(--border-strong);
}
.vs-tree__cell:first-child::after { left: 50%; }
.vs-tree__cell:last-child::after  { right: 50%; }
.vs-tree__cell:only-child::after  { display: none; }
.vs-tree__cell::before {                      /* drop into this node */
  content: ''; position: absolute; top: 0; left: 50%;
  width: 1px; height: var(--s-6); background: var(--border-strong);
}

/* A reporting line into an AI employee is drawn dashed — the org chart's one
   piece of real information: which of these boxes is a person. */
.vs-tree__cell--ai::before, .vs-tree__cell--ai::after { background: none; }
.vs-tree__cell--ai::before { border-left: 1px dashed var(--ai-bd); }
.vs-tree__cell--ai::after  { border-top: 1px dashed var(--ai-bd); }

/* The tray of people nobody has placed yet. It sits under the canvas, not
   inside it, because an unplaced person is not part of the tree. */
.vs-tray {
  border-top: 1px solid var(--border); background: var(--surface);
  padding: var(--s-4) var(--s-6); flex: none;
}
.vs-tray__row { display: flex; gap: var(--s-3); flex-wrap: wrap; align-items: center; }
.vs-canvas--chart { overflow: auto; padding: var(--s-8); }


/* --- THE CADENCE SPINE ---------------------------------------------------
   A sequence is an ordered list of timed steps, so it is drawn as a spine:
   a day marker on the rail, the step beside it, a connecting line between.
   Same reasoning as the org tree -- the cards are .v-card, only the
   connective tissue lives here. */

.vs-spine { display: flex; flex-direction: column; }
.vs-step {
  display: grid; grid-template-columns: 54px 1fr; column-gap: var(--s-4);
  position: relative; padding-bottom: var(--s-4);
}
.vs-step:last-child { padding-bottom: 0; }
/* the line runs from under this step's marker to the next one */
.vs-step:not(:last-child)::before {
  content: ''; position: absolute; left: 27px; top: 34px; bottom: 0;
  width: 1px; background: var(--border-strong);
}
.vs-step__mark {
  grid-row: 1 / span 2; width: 34px; height: 34px; border-radius: var(--r-full);
  border: 1px solid; display: grid; place-items: center; z-index: var(--z-raised);
  justify-self: center;
}
.vs-step__day {
  grid-column: 1; grid-row: 3; text-align: center; margin-top: 4px;
  color: var(--text-muted); white-space: nowrap;   /* "Day 30" must not stack */
}
.vs-step__card { grid-column: 2; grid-row: 1 / span 3; }


/* --- WALKTHROUGH LAYERS ----------------------------------------------------
   A modal, drawer or confirm dialog lifted out of its frame by tools/wtgen.py
   and opened by screens/assets/flows.js. Sits over the stage only, like the
   drawers it replaces, so the sidebar and top bar stay usable behind it. */
.wt-layer { position: absolute; inset: 0; z-index: var(--z-layer); }
.wt-layer[hidden] { display: none; }

/* --- DIALOG SHEETS ---------------------------------------------------------
   A design-sheet frame that lays a module's small dialogs side by side. Each
   dialog is a real overlay (data-layer) so the walkthrough can lift it out and
   open it over a screen; inside the sheet it sits static in its own tile. */
.vs-dialogs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(560px, 100%), 1fr)); gap: var(--s-5); padding: var(--s-6); background: var(--surface-muted); }
.vs-dialogs > .vs-dialog { display: flex; flex-direction: column; gap: var(--s-2); }
.vs-dialogs .vs-overlay { position: relative; inset: auto; min-height: 100%; padding: var(--s-5) 0; border-radius: var(--r-card); }
.vs-dialogs .vs-overlay .v-scrim { border-radius: var(--r-card); }


/* --- NARROW SCREENS ------------------------------------------------------
   The frames are drawn at desktop width, but the walkthrough is the product
   and a reviewer opens it on a phone. Two bands, matching --bp-tablet and
   --bp-phone in tokens.css (custom properties cannot be used in a media
   query, so the numbers are repeated here and nowhere else).

   Inline grids carry their columns in a style attribute, which only
   !important can outrank. The selector is scoped to app bodies, so the guest
   pages (built 390-first) and the seven-column calendars keep their columns. */

@media (max-width: 1024px) {
  .vs-canvas { padding: var(--s-5) var(--s-5) var(--s-10); }
  .vs-tabstrip { padding: 0 var(--s-5); overflow-x: auto; }
  .vs-split, .vs-split--wide { grid-template-columns: minmax(0, 1fr); }
  .vs-panes--inbox { grid-template-columns: 280px minmax(0, 1fr); }
  .vs-panes--builder { grid-template-columns: 180px minmax(0, 1fr); }
  .vs-panes--inbox > .vs-pane:nth-child(3),
  .vs-panes--builder > .vs-pane:nth-child(3) { grid-column: 1 / -1; border-top: 1px solid var(--border); }
  .vs-body--panes { overflow: auto; }
  .vs-overlay .v-drawer { max-width: 88%; }
  .vs-topbar__search { max-width: 280px; }
  /* An inline main + fixed side column (the dashboard brief, the email
     studio) stacks: beside a rail there is no room for the fixed column, and
     the figures inside the main one were clipped. */
  .vs-body [style*="grid-template-columns"][style*="px"]:not([style*="repeat("]):not(.vs-panes):not(.vs-pane) {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .vs-body [style*="grid-template-columns"][style*="px"]:not([style*="repeat("]):not(.vs-panes) > [style*="border-right"] {
    border-right: 0 !important; border-bottom: 1px solid var(--border);
  }
  /* Builders: list, form and preview side by side do not fit beside a rail
     and a section nav, so they stack from tablet down. */
  .vs-body:has(> .vs-pane) { flex-direction: column; overflow: auto; }
  .vs-body > .vs-pane { width: auto !important; flex: none !important; border-right: 0 !important; border-bottom: 1px solid var(--border); }
}

@media (max-width: 760px) {
  .vs-overlay--modal { align-items: flex-end; }
  .vs-overlay .v-modal { max-height: 92%; }

  /* frames: the rail would take two thirds of the screen; the walkthrough
     turns it into an off-canvas menu instead (walkthrough.html) */
  .vs-app, .vs-app:has(> .v-rail.is-expanded) { grid-template-columns: minmax(0, 1fr); }
  .vs-app > .v-rail { display: none; }

  .vs-canvas { padding: var(--s-4) var(--s-4) var(--s-8); }
  .vs-tabstrip { padding: 0 var(--s-4); }

  /* The section nav becomes one sideways-scrolling strip above the page. As a
     stacked list it was a whole screen of links before the page began. Group
     labels, its search and the help card fold away; behaviour.js scrolls the
     active item into view. */
  .vs-body--sectioned { flex-direction: column; }
  /* A centred canvas (margin:0 auto) sizes to its content, not the screen,
     so one wide stepper made the whole setup guide wider than the phone. */
  .vs-body > .vs-canvas { width: 100%; min-width: 0; }
  .vs-body--sectioned > .v-sidenav {
    width: auto; flex: none; flex-direction: row; align-items: center; gap: var(--s-1);
    padding: var(--s-2) var(--s-4); overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
    border-right: 0; border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: var(--z-sticky);
    /* Soft edges say "there is more this way". Mask alpha only; the colour is irrelevant. */
    -webkit-mask-image: linear-gradient(to right, transparent, var(--text-primary) var(--s-3), var(--text-primary) calc(100% - var(--s-6)), transparent);
            mask-image: linear-gradient(to right, transparent, var(--text-primary) var(--s-3), var(--text-primary) calc(100% - var(--s-6)), transparent);
  }
  .vs-body--sectioned > .v-sidenav::-webkit-scrollbar { display: none; }
  .vs-body--sectioned > .v-sidenav :is(.vs-sidenav__head, .v-sidenav__label, .v-sidenav__help, .vs-sidenav__search) { display: none; }
  .vs-body--sectioned > .v-sidenav > :not(.v-sidenav__group):not(.v-sidenav__item):not(.vs-sidenav__head):not(.v-sidenav__help) { flex: none; }
  .vs-body--sectioned > .v-sidenav .v-sidenav__group { flex-direction: row; gap: var(--s-1); flex: none; }
  .vs-body--sectioned > .v-sidenav .v-sidenav__group + .v-sidenav__group { border-left: 1px solid var(--border); padding-left: var(--s-1); }
  .vs-body--sectioned > .v-sidenav .v-sidenav__item { white-space: nowrap; flex: none; padding: 6px var(--s-3); min-height: var(--tap); }
  .vs-body--sectioned > .v-sidenav .v-sidenav__item.is-active::before { left: var(--s-3); right: var(--s-3); top: auto; bottom: 0; width: auto; height: 2px; }

  .vs-panes, .vs-panes--inbox, .vs-panes--builder { grid-template-columns: minmax(0, 1fr) !important; }
  /* Inbox, master/detail: the list, or one conversation with a way back.
     Stacked, the thread sat a full list-length below the list that opened it.
     behaviour.js toggles .is-thread and adds the back button. */
  /* !important: the thread pane carries an inline display:flex. */
  .vs-panes--inbox:not(.is-thread) > .vs-pane:not(:first-child) { display: none !important; }
  .vs-panes--inbox.is-thread > .vs-pane:first-child { display: none !important; }
  .vs-pane__back { display: inline-flex; margin: 0 0 var(--s-2) calc(-1 * var(--s-2)); }
  /* stacked panes take their natural height; the body scrolls, not each pane */
  .vs-pane { border-right: 0; border-bottom: 1px solid var(--border); overflow: visible; }
  .vs-panes { flex: none !important; height: auto !important; min-height: 0 !important; align-content: start; }
  /* ...and its row-flex parent must not stretch it back to the screen's
     height: stretched, the rows split 788px and the steps spilled over the
     pane below. */
  .vs-body--panes { align-items: flex-start; }
  /* Builders lay their panes out as a flex row with fixed pane widths; on a
     phone they stack the same way the grid panes do. Stacked, a pane header
     no longer pins -- it would slide over the pane above it. */
  .vs-body:has(> .vs-pane) { flex-direction: column; overflow: auto; }
  .vs-body > .vs-pane { width: auto !important; flex: none !important; }
  .vs-pane__hd { position: static; }
  .vs-pane--canvas { padding: var(--s-4) !important; }
  /* a fixed-size preview (the creative studio's square) scales to the screen */
  .vs-pane--canvas [style*="width:380px"][style*="height:380px"] { width: 100% !important; max-width: 380px; height: auto !important; aspect-ratio: 1; }
  /* Inline grids: a row of four to six figures pairs up; anything else -- a
     form's two columns, main + side, three cards -- stacks. */
  .vs-body [style*="grid-template-columns"]:not([style*="repeat(7"]):not(.vs-pane) {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .vs-body [style*="grid-template-columns"]:is([style*="repeat(4,"], [style*="repeat(5,"], [style*="repeat(6,"]):not(.vs-pane) {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  /* A pipeline board on a phone: one stage at a time, swiped sideways, with
     the next stage's edge showing so the swipe is discoverable. Two squeezed
     columns read stages out of order (New, Qualified / Proposal, ...). */
  .vs-body .vs-board[style*="grid-template-columns"]:not(.vs-pane) {
    grid-template-columns: none !important; grid-auto-flow: column; grid-auto-columns: 82%;
    overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
    padding-bottom: var(--s-2);
  }
  .vs-board > * { scroll-snap-align: start; }
  .vs-board::-webkit-scrollbar { display: none; }
  /* ...and when those figures are ruled, the rules follow the new grid. */
  .vs-body :is([style*="repeat(4,"], [style*="repeat(5,"], [style*="repeat(6,"]) > [style*="border-right"]:nth-child(2n) { border-right: 0 !important; }
  .vs-body :is([style*="repeat(4,"], [style*="repeat(5,"], [style*="repeat(6,"]):has(> [style*="border-right"]) > :nth-child(n+3) { border-top: 1px solid var(--border); }
  .vs-body :is([style*="repeat(5,"]):has(> [style*="border-right"]) > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  /* stacked, a ruled column's right rule becomes the rule between rows */
  .vs-body [style*="grid-template-columns"]:not(:is([style*="repeat(4,"], [style*="repeat(5,"], [style*="repeat(6,"], [style*="repeat(7"])) > [style*="border-right"] {
    border-right: 0 !important; border-bottom: 1px solid var(--border);
  }
  .vs-body [style*="grid-template-columns"]:not(:is([style*="repeat(4,"], [style*="repeat(5,"], [style*="repeat(6,"], [style*="repeat(7"])) > [style*="border-right"]:last-child { border-bottom: 0; }
  /* An inline flex row of copy and controls wraps like .row does. */
  .vs-body :is(.vs-canvas, .vs-pane, .v-drawer__body, .v-card) [style*="display:flex"]:not([style*="column"]):not(td *) { flex-wrap: wrap; }
  .vs-body :is(.vs-canvas, .vs-pane, .v-drawer__body, .v-card) [style*="display:flex"]:not([style*="column"]):not(td *) > :is(.grow, [style*="flex:1"]):not(:empty) {
    flex: 1 1 0; min-width: min(14rem, 100%);
  }
  .vs-filterbar__search { min-width: 0; flex-basis: 100%; }
  .vs-filterbar > .grow:not(:empty) { flex: 1 1 0; min-width: min(13rem, 100%); }
  /* A settings row drawn as label | fields | switch: the label takes its own
     line and the fields shrink to fit the one below. */
  .vs-body [style*="display:flex"] > span.t-small[style*="width:"]:first-child { flex-basis: 100% !important; width: auto !important; }
  .vs-body [style*="display:flex"] > .v-input[style*="width:"] { width: auto !important; flex: 0 1 7rem; min-width: 4.5rem; }

  .vs-topbar__search, .v-topbar__who { display: none; }
  .vs-overlay .v-drawer { width: 100%; max-width: 100%; }
  .vs-overlay .v-modal { width: calc(100% - 2 * var(--s-4)); }
  /* the org chart keeps its width and scrolls from its left edge */
  .vs-tree { margin: 0; }
  .vs-canvas--chart { padding: var(--s-4); }
}

/* Sign-in and its siblings: the brand panel stacks above the form on a phone
   and gives up its decorative bullets, so the form is the first thing seen. */
@media (max-width: 760px) {
  :has(> .vs-auth) { grid-template-columns: minmax(0, 1fr); padding: var(--s-4) !important; min-height: 0 !important; }
  .vs-auth { flex-direction: column; width: auto !important; min-height: 0 !important; }
  .vs-auth__aside { width: auto !important; padding: var(--s-5) !important; }
  .vs-auth__aside > :not(:first-child) { display: none !important; }
  .vs-auth > :last-child { padding: var(--s-5) !important; }
}
