/* ==========================================================================
   DITS Enterprise Application Layout & Shell
   Sidebar, Navigation Desks, Collapsible Modes, and Responsive Viewports
   ========================================================================== */

.app-shell {
  display: flex;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--bg-app);
}

/* --------------------------------------------------------------------------
   Left Sidebar Navigation
   -------------------------------------------------------------------------- */
.sidebar {
  width: 290px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex-shrink: 0;
  transition: width var(--transition-smooth), transform var(--transition-smooth);
  z-index: 50;
  overflow: hidden;
}

/* Collapsed Sidebar State */
.sidebar.collapsed {
  width: 72px;
}

.sidebar.collapsed .hide-on-collapse {
  display: none !important;
}

.sidebar.collapsed .sidebar-brand-text {
  display: none !important;
}

.sidebar.collapsed .nav-label {
  display: none !important;
}

.sidebar.collapsed .nav-badge {
  display: none !important;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 10px 0;
}

.sidebar.collapsed .primary-action-btn {
  padding: 10px 0;
  justify-content: center;
}

.sidebar.collapsed .primary-action-btn span:not(.btn-icon) {
  display: none;
}

/* Sidebar Brand Header */
.sidebar-header {
  height: 64px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #1e3a8a, #3b82f6);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 0 16px rgba(59, 130, 246, 0.3);
  flex-shrink: 0;
}

.brand-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-sub {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
}

/* Sidebar Body & Nav Lists */
.sidebar-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.nav-group-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 8px;
  margin-bottom: 6px;
  display: block;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
}

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

.nav-item.active {
  background-color: var(--accent-primary-dim);
  color: #60a5fa;
  font-weight: 600;
  border-left: 3px solid var(--accent-primary);
}

.nav-icon {
  font-size: 16px;
  width: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  font-size: 10px;
  padding: 2px 6px;
  background: #192339;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
}

.nav-item.active .nav-badge {
  background: rgba(59, 130, 246, 0.25);
  color: #93c5fd;
}

/* History Items */
.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.history-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.history-item.active {
  background: var(--bg-card-hover);
  color: #60a5fa;
}

/* Sidebar Footer & System Status */
.sidebar-footer {
  border-top: 1px solid var(--border-subtle);
  background-color: rgba(9, 13, 23, 0.85);
  padding: 12px 14px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cluster-pills-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-dim);
}

.officer-profile-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.officer-profile-card:hover {
  background: var(--bg-card-hover);
}

/* --------------------------------------------------------------------------
   Main Content Shell & Global Top Header
   -------------------------------------------------------------------------- */
.main-viewport {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.top-header {
  height: 56px;
  padding: 0 20px;
  background-color: var(--bg-header);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  z-index: 20;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  overflow: hidden;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.module-title-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.module-title-bar h2 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.scope-indicator-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.25);
  color: #93c5fd;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.scope-indicator-pill:hover {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.4);
}

/* View Panels */
.view-panel {
  display: none;
  width: 100%;
  height: 100%;
  overflow: hidden;
  flex: 1;
}

.view-panel.active {
  display: flex;
  flex-direction: column;
}

/* Mobile Off-Canvas Sidebar */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 82vw;
    max-width: 320px;
    transform: translateX(-100%);
    box-shadow: var(--shadow-xl);
  }

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

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 40;
    display: none;
  }

  .sidebar-backdrop.active {
    display: block;
  }

  .top-header {
    padding: 0 12px;
  }
}
