/* The page frame shared by the application and Job activity pages: sidebar, top bar, and status pills. */

/*
 * A status pill: one per displayed status on every page. The tone comes from
 * statusTones (internal/webui/status.go); colours from the status tokens.
 */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: fit-content;
  padding: 1px 9px 1px 7px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 560;
  line-height: 20px;
  white-space: nowrap;
}
.status-pill::before {
  width: 12px;
  font-size: 11px;
  text-align: center;
}
.status-pill.tone-ok {
  color: var(--s-ok);
  background: var(--s-ok-bg);
}
.status-pill.tone-ok::before {
  content: "✓";
}
.status-pill.tone-bad {
  color: var(--s-bad);
  background: var(--s-bad-bg);
}
.status-pill.tone-bad::before {
  content: "✕";
}
.status-pill.tone-run {
  color: var(--s-run);
  background: var(--s-run-bg);
}
.status-pill.tone-run::before {
  content: "▶";
}
.status-pill.tone-warn {
  color: var(--s-warn);
  background: var(--s-warn-bg);
}
.status-pill.tone-warn::before {
  content: "!";
}
.status-pill.tone-off {
  color: var(--s-off);
  background: var(--s-off-bg);
}
.status-pill.tone-off::before {
  content: "■";
}
.status-pill.carried {
  border: 1px dashed currentColor;
  background: transparent;
}
.status-pill.carried::before {
  content: "↩";
}
/* Sidebar: brand, views, and the basedir tree. */
.sidebar {
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 260px;
  min-width: 190px;
  max-width: 520px;
  height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  overflow-anchor: none;
  padding: 18px 12px 22px;
  border-right: 1px solid var(--line-soft);
  background: var(--surface);
}

.sidebar-brand {
  display: grid;
  grid-template-columns: 34px 1fr;
  grid-template-rows: 20px 15px;
  align-items: center;
  column-gap: 10px;
  margin: 0 4px 10px;
  padding: 2px 4px 14px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  grid-row: 1 / 3;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid color-mix(in oklab, var(--logo-red) 40%, transparent);
  border-radius: 10px;
  background: color-mix(in oklab, var(--logo-red) 10%, var(--surface));
  line-height: 1;
}

.brand-mark .brand-icon {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.brand-name {
  align-self: end;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.brand-caption {
  align-self: start;
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
}

.sidebar-section-heading {
  margin: 14px 8px 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-section-note {
  margin: -2px 8px 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.sidebar-link,
.sidebar-project-link,
.sidebar-run {
  border-radius: 6px;
  text-decoration: none;
  transition:
    color 140ms ease,
    background 140ms ease;
}

.sidebar-link {
  display: block;
  padding: 5px 8px;
  color: var(--text-2);
  font-size: 13px;
}

.sidebar-link:hover,
.sidebar-project-row:hover,
.sidebar-run:hover {
  background: var(--surface-2);
}

.sidebar-link.active,
.sidebar-run.active,
.sidebar-project:not(.basedir-entry) .sidebar-project-link.active {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: inset 2px 0 0 var(--accent);
}

.sidebar-project {
  min-width: 0;
}

.sidebar-project-row {
  display: flex;
  min-height: 30px;
  align-items: center;
  gap: 2px;
  padding: 0 2px;
  border-radius: 6px;
}

.sidebar-project-link {
  flex: 1;
  min-width: 0;
  padding: 4px 6px 4px 8px;
  color: var(--text);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A basedir is labelled by its parent directory and its own name (basedirLabelHTML). */
.basedir-path {
  font-family: var(--font-mono);
  font-size: 12px;
}
.basedir-parent {
  font-weight: 600;
}
.basedir-name {
  color: var(--muted);
}

/* The bell is a checkbox: notify about runs in this basedir. */
.basedir-bell {
  position: relative;
  display: grid;
  flex: none;
  width: 26px;
  height: 24px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
}
.basedir-bell:hover {
  border-color: var(--line);
}
.basedir-bell input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}
.basedir-bell svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}
.basedir-bell:has(input:checked) {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.basedir-bell:has(input:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.sidebar-toggle {
  display: flex;
  flex: 0 0 auto;
  width: 22px;
  height: 28px;
  min-height: 0;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.sidebar-toggle-placeholder {
  display: block;
  flex: 0 0 22px;
  height: 28px;
}

.sidebar-toggle::before {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 4px 0 4px 6px;
  border-color: transparent transparent transparent currentColor;
  content: "";
  transition: transform 100ms ease;
}

.sidebar-project.expanded .sidebar-toggle::before {
  transform: rotate(90deg);
}

.sidebar-projects,
.sidebar-runs {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-left: 10px;
  padding-left: 8px;
  border-left: 1px solid var(--line-soft);
}

.basedir-contents {
  margin-left: 20px;
  padding-left: 0;
  border-left: 0;
}

.sidebar-projects[hidden],
.sidebar-runs[hidden] {
  display: none;
}

.sidebar-run {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 4px 8px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-run-dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--s-off);
}
.sidebar-run-dot.tone-ok {
  background: var(--s-ok);
}
.sidebar-run-dot.tone-bad {
  background: var(--s-bad);
}
.sidebar-run-dot.tone-run {
  background: var(--s-run);
}
.sidebar-run-dot.tone-warn {
  background: var(--s-warn);
}

.brand-icon {
  width: 0.85em;
  height: 0.85em;
}

.sidebar-resizer {
  position: relative;
  z-index: 4;
  flex: 0 0 12px;
  align-self: stretch;
  margin-left: -6px;
  margin-right: -6px;
  cursor: col-resize;
  touch-action: none;
}

.sidebar-resizer::after {
  position: absolute;
  top: 0;
  right: 3px;
  bottom: 0;
  width: 2px;
  background: transparent;
  content: "";
  transition: background 120ms ease;
}

.sidebar-resizer:hover::after,
.sidebar-resizer:focus-visible::after,
.sidebar-resizer.dragging::after {
  background: color-mix(in oklab, var(--accent) 78%, transparent);
}

/* Top bar: breadcrumbs, then notifications, refresh, and the Settings menu. */
.content {
  --content-x: clamp(22px, 3.1vw, 48px);
  padding-top: 0;
}

.content > .topbar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 6;
  display: flex;
  flex-direction: row;
  min-height: 0;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  margin: 0 calc(-1 * var(--content-x)) 24px;
  padding: 10px var(--content-x);
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklab, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
}

.crumbs {
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.crumbs a {
  color: var(--text-2);
  text-decoration: none;
}
.crumbs a:hover {
  text-decoration: underline;
}
.crumb-basedir {
  font-family: var(--font-mono);
  font-size: 12.5px;
}
.crumb-here {
  overflow: hidden;
  color: var(--text);
  font-weight: 500;
  text-overflow: ellipsis;
}
.crumb-sep {
  color: var(--line);
}
.crumbs .identity-copy,
.crumbs .jobs-copy {
  flex: none;
  width: 24px;
  height: 24px;
  min-height: 0;
  margin: 0;
  padding: 4px;
  border-color: transparent;
  background: transparent;
}

.content > .topbar .toolbar {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.content > .topbar .toolbar button {
  min-height: 32px;
  padding: 5px 11px;
}
#notify-toggle.notifications-on {
  border-color: color-mix(in oklab, var(--accent) 60%, var(--line));
  background: var(--accent-soft);
  color: var(--accent-text);
}

.settings-menu {
  position: relative;
}
.settings-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  display: flex;
  width: 270px;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-pop);
}
.settings-panel[hidden] {
  display: none;
}
.theme-choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-2);
  font-size: 13px;
}
.theme-choice select {
  min-width: 0;
  min-height: 30px;
  padding: 3px 8px;
  font-size: 12px;
}
.settings-actions {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
}
.settings-actions:empty {
  display: none;
}
.content > .topbar .settings-actions button {
  width: 100%;
  min-height: 0;
  padding: 7px 8px;
  border-color: transparent;
  background: transparent;
  text-align: left;
}
.content > .topbar .settings-actions button:hover:not(:disabled) {
  background: var(--surface-2);
}

/* The page's title and its facts. */
.page-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0 0 20px;
}
.page-head[hidden] {
  display: none;
}
.page-head h1 {
  display: block;
  margin: 0;
  font-size: clamp(22px, 2vw, 26px);
  font-weight: 600;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.facts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
  color: var(--text-2);
  font-size: 13px;
}

/* Below 760px the sidebar is a drawer over the page (web_shell.js). */
.drawer-toggle,
.drawer-scrim {
  display: none;
}

@media (max-width: 760px) {
  .content {
    --content-x: 18px;
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: min(300px, 86vw) !important;
    max-width: none;
    height: 100%;
    visibility: hidden;
    transform: translateX(-100%);
    transition:
      transform 160ms ease,
      visibility 160ms;
    box-shadow: var(--shadow-pop);
  }
  body.drawer-open .sidebar {
    visibility: visible;
    transform: none;
  }
  body.drawer-open .drawer-scrim {
    position: fixed;
    inset: 0;
    z-index: 25;
    display: block;
    background: var(--overlay);
  }
  .sidebar-resizer {
    display: none;
  }
  .content > .topbar .drawer-toggle {
    display: inline-flex;
    min-height: 32px;
    padding: 5px 9px;
  }
  .content > .topbar .toolbar button {
    padding: 5px 8px;
  }
  .crumbs > .crumb-basedir,
  .crumbs > .crumb-basedir + button,
  .crumbs > .crumb-basedir + button + .crumb-sep {
    display: none;
  }
}

/* On a phone the page refreshes itself; its breadcrumb needs the room. */
@media (max-width: 520px) {
  .content > .topbar #refresh-button {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar {
    transition: none;
  }
}

/* A long ID shown by its end with a leading ellipsis; the text and title
   keep the whole ID (idTailHTML in assets.go, idTailHTML in
   web_app_core.js). The line height leaves room for underscores. */
.id-tail {
  display: inline-block;
  max-width: 16ch;
  overflow: hidden;
  direction: rtl;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
  line-height: 1.5;
  font-family: var(--font-mono);
  font-size: 12.5px;
}
.id-tail > bdi {
  direction: ltr;
  unicode-bidi: isolate;
}
