/*
 * Admin shell: fixed sidebar, sticky header, scrolling content.
 *
 * The grid is defined on the shell rather than with position:fixed children so
 * the content column establishes its own containing block - which is what lets
 * wide tables scroll horizontally inside the page instead of pushing the whole
 * layout sideways.
 */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  grid-template-rows: 100dvh;
}

/* --- Sidebar --------------------------------------------------------------- */

.sidebar {
  grid-column: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  height: 100dvh;
  position: sticky;
  top: 0;
  overflow: hidden;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--header-height);
  padding: 0 var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  flex: 0 0 auto;
}

/* The brand mark. No tinted tile behind it: the monogram is gold on
   transparent, which sits correctly on both the light and the dark sidebar,
   and a coloured tile would fight it. Slightly larger than the old lettered
   box because the serifs thin out below about 30px. */
.sidebar__mark {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  object-fit: contain;
}

.sidebar__name {
  font-weight: var(--weight-semibold);
  letter-spacing: -0.01em;
  font-size: var(--text-base);
}

.sidebar__nav {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-3) var(--space-2) var(--space-6);
}

.sidebar__section + .sidebar__section { margin-top: var(--space-5); }

.sidebar__heading {
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0 var(--space-3);
  margin-bottom: var(--space-1);
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  line-height: 1.4;
  transition: background-color var(--duration-fast) ease,
              color var(--duration-fast) ease;
}
.sidebar__link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  text-decoration: none;
}
.sidebar__link[aria-current="page"] {
  background: var(--bg-selected);
  color: var(--text-accent);
  font-weight: var(--weight-semibold);
}
.sidebar__link svg { flex: 0 0 auto; width: 16px; height: 16px; }

/* Count of items needing attention, e.g. unanswered enquiries. */
.sidebar__badge {
  margin-left: auto;
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  padding: 1px var(--space-2);
  border-radius: var(--radius-full);
  background: var(--bg-sunken);
  color: var(--text-secondary);
}

.sidebar__footer {
  flex: 0 0 auto;
  border-top: 1px solid var(--border-subtle);
  padding: var(--space-3);
}

/* --- Main column ----------------------------------------------------------- */

.main {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100dvh;
  overflow: hidden;
}

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  height: var(--header-height);
  padding: 0 var(--space-5);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  z-index: var(--z-header);
}

.content {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: var(--space-6) var(--space-5) var(--space-12);
}

.content__inner {
  max-width: var(--content-max);
  margin: 0 auto;
}

/* --- Page header ----------------------------------------------------------- */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-6);
}

.page-header__title { display: flex; flex-direction: column; gap: var(--space-1); }
.page-header__description { color: var(--text-secondary); font-size: var(--text-base); }
.page-header__actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

/* --- Grids ----------------------------------------------------------------- */

/* auto-fit + minmax so cards reflow without media queries. */
.grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.grid--wide { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid--halves { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }

/* --- Responsive ------------------------------------------------------------
   Below 960px the sidebar becomes an off-canvas drawer toggled by the header
   button. The checkbox-free approach keeps it operable without JavaScript. */
@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    z-index: var(--z-drawer);
    transform: translateX(-100%);
    transition: transform var(--duration-base) var(--ease);
    box-shadow: var(--shadow-xl);
  }
  .shell[data-sidebar="open"] .sidebar { transform: translateX(0); }

  .main { grid-column: 1; }

  .sidebar-scrim {
    position: fixed;
    inset: 0;
    background: rgb(13 17 23 / 0.5);
    z-index: calc(var(--z-drawer) - 1);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration-base) ease;
  }
  .shell[data-sidebar="open"] .sidebar-scrim { opacity: 1; pointer-events: auto; }

  .content { padding: var(--space-5) var(--space-4) var(--space-10); }
}

@media (min-width: 961px) {
  .sidebar-toggle { display: none; }
  .sidebar-scrim { display: none; }
}
