/* =====================================================
   MODERN NAVIGATION SYSTEM
   Supports both sidebar and horizontal navigation
   ===================================================== */

/* =====================================================
   SIDEBAR NAVIGATION (Default - No Map)
   ===================================================== */

.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--surface-primary);
  border-right: 1px solid var(--border-primary);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  z-index: var(--z-fixed);
  transform: translateX(0);
  transition: width var(--duration-normal) var(--ease-out), transform var(--duration-normal) var(--ease-out);
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-width-collapsed);
}

.sidebar.collapsed .nav-item-text,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .user-info-details,
.sidebar.collapsed .sidebar-logo,
.sidebar.collapsed .sidebar-brand,
.sidebar.collapsed .user-initials-display {
  display: none;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
}

.sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: var(--space-4) var(--space-2);
  width: 100%;
}

.sidebar.collapsed .sidebar-toggle {
  margin: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Sidebar Header */
.sidebar-header {
  height: var(--header-height);
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border-primary);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.sidebar-logo {
  height: 32px;
  width: auto;
  flex-shrink: 0;
}

.sidebar-brand {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-toggle {
  margin-left: auto;
  background: none;
  border: none;
  padding: var(--space-2);
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all var(--duration-fast) var(--ease-out);
  z-index: 10;
  position: relative;
}

.sidebar-toggle:hover {
  background: var(--surface-tertiary);
  color: var(--text-primary);
}

/* User Initials Display in Header */
.user-initials-display {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--primary-500);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
  flex-shrink: 0;
}

.sidebar.collapsed .user-initials-display {
  margin-left: auto;
  margin-right: auto;
}

/* Navigation Content */
.sidebar-content {
  flex: 1;
  padding: var(--space-3) 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-section {
  margin-bottom: var(--space-4);
}

.nav-section-title {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 var(--space-6) var(--space-1) var(--space-6);
  margin-bottom: var(--space-1);
  transition: opacity var(--duration-normal) var(--ease-out);
}

.nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-item {
  margin: 0 var(--space-3) 0 var(--space-3);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-weight: var(--font-medium);
  transition: all var(--duration-fast) var(--ease-out);
  position: relative;
}

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

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

[data-theme="dark"] .nav-link.active {
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary-300);
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.nav-item-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity var(--duration-normal) var(--ease-out);
}

.nav-badge {
  background: var(--error-500);
  color: var(--text-inverse);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* User Section */
.sidebar-footer {
  padding: var(--space-3) var(--space-3);
  border-top: 1px solid var(--border-primary);
}

.user-info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
}

.user-info:hover {
  background: var(--surface-tertiary);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--primary-500);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-inverse);
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
  flex-shrink: 0;
}

.user-info-details {
  flex: 1;
  min-width: 0;
  transition: opacity var(--duration-normal) var(--ease-out);
}

.user-name {
  font-weight: var(--font-medium);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: var(--text-sm);
}

.user-role {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =====================================================
   HORIZONTAL NAVIGATION (With Map)
   ===================================================== */

.navbar {
  height: var(--navbar-height);
  background: var(--surface-primary);
  border-bottom: 1px solid var(--border-primary);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-right: var(--space-8);
}

.navbar-logo {
  height: 28px;
  width: auto;
}

.navbar-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  text-decoration: none;
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
  list-style: none;
  margin: 0;
  padding: 0;
}

.navbar-item {
  position: relative;
}

.navbar-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-weight: var(--font-medium);
  font-size: var(--text-sm);
  transition: all var(--duration-fast) var(--ease-out);
}

.navbar-link:hover {
  background: var(--surface-tertiary);
  color: var(--text-primary);
}

.navbar-link.active {
  background: var(--primary-50);
  color: var(--primary-700);
}

[data-theme="dark"] .navbar-link.active {
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary-300);
}

.navbar-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Navbar Actions */
.navbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: auto;
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
}

.navbar-user:hover {
  background: var(--surface-tertiary);
}

.navbar-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--primary-500);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-inverse);
  font-weight: var(--font-semibold);
  font-size: var(--text-xs);
}

/* =====================================================
   MOBILE NAVIGATION
   ===================================================== */

.mobile-nav-toggle {
  display: none;
  position: fixed;
  top: var(--space-3);
  left: var(--space-3);
  z-index: calc(var(--z-modal) + 10); /* Above sidebar */
  background: var(--surface-primary);
  border: 1px solid var(--border-color);
  padding: var(--space-3);
  color: var(--text-primary);
  cursor: pointer;
  border-radius: var(--radius-md);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  font-size: 20px;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast) var(--ease-out);
}

.mobile-nav-toggle:hover {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transform: scale(1.05);
}

.mobile-nav-toggle:active {
  transform: scale(0.95);
}

.mobile-nav-overlay {
  position: fixed;
  inset: 0;
  background: var(--surface-overlay);
  z-index: var(--z-modal-backdrop);
  opacity: 0;
  visibility: hidden;
  transition: all var(--duration-normal) var(--ease-out);
}

.mobile-nav-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* =====================================================
   LAYOUT ADJUSTMENTS
   ===================================================== */

/* Default layout with sidebar */
.layout-sidebar .main-content {
  margin-left: var(--sidebar-width);
  transition: margin-left var(--duration-normal) var(--ease-out);
}

.layout-sidebar.sidebar-collapsed .main-content {
  margin-left: var(--sidebar-width-collapsed);
}

/* Map layout with horizontal nav */
.layout-navbar .sidebar {
  display: none;
}

.layout-navbar .main-content {
  margin-left: 0;
}

/* =====================================================
   RESPONSIVE BEHAVIOR
   ===================================================== */

@media (max-width: 1024px) {
  /* Force mobile navigation on tablets */
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  
  .layout-sidebar .main-content {
    margin-left: 0;
  }
  
  .mobile-nav-toggle {
    display: flex;
  }
  
  /* Simplify navbar on smaller screens */
  .navbar-nav {
    display: none;
  }
  
  .navbar-actions {
    gap: var(--space-2);
  }
}

@media (max-width: 640px) {
  .sidebar {
    width: 100%;
  }
  
  .navbar {
    padding: 0 var(--space-4);
  }
  
  .navbar-brand {
    margin-right: var(--space-4);
  }
  
  .navbar-title {
    display: none;
  }
}

/* =====================================================
   VIEW TOGGLE COMPONENT
   ===================================================== */

.view-toggle {
  display: flex;
  background: var(--surface-tertiary);
  border-radius: var(--radius-lg);
  padding: var(--space-1);
  gap: var(--space-1);
}

.view-toggle-button {
  padding: var(--space-2) var(--space-4);
  background: none;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-weight: var(--font-medium);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.view-toggle-button.active {
  background: var(--surface-primary);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.view-toggle-button:hover:not(.active) {
  color: var(--text-primary);
}

.view-toggle-icon {
  width: 16px;
  height: 16px;
}

/* View toggle in collapsed sidebar */
.sidebar.collapsed .view-toggle {
  flex-direction: column;
  padding: var(--space-2);
  gap: var(--space-3);
  width: 64px;
  background: var(--surface-secondary);
}

.sidebar.collapsed .view-toggle-button {
  padding: var(--space-3);
  width: 48px;
  height: 48px;
  justify-content: center;
  font-size: 0; /* Hide text */
  border: 2px solid var(--border-primary);
  position: relative;
}

.sidebar.collapsed .view-toggle-button:not(.active) {
  background: var(--surface-primary);
}

.sidebar.collapsed .view-toggle-button.active {
  background: var(--primary-600);
  border-color: var(--primary-700);
}

.sidebar.collapsed .view-toggle-button .view-toggle-icon {
  margin: 0;
  font-size: 20px;
  color: var(--text-secondary);
}

.sidebar.collapsed .view-toggle-button.active .view-toggle-icon {
  color: white;
}

/* Tooltip for collapsed view toggle */
.sidebar.collapsed .view-toggle-button::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--neutral-900);
  color: white;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-fast) var(--ease-out);
  z-index: 1000;
}

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

/* =====================================================
   NOTIFICATION BUTTON & BADGE
   ===================================================== */

.notification-button {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  color: var(--primary-600);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-weight: var(--font-medium);
  font-size: var(--text-sm);
  transition: all var(--duration-fast) var(--ease-out);
  position: relative;
  width: 100%;
  background: var(--primary-50);
  border: 1px solid var(--primary-200);
  cursor: pointer;
}

.notification-button:hover {
  background: var(--primary-100);
  color: var(--primary-700);
  text-decoration: none;
  border-color: var(--primary-300);
}

.notification-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.notification-badge {
  position: absolute;
  top: 2px;
  right: 4px;
  background: #ff4757;
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transform: scale(1);
  animation: badge-appear 0.2s ease-out;
  box-shadow: 0 2px 4px rgba(255, 71, 87, 0.3);
  border: 2px solid white;
}

@keyframes badge-appear {
  from {
    transform: scale(0);
  }
  to {
    transform: scale(1);
  }
}

/* =====================================================
   USER FILTER SECTION
   ===================================================== */

.filter-group {
    margin-bottom: var(--space-3);
}


.filter-select {
    width: 100%;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    background: var(--surface-primary);
    color: var(--text-primary);
    font-size: var(--text-sm);
}

/* Select2 styling for user filter */
.nav-section .select2-container {
    width: 100% !important;
}

.nav-section .select2-selection--multiple {
    border: 1px solid var(--border-primary) !important;
    border-radius: var(--radius-md) !important;
    background: var(--surface-primary) !important;
    min-height: 36px !important;
    padding: 3px 6px !important;
}

.nav-section .select2-selection--multiple:focus-within {
    border-color: var(--border-focus) !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
}

/* Single select styling (when not multiple) */
.nav-section .select2-selection--single {
    border: 1px solid var(--border-primary) !important;
    border-radius: var(--radius-md) !important;
    background: var(--surface-primary) !important;
    height: 36px !important;
    display: flex !important;
    align-items: center !important;
    padding: 0 12px !important;
}

.nav-section .select2-selection--single:focus-within {
    border-color: var(--border-focus) !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
}

.nav-section .select2-selection__rendered {
    color: var(--text-primary) !important;
    line-height: 34px !important;
    font-size: var(--text-sm) !important;
    padding: 0 !important;
}

.nav-section .select2-selection__placeholder {
    color: var(--text-tertiary) !important;
    line-height: 34px !important;
}

.nav-section .select2-selection__arrow {
    height: 34px !important;
    top: 1px !important;
    right: 8px !important;
}

.nav-section .select2-search__field {
    color: var(--text-primary) !important;
    background: transparent !important;
    border: none !important;
    font-size: var(--text-sm) !important;
    height: 28px !important;
    line-height: 28px !important;
    padding: 0 !important;
}

.nav-section .select2-search__field::placeholder {
    color: var(--text-tertiary) !important;
    line-height: 28px !important;
}

/* Placeholder for multiple select when empty */
.nav-section .select2-selection--multiple .select2-selection__placeholder {
    color: var(--text-tertiary) !important;
    line-height: 28px !important;
    padding: 0 !important;
    margin: 0 !important;
}

.nav-section .select2-selection__choice {
    background: white !important;
    border: 1px solid var(--border-secondary) !important;
    color: var(--text-primary) !important;
    border-radius: var(--radius-sm) !important;
    padding: 3px 6px 3px 6px !important;
    margin: 2px 4px 2px 0 !important;
    font-size: var(--text-xs) !important;
    line-height: 1.4 !important;
    height: 22px !important;
    display: inline-flex !important;
    align-items: center !important;
}

.nav-section .select2-selection__choice__remove {
    color: var(--text-secondary) !important;
    font-weight: bold !important;
    margin-right: 4px !important;
    margin-left: 0 !important;
    padding: 0 !important;
    font-size: 16px !important;
    line-height: 1 !important;
    display: inline-block !important;
    float: none !important;
    position: relative !important;
}

.nav-section .select2-selection__choice__remove:hover {
    color: var(--error-600) !important;
    background: none !important;
}

.nav-section .select2-dropdown {
    background: var(--surface-primary) !important;
    border: 1px solid var(--border-primary) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-lg) !important;
}

.nav-section .select2-results__option {
    color: var(--text-primary) !important;
    padding: var(--space-2) var(--space-3) !important;
    font-size: var(--text-sm) !important;
}

.nav-section .select2-results__option--highlighted {
    background: var(--surface-secondary) !important;
    color: var(--text-primary) !important;
}

.nav-section .select2-results__option[aria-selected="true"] {
    background: var(--primary-100) !important;
    color: var(--primary-800) !important;
}

/* =====================================================
   USER DROPDOWN ENHANCEMENTS
   ===================================================== */

.navbar-avatar {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-full);
    transition: all var(--duration-fast) var(--ease-out);
    background: var(--primary-500) !important;
    color: white !important;
    border: none !important;
    font-weight: var(--font-semibold);
}

.navbar-avatar:hover {
    background: var(--primary-600) !important;
    color: white !important;
}

.navbar-avatar:focus {
    background: var(--primary-600) !important;
    color: white !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3) !important;
}

.dropdown-arrow {
    font-size: var(--text-xs);
    transition: transform var(--duration-fast) var(--ease-out);
}

.dropdown[aria-expanded="true"] .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-menu {
    min-width: 280px !important;
    padding: var(--space-2) !important;
    border: 1px solid var(--border-primary) !important;
    border-radius: var(--radius-lg) !important;
    background: var(--surface-primary) !important;
    box-shadow: var(--shadow-lg) !important;
    z-index: 9999 !important;
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    display: none !important;
}

.dropdown-menu.show {
    display: block !important;
}

/* Force dropdown visibility for debugging */
.dropdown.show .dropdown-menu {
    display: block !important;
}

.dropdown-header {
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-2);
}

.user-info {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.user-avatar-large {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background: var(--primary-500);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: var(--text-base);
    font-weight: var(--font-medium);
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}

.user-role {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    text-transform: capitalize;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    color: var(--text-primary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all var(--duration-fast) var(--ease-out);
    font-size: var(--text-sm);
}

.dropdown-item:hover {
    background: var(--surface-secondary);
    color: var(--text-primary);
}

.dropdown-item.text-danger {
    color: var(--error-600);
}

.dropdown-item.text-danger:hover {
    background: var(--error-50);
    color: var(--error-700);
}

.dropdown-divider {
    height: 1px;
    margin: var(--space-2) 0;
    background: var(--border-primary);
    border: none;
}

/* =====================================================
   SIDEBAR USER INFO BUTTON
   ===================================================== */

.user-info-button {
    width: 100%;
    padding: var(--space-3);
    background: var(--surface-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
    color: var(--text-primary);
    text-align: left;
}

.user-info-button:hover {
    background: var(--surface-secondary);
    border-color: var(--border-secondary);
    color: var(--text-primary);
}

.user-info-button:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.user-info-button .user-info-details {
    flex: 1;
    min-width: 0;
}

.user-info-button .user-name {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-primary);
    margin-bottom: var(--space-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-info-button .user-role {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    text-transform: capitalize;
}

.user-info-button .dropdown-arrow {
    color: var(--text-tertiary);
    font-size: var(--text-xs);
}