/* BlindsDirect operator console — page layouts.
 * Token-only. NO hex literals. Owns body resets + the two layouts shipped in
 * Phase 3 (`centered` for /login + /404, `app-shell` for /dashboard).
 */

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  color: var(--color-on-neutral);
  background: var(--color-neutral-muted);
  -webkit-font-smoothing: antialiased;
}

*, *::before, *::after { box-sizing: border-box; }

a { color: var(--color-info); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Centered layout (login, 404, simple pages) ─────────────────────────── */
body.bd-layout-centered {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--spacing-md);
}
.bd-layout-centered .bd-page {
  width: 100%;
  max-width: 380px;
}

/* ── App shell layout (dashboard + every authenticated page) ────────────── */
body.bd-layout-app-shell {
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
  overscroll-behavior: none;
}
.bd-app {
  min-height: 100vh;
  height: 100vh;
  max-height: 100vh;
  position: fixed;
  inset: 0;
  width: 100%;
  display: flex;
  overflow: hidden;
}
.bd-app__sidebar {
  flex: 0 0 var(--layout-sidebar-w);
  width: var(--layout-sidebar-w);
  background: var(--color-neutral);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: flex-basis var(--motion-fast, 200ms) var(--motion-ease, cubic-bezier(0.4,0,0.2,1)),
              width var(--motion-fast, 200ms) var(--motion-ease, cubic-bezier(0.4,0,0.2,1));
  will-change: width;
}
body[data-bd-sidebar-collapsed="true"] .bd-app__sidebar {
  flex-basis: var(--layout-sidebar-w-collapsed);
  width: var(--layout-sidebar-w-collapsed);
}
/* Lock inner contents to expanded width — they get clipped via overflow:hidden
   so labels disappear behind the right edge during the transition. */
body[data-bd-sidebar-collapsed="true"] .bd-app__sidebar > * {
  width: var(--layout-sidebar-w);
  flex-shrink: 0;
  box-sizing: border-box;
}
.bd-app__column {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.bd-app__topbar {
  flex: 0 0 var(--layout-topbar-h);
  height: var(--layout-topbar-h);
  min-height: var(--layout-topbar-h);
  background: var(--color-neutral);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
}
.bd-app__content {
  flex: 1 1 auto;
  min-height: 0;
  padding: var(--spacing-md);
  background: var(--color-neutral-muted);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}
.bd-app__content > * {
  width: 100%;
  max-width: var(--layout-content-max, none);
  margin-left: 0;
  margin-right: 0;
  flex: 0 0 auto;
}

@media (max-width: 768px) {
  .bd-app {
    position: fixed;
  }

  .bd-app::before {
    content: '';
    position: absolute;
    inset: 0;
    background: color-mix(in srgb, var(--color-on-neutral) 18%, transparent);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--motion-fast, 200ms) var(--motion-ease, cubic-bezier(0.4,0,0.2,1));
    z-index: 10;
  }

  body[data-bd-sidebar-collapsed="false"] .bd-app::before {
    opacity: 1;
    pointer-events: auto;
  }

  .bd-app__sidebar,
  body[data-bd-sidebar-collapsed="true"] .bd-app__sidebar {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(320px, calc(100vw - 48px));
    max-width: calc(100vw - 48px);
    flex: 0 0 auto;
    border-right: 1px solid var(--color-border);
    box-shadow: var(--shadow-overlay);
    transform: translateX(0);
    transition:
      transform var(--motion-fast, 200ms) var(--motion-ease, cubic-bezier(0.4,0,0.2,1)),
      width var(--motion-fast, 200ms) var(--motion-ease, cubic-bezier(0.4,0,0.2,1));
    z-index: 12;
  }

  body[data-bd-sidebar-collapsed="true"] .bd-app__sidebar {
    transform: translateX(-100%);
  }

  .bd-app__sidebar > *,
  body[data-bd-sidebar-collapsed="true"] .bd-app__sidebar > * {
    width: 100%;
    flex-shrink: 1;
  }

  .bd-app__column {
    width: 100%;
    flex: 1 1 100%;
  }

  .bd-app__content {
    padding: var(--spacing-md);
    gap: var(--spacing-md);
  }
}

@media (max-width: 640px) {
  .bd-app__topbar {
    min-height: var(--layout-topbar-h);
  }

  .bd-app__content {
    padding: var(--spacing-sm);
    gap: var(--spacing-sm);
  }
}
/* Settings pages: 896px (Tailwind max-w-4xl) */
body.bd-page-settings-providers,
body.bd-page-settings-email { --layout-content-max: 896px; }
body.bd-page-settings-logging { --layout-content-max: none; }
/* Account: 768px (Tailwind max-w-3xl) */
body.bd-page-settings-account { --layout-content-max: 768px; }

/* ── 403 fallback page ──────────────────────────────────────────────────── */
.bd-page--403 {
  max-width: 480px;
  margin: 10vh auto;
  text-align: center;
}
.bd-page--403 h1 {
  font-size: 24px;
  margin: 0 0 var(--spacing-sm);
}
.bd-page--403 p {
  color: var(--color-on-neutral-muted);
  margin: 0;
}

/* ── Quote workspace: 2-col layout ──────────────────────────────────────── */
body.bd-page-quote-workspace .bd-app__content {
  flex-direction: row;
  gap: 0;
  padding: 0;
  overflow: hidden;
  flex-wrap: nowrap;
  align-items: stretch;
  min-height: 0;
}

/* Main column: workspace-header gets 2/3 width */
body.bd-page-quote-workspace #workspace-header {
  flex: 2;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  padding: var(--spacing-md);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  order: 1;
}

/* Chat column: workspace-chat-section gets 1/3 width */
body.bd-page-quote-workspace #workspace-chat-section {
  flex: 1;
  min-width: 340px;
  max-width: 480px;
  min-height: 0;
  height: 100%;
  border-left: 1px solid var(--color-border);
  background: var(--color-neutral);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  order: 2;
}

body.bd-page-quote-workspace #workspace-chat-section .bd-section__grid,
body.bd-page-quote-workspace #workspace-chat-section .bd-section__body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  gap: 0;
}

body.bd-page-quote-workspace #workspace-chat-section .bd-chat {
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  border: 0;
  border-radius: 0;
}

/* Take the modal/bridge wrapper sections out of the flex flow without
   hiding them — the modals inside use position: fixed and need to render
   when opened. display: none on the parent would suppress the modal too. */
body.bd-page-quote-workspace #workspace-source-files-section,
body.bd-page-quote-workspace #workspace-confirm-push-section,
body.bd-page-quote-workspace #workspace-approval-bridge-section,
body.bd-page-quote-workspace #workspace-row-editor-bridge-section {
  position: absolute;
  width: 0;
  height: 0;
  overflow: visible;
  order: 99;
}

/* ── Quote workspace: auto-collapse sidebar on load ─────────────────────── */
body.bd-page-quote-workspace .bd-app__sidebar {
  flex-basis: var(--layout-sidebar-w-collapsed);
  width: var(--layout-sidebar-w-collapsed);
}

body.bd-page-quote-workspace .bd-app__sidebar > * {
  width: var(--layout-sidebar-w);
  flex-shrink: 0;
  box-sizing: border-box;
}

/* Hover to expand */
body.bd-page-quote-workspace .bd-app__sidebar:hover {
  flex-basis: var(--layout-sidebar-w);
  width: var(--layout-sidebar-w);
  z-index: 20;
  box-shadow: var(--shadow-overlay);
}

/* Hide labels/lockup/counts when sidebar is collapsed (not hovered) */
body.bd-page-quote-workspace .bd-app__sidebar:not(:hover) .bd-brand__lockup,
body.bd-page-quote-workspace .bd-app__sidebar:not(:hover) .bd-sidebar__label,
body.bd-page-quote-workspace .bd-app__sidebar:not(:hover) .bd-sidebar__count,
body.bd-page-quote-workspace .bd-app__sidebar:not(:hover) .bd-sidebar__group-label,
body.bd-page-quote-workspace .bd-app__sidebar:not(:hover) .bd-sidebar__user {
  opacity: 0;
  visibility: hidden;
}

/* ── Quote workspace: chat panel collapse/expand ────────────────────────── */
.bd-chat__collapse {
  margin-left: auto;
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  color: var(--color-text-muted);
  border-radius: var(--rounded-sm);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.bd-chat__collapse:hover {
  background: var(--color-neutral-muted);
  color: var(--color-text);
}

body.bd-workspace-chat-collapsed #workspace-chat-section {
  display: none !important;
}

.bd-chat__reopen {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 56px;
  border: 1px solid var(--color-border);
  border-right: 0;
  background: var(--color-neutral);
  color: var(--color-text-muted);
  border-radius: var(--rounded-sm) 0 0 var(--rounded-sm);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-card, 0 1px 3px rgba(0,0,0,0.08));
}
body.bd-workspace-chat-collapsed .bd-chat__reopen {
  display: inline-flex;
}
.bd-chat__reopen:hover {
  background: var(--color-neutral-muted);
  color: var(--color-text);
}
