/* layout.css
   App shell + sidebar layout only.
   Page-specific styling lives elsewhere (createpolicy.css etc). */

html, body {
  margin: 0;
  padding: 0;
  background: #0d0d0d;
  width: 100%;
  height: 100%;
  overflow-x: hidden;
}

:root {
  --sidebar-w: 94px;
  --sidebar-icon: 22px;
  --sidebar-btn: clamp(44px, calc(var(--sidebar-w) * 0.55), 56px);
}

/* App Shell */
.app-shell {
  min-height: 100vh;
  background: #0d0d0d;
  color: #e0e0e0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
}

.sidebar-toggle__checkbox {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  left: -9999px;
}

.sidebar-toggle {
  display: flex;
  position: fixed;
  top: auto;
  bottom: 20px;
  width: var(--sidebar-btn);
  height: var(--sidebar-btn);
  left: calc((var(--sidebar-w) - var(--sidebar-btn)) / 2);
  border-radius: 10px;
  background: #141414;
  border: 1px solid #3a3a3a;
  color: #e0e0e0;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  z-index: 80;
}

.sidebar-toggle span {
  position: relative;
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
}

.sidebar-toggle span::before,
.sidebar-toggle span::after {
  content: "";
  position: absolute;
  left: 0;
  width: 18px;
  height: 2px;
  background: currentColor;
}

.sidebar-toggle span::before {
  top: -6px;
}

.sidebar-toggle span::after {
  top: 6px;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  z-index: 40;
}

/* Sidebar (fixed) */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0; /* top:0; right:auto; bottom:0; left:0 */

  width: var(--sidebar-w);
  height: 100vh;

  box-sizing: content-box;
  background: #0d0d0d;
  border-right: 1px solid #2a2a2a;

  display: flex;
  flex-direction: column;
  align-items: center;

  z-index: 50;
}

.sidebar,
.sidebar *,
.sidebar *::before,
.sidebar *::after {
  box-sizing: content-box;
}

/* Logo */
.sidebar__logo {
  padding: 16px 0;
  width: 100%;
  display: flex;
  justify-content: center;
}

.sidebar__logo img {
  /* scales with sidebar width (no !important so your variable works) */
  width: calc(var(--sidebar-w) - 24px);
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

/* Main nav wrapper */
.sidebar__main {
  flex: 1;
  width: 100%;

  display: flex;
  align-items: center;
  justify-content: center;

  overflow: visible; /* tooltips can pop out */
}

/* Nav list */
.sidebar__nav {
  list-style: none;
  padding: 0;
  margin: 0;

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

/* Icon button */
.sidebar__nav a {
  /* scales a bit with sidebar width so width changes “feel real” */
  width: var(--sidebar-btn);
  height: var(--sidebar-btn);

  display: grid;
  place-items: center;

  background: #141414;
  border: 1px solid #2a2a2a;
  border-radius: 10px;

  text-decoration: none;
  color: #b0b0b0;

  position: relative;

  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease;
}

/* Standardise icon rendering */
.sidebar__nav .icon {
  display: block;
  line-height: 0;
}

.sidebar__nav .icon svg {
  width: var(--sidebar-icon);
  height: var(--sidebar-icon);
  display: block;
  transform-origin: center;
}

.sidebar__nav .icon--manage {
  width: calc(var(--sidebar-icon) + 4px);
  height: calc(var(--sidebar-icon) + 4px);
}

/* Tiny optical fix for the dashboard grid icon */
.sidebar__nav .icon--dashboard svg {
  transform: translateX(0.5px);
}

/* States */
.sidebar__nav a:hover {
  background: #1a1a1a;
  border-color: #3a3a3a;
  color: #ffffff;
}

.sidebar__nav a.active {
  background: #1a1a1a;
  border-color: #3a3a3a;
  color: #ffffff;
}

/* Tooltip labels */
.sidebar__nav .text {
  position: absolute;
  left: calc(var(--sidebar-w) + 12px); /* follows sidebar width */
  top: 50%;
  transform: translate(-6px, -50%);

  white-space: nowrap;

  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 8px;

  padding: 8px 12px;
  font-size: 0.9em;
  font-weight: 600;
  color: #ffffff;

  opacity: 0;
  pointer-events: none;

  transition: opacity 0.15s ease, transform 0.15s ease;
}

.sidebar__nav a:hover .text,
.sidebar__nav a:focus-visible .text {
  opacity: 1;
  transform: translate(0, -50%);
}

/* Keyboard focus ring */
.sidebar__nav a:focus-visible {
  outline: 2px solid #3a3a3a;
  outline-offset: 2px;
}

/* Logout (bottom) */
.sidebar__bottom {
  width: 100%;
  padding-bottom: calc(20px + var(--sidebar-btn) + 14px);

  display: flex;
  justify-content: center;
}

/* Main content area */
.app-main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;

  display: flex;
  justify-content: center;

  background: #0d0d0d;
  transition: margin-left 0.25s ease;
}

.content {
  width: 100%;
  max-width: 1100px;
  padding: 40px 20px;
}

/* Mobile sidebar toggle */
@media (max-width: 860px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  #sidebarToggle:checked ~ .sidebar {
    transform: translateX(0);
  }

  .app-main {
    margin-left: 0;
  }

  #sidebarToggle:checked ~ .sidebar-backdrop {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
  }
}

/* Desktop toggle: hide sidebar when checked */
@media (min-width: 861px) {
  .sidebar {
    transform: translateX(0);
    transition: transform 0.25s ease;
  }

  #sidebarToggle:checked ~ .sidebar {
    transform: translateX(-100%);
  }

  #sidebarToggle:checked ~ .app-main {
    margin-left: 0;
  }
}

/* Small screen: keep tooltips from going off-screen */
@media (max-width: 420px) {
  .sidebar__nav .text {
    left: calc(var(--sidebar-w) + 8px);
    font-size: 0.85em;
    padding: 7px 10px;
  }
}

/* Accessibility: reduce animation if user prefers */
@media (prefers-reduced-motion: reduce) {
  .sidebar__nav a,
  .sidebar__nav .text {
    transition: none;
  }
}
