/*
 * Colours, sizes and radii follow the Craft 6.0.0-beta.3 control panel tokens
 * (craftcms/cms-assets cp.css), resolved to plain values.
 * Dark theme only.
 */

/* Palette (dark) */
:root {
  --base-50: #26313c;
  --base-100: #313e49;
  --slate-400: #7e8997;
  --slate-600: #a6b2be;
  --slate-700: #b6c1ce;
  --slate-900: #dfe7ef;
  --blue-400: #4e83f6;
  --blue-600: #8eb0f9;
  color-scheme: dark;

  /* Semantic tokens */
  --surface-page: color-mix(in oklab, var(--base-50), #000 25%);
  --surface-default: color-mix(in oklab, color-mix(in oklab, var(--base-100), var(--base-50) 30%), #000 15%);
  --surface-overlay: color-mix(in oklab, var(--base-100), var(--base-50) 30%);
  --hover: color-mix(in oklab, var(--base-50), #000 5%);
  --text: var(--slate-900);
  --text-quiet: var(--slate-600);
  --chrome-text: var(--slate-700);
  --link: var(--blue-600);
  --border-quiet: color-mix(in srgb, var(--slate-400), transparent 40%);
  --border-faint: color-mix(in srgb, var(--slate-400), transparent 70%);
  --border-normal: var(--slate-600);
  --accent-border: var(--blue-400);
  --dev: #f3b53e;
  --dev-fill: #4a3112;
  --dev-border: #9f541d;
  --green: #59c48d;
  --violet-fill: #5118ac;
  --violet-text: #e7e3fc;
  --danger: #f19996;
  --shadow: 0 6px 16px rgba(0, 0, 0, .25), 0 1px 2px rgba(0, 0, 0, .2);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  background: var(--surface-page);
  color: var(--text);
  font: 14px/1.43 Inter, system-ui, BlinkMacSystemFont, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11";
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
button { background: none; border: 0; margin: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--blue-400); outline-offset: 1px; border-radius: 4px; }

.spacer { flex: 1 1 auto; }

/* Layout: sidebar 226px, rail 40px, header 46px (Craft's --cp-* sizes) */
.shell { height: 100vh; min-height: 520px; display: flex; flex-direction: column; }
.shell__row { flex: 1 1 auto; min-height: 0; display: flex; }

.sidebar {
  width: 226px;
  flex: none;
  display: flex;
  flex-direction: column;
  position: relative;
  color: var(--chrome-text);
}
.is-collapsed .sidebar { width: 40px; }

.sidebar__head { height: 46px; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 8px 0 7px; }
.is-collapsed .sidebar__head { justify-content: center; padding: 0; }

.system { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--text); font-weight: 600; font-size: 15px; }
.system__logo {
  width: 26px; height: 26px; flex: none; border-radius: 6px;
  border: 1px solid var(--border-normal);
  display: grid; place-items: center;
}
.system__name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar__body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 4px 5px 8px; }

.nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav__heading { margin: 10px 0 2px; padding: 0 5px; font-size: 12px; font-weight: 600; color: var(--text); }
.nav__item {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  /* 6px left padding centres the icon at 20px, where it sits in the collapsed 40px rail */
  height: 30px; padding: 0 5px 0 6px; border-radius: 6px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.nav__item:hover { background: var(--hover); }
.nav__item svg { flex: none; }
.nav__item .trail { margin-left: auto; display: flex; align-items: center; gap: 6px; color: var(--text-quiet); }
/* Page indicator: a pill centred on the sub-nav line beside the current page.
   The line sits 7px padding + 1px border left of the item; the item's own 1px border shifts the origin. */
.nav__sub .nav__item[aria-current="page"]::before {
  content: ""; position: absolute; left: -10px; top: 5px; bottom: 5px; width: 3px; border-radius: 2px;
  background: var(--accent-border);
}
/* Collapsed rail hides the sub-nav, so mark the parent instead */
.is-collapsed .nav__item--parent::before {
  content: ""; position: absolute; left: -5px; top: 6px; bottom: 6px; width: 3px; border-radius: 2px;
  background: var(--accent-border);
}
.nav__sub { list-style: none; margin: 2px 0 2px 14px; padding: 0 0 0 7px; border-left: 1px solid var(--border-faint); display: flex; flex-direction: column; gap: 2px; }
.nav__sub .nav__item { padding: 0 8px; }
.nav__item[aria-current="page"] { color: var(--text); font-weight: 500; }

.is-collapsed .label,
.is-collapsed .trail,
.is-collapsed .nav__heading,
.is-collapsed .nav__sub,
.is-collapsed .system__name,
.is-collapsed .user__name,
.is-collapsed .user__chevron { display: none; }
.is-collapsed .nav__item { justify-content: center; padding: 0; }
.is-collapsed .sidebar__body { padding: 4px 5px; }
.is-collapsed .nav__heading + li { margin-top: 8px; }

.icon-btn {
  width: 30px; height: 30px; border-radius: 6px; flex: none;
  display: grid; place-items: center; color: var(--chrome-text); position: relative;
}
.icon-btn:hover, .user:hover, .crumb:hover, .menu a:hover, .menu button:hover, .ask-ai:hover { background: var(--hover); }
.icon-btn--dev { color: var(--dev); }
.dot {
  position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--blue-400); box-shadow: 0 0 0 2px var(--surface-page);
}

/* Proposed sidebar footer */
.sidebar__foot { flex: none; display: flex; align-items: center; gap: 2px; padding: 6px 5px 8px; border-top: 1px solid var(--border-faint); }
.is-collapsed .sidebar__foot { flex-direction: column-reverse; gap: 2px; }
.sidebar__icons { display: flex; align-items: center; gap: 2px; }
.is-collapsed .sidebar__icons { flex-direction: column; }

/* 4px left padding puts the avatar at 9px, centred on the 40px rail as when collapsed */
.user { flex: 1 1 auto; min-width: 0; height: 34px; padding: 0 5px 0 4px; border-radius: 6px; display: flex; align-items: center; gap: 8px; color: var(--text); }
.is-collapsed .user { flex: none; width: 30px; padding: 0; justify-content: center; }
.user__name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user__chevron { color: var(--text-quiet); flex: none; display: flex; }

.avatar {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  background: #6e4fd1; color: #fff;
  display: grid; place-items: center; font-size: 10px; font-weight: 600;
}
.avatar--lg { width: 32px; height: 32px; font-size: 12px; }

/* Popovers */
.popover {
  /* 6px from the sidebar edge, 6px above the footer (49px tall) */
  position: absolute; left: 6px; bottom: 55px; width: 240px; z-index: 10;
  padding: 4px; display: flex; flex-direction: column;
  background: var(--surface-overlay);
  border-radius: 6px; box-shadow: 0 0 0 1px var(--border-quiet), var(--shadow);
}
.popover[hidden] { display: none; }
.is-collapsed .popover { left: 46px; bottom: 6px; }

/* Nav flyouts: 8px back over the sidebar's right edge; top is set from the hovered item */
.popover.flyout,
.is-collapsed .popover.flyout { left: calc(100% - 8px); bottom: auto; width: 200px; }
.flyout a[aria-current="page"] { color: var(--text); font-weight: 500; }
.flyout svg { color: var(--text-quiet); flex: none; }

.menu a, .menu button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; height: 30px; padding: 0 8px; border-radius: 4px; }
.menu .danger { color: var(--danger); }
.menu hr { border: 0; height: 1px; background: var(--border-quiet); margin: 4px -4px; }
.menu__who { display: flex; align-items: center; gap: 10px; padding: 8px; }
.menu__who small { display: block; color: var(--text-quiet); font-size: 12px; }
.menu__title { display: flex; align-items: center; gap: 8px; padding: 8px 8px 2px; font-weight: 600; }
.menu__sub { padding: 0 8px 8px; color: var(--text-quiet); font-size: 13px; }
.menu .bullet { width: 7px; height: 7px; border-radius: 50%; background: var(--blue-400); }

.edition {
  border: 1px solid var(--border-normal); border-radius: 3px; padding: 0 4px;
  font-size: 10px; line-height: 15px; font-weight: 600; letter-spacing: .05em; color: var(--chrome-text);
}

.tooltip {
  position: absolute; left: 96px; bottom: 50px; z-index: 11;
  padding: 4px 8px; border-radius: 4px; white-space: nowrap; font-size: 12px;
  background: var(--slate-900); color: var(--surface-page);
}
.tooltip[hidden] { display: none; }
.is-collapsed .tooltip { left: 44px; bottom: 108px; }

/* Main column */
.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.header { height: 46px; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 8px 0 10px; color: var(--chrome-text); }
.crumbs { display: flex; align-items: center; gap: 2px; min-width: 0; }
/* Expanded: line the first crumb's icon up with the panel's left edge
   (cancels the header's 10px padding and the crumb's 6px padding, plus 1px for the panel's outer ring) */
.shell:not(.is-collapsed) .crumbs { margin-left: -17px; }
.crumb { display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 6px; border-radius: 4px; white-space: nowrap; }
.crumb[aria-current="page"] { color: var(--text); }
.crumb-sep { color: var(--text-quiet); display: flex; opacity: .7; }
.header__end { display: flex; align-items: center; gap: 2px; }

.ask-ai {
  height: 30px; padding: 0 10px 0 8px; margin-left: 4px; border-radius: 6px;
  border: 1px solid var(--border-faint); display: flex; align-items: center; gap: 6px; font-weight: 500; color: var(--text);
}
.spark { color: var(--blue-400); }

.panel {
  flex: 1 1 auto; min-height: 0; position: relative; overflow: hidden;
  margin: 0 8px 8px 0;
  background: var(--surface-default);
  box-shadow: 0 0 0 1px var(--border-quiet);
  border-radius: 6px;
  display: flex; flex-direction: column;
}

.panel__head { padding: 22px 40px 14px; }
.panel__head h1 { margin: 0 0 18px; font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.toolbar { display: flex; align-items: center; gap: 8px; }
.select, .search {
  height: 34px; border: 1px solid var(--border-normal); border-radius: 4px;
  display: flex; align-items: center; gap: 8px; padding: 0 10px; background: transparent;
}
.select .diamond { width: 8px; height: 8px; background: #a855f7; transform: rotate(45deg); border-radius: 1px; }
.search { width: 280px; color: var(--text-quiet); }

.table { border-top: 1px solid var(--border-quiet); }
.tr { display: flex; align-items: center; gap: 14px; height: 50px; padding: 0 40px; border-bottom: 1px solid var(--border-quiet); }
.tr--head { height: 44px; font-weight: 600; }
.check { width: 16px; height: 16px; border: 1px solid var(--border-normal); border-radius: 3px; flex: none; }
.entry { display: flex; align-items: center; gap: 8px; color: var(--link); }
.status { width: 9px; height: 9px; border-radius: 50%; background: var(--green); flex: none; }
.status--off { background: transparent; border: 1px solid var(--text-quiet); }
.badge { height: 20px; padding: 0 7px; border-radius: 10px; font-size: 12px; display: inline-flex; align-items: center; gap: 4px; background: var(--violet-fill); color: var(--violet-text); }
.td-quiet { color: var(--text-quiet); margin-left: auto; width: 140px; }

@media (max-width: 760px) {
  .search { width: auto; flex: 1 1 auto; }
  .td-quiet { display: none; }
  .panel__head, .tr { padding-inline: 16px; }
}

/* Unofficial-mockup note, pinned in the panel's bottom-right corner */
.mock-note {
  position: absolute; right: 6px; bottom: 6px; margin: 0;
  padding: 4px 8px; border-radius: 4px; font-size: 12px; color: var(--text-quiet);
  background: var(--surface-overlay); box-shadow: 0 0 0 1px var(--border-faint);
  pointer-events: none;
}

/* Collapse toggle: arrow flips when collapsed */
.toggle-icon { display: flex; }
.is-collapsed .toggle-icon { transform: scaleX(-1); }

/* When collapsed, the system name moves into the header, before the breadcrumbs */
.crumb--system { display: none; color: var(--text); font-weight: 600; font-size: 15px; }
.is-collapsed .crumb--system { display: flex; }
/* Keep the expanded 10px logo-to-name gap: logo ends 33px into the 40px rail;
   header padding (10px) + crumb padding (6px) would put the name at 56px, so pull it back to 43px */
.is-collapsed a.crumb--system { margin-left: -13px; }
.system__logo svg { color: var(--text); }

/* Ask AI launcher and its chats panel (proposal) */
.ai-launcher-wrap { position: relative; }
.ai-launcher .chev { color: var(--text-quiet); }
.popover.ai-panel,
.is-collapsed .popover.ai-panel { left: auto; right: 0; bottom: auto; top: calc(100% + 6px); width: 300px; }
.ai-panel__new { font-weight: 500; }
.ai-panel__new svg { color: var(--blue-400); }
.ai-panel__label { padding: 6px 8px 2px; font-size: 12px; font-weight: 600; color: var(--text-quiet); }
.ai-panel a { justify-content: space-between; gap: 12px; }
.ai-panel__title { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-panel__when { flex: none; font-size: 12px; color: var(--text-quiet); }
.ai-launcher[aria-expanded="true"] .chev { transform: rotate(180deg); }

/* About Craft CMS panel, matching the 6.0.0-beta.3 popover */
.popover.about { width: 380px; padding: 0; }
.about__head { display: flex; align-items: center; gap: 14px; padding: 16px; }
.about__logo {
  width: 48px; height: 48px; border-radius: 8px; flex: none;
  background: #e5422b; color: #fff; display: grid; place-items: center;
}
.about__name { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 700; color: var(--text); }
.about__version { color: var(--text-quiet); font-size: 13px; }
.about__row { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--border-quiet); }
/* Centre the icon on the first line of text (20px line box), not the whole row */
.about__icon { color: var(--text-quiet); display: flex; align-items: center; flex: none; align-self: flex-start; height: 20px; }
.about__text { flex: 1 1 auto; min-width: 0; color: var(--text); }
.about__text small { display: block; color: var(--text-quiet); font-size: 12px; }
.about__buy { display: flex; align-items: center; gap: 6px; color: var(--link); white-space: nowrap; }
