/* App Shell Layout */
.app-layout {
  display: flex;
  width: 100%;
  min-height: 100vh;
  background-color: var(--bg-app);
}

/* Sidebar */
.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-surface);
  border-inline-end: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  inset-inline-start: 0;
  z-index: 40;
  transition: transform var(--transition-normal);
}

.sidebar-header {
  height: var(--header-height);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.app-logo-badge {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #0284c7 0%, #38bdf8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.4);
}

.brand-text h1 {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.brand-text span {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
}

/* Navigation List */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.nav-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 12px;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.nav-items {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 13.5px;
  transition: all var(--transition-fast);
  cursor: pointer;
  border: 1px solid transparent;
}

.nav-link:hover {
  color: var(--text-primary);
  background-color: var(--bg-card);
  border-color: var(--border-subtle);
}

.nav-link.active {
  color: #ffffff;
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.2) 0%, rgba(14, 165, 233, 0.1) 100%);
  border-color: rgba(2, 132, 199, 0.35);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.nav-icon {
  font-size: 18px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.85;
}
.nav-link.active .nav-icon {
  opacity: 1;
  color: var(--accent-primary);
}

.nav-badge {
  margin-inline-start: auto;
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-weight: 600;
}
.badge-preview {
  background-color: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 12px;
}

.tenant-chip {
  flex: 1;
  overflow: hidden;
}
.tenant-chip .tenant-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tenant-chip .tenant-tier {
  font-size: 10.5px;
  color: var(--accent-emerald);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Main Content Wrapper */
.app-main {
  flex: 1;
  margin-inline-start: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* App Header */
.app-header {
  height: var(--header-height);
  background-color: rgba(17, 24, 39, 0.75);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-primary);
  cursor: pointer;
}

.page-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text-secondary);
}
.breadcrumb-active {
  color: var(--text-primary);
  font-weight: 700;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.header-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-default);
  background: var(--bg-card-hover);
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 10px 5px 6px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
}
.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
}
.user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  text-align: start;
}
.user-info .user-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
}
.user-info .user-role {
  font-size: 10px;
  color: var(--accent-primary);
}

/* Page Content Viewport */
.app-content {
  flex: 1;
  padding: 28px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

/* Responsive Media Queries */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 240px;
  }
  .app-content {
    padding: 20px;
  }
}

@media (max-width: 768px) {
  .app-sidebar {
    transform: translateX(100%);
  }
  [dir="ltr"] .app-sidebar {
    transform: translateX(-100%);
  }
  .app-sidebar.open {
    transform: translateX(0);
  }
  .app-main {
    margin-inline-start: 0;
  }
  .mobile-menu-btn {
    display: block;
  }
  .app-header {
    padding: 0 16px;
  }
}
