/* ==========================================================================
   BEYOND NEXUS MSP (msp.bydnx.com) - Layout Architecture
   Sidebar, Topbar, Main Shell & Containers
   ========================================================================== */

.app-shell {
  display: flex;
  min-height: 100vh;
  background-color: var(--background-soft);
}

/* --------------------------------------------------------------------------
   SIDEBAR
   -------------------------------------------------------------------------- */
.app-sidebar {
  width: var(--sidebar-width);
  background-color: #FFFFFF;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  transition: width var(--transition-normal), transform var(--transition-normal);
  user-select: none;
}

.sidebar-header {
  height: var(--topbar-height);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background-color: #FFFFFF;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  overflow: hidden;
}

.brand-logo-img {
  height: 38px;
  width: auto;
  display: block;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.nav-group-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0.35rem 0.75rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition-fast);
  position: relative;
}

.nav-item:hover {
  background-color: var(--background-section);
  color: var(--primary);
}

.nav-item.active {
  background-color: var(--accent-subtle);
  color: var(--accent);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 15%;
  bottom: 15%;
  width: 3px;
  background-color: var(--accent);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  stroke-width: 2;
}

.nav-label {
  flex: 1;
  white-space: nowrap;
}

.nav-badge {
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
  font-weight: 600;
  line-height: 1;
}

.nav-badge.danger {
  background-color: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

.nav-badge.warning {
  background-color: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
}

.nav-badge.info {
  background-color: var(--info-bg);
  color: var(--info-text);
  border: 1px solid var(--info-border);
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  background-color: var(--background-soft);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.msp-motto {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sidebar-demo-note {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--success);
  display: inline-block;
  box-shadow: 0 0 0 2px var(--success-bg);
}

.status-dot.pulsing {
  animation: pulse-dot 2s infinite ease-in-out;
}

@keyframes pulse-dot {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* --------------------------------------------------------------------------
   MAIN CONTENT WRAPPER
   -------------------------------------------------------------------------- */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition-normal);
}

/* --------------------------------------------------------------------------
   TOPBAR
   -------------------------------------------------------------------------- */
.app-topbar {
  height: var(--topbar-height);
  background-color: var(--background-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.sidebar-toggle-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.sidebar-toggle-btn:hover {
  background-color: var(--background-section);
  color: var(--primary);
  border-color: var(--border-hover);
}

/* Org / Tenant Selector Dropdown */
.tenant-selector {
  position: relative;
}

.tenant-selector-btn {
  background-color: var(--background-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.45rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tenant-selector-btn:hover {
  border-color: var(--border-hover);
  background-color: #FFFFFF;
}

.tenant-badge {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  background-color: var(--primary);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 700;
}

.tenant-info {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.tenant-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  line-height: 1;
}

.tenant-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  line-height: 1.2;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Global Search Trigger */
.search-trigger-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background-color: var(--background-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.45rem 0.9rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
  min-width: 220px;
  transition: all var(--transition-fast);
}

.search-trigger-btn:hover {
  border-color: var(--border-hover);
  background-color: #FFFFFF;
  color: var(--text-secondary);
}

.search-kbd {
  margin-left: auto;
  font-size: 0.7rem;
  background-color: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 0.15rem 0.4rem;
  color: var(--text-secondary);
  font-weight: 600;
}

/* Demo Mode Badge */
.demo-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background-color: #EFF6FF;
  border: 1px solid #BFDBFE;
  color: var(--accent);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.demo-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--accent);
}

/* Icon Buttons (Notifications, Help) */
.topbar-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: none;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
  transition: all var(--transition-fast);
}

.topbar-icon-btn:hover {
  background-color: var(--background-section);
  color: var(--primary);
  border-color: var(--border);
}

.notification-count {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: var(--danger);
  color: #FFFFFF;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #FFFFFF;
}

/* User Menu Button */
.user-profile-btn {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-md);
  transition: background-color var(--transition-fast);
}

.user-profile-btn:hover {
  background-color: var(--background-section);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background-color: var(--accent-subtle);
  color: var(--accent);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #BFDBFE;
}

.user-meta {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.user-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary);
  line-height: 1.2;
}

.user-role {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1;
}

/* --------------------------------------------------------------------------
   CONTENT CONTAINER
   -------------------------------------------------------------------------- */
.app-content {
  flex: 1;
  padding: 1.75rem;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
}

/* Page Header with Breadcrumbs & Action Toolbar */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-title-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.page-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.page-breadcrumbs a {
  color: var(--text-secondary);
}

.page-breadcrumbs a:hover {
  color: var(--accent);
}

.breadcrumb-separator {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.page-title {
  font-size: 1.65rem;
  color: var(--primary);
  font-weight: 700;
}

.page-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
