/* QuantumStream - Layout System */

/* Main App Layout */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* ============= VERTICAL SIDEBAR NAVIGATION ============= */

/* Sidebar Container */
.app-sidebar {
  width: 280px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 150;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
}

.app-sidebar[data-collapsed="true"] {
  width: 72px;
}

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

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.sidebar-logo-img {
  height: 32px;
  width: 32px;
  min-width: 32px;
  object-fit: contain;
}

.sidebar-logo-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  opacity: 1;
  transition: opacity 0.2s;
}

.app-sidebar[data-collapsed="true"] .sidebar-logo-text {
  opacity: 0;
  pointer-events: none;
}

.sidebar-toggle {
  width: 36px;
  height: 36px;
  min-width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink-muted);
  transition: all 0.25s ease;
}

.sidebar-toggle:hover {
  background: rgba(122, 183, 255, 0.1);
  border-color: var(--accent);
  color: var(--accent);
}

.app-sidebar[data-collapsed="true"] .sidebar-toggle {
  opacity: 0;
  pointer-events: none;
}

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  /* Global scrollbar styling will apply from design-system.css */
}

/* Hide scrollbar when sidebar is collapsed */
.app-sidebar[data-collapsed="true"] .sidebar-nav {
  scrollbar-width: none;
}

.app-sidebar[data-collapsed="true"] .sidebar-nav::-webkit-scrollbar {
  display: none;
}

/* Hide scrollbar on sidebar itself when collapsed */
.app-sidebar[data-collapsed="true"]::-webkit-scrollbar {
  display: none;
}

/* Navigation Groups */
.nav-group {
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.nav-group:last-child {
  border-bottom: none;
}

.nav-group-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-muted);
  padding: 8px 24px;
  margin-bottom: 4px;
  opacity: 1;
  transition: opacity 0.2s;
  white-space: nowrap;
}

.app-sidebar[data-collapsed="true"] .nav-group-label {
  opacity: 0;
  pointer-events: none;
}

/* Navigation Items */
.nav-items {
  display: flex;
  flex-direction: column;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  color: var(--ink-muted);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  text-decoration: none;
  margin: 2px 8px;
  border-radius: 8px;
  min-height: 56px;
  height: 56px;
}

.nav-item-icon {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: transparent;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--ink-muted);
}

.nav-item-text {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 1;
  transition: opacity 0.2s;
  flex: 1;
}

.app-sidebar[data-collapsed="true"] .nav-item-text {
  display: none;
}

/* Navigation Item States */
.nav-item:hover {
  background: rgba(122, 183, 255, 0.08);
  color: var(--ink);
}

.nav-item:hover .nav-item-icon {
  color: var(--accent);
}

.nav-item.active {
  color: var(--accent);
  background: rgba(122, 183, 255, 0.12);
}

.nav-item.active .nav-item-icon {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  box-shadow: 0 4px 16px rgba(122, 183, 255, 0.4);
  color: #ffffff;
}

.nav-item.active .nav-item-icon i {
  color: #ffffff !important;
}

/* Collapsed Sidebar State */
.app-sidebar[data-collapsed="true"] .nav-item {
  padding: 8px;
  margin: 2px 8px;
  justify-content: center;
  min-width: 56px;
  width: 56px;
  height: 56px;
  min-height: 56px;
}

.app-sidebar[data-collapsed="true"] .nav-item.active {
  background: rgba(122, 183, 255, 0.12);
}

.app-sidebar[data-collapsed="true"] .nav-item:hover {
  background: rgba(122, 183, 255, 0.08);
}

/* Tooltip for Collapsed State */
.nav-item-tooltip {
  position: absolute;
  left: 72px;
  background: var(--panel-elev);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-8px);
  transition: all 0.2s;
  border: 1px solid rgba(122, 183, 255, 0.2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  color: var(--ink);
}

.app-sidebar[data-collapsed="true"] .nav-item:hover .nav-item-tooltip {
  opacity: 1;
  transform: translateX(0);
}

/* Main Wrapper */
.app-main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin-left: 72px;
  transition: none;
  will-change: auto;
}

/* Top Bar */
.app-topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 0 24px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
  height: 64px;
  min-height: 64px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  justify-self: start;
}

.topbar-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  justify-self: end;
}

.page-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  margin: 0;
}

.topbar-info {
  font-size: 13px;
  color: var(--ink-muted);
}

.mobile-menu-toggle {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink-muted);
  transition: all 0.25s ease;
}

.mobile-menu-toggle:hover {
  background: rgba(122, 183, 255, 0.1);
  border-color: var(--accent);
  color: var(--accent);
}

/* Main Content */
.app-main {
  flex: 1;
  padding: var(--spacing-xl) var(--spacing-lg);
  max-width: 1920px;
  width: 100%;
  margin: 0 auto;
}

/* Page Sections */
.page-section {
  display: none;
}

.page-section.active {
  display: block;
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Grid System */
.grid {
  display: grid;
  gap: var(--spacing-lg);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-12 { grid-template-columns: repeat(12, 1fr); }

.col-span-1 { grid-column: span 1; }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }
.col-span-4 { grid-column: span 4; }
.col-span-5 { grid-column: span 5; }
.col-span-6 { grid-column: span 6; }
.col-span-7 { grid-column: span 7; }
.col-span-8 { grid-column: span 8; }
.col-span-9 { grid-column: span 9; }
.col-span-12 { grid-column: span 12; }

/* Flex Utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }

/* Spacing Utilities */
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }
.mb-xl { margin-bottom: var(--spacing-xl); }

.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }

.p-md { padding: var(--spacing-md); }
.p-lg { padding: var(--spacing-lg); }

/* Mobile Sidebar Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* Responsive Breakpoints */
@media (max-width: 1199px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-12 { grid-template-columns: repeat(6, 1fr); }
  .col-span-5 { grid-column: span 6; }
  .col-span-7 { grid-column: span 6; }
  .col-span-8 { grid-column: span 6; }
  .col-span-9 { grid-column: span 6; }
}

@media (max-width: 899px) {
  .grid-2,
  .grid-3,
  .grid-4 { grid-template-columns: 1fr; }
  .grid-12 { grid-template-columns: 1fr; }
  .col-span-2,
  .col-span-3,
  .col-span-4,
  .col-span-5,
  .col-span-6,
  .col-span-7,
  .col-span-8,
  .col-span-9,
  .col-span-12 { grid-column: span 1; }
  
  .app-main {
    padding: var(--spacing-md);
  }
}

/* Mobile Sidebar (Tablet and below) */
@media (max-width: 768px) {
  .app-sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    bottom: 0;
    width: 280px !important;
    z-index: 200;
    transition: left 0.3s ease;
  }
  
  .app-sidebar.mobile-open {
    left: 0;
  }
  
  .app-sidebar[data-collapsed="true"] {
    width: 280px !important;
    left: -280px;
  }
  
  .app-sidebar[data-collapsed="true"] .sidebar-logo-text,
  .app-sidebar[data-collapsed="true"] .nav-item-text,
  .app-sidebar[data-collapsed="true"] .nav-group-label {
    opacity: 1;
    pointer-events: auto;
  }
  
  .app-sidebar[data-collapsed="true"] .sidebar-toggle {
    opacity: 1;
    pointer-events: auto;
  }
  
  .app-sidebar[data-collapsed="true"] .nav-item-tooltip {
    display: none;
  }
  
  .app-main-wrapper {
    margin-left: 0 !important;
  }
  
  .mobile-menu-toggle {
    display: flex;
  }
  
  .page-title {
    font-size: 16px;
  }
  
  .topbar-info {
    display: none;
  }
  
  .app-topbar {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 8px 16px;
    height: auto;
    min-height: 64px;
  }
  
  .topbar-center {
    order: 2;
    justify-self: start;
    margin-top: 8px;
  }
  
  .topbar-right {
    order: 3;
    justify-self: start;
  }
  
  .topbar-left {
    order: 1;
  }
}

/* Accessibility - Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .app-sidebar,
  .app-main-wrapper,
  .nav-item,
  .nav-item-icon,
  .nav-item-text,
  .nav-item-tooltip,
  .sidebar-logo-text,
  .nav-group-label,
  .sidebar-overlay {
    transition-duration: 0.01ms !important;
  }
}

/* Focus States for Accessibility */
.nav-item:focus,
.sidebar-toggle:focus,
.mobile-menu-toggle:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.nav-item:focus-visible,
.sidebar-toggle:focus-visible,
.mobile-menu-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Chart Container */
.chart-container {
  width: 100%;
  height: 300px;
  position: relative;
}

.chart-container svg {
  width: 100%;
  height: 100%;
}

/* Detail Panel */
.detail-panel {
  background: var(--panel-elev);
  border-radius: var(--radius);
  padding: var(--spacing-lg);
  margin-top: var(--spacing-md);
}

.detail-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-md);
  border-bottom: 1px solid var(--line);
}

/* Action Bar */
.action-bar {
  display: flex;
  gap: var(--spacing-md);
  align-items: center;
  padding: var(--spacing-md) 0;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: var(--spacing-xl);
  color: var(--ink-muted);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: var(--spacing-md);
  opacity: 0.5;
}

