/* ============================================================
   PEDCAM — App shell: <aside class="sidebar"> + main column.
   Same structure and behaviour as the Indigo KB shell.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { background: var(--bg); color: var(--text); }

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  display: flex; flex-direction: column;
  min-height: 0; overflow-y: auto; overflow-x: hidden;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 50;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px 12px; flex-shrink: 0; text-decoration: none; }
.brand-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; align-items: center; }
.brand-wordmark, .brand-wordmark img { display: block; width: 200px; height: auto; max-width: 100%; }
/* The navy "PED" disappears on the dark surface: give the wordmark a light plate there. */
[data-theme="dark"] .brand-wordmark img { background: #f8fafc; border-radius: 6px; padding: 3px 6px; box-sizing: border-box; }
.brand-sub { font-size: 13px; color: var(--text-3); font-weight: 600; letter-spacing: .02em; display: flex; justify-content: center; }

/* Printshop switcher */
.shop-switch { padding: 4px 12px 8px; flex-shrink: 0; }
.shop-switch label { display: block; font-size: var(--fs-micro); font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--text-3); padding: 0 4px 4px; }
.shop-switch select {
  width: 100%; height: 36px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text);
  font: 600 13px var(--font-ui); cursor: pointer;
}
.shop-switch select:focus { outline: none; box-shadow: var(--ring); border-color: var(--primary); }

/* Nav */
.sidebar-nav { padding: 4px 12px 8px; display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; }
.nav-section { display: flex; align-items: center; gap: 8px; padding: 12px 10px 4px; }
.sidebar-nav > .nav-section:first-child { padding-top: 4px; }
.nav-section-lbl {
  font-size: var(--fs-micro); font-weight: 700; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--text-3); white-space: nowrap; line-height: 1;
}
.nav-section::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.nav-section.nav-toggle { width: 100%; background: none; border: none; cursor: pointer; font-family: inherit; }
.nav-section.nav-toggle:hover .nav-section-lbl { color: var(--text-2); }
.nav-sec-chev {
  font-size: 10px; color: var(--text-2); flex-shrink: 0; order: 1;
  width: 18px; height: 18px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--border);
  transition: transform .22s cubic-bezier(.2,.8,.2,1), background .14s, color .14s;
}
.nav-section.is-collapsed .nav-sec-chev { transform: rotate(-90deg); }
.nav-section.nav-toggle:hover .nav-sec-chev { background: var(--primary-soft); color: var(--primary); border-color: var(--primary-border); }
.nav-collapse { display: flex; flex-direction: column; gap: 2px; }
.nav-collapse.is-collapsed { display: none; }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); cursor: pointer;
  font: 550 13.5px var(--font-ui);
  border: none; background: none; width: 100%;
  text-align: left; text-decoration: none; position: relative;
  transition: background .14s, color .14s, transform .18s cubic-bezier(.23,1,.32,1);
}
.nav-item:hover { background: var(--surface-2); color: var(--text); transform: translateX(2px); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 650; }
.nav-item.active::before {
  content: ''; position: absolute; left: -12px; top: 18%; bottom: 18%;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--primary);
}
.nav-icon { color: var(--text-3); flex-shrink: 0; font-size: 17px; line-height: 1; }
.nav-item:hover .nav-icon { color: var(--text-2); }
.nav-item.active .nav-icon { color: var(--primary); }
.nav-badge {
  margin-left: auto; font: 700 11px var(--font-mono);
  background: var(--accent-soft); color: var(--accent);
  border-radius: 99px; padding: 1px 8px; min-width: 22px; text-align: center;
}
.nav-badge:empty { display: none; }

/* Resources */
.sidebar-resources { border-top: 1px solid var(--border); padding: 10px 12px; flex-shrink: 0; }
.res-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px;
  border-radius: var(--radius-sm); color: var(--text-2); text-decoration: none;
}
.res-item:hover { background: var(--surface-2); color: var(--text); }
.res-ic { width: 27px; height: 27px; border-radius: 7px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex-shrink: 0; font-size: 14px; }
.res-tx { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.res-name { font-size: 12.5px; font-weight: 650; color: var(--text); }
.res-desc { font-size: 10.5px; color: var(--text-3); }

/* User footer */
.sys-footer { border-top: 1px solid var(--border); padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; flex-shrink: 0; margin-top: auto; }
.user-card { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 800; font-size: 13px;
  background: linear-gradient(150deg, var(--primary), var(--navy)); color: #fff;
}
.user-meta { min-width: 0; line-height: 1.2; }
.user-name { font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-3); }
.sys-actions { display: flex; gap: 6px; }
.sys-actions > * { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { flex: 1; border: none; background: var(--surface); color: var(--text-2); font: 700 11px var(--font-ui); padding: 6px 8px; cursor: pointer; }
.seg button.active { background: var(--primary-soft); color: var(--primary); }
.icon-btn {
  height: 30px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-2); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: 600 12px var(--font-ui);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ── Main column ── */
.app-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); overflow: hidden; }
.app-screen { flex: 1; min-height: 0; overflow-y: auto; position: relative; }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.screen-anim { animation: screen-in .32s cubic-bezier(.16,1,.3,1); }

/* Topbar (mobile) */
.shell-topbar {
  display: none; height: 56px; flex-shrink: 0; align-items: center; gap: 14px; padding: 0 16px;
  border-bottom: 1px solid var(--border); background: var(--surface);
}
.shell-topbar-title { font-size: 16px; font-weight: 700; }
.hamburger { display: none; width: 34px; height: 34px; border: none; background: transparent; cursor: pointer; border-radius: var(--radius-sm); color: var(--text-2); font-size: 20px; align-items: center; justify-content: center; }
.nav-scrim { position: fixed; inset: 0; background: rgba(17,24,39,.35); z-index: 39; opacity: 0; pointer-events: none; transition: opacity .25s; }
.nav-scrim.visible { opacity: 1; pointer-events: auto; }

@media (max-width: 1080px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 40; top: 0; left: 0; width: var(--sidebar-w); height: 100%;
    transform: translateX(-100%); transition: transform .25s; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .hamburger, .shell-topbar { display: flex; }
}
