/* ============================================================
   NIREV AI — Layout System  [Modernized: UI Pass]
   ============================================================ */

/* ── App Shell ── */
#nirev-app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

/* ── Screens ── */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; }

/* ── Auth Screen ── */
.screen--auth {
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background:
    radial-gradient(ellipse 60% 60% at 50% -5%, rgba(201,168,76,0.08) 0%, transparent 55%),
    radial-gradient(ellipse 40% 40% at 90% 90%, rgba(224,123,0,0.04) 0%, transparent 50%),
    var(--black-void);
}

/* ── Main App ── */
.screen--app { flex-direction: row; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  height: 100dvh; /* iOS dynamic viewport */
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: rgba(10, 10, 10, 0.92);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-right: 1px solid var(--black-border);
  transition: transform var(--dur-slow) var(--ease-smooth);
}

/* Sidebar Brand */
.sidebar__brand {
  padding: var(--space-6) var(--space-5) var(--space-5);
  border-bottom: 1px solid var(--black-border);
  flex-shrink: 0;
}

.sidebar__logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}

.sidebar__logo-text {
  font-family: var(--font-display);
  font-size: 1.625rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  background: linear-gradient(135deg, var(--gold-pure) 0%, var(--gold-light) 60%, var(--gold-pure) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}

.sidebar__logo-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--orange-core);
  box-shadow: 0 0 8px rgba(224, 123, 0, 0.6);
  flex-shrink: 0;
  animation: glow-pulse 3s ease-in-out infinite;
}

.sidebar__tagline {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--white-muted);
  text-transform: uppercase;
}

/* Sidebar Nav */
.sidebar__nav {
  flex: 1;
  padding: var(--space-4) var(--space-3);
  overflow-y: auto;
}

.nav-section { margin-bottom: var(--space-5); }

.nav-section__label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--white-muted);
  padding: 0 var(--space-3);
  margin-bottom: var(--space-2);
  display: block;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 11px var(--space-3);
  border-radius: var(--radius-md);
  margin-bottom: 1px;
  color: var(--white-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: -0.01em;
  transition:
    background var(--dur-fast) var(--ease-smooth),
    color var(--dur-fast) var(--ease-smooth),
    border-color var(--dur-fast);
  cursor: pointer;
  position: relative;
  user-select: none;
  border: 1px solid transparent;
}

.nav-item:hover {
  background: var(--white-ghost);
  color: var(--white-secondary);
}

.nav-item.active {
  background: rgba(224, 123, 0, 0.08);
  color: var(--orange-bright);
  border-color: rgba(224, 123, 0, 0.15);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 25%;
  height: 50%;
  width: 2px;
  background: var(--orange-core);
  border-radius: var(--radius-pill);
  box-shadow: 0 0 6px var(--orange-core);
}

.nav-item__icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.6;
  font-size: 0.875rem;
  transition: opacity var(--dur-fast);
}

.nav-item.active .nav-item__icon,
.nav-item:hover  .nav-item__icon { opacity: 1; }

.nav-item__label { flex: 1; }

.nav-item__badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: var(--orange-ghost);
  color: var(--orange-bright);
  border: 1px solid var(--orange-line);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Sidebar Footer */
.sidebar__footer {
  padding: var(--space-4);
  border-top: 1px solid var(--black-border);
  flex-shrink: 0;
}

.sidebar__user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--dur-fast);
  margin-bottom: var(--space-2);
}

.sidebar__user:hover { background: var(--white-ghost); }

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--gold-dim), var(--gold-pure));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--black-base);
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.user-info { flex: 1; min-width: 0; }

.user-info__name {
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--white-primary);
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.user-info__role {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--white-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  line-height: 1.3;
}

/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-8);
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--black-border);
  position: sticky;
  top: 0;
  z-index: 160; /* Above overlay (150) so toggle button is never blocked */
  flex-shrink: 0;
}

.topbar__left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.topbar__page-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--white-primary);
  letter-spacing: -0.01em;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.topbar__status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--white-secondary);
  letter-spacing: 0.06em;
  padding: 5px var(--space-3);
  background: var(--black-elevated);
  border: 1px solid var(--black-border);
  border-radius: var(--radius-pill);
}

.topbar__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--black-elevated);
  border: 1px solid var(--black-border);
  color: var(--white-muted);
  transition: all var(--dur-fast) var(--ease-smooth);
}

.topbar__btn:hover {
  background: var(--black-card);
  border-color: var(--black-subtle);
  color: var(--white-secondary);
}

/* ── Page Content ── */
.page-content {
  flex: 1;
  padding: var(--space-8);
  max-width: var(--content-max);
  width: 100%;
  overflow-x: hidden;
}

/* ── Mobile Overlay ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-smooth);
  cursor: pointer;
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* ── Sidebar Close Button ── */
.sidebar__close {
  display: none;
  margin-left: auto;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  background: var(--black-elevated);
  border: 1px solid var(--black-border);
  color: var(--white-muted);
  font-size: var(--text-sm);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--dur-fast);
}

.sidebar__close:hover {
  background: var(--black-card);
  color: var(--white-primary);
  border-color: var(--black-subtle);
}

/* ── Sidebar Toggle Button ── */
.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--black-elevated);
  border: 1px solid var(--black-border);
  color: var(--white-secondary);
  transition: all var(--dur-fast);
}

.sidebar-toggle:hover {
  background: var(--black-card);
  border-color: var(--black-subtle);
  color: var(--white-primary);
}

/* ── Responsive ── */
@media (max-width: 900px) {
  /* Sidebar */
  .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
    z-index: 200;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }

  .sidebar-overlay { display: block; }
  .sidebar__close  { display: flex; }
  .sidebar-toggle  { display: flex; }

  /* Main content */
  .main-content { margin-left: 0; }
  .page-content { padding: var(--space-4) var(--space-4); }
  .topbar { padding: 0 var(--space-4); }

  /* Hide status pill on mobile — save space */
  .topbar__status { display: none; }
}

@media (max-width: 480px) {
  .page-content { padding: var(--space-3) var(--space-3); }
  .topbar__page-title { font-size: var(--text-sm); }
}

/* ── Sidebar Logo Image ── */
.sidebar__brand-top {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.sidebar__logo-img {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  flex-shrink: 0;
  object-fit: cover;
  filter: drop-shadow(0 2px 8px rgba(201, 168, 76, 0.20));
}

.sidebar__brand-info {
  flex: 1;
  min-width: 0;
}
