/**
 * StokeAir Layout System
 * Core layout structure for the StokeAir application
 */

/* ========== CORE LAYOUT STRUCTURE ========== */

/* Base layout */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

/* App container - main wrapper */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
  overflow: hidden;
  min-height: 100%;
}

/* Header styling */
.app-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-md);
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  position: relative;
  z-index: var(--z-above);
  flex-wrap: nowrap;
  overflow: hidden;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  white-space: nowrap;
  gap: 20px;
  padding-right: 20px;
  overflow: visible;
}

.logo-container {
  display: flex;
  align-items: center;
  padding: 0 var(--space-xl) 0 var(--space-md);
}

/* Logo styling with responsive behavior */
.logo {
  height: 32px;
  display: block;
}

/* Icon logo (FM_000) styling */
.logo-icon {
  height: 32px;
  display: block;
}

/* Show full logo by default, hide icon logo */
.full-logo {
  display: block;
}

.icon-logo {
  display: none;
}

/* Switch to icon logo under 640px width */
@media (max-width: 640px) {
  .full-logo {
    display: none;
  }
  
  .icon-logo {
    display: block;
  }
}

/* Logo and icon theme toggling */
.logo-dark, .sidebar-icon-dark {
  display: none;
}

[data-theme="dark"] .logo-light, [data-theme="dark"] .sidebar-icon-light {
  display: none;
}

[data-theme="dark"] .logo-dark, [data-theme="dark"] .sidebar-icon-dark {
  display: block;
}

/* Dashboard icon styling - COMMENTED OUT AS ICON IS TEMPORARILY REMOVED */
/*
.dashboard-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 15px;
  margin-top: 15px;
}

.dashboard-icon img {
  height: 32px; 
  width: auto;
}
*/

/* Dashboard icon styling */

/* Dashboard icon sizing */
.dashboard-icon img {
  max-width: 100%;
  height: 32px; /* Fixed height for consistency */
  width: auto;
  display: block;
}

/* Dashboard icon in collapsed state */
.sidebar-collapsed .dashboard-icon img {
  width: 42px; /* Larger for better visibility */
  height: 42px;
  display: block !important;
  margin: 0 auto;
  object-fit: contain;
  opacity: 1;
  visibility: visible;
}
*/

/* Mobile menu toggle - only visible on mobile devices */
.mobile-menu-toggle {
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  display: none; /* Hidden by default on desktop */
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  background-color: transparent;
  padding: 0;
  margin-right: var(--space-xs);
}

/* Only show on mobile */
@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: flex;
  }
}

.mobile-menu-toggle:hover {
  color: var(--color-primary);
  background-color: var(--bg-tertiary);
}

.mobile-menu-toggle svg {
  width: 24px;
  height: 24px;
}

/* Navigation styling */
.primary-nav {
  display: flex;
  align-items: center;
  height: 100%;
}

.nav-link {
  display: flex;
  align-items: center;
  height: var(--header-height);
  padding: 0 var(--space-md);
  color: var(--text-secondary);
  font-weight: 500;
  transition: color var(--transition-fast), box-shadow var(--transition-fast);
  position: relative;
}

.nav-link:hover {
  color: var(--text-primary);
}

.nav-link.active {
  color: var(--color-primary);
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: var(--space-md);
  right: var(--space-md);
  height: 2px;
  background-color: var(--color-primary);
}

/* App main content with sidebar */
.app-main {
  display: flex;
  height: calc(100vh - var(--header-height) - var(--footer-height));
  flex: 1;
  overflow: hidden; /* Contains child scrolling */
  background-color: var(--bg-secondary);
  position: relative;
}

/* No left padding/margin for content with collapsed sidebar */
.sidebar-collapsed .content-container {
  margin-left: 0;
}

.sidebar-collapsed .app-main {
  padding-left: 0;
}

/**
 * Comprehensive Sidebar Styling
 * - Handles expanded and collapsed states
 * - Mobile-responsive with proper scrolling
 * - Proper centering of icons in collapsed state
 */

/* Base sidebar styling */
.app-sidebar {
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height) - var(--footer-height));
  background-color: var(--bg-primary);
  border-right: 1px solid var(--border-color);
  flex-shrink: 0;
  transition: width var(--transition-normal);
  overflow-y: auto; /* Allow vertical scrolling */
  overflow-x: hidden; /* Hide horizontal overflow */
  scrollbar-width: thin; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
  padding: var(--space-xs); /* Reduced padding */
  padding-left: var(--space-sm); /* Reduced left padding */
  position: relative;
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

/* Hide scrollbar in Webkit browsers while preserving functionality */
.app-sidebar::-webkit-scrollbar {
  width: 4px;
}

.app-sidebar::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 2px;
}

/* Sidebar in collapsed state */
.sidebar-collapsed .app-sidebar {
  width: var(--sidebar-collapsed-width);
  height: calc(100vh - var(--header-height) - var(--footer-height)) !important; /* Match expanded sidebar height */
  padding: 0;
  padding-top: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Enhanced scrolling for collapsed sidebar */
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch !important;
  overscroll-behavior: contain !important;
  scrollbar-width: thin !important;
}

/* Ensure sidebar sections are properly spaced and centered in collapsed mode */
.sidebar-collapsed .sidebar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  text-align: center;
}

/* Add space above dashboard icon in collapsed state */
.sidebar-collapsed .sidebar-section:first-child {
  margin-top: 10px; /* Reset to smaller value */
}

/* Scrollbar styling for all sidebar states */
.app-sidebar::-webkit-scrollbar {
  width: 4px;
  display: block;
}

.app-sidebar::-webkit-scrollbar-thumb {
  background-color: rgba(120, 120, 120, 0.3);
  border-radius: 2px;
}

.app-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

/* Hide scrollbar in collapsed sidebar while maintaining scroll functionality */
.sidebar-collapsed .app-sidebar::-webkit-scrollbar,
.sidebar-collapsed .app-sidebar::-webkit-scrollbar-thumb,
.sidebar-collapsed .app-sidebar::-webkit-scrollbar-track {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
  background: transparent !important;
  opacity: 0 !important;
  visibility: hidden !important;
}

/* Hide scrollbar for Firefox */
.sidebar-collapsed .app-sidebar {
  scrollbar-width: none !important;
}

/* Hide scrollbar for IE/Edge */
.sidebar-collapsed .app-sidebar {
  -ms-overflow-style: none !important;
}

/* Sidebar toggle styling */
.sidebar-toggle {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 101;
  background-color: transparent;
  border: none;
  box-shadow: none;
  cursor: pointer;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* REMOVED: No longer rotating the toggle in collapsed state - keeping original position */
.sidebar-collapsed .sidebar-toggle {
  position: relative; /* Keep at least one property to avoid empty ruleset warning */
}

.sidebar-collapsed .sidebar-toggle:hover {
  opacity: 1;
}

.sidebar-collapsed .sidebar-brand-text,
.sidebar-collapsed .sidebar-link span:not(.tooltip),
.sidebar-collapsed .sidebar-title,
.sidebar-collapsed .sidebar-header h3 {
  display: none;
}

.sidebar-toggle {
  transition: all var(--transition-normal);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  border: 1px solid transparent;
  background-color: transparent; /* No background when expanded */
}

.sidebar-toggle:hover {
  color: var(--color-primary);
}

/* Sidebar toggle hover style */
.sidebar-toggle:hover {
  color: var(--color-primary);
  background-color: var(--bg-hover);
}

.sidebar-toggle i {
  font-size: 0.85rem; /* Further reduced chevron size as requested */
  display: block;
  line-height: 1;
}

.sidebar-toggle:hover {
  opacity: 1;
}

/* Toggle button positioning that stays in the upper right of the sidebar */
.sidebar-toggle {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1000; /* High z-index to ensure visibility */
  background-color: transparent;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 0;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer;
  color: var(--text-secondary);
  opacity: 0.7;
  /* Ensure it's relative to the sidebar */
  left: auto;
  transition: opacity 0.2s ease;
}

/* Rotated state when collapsed - keep at top right of sidebar */
.sidebar-collapsed .sidebar-toggle {
  position: absolute;
  top: 10px;
  left: auto;
  right: 10px; /* Keep in the right corner of the sidebar even when collapsed */
  /* transform: rotate(180deg); REMOVED to fix chevron direction */
  background-color: transparent;
  border: none;
  opacity: 1;
}

.sidebar-open .app-sidebar,
.sidebar-collapsed .app-sidebar {
  overflow: visible;
}

.sidebar-section {
  padding: var(--space-xs) var(--space-xs);
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 2px;
  width: 100%;
}

.sidebar-section:last-child {
  border-bottom: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: flex-start; /* Left justify expanded headers */
  margin-bottom: 4px;
  position: relative;
  padding: 0 var(--space-xs);
  width: 100%;
  text-align: left;
}

.sidebar-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  width: 100%;
  text-align: left;
  margin-left: 8px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

/* Icon styling for normal (expanded) sidebar */
.sidebar-nav i {
  font-size: 0.95rem; /* Reduced from 1.15rem */
  width: 16px; /* Reduced from 20px */
  height: 16px; /* Reduced from 20px */
  margin-right: 10px; /* Reduced spacing between icon and text */
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--text-secondary);
  padding: 6px 10px; /* Reduced from 8px 12px */
  margin: 1px 0; /* Reduced from 2px */
  border-radius: 4px;
  transition: all 0.2s ease;
  height: 32px; /* Reduced from 36px */
  font-size: 0.9rem; /* Smaller text */
}

.sidebar-link:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

/* The sidebar link active styling */
.sidebar-link.active {
  background-color: rgba(30, 102, 245, 0.12); /* Even more subtle */
  color: var(--color-primary, #0063c5); /* Using CSS variable with fallback */
  position: relative;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  border-left: 2px solid var(--color-primary, #0063c5); /* Left border indicator */
  padding: 6px 10px 6px 8px; /* Adjusted for the left border */
  font-weight: 500;
}

/* Active link style - subtle highlight */
.sidebar-link.active {
  background-color: rgba(30, 102, 245, 0.08);
  color: var(--color-primary);
  border-left: 2px solid var(--color-primary);
  font-weight: 500;
  position: relative;
}

/* Special active style for collapsed mode - with subtle styling */
.sidebar-collapsed .sidebar-link.active {
  background-color: rgba(30, 102, 245, 0.15);
  color: var(--color-primary);
  border-radius: 0;
  width: 100%; /* Extend to full width of sidebar */
  margin: 0; /* Remove any margin to ensure full width */
  padding: 12px 0; /* Match padding with regular links */
  border-left: 3px solid var(--color-primary); /* Left border for visibility */
  z-index: 10; /* Ensure it appears above other elements */
}

/* Sidebar links in collapsed state */
.sidebar-collapsed .sidebar-link {
  height: 32px; /* Reduced from 36px to match expanded size */
  display: flex;
  flex-direction: column;
  margin: 1px 0; /* Reduced from 2px */
  width: 100%;
  position: relative;
  justify-content: center;
  padding: 18px 0; /* Adjusted from 20px */
  text-align: center;
}

/**
 * Icon and Link Styling - Consolidated
 * Ensures proper centering and consistent display in both states
 */

/* Base sidebar icon styling */
.sidebar-nav i {
  font-size: 1.15rem;
  width: 20px;
  height: 20px;
  margin-right: 12px; /* Spacing between icon and text */
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Icons are slightly larger in collapsed mode for better visibility */
.sidebar-collapsed .sidebar-nav i {
  font-size: 1rem; /* Reduced from 1.15rem */
  width: 20px; /* Reduced from 24px */
  height: 20px; /* Reduced from 24px */
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Links in collapsed state - centered with proper spacing */
.sidebar-collapsed .sidebar-link {
  justify-content: center;
  position: relative; /* For tooltip positioning */
  padding: 20px 0; /* Increased padding for more space */
  width: 100%; /* Ensure full width */
  box-sizing: border-box; /* Include padding in width calculation */
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* Separator above dashboard icon in collapsed state */
.sidebar-collapsed .sidebar-section:first-child::before {
  content: '';
  display: block;
  height: 1px;
  background-color: var(--border-color);
  margin: 20px 0; /* Standard margin */
  width: 80%;
  margin-left: auto;
  margin-right: auto;
}

/* Specific targeting for dashboard link with its dedicated class */
.sidebar-collapsed .dashboard-link {
  margin-top: 25px !important; /* Further reduced spacing above first icon */
}

/* Tooltip for collapsed sidebar items - with pointer */
.sidebar-collapsed .sidebar-link .tooltip {
  position: absolute;
  left: calc(var(--sidebar-collapsed-width) + 10px);
  top: 50%;
  transform: translateY(-50%);
  background-color: #000000;
  color: #ffffff;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 0.85rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 1000;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
  visibility: hidden; /* Start hidden */
  display: block !important; /* Ensure display */
}

/* Add pointer/triangle to tooltip */
.sidebar-collapsed .sidebar-link .tooltip::before {
  content: '';
  position: absolute;
  top: 50%;
  left: -6px;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 6px solid #000000;
}

/* Show tooltip on hover */
.sidebar-collapsed .sidebar-link:hover .tooltip {
  opacity: 1;
  visibility: visible;
}

/* Removed duplicate tooltip rule */

/* Tooltip styling for collapsed sidebar */
.sidebar-link .tooltip {
  display: none;
}

.sidebar-collapsed .sidebar-link .tooltip {
  display: block;
  visibility: hidden;
  background-color: black;
  color: white;
  text-align: center;
  border-radius: 6px;
  padding: 5px 10px;
  position: absolute;
  z-index: 1001;
  left: 60px;
  opacity: 0;
  transition: opacity 0.3s;
  white-space: nowrap;
  pointer-events: none; /* Prevent tooltip from blocking clicks */
}

/* Tooltip arrow */
.sidebar-collapsed .sidebar-link .tooltip::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 100%;
  margin-top: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: transparent black transparent transparent;
}

/* Show tooltip on hover */
.sidebar-collapsed .sidebar-link:hover .tooltip {
  visibility: visible;
  opacity: 1;
}

/* Content container */
.content-container {
  flex: 1;
  overflow-y: auto !important;
  overflow-x: hidden;
  padding: var(--space-lg);
  padding-left: 32px; /* Fixed left padding for better spacing from sidebar */
  -webkit-overflow-scrolling: touch;
  height: calc(100vh - var(--header-height) - var(--footer-height));
  position: relative;
  overscroll-behavior: contain;
}

/* Page header */
.page-header {
  margin-bottom: var(--space-xl);
}

.page-title {
  font-size: var(--text-3xl);
  margin-bottom: var(--space-xs);
}

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

/* Standard page container */
.page-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-md);
  background-color: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-md);
}

/* Layouts for standard content patterns */
.layout-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-lg);
}

.layout-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xl);
}

.layout-sidebar-content {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: var(--space-lg);
}

/* Footer styling */
.app-footer {
  height: var(--footer-height);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  background-color: var(--bg-primary);
  border-top: 1px solid var(--border-color);
  font-size: 0.85rem;
  color: var(--text-secondary);
  z-index: var(--z-above);
  flex-wrap: nowrap;
  overflow: hidden;
  min-height: 60px;
  max-width: 100%;
  flex-shrink: 0;
}

.footer-links {
  display: flex;
  gap: 25px;
  white-space: nowrap;
  flex-wrap: nowrap;
  overflow: visible;
}

/* Command bar - settings popup */
.command-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  z-index: 2147483647; /* Maximum possible z-index */
}

.command-modal {
  width: 600px;
  max-width: 90%;
  background-color: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}

.command-input {
  display: flex;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-color);
}

.command-icon {
  color: var(--text-muted);
  margin-right: var(--space-sm);
  font-size: 18px;
}

.command-input input {
  border: none;
  background: transparent;
  font-size: var(--text-lg);
  padding: var(--space-xs) 0;
  width: 100%;
}

.command-input input:focus {
  outline: none;
  box-shadow: none;
}

.command-results {
  max-height: 50vh;
  overflow-y: auto;
  padding: var(--space-md) 0;
}

.command-group {
  padding: 0 var(--space-md);
  margin-bottom: var(--space-md);
}

.command-group.sidebar-title {
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 15px;
  padding-left: 15px;
  margin-top: 0; /* No extra space needed as the dashboard icon has its own margins */
  text-align: center; /* Center the navigation title */
}

.command-group-title {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0 var(--space-md) var(--space-xxs);
}

.command-item {
  display: flex;
  align-items: center;
  padding: var(--space-xs) var(--space-md);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background-color var(--transition-fast);
}

.command-item:hover, .command-item.active {
  background-color: var(--bg-tertiary);
}

.command-item-icon {
  color: var(--text-muted);
  margin-right: var(--space-sm);
  flex-shrink: 0;
}

.command-item-content {
  flex: 1;
  overflow: hidden;
}

.command-item-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.command-item-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.command-item-shortcut {
  display: flex;
  align-items: center;
  margin-left: var(--space-md);
}

.command-shortcut-key {
  font-size: var(--text-sm);
  padding: 0 var(--space-xxs);
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  min-width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* User menu */
.user-menu {
  position: relative;
  white-space: nowrap;
  display: inline-block;
  align-items: center;
  padding: 5px;
}

/* Remove duplicate style - exists elsewhere */

.user-menu-trigger {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  padding: var(--space-xxs) var(--space-xs);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color var(--transition-fast);
  background: transparent;
  border: none;
  overflow: visible;
}

.user-menu-trigger:hover {
  background-color: var(--bg-tertiary);
}

.user-name {
  margin-left: var(--space-xs);
  font-weight: 500;
}

/* Command trigger button */
.command-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  position: relative;
  z-index: 100;
  padding: 8px;
  margin-right: 0;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  background-color: transparent;
}

.command-trigger:hover {
  color: var(--color-primary);
  background-color: var(--bg-tertiary);
}

.command-trigger .icon {
  width: 18px;
  height: 18px;
}

/* Theme toggle */
.theme-toggle {
  position: relative;
  margin-right: var(--space-md);
}

.theme-checkbox {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.theme-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.theme-label:hover {
  background-color: var(--bg-tertiary);
}

.theme-icon {
  font-size: 18px;
}

.theme-icon.light {
  display: none;
}

.theme-icon.dark {
  display: block;
}

[data-theme="dark"] .theme-icon.light {
  display: block;
}

[data-theme="dark"] .theme-icon.dark {
  display: none;
}

/**
 * Mobile-specific sidebar styling
 * Comprehensive solution for mobile scrolling and responsive display
 */
@media (max-width: 768px) {
  /* Critical mobile sidebar overrides for expanded and collapsed states */
  html body .app-container .app-sidebar {
    /* Scrolling behavior */
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overflow-x: hidden !important;
    overscroll-behavior: contain !important;
    
    /* Positioning */
    position: fixed !important;
    left: 0 !important;
    top: var(--header-height) !important;
    bottom: 0 !important;
    z-index: 50 !important; /* Positive z-index to ensure sidebar is visible */
    
    /* Dimensions */
    height: calc(100vh - var(--header-height)) !important;
    width: var(--sidebar-width) !important;
    max-width: 85vw !important;
    
    /* Other properties */
    box-sizing: border-box !important;
    touch-action: pan-y !important;
    padding-bottom: 60px !important; /* Moderate padding at bottom */
    transform: translateZ(0) !important; /* Force hardware acceleration */
    -webkit-transform: translate3d(0,0,0) !important; /* iOS hardware acceleration */
  }
  
  /* Collapsed sidebar width override - ensure proper collapse on all devices */
  html body .app-container.sidebar-collapsed .app-sidebar {
    width: var(--sidebar-collapsed-width) !important;
    min-width: var(--sidebar-collapsed-width) !important;
    max-width: var(--sidebar-collapsed-width) !important;
    padding: 0 !important;
  }
  
  /* Portrait-specific sidebar styles */
  @media (orientation: portrait) {
    /* Collapsed sidebar in portrait */
    html body .app-container.sidebar-collapsed .app-sidebar {
      width: var(--sidebar-collapsed-width) !important;
      min-width: var(--sidebar-collapsed-width) !important;
      max-width: var(--sidebar-collapsed-width) !important;
      flex-basis: var(--sidebar-collapsed-width) !important;
    }
    
    /* When sidebar is open in portrait, push content instead of overlay */
    body.sidebar-open .app-content {
      margin-left: 280px !important; /* Match sidebar width */
      width: calc(100% - 280px) !important;
    }
    
    /* Fixed position for sidebar in portrait when opened */
    body.sidebar-open .app-sidebar {
      position: fixed !important;
      box-shadow: 2px 0 10px rgba(0,0,0,0.1) !important;
    }
  }
  
  /* Fix spacing between sidebar sections */
  .app-sidebar .sidebar-section {
    margin: 0 !important; /* Remove all margins between sections */
    padding: var(--space-xs) var(--space-sm) !important; /* Consistent, minimal padding */
    overflow-y: visible !important;
  }
  
  /* Remove any excessive spacing between sidebar links */
  .app-sidebar .sidebar-link {
    margin: 2px 0 !important;
    padding: 8px 12px !important;
  }
  
  /* Force entire sidebar to be scrollable */
  body .app-sidebar {
    margin-bottom: 60px !important;
  }
  
  /* Make scrollbar visible on mobile */
  .app-sidebar::-webkit-scrollbar {
    width: 4px !important;
    display: block !important;
  }
  
  .app-sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.3) !important;
    border-radius: 2px !important;
  }
}

@media (max-width: 768px) {
  /* Mobile behavior for sidebar */
  .app-sidebar {
    position: fixed !important;
    left: 0 !important;
    top: var(--header-height) !important;
    bottom: 0 !important;
    z-index: 9000 !important; /* High z-index to appear above content when visible */
    transform: translateX(-100%) !important; /* Hide offscreen by default */
    transition: transform 0.3s ease !important;
    width: 80% !important; /* Limit width on mobile */
    max-width: 280px !important;
  }
  
  body.sidebar-open .app-sidebar {
    transform: translateX(0) !important; /* Show when sidebar-open class is present */
  }
  
  /* Main content should not shift in landscape orientation */
  .app-content {
    margin-left: 0 !important;
    transition: margin-left 0.3s ease !important;
  }
}

/* Tooltip styling for collapsed sidebar */
.sidebar-collapsed .sidebar-link .tooltip {
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 0.9rem;
  white-space: nowrap;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s, visibility 0.2s;
  pointer-events: none;
  margin-left: 10px;
  z-index: 1000;
}

/* Show tooltip on hover */
.sidebar-collapsed .sidebar-link:hover .tooltip {
  visibility: visible;
  opacity: 1;
}

/* Add triangle pointer to tooltip */
.sidebar-collapsed .sidebar-link .tooltip::before {
  content: '';
  position: absolute;
  left: -5px;
  top: 50%;
  transform: translateY(-50%);
  border-width: 5px 5px 5px 0;
  border-style: solid;
  border-color: transparent rgba(0, 0, 0, 0.8) transparent transparent;
}

/* Hide scrollbars in collapsed sidebar */
.sidebar-collapsed .app-sidebar::-webkit-scrollbar,
.sidebar-collapsed .app-sidebar::-webkit-scrollbar-thumb,
.sidebar-collapsed .app-sidebar::-webkit-scrollbar-track {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
  opacity: 0 !important;
}

/* Hide scrollbar for Firefox */
.sidebar-collapsed .app-sidebar {
  scrollbar-width: none !important;
}

/* Wider active link in collapsed sidebar */
.sidebar-collapsed .sidebar-link.active {
  width: 100%;
  padding-left: 8px;
  padding-right: 8px;
  text-align: center;
}

/* Mobile layout adjustments */
@media (max-width: 768px) {
  .layout-split,
  .layout-sidebar-content {
    grid-template-columns: 1fr;
  }
  
  .command-trigger .label {
    display: none;
  }
}
  
  .user-name {
    display: none;
  }
}
/* End mobile header adjustments */

/* Mobile backdrop overlay for sidebar */
@media (max-width: 768px) {
  /* Add backdrop when sidebar is open */
  body.sidebar-open::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 8000;
  }
  
  /* Keep content positioned correctly */
  html body .app-container .app-content {
    position: relative !important;
    z-index: 100 !important;
    background-color: var(--bg-primary) !important;
  }
  
  /* Fix container settings */
  html body .app-container {
    overflow: visible !important;
  }
  
  /* Ensure content fills width */
  html body .main-content {
    width: 100% !important;
  }
}
