/**
 * Enhanced Sidebar Navigation Styles
 * Collapsible sections with quick search
 */

/* Quick Search */
.nav-quick-search {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  position: relative;
}

.quick-search-input-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-secondary, #f3f4f6);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  transition: all 0.2s ease;
}

.quick-search-input-wrapper:focus-within {
  background: var(--bg-primary, #fff);
  box-shadow: 0 0 0 2px var(--primary-color, #4A90E2);
}

.quick-search-input-wrapper svg {
  color: var(--text-muted, #9ca3af);
  flex-shrink: 0;
}

.quick-search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.875rem;
  color: var(--text-primary, #1f2937);
  outline: none;
  min-width: 0;
}

.quick-search-input::placeholder {
  color: var(--text-muted, #9ca3af);
}

.quick-search-kbd {
  font-size: 0.625rem;
  padding: 0.125rem 0.375rem;
  background: var(--bg-tertiary, #e5e7eb);
  border-radius: 4px;
  color: var(--text-muted, #9ca3af);
  font-family: system-ui, -apple-system, sans-serif;
  flex-shrink: 0;
}

/* Quick Search Results */
.quick-search-results {
  position: absolute;
  top: 100%;
  left: 0.75rem;
  right: 0.75rem;
  background: var(--bg-primary, #fff);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  z-index: 100;
  max-height: 300px;
  overflow-y: auto;
  display: none;
}

.quick-search-results.visible {
  display: block;
}

.quick-search-result {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  text-decoration: none;
  color: var(--text-primary, #1f2937);
  transition: background 0.15s ease;
}

.quick-search-result:hover {
  background: var(--bg-secondary, #f3f4f6);
}

.quick-search-result-icon {
  font-size: 1.125rem;
}

.quick-search-result-label {
  flex: 1;
  font-weight: 500;
}

.quick-search-result-section {
  font-size: 0.75rem;
  color: var(--text-muted, #9ca3af);
}

.quick-search-no-results {
  padding: 1rem;
  text-align: center;
  color: var(--text-muted, #9ca3af);
  font-size: 0.875rem;
}

/* Nav Section - Collapsible */
.nav-section {
  border-bottom: 1px solid var(--border-color, #e5e7eb);
}

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

.nav-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease;
}

.nav-section-header:hover {
  background: var(--bg-secondary, #f3f4f6);
}

.nav-section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted, #6b7280);
}

.nav-section-icon {
  font-size: 1rem;
}

.nav-section-arrow {
  color: var(--text-muted, #9ca3af);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.nav-section.expanded .nav-section-arrow {
  transform: rotate(0deg);
}

.nav-section.collapsed .nav-section-arrow {
  transform: rotate(-90deg);
}

/* Nav Section Items */
.nav-section-items {
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.2s ease;
}

.nav-section.expanded .nav-section-items {
  max-height: 500px;
  opacity: 1;
}

.nav-section.collapsed .nav-section-items {
  max-height: 0;
  opacity: 0;
}

/* Nav Items */
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem 0.5rem 2.5rem;
  color: var(--text-secondary, #4b5563);
  text-decoration: none;
  font-size: 0.875rem;
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: var(--bg-secondary, #f3f4f6);
  color: var(--text-primary, #1f2937);
}

.nav-item.active {
  background: var(--primary-light, #e8f4fd);
  color: var(--primary-color, #4A90E2);
  border-left-color: var(--primary-color, #4A90E2);
  font-weight: 500;
}

.nav-icon {
  font-size: 1.125rem;
  width: 1.5rem;
  text-align: center;
  flex-shrink: 0;
}

/* Sidebar Scrollbar */
.sidebar-nav {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color, #e5e7eb) transparent;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

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

.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--border-color, #e5e7eb);
  border-radius: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted, #9ca3af);
}

/* Dark Mode Overrides */
[data-theme="dark"] .quick-search-input-wrapper {
  background: var(--bg-tertiary, #374151);
}

[data-theme="dark"] .quick-search-input-wrapper:focus-within {
  background: var(--bg-secondary, #1f2937);
}

[data-theme="dark"] .quick-search-results {
  background: var(--bg-secondary, #1f2937);
  border: 1px solid var(--border-color, #374151);
}

[data-theme="dark"] .quick-search-result:hover {
  background: var(--bg-tertiary, #374151);
}

[data-theme="dark"] .nav-section-header:hover {
  background: var(--bg-tertiary, #374151);
}

[data-theme="dark"] .nav-item:hover {
  background: var(--bg-tertiary, #374151);
}

[data-theme="dark"] .nav-item.active {
  background: rgba(74, 144, 226, 0.15);
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .quick-search-kbd {
    display: none;
  }
  
  /* Reduce spacing for mobile to fit more content */
  .nav-quick-search {
    padding: 0.5rem 0.75rem;
  }
  
  .quick-search-input-wrapper {
    padding: 0.375rem 0.625rem;
  }
  
  .quick-search-input {
    font-size: 0.8125rem;
  }
  
  .nav-section-header {
    padding: 0.5rem 0.75rem;
  }
  
  .nav-section-title {
    font-size: 0.6875rem;
  }
  
  .nav-section-icon {
    font-size: 0.875rem;
  }
  
  .nav-item {
    padding: 0.5rem 0.75rem 0.5rem 2rem;
    font-size: 0.8125rem;
  }
  
  .nav-icon {
    font-size: 1rem;
    width: 1.25rem;
  }
}

/* Compact Mode for smaller screens */
@media (max-height: 700px) {
  .nav-quick-search {
    padding: 0.375rem 0.625rem;
  }
  
  .quick-search-input-wrapper {
    padding: 0.25rem 0.5rem;
  }
  
  .nav-section-header {
    padding: 0.375rem 0.75rem;
  }
  
  .nav-item {
    padding: 0.375rem 0.75rem 0.375rem 2rem;
    font-size: 0.8125rem;
  }
}

/* Extra compact for very small screens */
@media (max-height: 600px) {
  .nav-quick-search {
    padding: 0.25rem 0.5rem;
  }
  
  .quick-search-input-wrapper {
    padding: 0.25rem 0.5rem;
  }
  
  .nav-section-header {
    padding: 0.25rem 0.625rem;
  }
  
  .nav-section-title {
    font-size: 0.625rem;
  }
  
  .nav-item {
    padding: 0.25rem 0.625rem 0.25rem 1.75rem;
    font-size: 0.75rem;
  }
  
  .nav-icon {
    font-size: 0.875rem;
    width: 1rem;
  }
}
/* Enhanced Section Styling */
.nav-section {
  margin-bottom: 0.25rem;
}

.nav-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 8px;
  margin: 0 0.5rem;
}

.nav-section-header:hover {
  background: var(--bg-hover, rgba(74, 144, 226, 0.05));
}

.nav-section-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--text-primary, #1f2937);
  white-space: nowrap;
}

.nav-section-icon {
  font-size: 1rem;
}

.nav-section-arrow {
  transition: transform 0.2s ease;
  color: var(--text-muted, #9ca3af);
}

.nav-section.expanded .nav-section-arrow {
  transform: rotate(180deg);
}

.nav-section-items {
  overflow: hidden;
  transition: all 0.3s ease;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.nav-section.collapsed .nav-section-items {
  max-height: 0;
  opacity: 0;
}

.nav-section.expanded .nav-section-items {
  max-height: 500px;
  opacity: 1;
  padding-bottom: 0.25rem;
}

/* Enhanced Nav Items */
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  margin: 0.0625rem 0;
  text-decoration: none;
  color: var(--text-secondary, #6b7280);
  border-radius: 6px;
  transition: all 0.2s ease;
  font-size: 0.875rem;
  font-weight: 500;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: var(--bg-hover, rgba(74, 144, 226, 0.05));
  color: var(--text-primary, #1f2937);
  transform: translateX(2px);
}

.nav-item.active {
  background: var(--primary-bg, rgba(74, 144, 226, 0.1));
  color: var(--primary-color, #4A90E2);
  border-left-color: var(--primary-color, #4A90E2);
  font-weight: 600;
}

.nav-item.active:hover {
  transform: none;
}

.nav-icon {
  font-size: 1rem;
  width: 1.25rem;
  text-align: center;
  flex-shrink: 0;
}

/* Section Dividers */
.nav-section + .nav-section {
  border-top: 1px solid var(--border-light, rgba(229, 231, 235, 0.5));
  padding-top: 0.25rem;
  margin-top: 0.25rem;
}

/* Mobile Enhancements */
@media (max-width: 768px) {
  .nav-section-header {
    padding: 0.625rem 0.75rem;
  }
  
  .nav-item {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
  }
  
  .nav-section-title {
    font-size: 0.8125rem;
  }
  
  .quick-search-input-wrapper {
    padding: 0.375rem 0.625rem;
  }
  
  .quick-search-input {
    font-size: 0.8125rem;
  }
}

/* Dark Mode Enhancements */
[data-theme="dark"] .nav-section-header:hover {
  background: rgba(74, 144, 226, 0.1);
}

[data-theme="dark"] .nav-item:hover {
  background: rgba(74, 144, 226, 0.1);
}

[data-theme="dark"] .nav-section + .nav-section {
  border-top-color: rgba(255, 255, 255, 0.1);
}

/* ============================================
   SIDEBAR FOOTER & USER PROFILE
   ============================================ */

.sidebar-footer {
  margin-top: auto;
  padding: 1rem;
  border-top: 1px solid var(--border-color, #e5e7eb);
  background: var(--bg-primary, #fff);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem;
  border-radius: 10px;
  background: var(--bg-secondary, #f8f9fa);
  transition: background 0.2s ease;
}

.user-profile:hover {
  background: var(--bg-tertiary, #f1f3f5);
}

.user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color, #4A90E2), var(--primary-dark, #357ABD));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1rem;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(74, 144, 226, 0.25);
}

.user-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.user-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary, #2C3E50);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.user-email {
  font-size: 0.75rem;
  color: var(--text-secondary, #7F8C8D);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.sidebar-footer .btn {
  margin-top: 0.75rem;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

/* Dark Mode */
[data-theme="dark"] .sidebar-footer {
  background: var(--bg-primary, #1f2937);
  border-top-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .user-profile {
  background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .user-profile:hover {
  background: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .user-name {
  color: var(--text-primary, #f3f4f6);
}

[data-theme="dark"] .user-email {
  color: var(--text-secondary, #9ca3af);
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .sidebar-footer {
    padding: 0.875rem;
  }

  .user-profile {
    padding: 0.5rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  
  .user-info {
    width: 100%;
  }

  .user-avatar {
    width: 38px;
    height: 38px;
    font-size: 0.9rem;
  }

  .user-name {
    font-size: 0.85rem;
  }

  .user-email {
    font-size: 0.7rem;
  }
  
  .sidebar-footer .btn {
    margin-top: 0.5rem;
  }
}

@media (max-width: 480px) {
  .user-profile {
    padding: 0.5rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  
  .user-info {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
  }
  
  .sidebar-footer .btn {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    padding: 0.625rem 1rem;
  }
}
