/* ==========================================================================
   PMS - App layout: sidebar + topbar + view root
   ========================================================================== */

#app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---------- Sidebar ---------- */
#sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  background: var(--bg-elevated);
  border-inline-end: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

/* The logo is a 3.6:1 wordmark, so a 250px sidebar cannot fit it beside the
   app name (the name would truncate to "Digital P..."). The name therefore
   goes UNDER the logo, which needs no horizontal room. The vertical padding is
   trimmed to 12px so the block stays close to its previous height and the nav
   barely moves. */
.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: var(--space-2) var(--space-4);
  color: var(--primary);
  border-block-end: 1px solid var(--border);
}

.sidebar-brand .brand-name {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.15;
  letter-spacing: 0.01em;
  color: var(--primary);
  text-align: center;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.sidebar-brand .brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--on-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
}
/* The logo is a 3.6:1 wordmark, so it is sized by height and given its width
   by the aspect ratio. `flex: 0 1 auto` + `max-width: 100%` mean that on a
   narrow window the logo shrinks instead of pushing the sidebar wider, and the
   brand row never grows taller than the logo needs. */
.sidebar-brand .brand-logo-img {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
}
.sidebar-brand .brand-logo-img img {
  height: 40px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

.sidebar-nav {
  padding: var(--space-3) var(--space-2);
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 9px var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  border: none;
  text-align: start;
  width: 100%;
  font-size: 0.95rem;
}

.nav-item:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-item .nav-icon { width: 20px; text-align: center; flex: 0 0 20px; }

.sidebar-footer {
  padding: var(--space-3);
  border-block-start: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-faint);
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

/* ---------- Main column ---------- */
#main-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#topbar {
  height: var(--topbar-height);
  flex: 0 0 var(--topbar-height);
  background: var(--bg-elevated);
  border-block-end: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-inline: var(--space-4);
}

.topbar-title {
  font-weight: 700;
  font-size: 1.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.save-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}

.save-indicator.ok { color: var(--success); background: var(--success-soft); border-color: transparent; }
.save-indicator.err { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.save-indicator .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.save-indicator.ok .dot { background: var(--success); }
.save-indicator.err .dot { background: var(--danger); }

.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  min-width: 220px;
}

.search-box input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
}

#view-root {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-5);
}

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  #sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: 950;
    transform: translateX(var(--sidebar-hidden-offset, 0));
    box-shadow: var(--shadow-lg);
    transition: transform 0.2s ease;
  }
  #sidebar.collapsed {
    --sidebar-hidden-offset: -100%;
  }
  #sidebar.collapsed + #main-col { /* no-op */ }
  #main-col { margin-inline-start: 0; }
  .search-box { display: none; }
}