/* VC-27: VybeCRM's look, laid over Flint.
 *
 * The VybeCRM design system (design-system/vybecrm/: indigo, teal and coral, the ribbon logo, system type)
 * is the app's look. This file gives Flint's own tokens VybeCRM's values, so every Flint component, and App
 * Builder's screens, which use only Flint's classes and tokens, take the look without being changed.
 * Flint keeps what it is better at: the density, neutral greys and narrow type of grids and spreadsheets.
 *
 * The selector outranks Flint's `:root`, so it wins wherever Flint's tokens are loaded again
 * (App Builder's stylesheet carries its own copy, further down the page).
 */
html[data-brand="vybecrm"] {
  /* Surfaces and ink: VybeCRM's tinted canvas, white work areas, indigo-black ink. */
  --ground: #F8F7FB;
  --paper: #FFFFFF;
  --paper-2: #F3F1F8;
  --paper-3: #ECE8F4;
  --line: #E5E0ED;
  --line-2: #D6CFE2;
  --rule: #8C829F;
  --ink: #211638;
  --ink-2: #665D78;
  --ink-3: #6B627E;
  /* The accent: brand indigo in place of Flint's blue. */
  --flint: #2D1192;
  --flint-hover: #3F24A6;
  --flint-text: #2D1192;
  --flint-tint: #EEE8FC;
  --on-flint: #FFFFFF;
  /* Flint's highlight becomes brand teal, with dark text over it. */
  --spark: #01C5AD;
  --ink-on-spark: #211638;
  --spark-text: #075D50;
  --ok: #075D50;
  --ok-tint: #DDF7EF;
  --risk: #704700;
  --risk-tint: #FFF1D7;
  --bad: #922B28;
  --bad-tint: #FDE9E7;
  --bad-fill: #922B28;
  --on-bad: #FFFFFF;
  /* Charts carry the ribbon: indigo, teal, coral, then quieter companions. */
  --cat-1: #2D1192;
  --cat-2: #01C5AD;
  --cat-3: #FC5E53;
  --cat-4: #8B6FE8;
  --cat-5: #665D78;
  --cat-6: #C98A00;
  --shadow-float: 0 14px 40px #21163818, 0 1px 2px #21163814;
  --focus-ring: 0 0 0 2px #FFFFFF, 0 0 0 4px #5835C7;
  --cell-ring: inset 0 0 0 2px #2D1192;
  --frame-halo: 0 0 0 3px #EEE8FC;
  /* Type: the system's own UI face for text and headings alike. */
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-slab: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  /* Softer corners on controls and surfaces. */
  --radius-2: 6px;
  --radius-3: 8px;
  --radius-4: 10px;
  /* The rail, in both modes. */
  --rail-width: 72px;
  --vy-nav: #211348;
  --vy-nav-text: #DAD2EB;
  --vy-nav-hover: #2F1F5E;
  --vy-nav-active: #3E296D;
  --vy-bottom-bar: 60px;
}

html[data-brand="vybecrm"] body { background: var(--ground); color: var(--ink); }
html[data-brand="vybecrm"] .fl-bar-title, html[data-brand="vybecrm"] .fl-card-title, html[data-brand="vybecrm"] .fl-pane-title { letter-spacing: -0.01em; font-weight: 650; }
html[data-brand="vybecrm"] .fl-btn { font-variation-settings: normal; }

/* Grids and spreadsheets stay Flint: its neutral greys, its narrow data face and its row heights. */
html[data-brand="vybecrm"] .fl-grid,
html[data-brand="vybecrm"] .ab-sheet-canvas,
html[data-brand="vybecrm"] js-sheet {
  --paper-2: #F4F5F7;
  --paper-3: #EEF0F3;
  --line: #E3E6EA;
  --line-2: #CBD0D6;
  --rule: #88929E;
  --ink: #1B2430;
  --ink-2: #5A6572;
  --font-sans: "Archivo", "Segoe UI", Helvetica, Arial, sans-serif;
}

/* ---- One rail, in the same place in both modes ------------------------------------------------------
 * VybeCRM draws the rail on its own pages and App Builder draws it on App Builder's; both use Flint's
 * Rail markup, so one set of rules places and paints both. The rail is fixed to the window's left edge,
 * top to bottom, and the page makes room for it, so nothing moves when the mode changes.
 */
html[data-mode] body { box-sizing: border-box; padding-left: var(--rail-width); }
html[data-mode] .fl-rail {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 30; width: var(--rail-width);
  padding: 12px 4px 10px; gap: 2px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none;
}
html[data-mode] .fl-rail-item {
  margin: 0; padding: 8px 0 7px; border-radius: var(--radius-3); box-shadow: none; text-decoration: none; text-align: center;
  font-variation-settings: normal; font-size: 10.5px; line-height: 12px; flex: none; overflow-wrap: break-word;
}
html[data-mode] .fl-rail-item[aria-current="page"] { box-shadow: none; }
html[data-mode] .fl-rail-spacer { flex: 1 0 12px; }

/* The logo: the approved symbol on a light tile, where the rail's wordmark is. The name stays for screen readers. */
html[data-mode] .fl-rail-word, html[data-brand="vybecrm"] .vy-logo {
  flex: none; width: 40px; height: 40px; margin: 0 auto 10px; padding: 0; border-radius: var(--radius-4);
  background: #FFFFFF url(/assets/vybecrm-logo.svg) center / 30px 30px no-repeat;
  font-size: 0; line-height: 0; color: transparent; overflow: hidden;
}

/* Admin mode: the workspace's and the account's own pages. A light rail that says so. */
html[data-mode="admin"] .fl-rail { background: var(--paper); border-right: 1px solid var(--line-2); }
html[data-mode="admin"] .fl-rail-word { background-color: var(--paper-2); }
html[data-mode="admin"] .fl-rail-item { color: var(--ink-2); }
html[data-mode="admin"] .fl-rail-item:hover { background: var(--paper-2); color: var(--ink); }
html[data-mode="admin"] .fl-rail-item[aria-current="page"] { background: var(--flint-tint); color: var(--flint-text); }
.vy-rail-mode { flex: none; margin: -4px 0 8px; text-align: center; font: 700 10.5px/12px var(--font-sans); color: var(--flint-text); }

/* Product mode: App Builder's pages. The dark indigo rail. */
html[data-mode="product"] .fl-rail { background: var(--vy-nav); border-right: 0; }
html[data-mode="product"] .fl-rail-item { color: var(--vy-nav-text); }
html[data-mode="product"] .fl-rail-item:hover { background: var(--vy-nav-hover); color: #FFFFFF; }
html[data-mode="product"] .fl-rail-item[aria-current="page"], html[data-mode="product"] .fl-rail-item[aria-expanded="true"] { background: var(--vy-nav-active); color: #FFFFFF; }
html[data-mode="product"] .fl-rail-item:focus-visible { box-shadow: 0 0 0 2px var(--vy-nav), 0 0 0 4px #C4B5F5; }

/* The way to the other mode sits at the foot of the rail and wears the other rail's colours. */
html[data-mode="admin"] .fl-rail-item.vy-rail-switch { background: var(--vy-nav); color: #FFFFFF; }
html[data-mode="admin"] .fl-rail-item.vy-rail-switch:hover { background: var(--vy-nav-active); color: #FFFFFF; }
html[data-mode="product"] .fl-rail-item.ab-rail-host { background: #FFFFFF; color: var(--flint-text); }
html[data-mode="product"] .fl-rail-item.ab-rail-host:hover { background: var(--flint-tint); color: var(--flint-text); }

/* On App Builder's pages the workspace bar is a slim row: App Builder titles its own screens. */
html[data-mode="product"] .app-canvas > .fl-bar { height: 40px; border-bottom: 1px solid var(--line); background: var(--paper); }

/* ---- A phone: the rail lies along the bottom ---------------------------------------------------------- */
@media (max-width: 639px) {
  html[data-mode] body { padding-left: 0; padding-bottom: calc(var(--vy-bottom-bar) + env(safe-area-inset-bottom, 0px)); }
  html[data-mode] .fl-rail {
    top: auto; right: 0; width: auto; height: calc(var(--vy-bottom-bar) + env(safe-area-inset-bottom, 0px));
    flex-direction: row; align-items: stretch; gap: 2px; padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px));
    overflow-x: auto; overflow-y: hidden; border-right: 0;
  }
  html[data-mode="admin"] .fl-rail { border-top: 1px solid var(--line-2); }
  html[data-mode] .fl-rail-word, html[data-mode] .vy-rail-mode { display: none; }
  html[data-mode] .fl-rail-item { flex: 0 0 64px; width: 64px; justify-content: center; padding: 4px 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; overflow-wrap: normal; }
  html[data-mode] .fl-rail-spacer { flex: 1 0 4px; }
  /* The way to the other mode stays in view at the bar's end while the rest scrolls under it. */
  html[data-mode] .fl-rail-item.vy-rail-switch, html[data-mode] .fl-rail-item.ab-rail-host { position: sticky; right: 0; flex: none; width: auto; min-width: 64px; padding: 4px 10px; overflow: visible; box-shadow: -8px 0 8px -4px #21163840; }
  /* The workspace bar keeps to one row: the name shortens before the account's actions wrap. */
  html[data-mode] .app-canvas > .fl-bar { flex-wrap: nowrap; gap: var(--space-2); }
  html[data-mode] .app-canvas > .fl-bar .fl-bar-actions { flex: none; flex-wrap: nowrap; }
  html[data-mode] .app-canvas > .fl-bar .app-ws-crumbs { overflow: hidden; }
  html[data-mode] .app-canvas > .fl-bar .app-ws-switch { overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  html[data-brand="vybecrm"] *, html[data-brand="vybecrm"] *::before, html[data-brand="vybecrm"] *::after { scroll-behavior: auto !important; transition-duration: 0ms !important; animation-duration: 0ms !important; }
}
