/* ============================================================
   THE BOT PLATFORM — SHARED DASHBOARD SHELL v1 (DASHBOARD-FOUNDATION-P2)
   ------------------------------------------------------------
   Canonical, generic sidebar + topbar + toast/scrim shell for every
   same-stack (vanilla JS/HTML) dashboard -- extracted verbatim (zero
   visual change) from admin-dashboard/console-shell.css, which THE BOT
   Dashboard originated and Commerce Dashboard already reused by
   <link>ing directly. See docs/architecture/DASHBOARD-ARCHITECTURE-P1.md
   §J/§K for the shared-shell-vs-domain-configuration-vs-domain-content
   ownership split this file embodies.

   admin-dashboard/console-shell.css now exists only as a thin
   backward-compatibility alias (`@import`) to this file -- kept so
   nothing that already references that exact path breaks.

   This file knows NOTHING about any one domain's business content: no
   Commerce/Yandex/warehouse/restaurant/order vocabulary anywhere below.
   The "Live Core" indicator (`.cs-core`) is genuine shared brand
   chrome -- both THE BOT and Commerce Dashboard already render it in
   their sidebar brand area -- only the JS that DRIVES its state
   (thinking/attention/error, from live conversation polling) is THE
   BOT-specific and stays in admin-dashboard/console-shell.js; a
   dashboard that never changes its `data-state` simply shows the
   default "idle" look, which is exactly what Commerce Dashboard does
   today.
   ============================================================ */

body.cs-on {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
}

.cs-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "sidebar topbar"
    "sidebar workspace";
  min-height: 100vh;
  height: 100vh;
}

/* ------------------------------------------------------------
   SIDEBAR
   ------------------------------------------------------------ */
.cs-sidebar {
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Brand. Noticeable, but not a Hero: the glow is local and faint. */
.cs-brand {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 18px;
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(70% 130% at 34px 50%, var(--cs-core-field) 0%, transparent 70%);
}
.cs-brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cs-brand-name {
  font-size: 15px;
  font-weight: 750;
  letter-spacing: 0.02em;
  color: var(--ink);
  white-space: nowrap;
}
.cs-brand-sub {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  white-space: nowrap;
}

/* ------------------------------------------------------------
   LIVE CORE
   ------------------------------------------------------------
   Not a logo -- an indicator. Four layers, like the chat widget: a
   far halo, a back rotation, a front rotation, and a core glow. Every
   state is distinguished by BEHAVIOR -- speed, pulse, halo density --
   never by color alone: a colored traffic light would turn the brand
   mark into a dashboard warning light.
   ------------------------------------------------------------ */
.cs-core {
  position: relative;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
}
.cs-core span {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}
.cs-core-halo {
  inset: -30%;
  background: radial-gradient(circle, var(--cs-core-glow) 0%, var(--cs-core-field) 42%, transparent 70%);
  opacity: var(--cs-halo-op);
  animation: cs-halo 9s ease-in-out infinite;
}
.cs-core-back {
  inset: 0;
  background: url("/widget/core-ring-48.webp") center / contain no-repeat;
  opacity: 0.36;
  animation: cs-spin-back 110s linear infinite;
}
.cs-core-front {
  inset: 0;
  background: url("/widget/core-ring-48.webp") center / contain no-repeat;
  animation: cs-spin 74s linear infinite;
}
.cs-core-center {
  inset: 34%;
  background: radial-gradient(circle, #DCE9FF 0%, var(--accent) 44%, transparent 74%);
  opacity: 0.5;
  animation: cs-halo 7s ease-in-out infinite;
}

@keyframes cs-spin      { to { transform: rotate(360deg); } }
@keyframes cs-spin-back { to { transform: rotate(-360deg); } }
@keyframes cs-halo {
  0%, 100% { opacity: var(--cs-halo-lo); }
  50%      { opacity: var(--cs-halo-hi); }
}
@keyframes cs-inward {
  0%, 100% { transform: scale(1);    opacity: 0.55; }
  50%      { transform: scale(0.72); opacity: 1; }
}
@keyframes cs-outward {
  0%   { transform: scale(0.9); opacity: 0.9; }
  100% { transform: scale(1.5); opacity: 0; }
}
@keyframes cs-attention {
  0%, 100% { opacity: var(--cs-halo-lo); }
  50%      { opacity: calc(var(--cs-halo-hi) + 0.2); }
}

/* THINKING -- rotation speeds up, energy pulls toward the center. */
.cs-core[data-state="thinking"] .cs-core-front  { animation-duration: 20s; }
.cs-core[data-state="thinking"] .cs-core-back   { animation-duration: 34s; }
.cs-core[data-state="thinking"] .cs-core-center { animation: cs-inward 1.6s ease-in-out infinite; }
.cs-core[data-state="thinking"] .cs-core-halo   { animation-duration: 2.8s; }

/* NEW CONVERSATION -- one outward pulse, then rest. */
.cs-core[data-state="new"] .cs-core-halo   { animation: cs-outward 1.2s ease-out 1 forwards; }
.cs-core[data-state="new"] .cs-core-center { animation: cs-halo 0.6s ease-in-out 2; }

/* ATTENTION -- the breathing is noticeably deeper, not faster: alarm
   should be felt, not jittery. */
.cs-core[data-state="attention"] .cs-core-halo { animation: cs-attention 2.6s ease-in-out infinite; }
.cs-core[data-state="attention"] .cs-core-center { opacity: 0.8; }

/* ERROR -- the one place color changes: an error must never look like
   ordinary operation. */
.cs-core[data-state="error"] .cs-core-halo {
  background: radial-gradient(circle, var(--danger-wash) 0%, transparent 70%);
  opacity: 0.9;
  animation: cs-halo 1.8s ease-in-out infinite;
}
.cs-core[data-state="error"] .cs-core-center {
  background: radial-gradient(circle, #FFE3E3 0%, var(--danger) 46%, transparent 74%);
}
.cs-core[data-state="error"] .cs-core-front,
.cs-core[data-state="error"] .cs-core-back { filter: saturate(0.35); }

/* ------------------------------------------------------------
   NAVIGATION
   ------------------------------------------------------------ */
.cs-nav { flex: 1; padding: 10px 10px 20px; }
.cs-group + .cs-group { margin-top: 14px; }
.cs-group-title {
  padding: 8px 10px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.cs-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink-muted);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 550;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease);
}
.cs-item:hover { background: var(--surface-alt); color: var(--ink); }
.cs-item[aria-current="page"] {
  background: var(--accent-wash);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 26%, transparent);
}
.cs-item-icon {
  flex: 0 0 18px;
  text-align: center;
  font-size: 14px;
  line-height: 1;
  opacity: 0.85;
}
.cs-item-label { flex: 1; min-width: 0; }
/* Overdue counter -- the same meaning as the orb's own ATTENTION state,
   hence the same color. */
.cs-item-count {
  flex: none;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: var(--warning-wash);
  color: var(--warning-ink);
  font-size: 10.5px;
  font-weight: 700;
}

/* ------------------------------------------------------------
   TOPBAR
   ------------------------------------------------------------ */
.cs-topbar {
  grid-area: topbar;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  min-height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.cs-topbar-context { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1 1 auto; }
.cs-topbar-title {
  font-size: 14px;
  font-weight: 650;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cs-topbar-org {
  font-size: 11.5px;
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cs-topbar-spacer { flex: 1; }
.cs-topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 4px;
  font-size: 13px;
  color: var(--ink-muted);
  white-space: nowrap;
}
.cs-role {
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.cs-topbar-actions { display: flex; align-items: center; gap: 8px; min-width: 0; }

/* Mobile-menu button appears only on narrow screens. */
.cs-burger {
  display: none;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font-size: 15px;
  line-height: 1;
}

/* ------------------------------------------------------------
   WORKSPACE
   ------------------------------------------------------------ */
.cs-workspace {
  grid-area: workspace;
  min-width: 0;
  min-height: 0;
  overflow: auto;
}
/* THE BOT's own legacy tab-bar row stays in the DOM (it still drives
   screen switching/role rules) but is visually replaced by the sidebar
   nav above -- this is a THE-BOT-specific legacy-DOM compatibility
   rule, kept here (rather than a THE-BOT-only file) only because it is
   harmless and inert for any consumer without that markup (Commerce
   Dashboard has no `.admin-tabs`/`.admin-header`/`.back-to-menu-btn`
   elements at all, so these rules simply never match there). */
body.cs-on .admin-tabs,
body.cs-on .admin-header { display: none !important; }
body.cs-on .admin-main { padding-top: 4px; }
body.cs-on .back-to-menu-btn { display: none !important; }

/* ------------------------------------------------------------
   DARK AND LIGHT
   In light theme the halo is noticeably quieter: a working screen
   should not glow.
   ------------------------------------------------------------ */
:root {
  --cs-core-glow:  rgba(61, 139, 255, 0.5);
  --cs-core-field: rgba(61, 139, 255, 0.16);
  --cs-halo-op:    0.85;
  --cs-halo-lo:    0.35;
  --cs-halo-hi:    0.62;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --cs-core-glow:  rgba(47, 123, 255, 0.26);
    --cs-core-field: rgba(47, 123, 255, 0.07);
    --cs-halo-op:    0.6;
    --cs-halo-lo:    0.18;
    --cs-halo-hi:    0.34;
  }
}
:root[data-theme="light"] {
  --cs-core-glow:  rgba(47, 123, 255, 0.26);
  --cs-core-field: rgba(47, 123, 255, 0.07);
  --cs-halo-op:    0.6;
  --cs-halo-lo:    0.18;
  --cs-halo-hi:    0.34;
}

/* ------------------------------------------------------------
   RESPONSIVE
   Tablet -- icon-only column. Phone -- slide-out panel.
   ------------------------------------------------------------ */
@media (max-width: 1100px) and (min-width: 761px) {
  .cs-shell { grid-template-columns: 64px minmax(0, 1fr); }
  .cs-brand { justify-content: center; padding: 14px 8px; }
  .cs-brand-text, .cs-group-title, .cs-item-label { display: none; }
  .cs-item { justify-content: center; padding: 10px 0; }
  .cs-item-count {
    position: absolute;
    margin: -14px 0 0 18px;
    padding: 0 5px;
    font-size: 9.5px;
  }
  .cs-item { position: relative; }
  .cs-group + .cs-group { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 8px; }
}

@media (max-width: 760px) {
  .cs-shell { grid-template-columns: minmax(0, 1fr); grid-template-areas: "topbar" "workspace"; }
  .cs-burger { display: inline-flex; align-items: center; }
  .cs-sidebar {
    position: fixed;
    z-index: 80;
    top: 0; bottom: 0; left: 0;
    width: min(78vw, 268px);
    transform: translateX(-100%);
    transition: transform var(--dur) var(--ease);
    box-shadow: 0 0 40px var(--shadow-color);
  }
  body.cs-nav-open .cs-sidebar { transform: translateX(0); }
  .cs-scrim {
    position: fixed;
    z-index: 79;
    inset: 0;
    background: rgba(4, 8, 16, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur) var(--ease);
  }
  body.cs-nav-open .cs-scrim { opacity: 1; pointer-events: auto; }
  .cs-topbar { padding: 0 12px; gap: 8px; }
  .cs-topbar-user span:not(.cs-role) { display: none; }
  /* Long button labels get clipped, not overflowed. */
  .cs-topbar-actions button {
    max-width: 112px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Respect reduced-motion: optional movement stops entirely, but states
   stay distinguishable -- THINKING keeps a dense core, ATTENTION a
   bright halo, ERROR its own color. */
@media (prefers-reduced-motion: reduce) {
  .cs-core span,
  .cs-core[data-state] span { animation: none !important; }
  .cs-core-halo { opacity: var(--cs-halo-hi); }
  .cs-core[data-state="thinking"] .cs-core-center { opacity: 1; transform: scale(0.8); }
  .cs-core[data-state="attention"] .cs-core-halo { opacity: calc(var(--cs-halo-hi) + 0.2); }
  .cs-core[data-state="new"] .cs-core-halo { opacity: 1; }
  .cs-sidebar { transition: none; }
  .cs-scrim { transition: none; }
}

/* ============================================================
   CONSOLE NOTIFICATIONS
   ------------------------------------------------------------
   Replace alert()'s system dialog. Never block work and never require
   a click: the message is visible and leaves on its own. Blocking
   confirmations for irreversible actions stay as real confirm()s and
   never land here.
   ============================================================ */
.cs-toasts {
  position: fixed;
  z-index: 200;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(380px, calc(100vw - 36px));
  pointer-events: none;
}
.cs-toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-raised);
  box-shadow: 0 12px 32px var(--shadow-color);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
  pointer-events: auto;
  animation: cs-toast-in 0.22s var(--ease) both;
}
.cs-toast.is-out { animation: cs-toast-out 0.35s var(--ease) both; }
@keyframes cs-toast-in  { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes cs-toast-out { to   { opacity: 0; transform: translateY(6px); } }
/* Color carries meaning: success and error are distinct semantic
   tokens, never accent shades. */
.cs-toast-ok  { box-shadow: inset 3px 0 0 var(--success), 0 12px 32px var(--shadow-color); }
.cs-toast-bad { box-shadow: inset 3px 0 0 var(--danger),  0 12px 32px var(--shadow-color); }
.cs-toast-x {
  flex: none;
  margin-left: auto;
  padding: 0 2px;
  border: none;
  background: transparent;
  color: var(--ink-faint);
  font-size: 13px;
  line-height: 1.3;
  cursor: pointer;
}
.cs-toast-x:hover { color: var(--ink); }
.cs-toast-x:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 560px) {
  .cs-toasts { right: 10px; left: 10px; bottom: 10px; max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  .cs-toast, .cs-toast.is-out { animation: none !important; }
}
