/* Project Diamond shared sidebar — scoped, no global body overrides */
.pd-shell {
  --pd-sb-navy: #021024;
  --pd-sb-royal: #052659;
  --pd-sb-steel: #5483B3;
  --pd-sb-soft: #7DA0CA;
  --pd-sb-ice: #C1E8FF;
  --pd-sb-width: 16.5rem;
  --pd-sb-width-collapsed: 0px;
  display: flex;
  align-items: stretch;
  gap: 0;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  position: relative;
  box-sizing: border-box;
}
.pd-shell *,
.pd-shell *::before,
.pd-shell *::after { box-sizing: border-box; }

.pd-shell-main {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

/* Floating hamburger — avoids Sngine header conflicts */
.pd-nav-toggle {
  position: fixed;
  top: 5.25rem;
  left: 0.75rem;
  z-index: 85;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid rgba(193, 232, 255, 0.35);
  border-radius: 0.85rem;
  background: linear-gradient(160deg, var(--pd-sb-navy), var(--pd-sb-royal));
  color: var(--pd-sb-ice);
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(2, 16, 36, 0.28);
  transition: transform 0.15s ease, background 0.15s ease;
}
.pd-nav-toggle:hover { transform: translateY(-1px); }
.pd-nav-toggle:focus-visible {
  outline: 2px solid var(--pd-sb-ice);
  outline-offset: 2px;
}
.pd-nav-toggle__icon {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  position: relative;
  border-radius: 2px;
}
.pd-nav-toggle__icon::before,
.pd-nav-toggle__icon::after {
  content: "";
  position: absolute;
  left: 0;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
}
.pd-nav-toggle__icon::before { top: -6px; }
.pd-nav-toggle__icon::after { top: 6px; }
.pd-shell.is-open .pd-nav-toggle__icon,
.pd-shell:not(.is-collapsed):not(.is-mobile) .pd-nav-toggle__icon {
  background: transparent;
}
.pd-shell.is-open .pd-nav-toggle__icon::before,
.pd-shell:not(.is-collapsed):not(.is-mobile) .pd-nav-toggle__icon::before {
  top: 0; transform: rotate(45deg);
}
.pd-shell.is-open .pd-nav-toggle__icon::after,
.pd-shell:not(.is-collapsed):not(.is-mobile) .pd-nav-toggle__icon::after {
  top: 0; transform: rotate(-45deg);
}

.pd-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(2, 16, 36, 0.55);
  z-index: 80;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.pd-shell.is-mobile.is-open .pd-sidebar-backdrop {
  display: block;
}

.pd-sidebar {
  --pd-navy: var(--pd-sb-navy);
  --pd-royal: var(--pd-sb-royal);
  --pd-steel: var(--pd-sb-steel);
  --pd-soft: var(--pd-sb-soft);
  --pd-ice: var(--pd-sb-ice);
  flex: 0 0 var(--pd-sb-width);
  width: var(--pd-sb-width);
  max-width: var(--pd-sb-width);
  background: linear-gradient(180deg, var(--pd-sb-navy) 0%, var(--pd-sb-royal) 55%, #031a3a 100%);
  color: var(--pd-sb-ice);
  border-right: 1px solid rgba(193, 232, 255, 0.12);
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 4rem);
  position: sticky;
  top: 4rem;
  align-self: flex-start;
  z-index: 81;
  overflow: hidden;
  transition: width 0.2s ease, max-width 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
}
.pd-sidebar__inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 0.85rem 0.7rem 1.25rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(193,232,255,.35) transparent;
}
.pd-sidebar__brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.35rem 0.45rem 0.85rem;
  border-bottom: 1px solid rgba(193, 232, 255, 0.12);
  margin-bottom: 0.75rem;
  text-decoration: none;
  color: inherit;
}
.pd-sidebar__brand:hover { color: #fff; }
.pd-sidebar__logo-icon {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  max-width: 36px;
  max-height: 36px;
  border-radius: 0.65rem;
  object-fit: cover;
  background: rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.pd-sidebar__logo-word {
  width: auto;
  height: 28px;
  max-width: 140px;
  max-height: 28px;
  object-fit: contain;
  background: rgba(255,255,255,0.08);
  border-radius: 0.5rem;
  padding: 0.2rem 0.4rem;
}
.pd-sidebar__brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.pd-sidebar__brand-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  line-height: 1.2;
}
.pd-sidebar__brand-sub {
  font-size: 0.68rem;
  color: var(--pd-sb-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pd-sidebar__close {
  display: none;
  margin-left: auto;
  width: 40px;
  height: 40px;
  min-width: 40px;
  border: 0;
  border-radius: 0.65rem;
  background: rgba(193,232,255,0.1);
  color: var(--pd-sb-ice);
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
}
.pd-sidebar__close:focus-visible {
  outline: 2px solid var(--pd-sb-ice);
  outline-offset: 2px;
}

.pd-sidebar__group { margin-bottom: 0.85rem; }
.pd-sidebar__group-label {
  display: block;
  padding: 0.35rem 0.65rem 0.4rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--pd-sb-soft);
}
.pd-sidebar__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.pd-sidebar__link {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 44px;
  padding: 0.45rem 0.7rem;
  border-radius: 0.75rem;
  color: var(--pd-sb-ice);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.25;
  transition: background 0.12s ease, color 0.12s ease;
}
.pd-sidebar__link:hover {
  background: rgba(193, 232, 255, 0.1);
  color: #fff;
}
.pd-sidebar__link:focus-visible {
  outline: 2px solid var(--pd-sb-ice);
  outline-offset: 1px;
}
.pd-sidebar__link.is-active {
  background: linear-gradient(135deg, var(--pd-sb-steel), var(--pd-sb-soft));
  color: #fff;
  box-shadow: 0 4px 14px rgba(84, 131, 179, 0.35);
}
.pd-sidebar__link.is-active[aria-current="page"] { font-weight: 700; }
.pd-sidebar__ico {
  width: 1.15rem;
  height: 1.15rem;
  min-width: 1.15rem;
  min-height: 1.15rem;
  flex-shrink: 0;
  opacity: 0.95;
}
.pd-sidebar__chev {
  margin-left: auto;
  width: 1rem;
  height: 1rem;
  transition: transform 0.15s ease;
  opacity: 0.8;
}
.pd-sidebar__link.is-expanded .pd-sidebar__chev { transform: rotate(180deg); }

.pd-sidebar__sub {
  list-style: none;
  margin: 0.15rem 0 0.35rem 0.55rem;
  padding: 0 0 0 0.55rem;
  border-left: 1px solid rgba(193,232,255,0.18);
  display: none;
  flex-direction: column;
  gap: 0.1rem;
}
.pd-sidebar__item.is-open > .pd-sidebar__sub { display: flex; }
.pd-sidebar__sub-link {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 0.35rem 0.65rem;
  border-radius: 0.6rem;
  color: var(--pd-sb-soft);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
}
.pd-sidebar__sub-link:hover,
.pd-sidebar__sub-link:focus-visible {
  color: #fff;
  background: rgba(193,232,255,0.08);
  outline: none;
}

/* Desktop collapsed (hamburger hides sidebar, content full width) */
@media (min-width: 1024px) {
  .pd-shell.is-collapsed .pd-sidebar {
    width: 0;
    max-width: 0;
    flex-basis: 0;
    opacity: 0;
    pointer-events: none;
    border: 0;
  }
  .pd-shell:not(.is-collapsed) .pd-shell-main {
    padding-left: 0.25rem;
  }
  .pd-shell:not(.is-collapsed) {
    padding-left: 0;
  }
  /* room for toggle when sidebar open — nudge content slightly */
  .pd-shell:not(.is-collapsed) .pd-nav-toggle { left: calc(var(--pd-sb-width) + 0.5rem); }
  .pd-shell.is-collapsed .pd-nav-toggle { left: 0.75rem; }
}

/* Mobile / tablet: off-canvas drawer */
@media (max-width: 1023px) {
  .pd-shell { display: block; }
  .pd-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100vh;
    min-height: 100vh;
    max-height: 100vh;
    width: min(var(--pd-sb-width), 88vw);
    max-width: min(var(--pd-sb-width), 88vw);
    transform: translateX(-105%);
    opacity: 1;
    z-index: 90;
    border-right: 1px solid rgba(193,232,255,0.15);
    box-shadow: 8px 0 32px rgba(2,16,36,0.35);
  }
  .pd-shell.is-open .pd-sidebar { transform: translateX(0); }
  .pd-sidebar__inner { max-height: 100vh; padding-top: 0.75rem; }
  .pd-sidebar__close { display: inline-flex; align-items: center; justify-content: center; }
  .pd-nav-toggle { top: 4.75rem; left: 0.65rem; }
  .pd-shell-main { width: 100%; max-width: 100%; }
  body.pd-nav-lock { overflow: hidden; }
}

/* Builder: start collapsed-friendly, keep preview usable */
.pd-shell.pd-shell--builder:not(.is-mobile):not(.is-collapsed) .pd-sidebar {
  /* still available when opened */
}
.pd-shell.pd-shell--builder .pd-shell-main { min-width: 0; }

/* Reduce risk of horizontal overflow inside PD pages */
.pd-shell-main > .pd-theme,
.pd-shell-main > .flex,
.pd-shell-main > .pb-8 {
  max-width: 100%;
}
