/* BuildFlow — primary navigation.
   Tailwind here is precompiled, so the sidebar owns its layout in plain CSS.
   Collapse is driven by .ap-sb-collapsed on <html>; the mobile drawer rules in
   theme.css (max-width: 767.98px) still win below that breakpoint. */

:root {
  --ap-sb-w: 16rem;        /* expanded  — 256px */
  --ap-sb-w-min: 4.5rem;   /* collapsed — 72px  */

  --ap-sb-bg: #ffffff;
  --ap-sb-border: rgba(15, 23, 42, 0.08);
  --ap-sb-text: #475569;
  --ap-sb-text-strong: #0f172a;
  --ap-sb-muted: #94a3b8;
  --ap-sb-hover: rgba(15, 23, 42, 0.04);
  --ap-sb-active-bg: rgba(29, 111, 165, 0.10);
  --ap-sb-active-fg: var(--ap-primary, #0b3c5d);
  --ap-sb-accent: #1d6fa5;
}

.dark {
  --ap-sb-bg: #0e1526;
  --ap-sb-border: rgba(148, 178, 232, 0.12);
  --ap-sb-text: #8fa0bd;
  --ap-sb-text-strong: #e8edf7;
  --ap-sb-muted: #64748b;
  --ap-sb-hover: rgba(148, 178, 232, 0.06);
  --ap-sb-active-bg: rgba(91, 158, 224, 0.14);
  --ap-sb-active-fg: #a9cdf0;
  --ap-sb-accent: #5b9ee0;
}

/* ============ Shell ============ */
.ap-sb {
  display: none;                       /* md:flex equivalent, see media query */
  flex-direction: column;
  flex: none;
  width: var(--ap-sb-w);
  background: var(--ap-sb-bg);
  border-right: 1px solid var(--ap-sb-border);
  transition: width .24s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}
@media (min-width: 768px) { .ap-sb { display: flex; } }

.ap-sb-collapsed .ap-sb { width: var(--ap-sb-w-min); }

/* ============ Header / brand ============ */
.ap-sb-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 4rem;          /* grows for the two-line tagline, never clips it */
  flex: none;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--ap-sb-border);
}
.ap-sb-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
  flex: 1;
  border-radius: 0.6rem;
  padding: 0.25rem;
}
.ap-sb-logo { height: 2rem; width: auto; flex: none; }
.ap-sb-brand-text { display: grid; min-width: 0; }
.ap-sb-brand-name {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.15;
  color: var(--ap-sb-text-strong);
  white-space: nowrap;
}
/* Wraps onto a second line instead of truncating — the tagline is longer than
   a 256px rail can show on one line in any of the three languages. */
.ap-sb-brand-sub {
  font-size: 0.625rem;
  line-height: 1.3;
  color: var(--ap-sb-muted);
  white-space: normal;
  overflow-wrap: break-word;
}

.ap-sb-collapse {
  display: grid;
  place-items: center;
  width: 1.85rem;
  height: 1.85rem;
  flex: none;
  border-radius: 0.5rem;
  color: var(--ap-sb-muted);
  transition: background-color .16s ease, color .16s ease, transform .24s cubic-bezier(0.4, 0, 0.2, 1);
}
.ap-sb-collapse:hover { background: var(--ap-sb-hover); color: var(--ap-sb-text-strong); }
.ap-sb-collapse:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--ap-sb-bg), 0 0 0 4px var(--ap-sb-accent);
}
.ap-sb-collapse-ico { width: 1.05rem; height: 1.05rem; }

/* Collapsed: brand shrinks to the mark, the toggle flips and centres below it. */
.ap-sb-collapsed .ap-sb-head {
  flex-direction: column;
  height: auto;
  gap: 0.35rem;
  padding: 0.75rem 0.5rem;
}
.ap-sb-collapsed .ap-sb-brand { justify-content: center; flex: none; }
.ap-sb-collapsed .ap-sb-brand-text { display: none; }
.ap-sb-collapsed .ap-sb-collapse { transform: rotate(180deg); }

/* ============ Nav ============ */
.ap-sb-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.75rem 0.625rem;
  display: grid;
  gap: 0.125rem;
  align-content: start;
}
.ap-sb-nav::-webkit-scrollbar { width: 6px; }

.ap-nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.575rem 0.7rem;
  border-radius: 0.625rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ap-sb-text);
  white-space: nowrap;
  transition: background-color .18s ease, color .18s ease, transform .18s ease;
}
.ap-nav-link:hover {
  background: var(--ap-sb-hover);
  color: var(--ap-sb-text-strong);
  transform: translateY(-1px);
}
.ap-nav-link:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--ap-sb-bg), 0 0 0 4px var(--ap-sb-accent);
}
.ap-nav-ico {
  width: 1.25rem;
  height: 1.25rem;
  flex: none;
  color: var(--ap-sb-muted);
  transition: color .18s ease;
}
.ap-nav-link:hover .ap-nav-ico { color: var(--ap-sb-text-strong); }
.ap-nav-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* Active — soft tinted container, accent icon, thin left marker. No flat fill. */
.ap-nav-link.is-active {
  background: var(--ap-sb-active-bg);
  color: var(--ap-sb-active-fg);
  font-weight: 600;
}
.ap-nav-link.is-active .ap-nav-ico { color: var(--ap-sb-accent); }
.ap-nav-link.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 22%;
  bottom: 22%;
  width: 3px;
  border-radius: 0 9999px 9999px 0;
  background: var(--ap-sb-accent);
}
.dark .ap-nav-link.is-active {
  box-shadow: inset 0 0 0 1px rgba(91, 158, 224, 0.18), 0 6px 18px -10px rgba(91, 158, 224, 0.5);
}
.ap-nav-link.is-active:hover { transform: none; }

/* Collapsed: icon-only, centred, text removed from layout. */
.ap-sb-collapsed .ap-nav-link { justify-content: center; padding-left: 0; padding-right: 0; gap: 0; }
.ap-sb-collapsed .ap-nav-text { display: none; }
.ap-sb-collapsed .ap-nav-link.is-active::before { left: 0.15rem; }

/* ============ Footer / user ============ */
.ap-sb-foot { flex: none; padding: 0.625rem; border-top: 1px solid var(--ap-sb-border); }
.ap-sb-user {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.45rem 0.5rem;
  border-radius: 0.625rem;
  min-width: 0;
  transition: background-color .16s ease;
}
.ap-sb-user:hover { background: var(--ap-sb-hover); }
.ap-sb-user:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--ap-sb-bg), 0 0 0 4px var(--ap-sb-accent);
}
.ap-sb-avatar {
  width: 2rem;
  height: 2rem;
  flex: none;
  border-radius: 9999px;
}
.ap-sb-avatar-fallback {
  display: grid;
  place-items: center;
  font-size: 0.6875rem;
  font-weight: 700;
  color: #fff;
}
.ap-sb-user-text { display: grid; min-width: 0; }
.ap-sb-user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ap-sb-text-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ap-sb-user-role {
  font-size: 0.6875rem;
  color: var(--ap-sb-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ap-sb-collapsed .ap-sb-user { justify-content: center; padding-left: 0; padding-right: 0; gap: 0; }
.ap-sb-collapsed .ap-sb-user-text { display: none; }

/* ============ Tooltip (collapsed only) ============ */
/* Rendered as one fixed node by sidebar.js so the nav's own scrollbox
   cannot clip it. */
.ap-sb-tip {
  position: fixed;
  z-index: 60;
  padding: 0.35rem 0.6rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  color: #f1f5f9;
  background: #111a2e;
  border: 1px solid rgba(148, 178, 232, 0.18);
  box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity .14s ease, transform .14s ease;
}
.ap-sb-tip[data-open="true"] { opacity: 1; transform: none; }

/* The drawer on phones is always full width — never the collapsed rail. */
@media (max-width: 767.98px) {
  .ap-sb-collapsed .ap-sb { width: 16rem; }
  .ap-sb-collapsed .ap-sb-head { flex-direction: row; min-height: 4rem; padding: 0.5rem 0.75rem; }
  .ap-sb-collapsed .ap-sb-brand-text,
  .ap-sb-collapsed .ap-nav-text,
  .ap-sb-collapsed .ap-sb-user-text { display: block; }
  .ap-sb-collapsed .ap-sb-brand-text,
  .ap-sb-collapsed .ap-sb-user-text { display: grid; }
  .ap-sb-collapsed .ap-nav-link,
  .ap-sb-collapsed .ap-sb-user { justify-content: flex-start; padding-left: 0.7rem; padding-right: 0.7rem; gap: 0.75rem; }
  .ap-sb-collapse { display: none; }
  .ap-sb-tip { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .ap-sb, .ap-nav-link, .ap-sb-collapse, .ap-sb-tip { transition: none; }
  .ap-nav-link:hover { transform: none; }
}
