/*
 * public/design/admin/_shared/sidebar.css
 *
 * Styles for the shared admin sidebar component (sibling: sidebar.js).
 * Mirrors the look of /design/09-admin.html with the sidebar INTEGRATED into
 * the page layout as a natural left column — not a fixed overlay.
 *
 * Layout strategy
 * ───────────────
 *   * Desktop (>= 1024px): the sidebar is a `position: sticky; top: 0` column
 *     inside a flex container `.lz-admin-layout` (sibling of the page's main
 *     content). This means the sidebar lives in normal document flow, never
 *     paints over the page header/title, and scrolls naturally within its own
 *     column while sticking to the viewport top.
 *   * Mobile (< 1024px): the sidebar collapses off-canvas; a hamburger button
 *     opens it as a slide-in drawer with backdrop overlay (unchanged from the
 *     original PR #142 behaviour).
 *
 * The injector script (scripts/inject-admin-sidebar.mjs) wraps each page's
 * existing markup so that the sidebar slot + the rest of the body live as
 * siblings inside `<div class="lz-admin-layout">`. The runtime (sidebar.js)
 * does the same wrapping in JS as a safety net for pages that ship the slot
 * but not the wrapper.
 *
 * All class names are namespaced with `lz-sb-` / `lz-admin-` to avoid
 * colliding with any utility classes inside the mockups (which use Tailwind v4).
 */

:root {
  --lz-sb-width: 240px;
}

/* ──────────────────────────────────────────────────────────────────────────
 * Page layout wrapper. The injector wraps the sidebar slot + everything after
 * it (until </body>) in this container. We use flex so the sidebar becomes a
 * natural left column and the main content fills the rest.
 * ─────────────────────────────────────────────────────────────────────────── */
.lz-admin-layout {
  display: flex;
  align-items: flex-start;
  min-height: 100vh;
  width: 100%;
}

/* The main column hosts the page's original header/main/etc. It needs to be
   able to shrink under flex (default min-width: auto on flex items would let
   wide tables push the column out and break sticky positioning). */
.lz-admin-main {
  flex: 1 1 0;
  min-width: 0;
  width: 100%;
}

/* ──────────────────────────────────────────────────────────────────────────
 * Sidebar slot — the container the JS renders into. On desktop it's a fixed-
 * width flex column; the inner `.lz-sb` <aside> handles its own sticky
 * positioning and overflow. On mobile the slot collapses to zero width; the
 * <aside> becomes a fixed off-canvas drawer instead.
 * ─────────────────────────────────────────────────────────────────────────── */
#lz-admin-sidebar {
  flex: 0 0 var(--lz-sb-width);
  width: var(--lz-sb-width);
  align-self: stretch;
}

/* ──────────────────────────────────────────────────────────────────────────
 * The sidebar itself (rendered inside #lz-admin-sidebar by sidebar.js).
 * Desktop: a sticky left column matching the reference layout in
 * /design/09-admin.html (.sidebar { … position: sticky; top: 0; }).
 * ─────────────────────────────────────────────────────────────────────────── */
.lz-sb {
  width: var(--lz-sb-width);
  min-height: 100vh;
  max-height: 100vh;
  background: #0f172a;
  border-right: 1px solid #334155;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  font-family: 'Inter', -apple-system, sans-serif;
  color: #f1f5f9;
  /* iOS safe-area: keep the top/bottom content clear of notch and home bar. */
  padding-top: calc(env(safe-area-inset-top, 0px) + 20px);
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
  /* Sticky to the viewport top inside its flex column. The slot above is also
     sticky, but we anchor the visual element here so the box never drifts. */
  position: sticky;
  top: 0;
}

/* Hamburger button — visible only on mobile.
   Each admin page already pins a `.top-back` ("← Admin Index") link at
   top-left and several pages (47, 48, 49, 50, 54) pin a `.lang-switch` at
   top-right. To avoid collision we drop the hamburger immediately under the
   back button on the left edge. */
.lz-sb-hamburger {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 56px);
  left: 14px;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid #334155;
  border-radius: 10px;
  color: #f1f5f9;
  font-size: 18px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background 0.15s ease;
}
.lz-sb-hamburger:hover {
  background: rgba(30, 41, 59, 0.95);
}

/* Backdrop overlay (mobile only, behind sidebar). */
.lz-sb-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.lz-sb-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

/* ──────────────────────────────────────────────────────────────────────────
 * Mobile behaviour
 * Sidebar collapses out of the flow; the slot has zero width so the page
 * content takes the full viewport. The <aside> becomes a fixed drawer that
 * slides in from the left when .open is set.
 * ─────────────────────────────────────────────────────────────────────────── */
@media (max-width: 1023px) {
  #lz-admin-sidebar {
    flex: 0 0 0;
    width: 0;
    position: static;
  }
  .lz-sb {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
    min-height: 100vh;
    max-height: 100vh;
  }
  .lz-sb.open {
    transform: translateX(0);
  }
  .lz-sb-hamburger {
    display: inline-flex;
  }
  body.lz-sb-no-scroll {
    overflow: hidden;
  }
}

/* ──────────────────────────────────────────────────────────────────────────
 * Desktop — sidebar always visible as a column; the page's own .top-back
 * ("← Admin Index") link is redundant (sidebar exposes navigation) and would
 * sit on top of the sidebar. Hide it so the corner stays clean.
 * ─────────────────────────────────────────────────────────────────────────── */
@media (min-width: 1024px) {
  .lz-sb-backdrop {
    display: none;
  }
  .lz-sb-close {
    display: none;
  }
  .top-back {
    display: none !important;
  }
}

/* Header row inside sidebar: logo + label, plus close button on mobile. */
.lz-sb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 4px;
  margin-bottom: 14px;
}
.lz-sb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.lz-sb-logo {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 16px;
  flex-shrink: 0;
}
.lz-sb-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.lz-sb-brand-title {
  font-weight: 700;
  font-size: 14px;
  color: #f1f5f9;
}
.lz-sb-brand-sub {
  font-size: 11px;
  color: #64748b;
}
.lz-sb-close {
  background: transparent;
  border: 1px solid #334155;
  color: #cbd5e1;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.lz-sb-close:hover {
  background: #1e293b;
}

/* Scrollable nav region. */
.lz-sb-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-bottom: 16px;
}

/* Section header (uppercase group label). */
.lz-sb-section {
  font-size: 11px;
  text-transform: uppercase;
  color: #64748b;
  padding: 14px 12px 4px;
  letter-spacing: 0.5px;
  font-weight: 600;
}

/* Individual nav link. */
.lz-sb-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  color: #94a3b8;
  font-size: 13px;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
  cursor: pointer;
  line-height: 1.3;
}
.lz-sb-link:hover {
  background: #1e293b;
  color: #f1f5f9;
}
.lz-sb-link.active {
  background: linear-gradient(135deg, rgba(30, 64, 175, 0.32), rgba(59, 130, 246, 0.18));
  color: white;
  border-left: 3px solid #3b82f6;
  padding-left: 9px;
}
.lz-sb-link-icon {
  font-size: 14px;
  flex-shrink: 0;
  width: 18px;
  text-align: center;
}
.lz-sb-link-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Footer block at bottom of sidebar — lang switcher + profile. */
.lz-sb-footer {
  border-top: 1px solid #1e293b;
  padding-top: 12px;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Language switcher. */
.lz-sb-lang {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
}
.lz-sb-lang-label {
  font-size: 11px;
  color: #64748b;
  font-weight: 600;
}
.lz-sb-lang-buttons {
  display: inline-flex;
  gap: 4px;
  margin-left: auto;
}
.lz-sb-lang-btn {
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  background: transparent;
  color: #64748b;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}
.lz-sb-lang-btn:hover {
  color: #cbd5e1;
}
.lz-sb-lang-btn.active {
  background: #1e293b;
  border-color: #334155;
  color: #f1f5f9;
}

/* Profile row (bottom of sidebar). */
.lz-sb-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  color: #cbd5e1;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.lz-sb-profile:hover {
  background: #1e293b;
}
.lz-sb-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #3b82f6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  font-size: 11px;
  flex-shrink: 0;
}
