/* ══════════════════════════════════════════════════════════════════════════
   Shell aplikasi: sidebar + topbar + content
   ══════════════════════════════════════════════════════════════════════════ */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
  background: var(--bg-app);
}

/* ── Header khusus mobile ── */
.mobile-header {
  display: none;
  position: sticky;
  top: 0;
  z-index: var(--z-mobile-header);
  align-items: center;
  gap: var(--sp-3);
  height: 56px;
  padding: 0 var(--sp-4);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-soft);
}

.mobile-header__brand img {
  height: 30px;
  width: auto;
}

.mobile-header__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-left: auto;
}

.mobile-header__avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  background: var(--primary);
  color: var(--on-primary);
  font-size: var(--fs-sm);
  font-weight: 700;
}

/* ── Sidebar ── */
.sidebar {
  position: sticky;
  top: 0;
  z-index: var(--z-sidebar);
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-card);
  border-right: 1px solid var(--border-soft);
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-soft);
  min-height: var(--topbar-h);
}

.sidebar__brand img {
  height: 36px;
  width: auto;
}

.sidebar__brand-copy small {
  display: block;
  margin-top: 1px;
  color: var(--text-dim);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar__close {
  display: none;
  margin-left: auto;
  background: transparent;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--sp-1);
  border-radius: var(--radius-sm);
}

.sidebar__close:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

.sidebar__scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--sp-4) var(--sp-3);
  display: grid;
  gap: var(--sp-5);
  align-content: start;
}

.nav-section {
  display: grid;
  gap: var(--sp-2);
}

.nav-heading {
  padding: 0 var(--sp-3);
  color: var(--text-faint);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-list {
  display: grid;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 9px var(--sp-3);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: var(--fs-base);
  font-weight: 500;
  transition: background var(--t-fast), color var(--t-fast);
}

.nav-item:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

.nav-item.is-active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.nav-item.is-active .nav-icon {
  color: var(--primary);
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  color: var(--text-dim);
}

.nav-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-badge {
  margin-left: auto;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: var(--bg-inset);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 700;
}

/* ── Footer sidebar ── */
.sidebar__footer {
  padding: var(--sp-3);
  border-top: 1px solid var(--border-soft);
  display: grid;
  gap: var(--sp-2);
}

.user-card {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
}

.user-card__avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: var(--radius-pill);
  background: var(--primary);
  color: var(--on-primary);
  font-size: var(--fs-base);
  font-weight: 700;
}

.user-card__meta {
  min-width: 0;
}

.user-card__name {
  display: block;
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-card__email {
  display: block;
  font-size: var(--fs-xs);
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Main ── */
.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  min-height: var(--topbar-h);
  padding: var(--sp-2) var(--sp-6);
  background: color-mix(in srgb, var(--bg-card) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
}

.topbar__title {
  min-width: 0;
}

.topbar__eyebrow {
  display: block;
  color: var(--text-faint);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar__heading {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-left: auto;
}

.content {
  flex: 1 1 auto;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--sp-6);
  display: grid;
  gap: var(--sp-5);
  align-content: start;
}

/* ── Header halaman ── */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
}

.page-header__eyebrow {
  display: block;
  margin-bottom: var(--sp-1);
  color: var(--text-faint);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-header h1 {
  font-size: var(--fs-2xl);
}

.page-header__sub {
  margin: var(--sp-2) 0 0;
  max-width: 62ch;
  color: var(--text-muted);
  font-size: var(--fs-md);
}

.page-header__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

/* ── Footer konten ── */
.content-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
  padding-top: var(--sp-4);
  margin-top: var(--sp-2);
  border-top: 1px solid var(--border-soft);
  color: var(--text-dim);
  font-size: var(--fs-sm);
}

/* ── Tema toggle ── */
.theme-toggle {
  display: grid;
  place-items: center;
  width: var(--control-h-sm);
  height: var(--control-h-sm);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}

.theme-toggle:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

.theme-toggle svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme='dark'] .theme-toggle .icon-sun { display: block; }
[data-theme='dark'] .theme-toggle .icon-moon { display: none; }

/* ── Overlay drawer ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-sidebar) - 1);
  background: rgba(9, 14, 22, 0.5);
  backdrop-filter: blur(2px);
}

.sidebar-overlay.is-open {
  display: block;
}

/* ── Logo yang menyesuaikan tema ── */
.logo-swap {
  display: inline-flex;
  align-items: center;
}

.logo-swap img {
  height: 100%;
  width: auto;
}

.logo-on-dark {
  display: none;
}

[data-theme='dark'] .logo-on-light {
  display: none;
}

[data-theme='dark'] .logo-on-dark {
  display: block;
}

.sidebar__brand .logo-swap,
.mobile-header__brand .logo-swap {
  height: 36px;
}

/* ── Lewati ke konten ── */
.skip-link {
  position: absolute;
  left: -9999px;
  top: var(--sp-2);
  z-index: calc(var(--z-toast) + 1);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
}

.skip-link:focus {
  left: var(--sp-2);
}

/* ══ Responsive ═══════════════════════════════════════════════════════════ */

@media (max-width: 1100px) {
  .content {
    padding: var(--sp-5);
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .mobile-header {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(290px, 86vw);
    height: 100%;
    transform: translateX(-102%);
    transition: transform var(--t-slow);
    box-shadow: var(--shadow-modal);
    border-right: 0;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar__close {
    display: grid;
  }

  .sidebar__brand img {
    height: 32px;
  }

  .topbar {
    display: none;
  }

  .content {
    padding: var(--sp-4);
    gap: var(--sp-4);
  }

  .page-header h1 {
    font-size: var(--fs-xl);
  }
}

@media (max-width: 560px) {
  .content {
    padding: var(--sp-3);
  }

  .page-header {
    align-items: flex-start;
  }
}
