/* ==========================================================================
   Layout — SFA Middleware Prototype
   ==========================================================================
   App shell: sidebar + topbar + content, kartu telepon simulator, dan grid
   utilitas. Mobile-first: gaya dasar untuk layar sempit, sidebar menjadi
   drawer overlay; breakpoint tunggal 1024px membuka layout dua kolom penuh.
   Bergantung sepenuhnya pada custom property dari css/tokens.css.
   ========================================================================== */

/* App shell
   ========================================================================== */
.app {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
  background: var(--bg);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 260px;
  max-width: 82vw;
  display: flex;
  flex-direction: column;
  background: var(--surface-glass);
  backdrop-filter: blur(14px);
  border-right: 1px solid var(--glass-border);
  overflow: hidden auto;
  transform: translateX(-100%);
  transition: transform 200ms ease;
  z-index: 100;
}

.app.is-drawer-open .sidebar {
  transform: translateX(0);
  box-shadow: var(--shadow-1);
}

.sidebar__nav {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  /* Right padding is intentionally larger than the other sides: it is the
     canvas the scoop-tab curve (.nav-item--active::before/::after, 20px
     wide) renders into. It must clear the curve's own 20px footprint plus
     the 2px .nav-item:hover translateX shift (also applied while an item is
     --active), so the curve never gets clipped by .sidebar's
     overflow-x:hidden, at rest or on hover. */
  padding: 8px 24px 8px 8px;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  background: var(--surface-glass);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--glass-border);
}

.content {
  flex: 1;
  min-width: 0;
  padding: 16px;
}

.drawer-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: var(--radius-s);
  border: 1px solid var(--glass-border);
  background: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease;
}

.drawer-toggle:hover {
  transform: translateY(-1px);
}

.drawer-toggle:active {
  transform: translateY(0) scale(0.96);
}

@media (min-width: 1024px) {
  .app {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    max-width: none;
    transform: none;
    transition: none;
    box-shadow: none;
  }

  .drawer-toggle {
    display: none;
  }

  .content {
    padding: 24px;
  }
}

/* Navigasi sidebar — scoop-tab
   ========================================================================== */
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-m);
  color: var(--text-secondary);
  background: transparent;
  border: none;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease;
  z-index: 1;
}

.nav-item:hover {
  transform: translateX(2px);
  color: var(--text-primary);
}

.nav-item:active {
  transform: translateX(2px) scale(0.98);
}

.nav-item--active,
.nav-item--active:hover {
  background: var(--surface);
  color: var(--text-primary);
  border-radius: var(--radius-m) 0 0 var(--radius-m);
}

/* Sudut "scoop" — dua pseudo-elemen di sudut atas/bawah item aktif yang
   membuat kurva cekung, seolah tab meluncur keluar dari permukaan sidebar. */
.nav-item--active::before,
.nav-item--active::after {
  content: "";
  position: absolute;
  right: -20px;
  width: 20px;
  height: 20px;
  pointer-events: none;
}

.nav-item--active::before {
  top: -20px;
  background: radial-gradient(circle at top left, transparent 19.5px, var(--surface) 20px);
}

.nav-item--active::after {
  bottom: -20px;
  background: radial-gradient(circle at bottom left, transparent 19.5px, var(--surface) 20px);
}

.nav-indicator {
  position: absolute;
  left: 0;
  top: 8px;
  width: 3px;
  height: 44px;
  border-radius: 0 4px 4px 0;
  background: var(--brand-primary);
  transform: translateY(0);
  transition: transform 200ms ease;
  pointer-events: none;
}

/* Login
   ========================================================================== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

/* Frame telepon — simulator SFA
   ========================================================================== */
.phone-frame {
  position: relative;
  width: 100%;
  max-width: 390px;
  height: 760px;
  max-height: calc(100vh - 48px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: 40px;
  box-shadow: var(--shadow-1);
}

/* Grid utilitas
   ========================================================================== */
.grid-kpi {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

/* Grid item default min-width:auto membuat konten lebar (mis. tabel ber-min-width di
   dalam .table-wrap) mendorong kolom melebihi viewport alih-alih scroll internal. */
.grid-2 > *,
.grid-kpi > * {
  min-width: 0;
}

@media (min-width: 1024px) {
  .grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
