:root {
  --cg-sidebar-bg: #0056d7;
  --cg-sidebar-width: 240px;
  --cg-rail-width: 64px;
}

.material-symbols-outlined {
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
  vertical-align: middle;
}

/* Sidebar: modelled on v1's SB Admin layout (translateX slide, 0.15s
   ease-in-out), collapsed by default at every width. Toggled by the
   `cg-sidenav-open` class on <body> (layout_dashboard.html). */
.cg-sidebar {
  position: fixed;
  top: 56px;
  bottom: 0;
  left: 0;
  width: min(80vw, var(--cg-sidebar-width));
  overflow-y: auto;
  background-color: var(--cg-sidebar-bg);
  transform: translateX(-100%);
  transition: transform 0.15s ease-in-out;
  z-index: 1038;
}

.cg-sidenav-open .cg-sidebar {
  transform: translateX(0);
}

/* MDB's btn-link paints a light background on hover/focus, which shows as a
   white box on the blue top bar. Keep a visible outline for keyboard focus
   only. */
.cg-topnav-btn:hover,
.cg-topnav-btn:focus,
.cg-topnav-btn:active {
  background-color: transparent !important;
  box-shadow: none !important;
}

.cg-topnav-btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.8);
  outline-offset: 2px;
}

.cg-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

/* Mobile: the open sidebar covers the content, with a backdrop (v1 mobile). */
.cg-sidenav-backdrop {
  display: none;
  position: fixed;
  top: 56px;
  right: 0;
  bottom: 0;
  left: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1037;
}

.cg-sidenav-open .cg-sidenav-backdrop {
  display: block;
}

.cg-nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.cg-nav-link {
  display: flex;
  align-items: center;
  padding: 0.75rem 1.25rem;
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
}

.cg-nav-link.active,
.cg-nav-link:hover {
  color: #fff;
  background-color: rgba(255, 255, 255, 0.12);
}

.cg-nav-link .material-symbols-outlined {
  margin-right: 0.75rem;
}

.cg-nav-label {
  white-space: nowrap;
}

.cg-main {
  padding-top: 56px;
}

.cg-main {
  transition: margin-left 0.15s ease-in-out;
}

/* Desktop: collapsed = an icon rail (--cg-rail-width) that stays visible;
   hovering or keyboard-focusing an icon shows its label as a tooltip, and
   clicking it navigates directly. ☰ expands it to the full sidebar, which
   pushes the content (v1 desktop). No backdrop on desktop. Mobile keeps the
   fully hidden slide-in drawer above. */
@media (min-width: 992px) {
  .cg-sidebar {
    transform: none;
    width: var(--cg-rail-width);
    /* Visible, so the label tooltips can extend past the rail's edge. */
    overflow: visible;
    transition: width 0.15s ease-in-out;
  }

  .cg-sidenav-open .cg-sidebar {
    width: var(--cg-sidebar-width);
    overflow-x: hidden;
    overflow-y: auto;
  }

  .cg-main {
    margin-left: var(--cg-rail-width);
  }

  .cg-sidenav-open .cg-main {
    margin-left: var(--cg-sidebar-width);
  }

  .cg-sidenav-open .cg-sidenav-backdrop {
    display: none;
  }

  body:not(.cg-sidenav-open) .cg-sidebar-header {
    display: none;
  }

  body:not(.cg-sidenav-open) .cg-nav-link {
    position: relative;
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }

  body:not(.cg-sidenav-open) .cg-nav-link .material-symbols-outlined {
    margin-right: 0;
  }

  /* Rail labels: visually hidden but still read by screen readers ... */
  body:not(.cg-sidenav-open) .cg-nav-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  /* ... and shown as a tooltip beside the icon on hover / keyboard focus. */
  body:not(.cg-sidenav-open) .cg-nav-link:hover .cg-nav-label,
  body:not(.cg-sidenav-open) .cg-nav-link:focus-visible .cg-nav-label {
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    padding: 0.35rem 0.65rem;
    border-radius: 0.25rem;
    background-color: #212529;
    color: #fff;
    font-size: 0.875rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    pointer-events: none;
    z-index: 1040;
  }
}

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

.cg-plan-card.cg-plan-current {
  border: 2px solid var(--cg-sidebar-bg);
}

/* Resources documents (templates/resources/_doc.html). */
.cg-doc h2 { font-size: 1.25rem; font-weight: 700; margin-top: 2rem; }
.cg-doc h3 { font-size: 1.05rem; font-weight: 700; margin-top: 1.5rem; }
.cg-doc pre { position: relative; background: #f5f7fb; border: 1px solid #dde3ee; border-radius: .5rem; padding: 2.4rem 1rem 1rem; overflow-x: auto; font-size: .85rem; }
.cg-doc pre .cg-copy { position: absolute; top: .4rem; right: .4rem; }
.cg-doc table { font-size: .9rem; }
.cg-doc td:first-child, .cg-doc th:first-child { white-space: nowrap; }
.cg-doc p code, .cg-doc li code { word-break: break-word; }
