/* The settings navigation uses the same floating card as the workbench. */
.platform-sidebar {
  --text: #18181b;
  --muted: #3f3f46;
  --muted-2: #52525b;
  --hover: #f4f4f5;
  --blue: #18181b;
  --blue-soft: #e8e8ea;
  --line: #e5e5e8;
  height: calc(100vh - 28px) !important;
  height: calc(100dvh - 28px) !important;
  margin: 14px 0;
  padding: 0 14px;
  border: 1px solid #e5e5e899;
  border-radius: 16px;
  background: var(--shell-canvas) !important;
  box-shadow: 0 2px 8px #00000006;
}

html[data-theme="dark"] .platform-sidebar {
  --text: #ededf0;
  --muted: #d4d4d8;
  --muted-2: #c4c4cc;
  --hover: #25252b;
  --blue: #ededf0;
  --blue-soft: #26262c;
  --line: #26262b;
  border-color: #36363e;
}

body.management-mode .app-shell::before {
  content: "";
  display: none;
  position: absolute;
  z-index: 1;
  top: 14px;
  bottom: 14px;
  left: var(--shell-inset-x);
  width: min(
    calc(var(--rail-w) + var(--sidebar-w)),
    calc(100% - var(--shell-inset-x))
  );
  border-radius: 16px;
  background: var(--rail-surface);
  pointer-events: none;
}

@media (min-width: 1001px) {
  body.management-mode .app-shell::before {
    display: block;
  }
}

.platform-sidebar > .settings-navigation-header {
  display: none;
  align-items: center;
  flex-shrink: 0;
  height: 64px;
  margin: -1px -15px 0;
  padding: 0 16px 0 18px;
}

body.management-mode .platform-sidebar > .settings-navigation-header {
  display: flex;
}

.settings-navigation-title {
  flex: 1;
  margin: 0;
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.2;
}

.settings-navigation-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted-2);
  cursor: pointer;
  transition:
    background-color 160ms ease,
    color 160ms ease;
}

.settings-navigation-toggle:hover {
  background: var(--hover);
  color: var(--text);
}

.platform-sidebar nav {
  /* Cancel the card's right padding so the thumb sits on the panel edge. */
  margin-right: -14px;
  padding: 0 10px 12px 0 !important;
}

/* Chrome 121+ ignores ::-webkit-scrollbar once scrollbar-width/color is set; this also resets platform.css. */
@supports selector(::-webkit-scrollbar) {
  .platform-sidebar nav {
    scrollbar-width: auto;
    scrollbar-color: auto;
  }
}

@supports not selector(::-webkit-scrollbar) {
  .platform-sidebar nav {
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
  }

  .platform-sidebar:hover nav,
  .platform-sidebar nav:focus-within {
    scrollbar-color: color-mix(in srgb, var(--muted) 22%, transparent) transparent;
  }

  .sidebar-resizing .platform-sidebar nav {
    scrollbar-color: transparent transparent;
  }
}

.platform-sidebar nav::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

.platform-sidebar nav::-webkit-scrollbar-track,
.platform-sidebar nav::-webkit-scrollbar-corner {
  background: transparent;
}

.platform-sidebar nav::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

.platform-sidebar nav::-webkit-scrollbar-thumb {
  border: 0;
  border-radius: 999px;
  background-color: transparent;
}

.platform-sidebar:hover nav::-webkit-scrollbar-thumb,
.platform-sidebar nav:focus-within::-webkit-scrollbar-thumb {
  background-color: color-mix(in srgb, var(--muted) 22%, transparent);
}

.platform-sidebar nav::-webkit-scrollbar-thumb:hover {
  background-color: color-mix(in srgb, var(--muted) 40%, transparent);
}

/* The width handle sits on the same edge. A full-height fill reads as a second scrollbar. */
.platform-sidebar > .sidebar-resize,
.platform-sidebar > .sidebar-resize:hover,
.platform-sidebar > .sidebar-resize:focus-visible,
.sidebar-resizing .platform-sidebar > .sidebar-resize {
  background: transparent;
}

.sidebar-resizing .platform-sidebar > .sidebar-resize {
  box-shadow: inset -2px 0 0 color-mix(in srgb, var(--muted) 40%, transparent);
}

.sidebar-resizing .platform-sidebar nav::-webkit-scrollbar-thumb {
  background-color: transparent;
}

/* Changing workspace mode swaps the card's contents, never its layout track. */
body.settings-mode-switch .app-shell,
body.settings-mode-switch .app-shell::before {
  transition: none !important;
}

.management-navigation .management-back {
  margin-bottom: 16px !important;
}

.management-navigation > p {
  margin: 18px 8px 8px;
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 500;
}

.platform-sidebar .nav {
  min-height: 38px;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 400;
}

.platform-sidebar .nav:hover {
  background: var(--hover);
  color: var(--text);
}

html[data-theme] .platform-sidebar .nav.active {
  background: var(--blue-soft);
  color: var(--text);
  font-weight: 600;
  box-shadow: none;
}

.platform-sidebar .nav .nav-icon,
html[data-theme] .platform-sidebar .nav.active .nav-icon {
  background: transparent;
  color: inherit;
}

html[data-theme] .platform-sidebar .nav.active::before {
  display: none;
}

/* Keep matching grid tracks in both states so the workspace follows the panel.
   The full-width card is clipped instead of reflowing its text during reveal. */
body.management-mode {
  --settings-sidebar-duration: 240ms;
  --settings-sidebar-ease: cubic-bezier(.16, 1, .3, 1);
  --settings-sidebar-space: var(--sidebar-w);
}

body.management-mode:is(.settings-sidebar-hidden, .settings-sidebar-entering) {
  --settings-sidebar-space: 0px;
}

body.management-mode .app-shell {
  grid-template-columns: var(--rail-w) var(--settings-sidebar-space) minmax(0, 1fr) !important;
  transition: grid-template-columns var(--settings-sidebar-duration) var(--settings-sidebar-ease);
}

body.management-mode.ai-assistant-open .app-shell {
  grid-template-columns: var(--rail-w) var(--settings-sidebar-space) minmax(0, 1fr) var(--ai-panel-w, 380px) !important;
}

body.management-mode .platform-sidebar {
  display: flex !important;
  grid-column: 2;
  min-width: 0;
  width: var(--sidebar-w) !important;
  clip-path: inset(0 0 0 0 round 16px);
  opacity: 1;
  visibility: visible;
  transition:
    clip-path var(--settings-sidebar-duration) var(--settings-sidebar-ease),
    visibility 0s;
}

body.management-mode .shell-main {
  grid-column: 3;
}

body.management-mode .app-shell::before {
  width: min(calc(var(--rail-w) + var(--settings-sidebar-space)), calc(100% - var(--shell-inset-x)));
  transition: width var(--settings-sidebar-duration) var(--settings-sidebar-ease);
}

body.management-mode:is(.settings-sidebar-hidden, .settings-sidebar-entering) .platform-sidebar {
  clip-path: inset(0 100% 0 0 round 16px);
  visibility: hidden;
  pointer-events: none;
  transition-delay: 0s, var(--settings-sidebar-duration);
}

@media (prefers-reduced-motion: reduce) {
  body.management-mode {
    --settings-sidebar-duration: 0ms;
  }

  body.management-mode .app-shell,
  body.management-mode .app-shell::before,
  body.management-mode .platform-sidebar {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 1000px) {
  body.management-mode .app-shell::before {
    display: block;
  }

  body.management-mode .app-shell {
    grid-template-columns: var(--rail-w) minmax(0, 1fr) !important;
  }

  body.management-mode.ai-assistant-open .app-shell {
    grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--ai-panel-w, 380px) !important;
  }

  body.management-mode .shell-main {
    grid-column: 2;
  }

  body.management-mode .platform-sidebar {
    position: fixed !important;
    inset: 14px auto 14px calc(var(--rail-w) + var(--shell-inset-x)) !important;
    width: min(
      var(--sidebar-w),
      calc(100vw - var(--rail-w) - var(--shell-inset-x))
    ) !important;
    height: calc(100vh - 28px) !important;
    height: calc(100dvh - 28px) !important;
    max-width: min(
      var(--sidebar-w),
      calc(100vw - var(--rail-w) - var(--shell-inset-x))
    ) !important;
    margin: 0;
    padding: 0 14px !important;
    align-items: stretch;
  }

  body.management-mode .platform-sidebar .nav-label {
    display: block !important;
  }

  body.management-mode .platform-sidebar .nav {
    width: 100% !important;
    margin: 2px 0 !important;
    padding: 8px 10px !important;
    justify-content: flex-start !important;
    gap: 10px !important;
  }
}
