/* ============================================
   SIDEBAR NAVIGATION SYSTEM
   ============================================ */

/* Sidebar Container */
.app-sidebar {
  position: fixed;
  left: 0;
  top: 64px; /* Below topbar */
  bottom: 0;
  width: 280px;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  box-shadow: 2px 0 8px rgba(15, 23, 42, 0.04);
  display: flex;
  flex-direction: column;
  z-index: 900;
  transition: transform 280ms cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.app-sidebar.collapsed {
  transform: translateX(-280px);
}

/* Sidebar Header */
.sidebar-header {
  padding: var(--space-3) var(--space-2);
  border-bottom: 1px solid var(--color-divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--color-text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-toggle-btn {
  background: none;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  color: var(--color-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all 160ms ease;
}

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

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-2) 0;
}

/* Scrollbar styling */
.sidebar-nav::-webkit-scrollbar {
  width: 6px;
}

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

.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: var(--color-muted);
}

/* Navigation Section */
.sidebar-section {
  margin-bottom: var(--space-2);
}

.sidebar-section-label {
  padding: 0.5rem var(--space-2);
  font-size: 12px;
  font-weight: 600;
  color: var(--color-subtle);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Navigation Items */
.sidebar-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar-nav-item {
  position: relative;
}

.sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem var(--space-2);
  color: var(--color-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 160ms ease;
  border-left: 3px solid transparent;
}

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

.sidebar-nav-link.active {
  background: rgba(2, 129, 82, 0.08);
  color: var(--color-accent);
  border-left-color: var(--color-accent);
}

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

.sidebar-nav-text {
  flex: 1;
}

.sidebar-nav-badge {
  background: var(--color-danger);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 0.125rem 0.375rem;
  border-radius: 10px;
  line-height: 1;
}

/* Dropdown Sections */
.sidebar-dropdown {
  position: relative;
}

.sidebar-dropdown-trigger {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem var(--space-2);
  color: var(--color-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: all 160ms ease;
  border-left: 3px solid transparent;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  border-radius: 0;
}

.sidebar-dropdown-trigger:hover {
  background: var(--color-surface-alt);
  color: var(--color-primary);
}

.sidebar-dropdown-trigger.active {
  background: rgba(27, 46, 75, 0.06);
  color: var(--color-primary);
}

.sidebar-dropdown-arrow {
  margin-left: auto;
  transition: transform 200ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-dropdown.open > .sidebar-dropdown-trigger .sidebar-dropdown-arrow {
  transform: rotate(90deg);
}

.sidebar-dropdown-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 280ms cubic-bezier(0.4, 0, 0.2, 1);
  background: var(--color-surface-alt);
}

.sidebar-dropdown.open > .sidebar-dropdown-content {
  max-height: 1000px;
}

.sidebar-dropdown-list {
  list-style: none;
  margin: 0;
  padding: 0.5rem 0;
}

.sidebar-dropdown-item {
  position: relative;
}

.sidebar-dropdown-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem var(--space-2) 0.5rem 3rem;
  color: var(--color-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 160ms ease;
}

.sidebar-dropdown-link:hover {
  background: rgba(27, 46, 75, 0.04);
  color: var(--color-text);
}

.sidebar-dropdown-link.active {
  background: rgba(2, 129, 82, 0.12);
  color: var(--color-accent);
  font-weight: 600;
}

/* Nested Dropdown Styles */
.sidebar-dropdown-nested {
  border-left: none;
  background: none;
}

.sidebar-dropdown-trigger-nested {
  padding: 0.5rem var(--space-2) 0.5rem 3rem;
  font-weight: 500;
  font-size: 13px;
  color: var(--color-muted);
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 160ms ease;
}

.sidebar-dropdown-trigger-nested:hover {
  background: rgba(27, 46, 75, 0.04);
  color: var(--color-text);
}

.sidebar-dropdown-trigger-nested.active {
  color: var(--color-accent);
  font-weight: 600;
}

.sidebar-dropdown-nested .sidebar-dropdown-arrow {
  font-size: 16px;
  margin-right: 0.5rem;
  transition: transform 200ms ease;
}

/* Rotate arrow when nested dropdown is open */
.sidebar-dropdown-nested.open .sidebar-dropdown-arrow {
  transform: rotate(90deg);
}

.sidebar-dropdown-nested .sidebar-dropdown-content {
  background: rgba(0, 0, 0, 0.02);
  max-height: 0;
  overflow: hidden;
  transition: max-height 280ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Expand content when nested dropdown is open */
.sidebar-dropdown-nested.open .sidebar-dropdown-content {
  max-height: 800px;
}

.sidebar-dropdown-list-nested {
  padding: 0.25rem 0;
}

.sidebar-dropdown-list-nested .sidebar-dropdown-link {
  padding-left: 4.5rem;
  font-size: 13px;
  font-weight: 500;
}

.sidebar-dropdown-list-nested .sidebar-dropdown-link:hover {
  background: rgba(27, 46, 75, 0.06);
}

.sidebar-dropdown-list-nested .sidebar-dropdown-link.active {
  background: rgba(2, 129, 82, 0.15);
  font-weight: 600;
}

/* Quick Actions Section */
.sidebar-quick-actions {
  padding: var(--space-2);
  border-top: 1px solid var(--color-divider);
}

.quick-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.625rem var(--space-2);
  background: var(--color-accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 160ms ease;
}

.quick-action-btn:hover {
  background: var(--color-accent-strong);
  box-shadow: var(--shadow-soft);
}

/* Main Content Area Adjustment */
.app-layout {
  display: flex;
  min-height: calc(100vh - 64px);
}

.app-content {
  flex: 1;
  width: 100%;
  transition: margin-left 280ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 899;
  opacity: 0;
  transition: opacity 280ms ease;
}

.sidebar-overlay.visible {
  opacity: 1;
}

/* Mobile Toggle Button (Hamburger) */
.sidebar-mobile-toggle {
  display: none;
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 56px;
  height: 56px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.3);
  cursor: pointer;
  z-index: 1000;
  transition: all 160ms ease;
}

.sidebar-mobile-toggle:hover {
  background: var(--color-primary-strong);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.4);
}

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

/* Desktop Reopen Button (appears when sidebar is collapsed) */
.sidebar-reopen-btn {
  position: fixed;
  top: 80px;
  left: 1rem;
  width: 40px;
  height: 40px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2);
  cursor: pointer;
  z-index: 950;
  transition: all 200ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
}

.sidebar-reopen-btn:hover {
  background: var(--color-primary-strong);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.3);
  transform: translateX(2px);
}

.sidebar-reopen-btn:active {
  transform: scale(0.95);
}

/* Show reopen button when sidebar is collapsed */
.sidebar-reopen-btn.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Icon Styles (using Unicode symbols for simplicity) */
.icon-chevron-right::before {
  content: "›";
  font-size: 20px;
  font-weight: bold;
}

.icon-dashboard::before {
  content: "◫";
  font-size: 18px;
}

.icon-admin::before {
  content: "⚙";
  font-size: 18px;
}

.icon-data::before {
  content: "⊞";
  font-size: 18px;
}

.icon-users::before {
  content: "👥";
  font-size: 16px;
}

.icon-chart::before {
  content: "📊";
  font-size: 16px;
}

.icon-alert::before {
  content: "⚠";
  font-size: 16px;
}

.icon-settings::before {
  content: "⚙";
  font-size: 16px;
}

.icon-reports::before {
  content: "📋";
  font-size: 16px;
}

.icon-info::before {
  content: "ℹ";
  font-size: 16px;
}

.icon-menu::before {
  content: "☰";
  font-size: 24px;
}

.icon-close::before {
  content: "✕";
  font-size: 24px;
}

/* Responsive Design */
@media (max-width: 960px) {
  .app-sidebar {
    transform: translateX(-280px);
  }

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

  .app-content {
    margin-left: 0;
  }

  .sidebar-overlay {
    display: block;
  }

  .sidebar-mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

@media (max-width: 640px) {
  .app-sidebar {
    width: 100%;
    max-width: 280px;
  }
}

/* Accessibility */
.sidebar-nav-link:focus,
.sidebar-dropdown-trigger:focus,
.sidebar-dropdown-link:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

/* Keyboard Navigation Indicator */
.sidebar-nav-link:focus-visible,
.sidebar-dropdown-trigger:focus-visible,
.sidebar-dropdown-link:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
