/**
 * 999DEX PROFESSIONAL SIDEBAR NAVIGATION SYSTEM
 *
 * DeFi/Web3 Professional Design with Glassmorphism
 * Designer: Agent 1 - DeFi/Web3 Specialist
 *
 * Version: 2.0.0 - Professional Redesign
 * Date: November 4, 2025
 *
 * FEATURES:
 * - Premium glassmorphism design
 * - Professional 300ms animations
 * - GPU-accelerated transforms
 * - Enhanced purple-cyan gradient system
 * - 260px expanded / 64px collapsed
 * - Smooth spring-like transitions
 * - Professional depth and layering
 * - Fully responsive and accessible
 */

/* ========================================
   CSS CUSTOM PROPERTIES (LOCAL OVERRIDES)
   ======================================== */

:root {
  /* Sidebar-specific sizing */
  --sidebar-width-expanded: 260px;
  --sidebar-width-collapsed: 64px;
  --sidebar-transition-speed: 200ms;  /* Fast professional animation */
  --sidebar-blur-amount: 20px;

  /* Use design system variables */
  --sidebar-gradient-purple: var(--accent-purple);
  --sidebar-gradient-cyan: var(--accent-cyan);
  --sidebar-bg-base: rgba(15, 23, 42, 0.85);
  --sidebar-border-color: rgba(168, 85, 247, 0.2);
  --sidebar-shadow-color: rgba(0, 0, 0, 0.37);
  --sidebar-hover-gradient: linear-gradient(135deg, rgba(168, 85, 247, 0.15) 0%, rgba(6, 182, 212, 0.15) 100%);
  --sidebar-active-gradient: linear-gradient(135deg, rgba(168, 85, 247, 0.25) 0%, rgba(6, 182, 212, 0.25) 100%);
}

/* ========================================
   SIDEBAR CONTAINER
   ======================================== */

.sidebar-nav {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width-expanded);
  height: 100vh;

  /* Premium Glassmorphism */
  background: var(--sidebar-bg-base);
  backdrop-filter: blur(var(--sidebar-blur-amount)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--sidebar-blur-amount)) saturate(180%);

  /* Border with gradient hint */
  border-right: 1px solid var(--sidebar-border-color);

  /* Layered Shadows for Depth */
  box-shadow:
    0 8px 32px var(--sidebar-shadow-color),
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1);

  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;

  /* Smooth Transforms */
  transform: translateX(0);
  transition:
    transform var(--sidebar-transition-speed) var(--ease-in-out),
    width var(--sidebar-transition-speed) var(--ease-in-out);

  /* GPU Acceleration */
  will-change: transform, width;
  transform: translateZ(0);
}

/* Collapsed State */
.sidebar-nav.collapsed {
  width: var(--sidebar-width-collapsed);
}

/* Hide text elements when collapsed */
.sidebar-nav.collapsed .sidebar-logo-text,
.sidebar-nav.collapsed .sidebar-nav-item span:not(.sidebar-nav-icon),
.sidebar-nav.collapsed .sidebar-user-info,
.sidebar-nav.collapsed .sidebar-nav-badge,
.sidebar-nav.collapsed .sidebar-category-arrow,
.sidebar-nav.collapsed .sidebar-section-title {
  opacity: 0;
  visibility: hidden;
  width: 0;
  overflow: hidden;
}

/* Center items when collapsed */
.sidebar-nav.collapsed .sidebar-nav-item,
.sidebar-nav.collapsed .sidebar-category-toggle {
  justify-content: center;
  padding: var(--spacing-base);
}

.sidebar-nav.collapsed .sidebar-create-btn {
  width: 48px;
  height: 48px;
  padding: 0;
  justify-content: center;
  margin: var(--spacing-md) var(--spacing-sm);
  border-radius: var(--spacing-base);
}

.sidebar-nav.collapsed .sidebar-create-btn span {
  display: none;
}

.sidebar-nav.collapsed .sidebar-user {
  justify-content: center;
  padding: var(--spacing-sm) 0;
}

.sidebar-nav.collapsed .sidebar-connect {
  padding: var(--spacing-base);
  width: calc(100% - var(--spacing-md));
  margin: 0 var(--spacing-sm);
}

.sidebar-nav.collapsed .sidebar-connect span {
  display: none;
}

/* Hide submenu when collapsed */
.sidebar-nav.collapsed .sidebar-submenu {
  display: none;
}

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

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

.sidebar-nav::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.3), rgba(6, 182, 212, 0.3));
  border-radius: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.5), rgba(6, 182, 212, 0.5));
}

/* Mobile: Hidden by default */
@media (max-width: 1023px) {
  .sidebar-nav {
    transform: translateX(-100%);
  }

  .sidebar-nav.active {
    transform: translateX(0);
  }
}

/* Desktop: Always visible, push content */
@media (min-width: 1024px) {
  .sidebar-nav {
    transform: translateX(0);
  }

  /* Adjust main content to account for sidebar */
  body.has-sidebar .main-content {
    margin-left: var(--sidebar-width-expanded);
    transition: margin-left var(--sidebar-transition-speed) var(--sidebar-transition-easing);
  }

  /* Adjust main content when sidebar is collapsed */
  body.has-sidebar.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-width-collapsed);
  }
}

/* ========================================
   SIDEBAR HEADER
   ======================================== */

.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid var(--sidebar-border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;

  /* Subtle gradient background */
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.05) 0%, rgba(6, 182, 212, 0.05) 100%);
}

.sidebar-logo {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  background: linear-gradient(135deg, var(--sidebar-gradient-purple) 0%, var(--sidebar-gradient-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: var(--spacing-base);
  transition: opacity var(--sidebar-transition-speed) var(--sidebar-transition-easing);
  cursor: pointer;
}

.sidebar-logo:hover {
  opacity: 0.85;
}

.sidebar-logo-text {
  transition: opacity 200ms, width 200ms;
}

.sidebar-close {
  display: none;
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  border-radius: 8px;
  transition: all 200ms;
  padding: 0;
  align-items: center;
  justify-content: center;
}

.sidebar-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
  transform: rotate(90deg);
}

.sidebar-close svg {
  width: 20px;
  height: 20px;
}

@media (max-width: 1023px) {
  .sidebar-close {
    display: flex;
  }
}

/* ========================================
   NAVIGATION MENU
   ======================================== */

.sidebar-menu {
  flex: 1;
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

/* Navigation Items */
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: var(--spacing-base) var(--spacing-md);
  margin: 0 var(--spacing-sm);
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  border-radius: 10px;
  border-left: 0;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  min-height: 44px;
  user-select: none;

  /* Smooth transitions */
  transition:
    background var(--sidebar-transition-speed) var(--sidebar-transition-easing),
    color var(--sidebar-transition-speed) var(--sidebar-transition-easing),
    transform 200ms var(--sidebar-transition-easing);

  /* GPU optimization */
  will-change: background, transform;
}

/* Hover state with gradient */
.sidebar-nav-item:hover {
  background: var(--sidebar-hover-gradient);
  color: rgba(255, 255, 255, 0.95);
  transform: translateX(2px);
}

.sidebar-nav-item:active {
  transform: translateX(1px) scale(0.98);
}

/* Active state with stronger gradient */
.sidebar-nav-item.active {
  background: var(--sidebar-active-gradient);
  color: #fff;
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.2);
}

/* Active indicator (left accent) */
.sidebar-nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: linear-gradient(135deg, var(--sidebar-gradient-purple) 0%, var(--sidebar-gradient-cyan) 100%);
  border-radius: 0 2px 2px 0;
  box-shadow: 0 0 8px rgba(168, 85, 247, 0.6);
}

/* Navigation Icons */
.sidebar-nav-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  transition: transform 200ms;
}

.sidebar-nav-item:hover .sidebar-nav-icon {
  transform: scale(1.1);
}

/* Navigation Badge */
.sidebar-nav-badge {
  margin-left: auto;
  padding: 3px 9px;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  border-radius: 12px;
  min-width: 20px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

.sidebar-nav-badge.green {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}

.sidebar-nav-badge.blue {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

/* ========================================
   CATEGORY SUBMENU
   ======================================== */

.sidebar-category {
  display: flex;
  flex-direction: column;
}

.sidebar-category-toggle {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: var(--spacing-base) var(--spacing-md);
  margin: 0 var(--spacing-sm);
  color: rgba(255, 255, 255, 0.7);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  border: none;
  background: transparent;
  cursor: pointer;
  min-height: 44px;
  border-radius: 10px;
  transition:
    background var(--sidebar-transition-speed) var(--sidebar-transition-easing),
    color var(--sidebar-transition-speed) var(--sidebar-transition-easing);
  width: 100%;
  text-align: left;
}

.sidebar-category-toggle:hover {
  background: var(--sidebar-hover-gradient);
  color: rgba(255, 255, 255, 0.95);
}

.sidebar-category-arrow {
  margin-left: auto;
  width: 16px;
  height: 16px;
  transition: transform var(--sidebar-transition-speed) var(--sidebar-transition-easing);
}

.sidebar-category.expanded .sidebar-category-arrow {
  transform: rotate(90deg);
}

/* Submenu */
.sidebar-submenu {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--sidebar-transition-speed) var(--sidebar-transition-easing);
}

.sidebar-category.expanded .sidebar-submenu {
  max-height: 500px;
}

.sidebar-submenu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px 10px 48px;
  margin: 0 var(--spacing-sm);
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-regular);
  border-radius: 10px;
  transition:
    background var(--sidebar-transition-speed) var(--sidebar-transition-easing),
    color var(--sidebar-transition-speed) var(--sidebar-transition-easing);
  min-height: 40px;
}

.sidebar-submenu-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.9);
}

.sidebar-submenu-item.active {
  color: var(--sidebar-gradient-purple);
  background: rgba(168, 85, 247, 0.1);
}

/* ========================================
   CREATE TOKEN BUTTON (Prominent CTA)
   ======================================== */

.sidebar-create-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: var(--spacing-md);
  padding: 14px 20px;
  background: linear-gradient(135deg, var(--sidebar-gradient-purple) 0%, var(--sidebar-gradient-cyan) 100%);
  color: #fff;
  text-decoration: none;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  border-radius: 12px;
  border: none;
  cursor: pointer;
  min-height: 52px;
  transition: all 300ms var(--sidebar-transition-easing);
  box-shadow:
    0 4px 12px rgba(168, 85, 247, 0.3),
    0 2px 4px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
}

/* Shine effect on hover */
.sidebar-create-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 500ms;
}

.sidebar-create-btn:hover::before {
  left: 100%;
}

.sidebar-create-btn:hover {
  transform: translateY(-2px);
  box-shadow:
    0 8px 20px rgba(168, 85, 247, 0.4),
    0 4px 8px rgba(0, 0, 0, 0.15);
}

.sidebar-create-btn:active {
  transform: translateY(0) scale(0.98);
  box-shadow:
    0 2px 8px rgba(168, 85, 247, 0.3),
    0 1px 2px rgba(0, 0, 0, 0.1);
}

.sidebar-create-btn svg {
  width: 20px;
  height: 20px;
}

/* ========================================
   SIDEBAR FOOTER (User Profile)
   ======================================== */

.sidebar-footer {
  padding: var(--spacing-md);
  border-top: 1px solid var(--sidebar-border-color);
  margin-top: auto;
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.03) 0%, rgba(6, 182, 212, 0.03) 100%);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--spacing-base);
  padding: 10px;
  border-radius: 10px;
  transition: background var(--sidebar-transition-speed) var(--sidebar-transition-easing);
  cursor: pointer;
  text-decoration: none;
  color: #fff;
}

.sidebar-user:hover {
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--sidebar-gradient-purple) 0%, var(--sidebar-gradient-cyan) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-sm);
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(168, 85, 247, 0.3);
}

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

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

.sidebar-user-address {
  font-size: var(--font-size-xs);
  color: rgba(255, 255, 255, 0.5);
  font-family: var(--font-family-mono);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Connect Wallet Button */
.sidebar-connect {
  width: 100%;
  padding: var(--spacing-base) var(--spacing-md);
  background: rgba(168, 85, 247, 0.15);
  color: var(--sidebar-gradient-purple);
  border: 1px solid var(--sidebar-gradient-purple);
  border-radius: 10px;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  transition: all var(--sidebar-transition-speed) var(--sidebar-transition-easing);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  min-height: 44px;
}

.sidebar-connect:hover {
  background: rgba(168, 85, 247, 0.25);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.2);
}

.sidebar-connect:active {
  transform: translateY(0) scale(0.98);
}

/* ========================================
   MOBILE OVERLAY
   ======================================== */

.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity var(--sidebar-transition-speed) var(--sidebar-transition-easing),
    visibility var(--sidebar-transition-speed) var(--sidebar-transition-easing);
}

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

@media (min-width: 1024px) {
  .sidebar-overlay {
    display: none;
  }
}

/* ========================================
   SIDEBAR TOGGLE BUTTON (DESKTOP)
   ======================================== */

.sidebar-toggle {
  position: absolute;
  top: 24px;
  right: -16px;
  width: 32px;
  height: 32px;
  background: var(--sidebar-bg-base);
  backdrop-filter: blur(10px);
  border: 1px solid var(--sidebar-border-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1001;
  transition: all 200ms var(--sidebar-transition-easing);
  color: #fff;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.sidebar-toggle:hover {
  transform: scale(1.15);
  background: rgba(168, 85, 247, 0.2);
  border-color: var(--sidebar-gradient-purple);
  box-shadow: 0 4px 16px rgba(168, 85, 247, 0.4);
}

.sidebar-nav.collapsed .sidebar-toggle {
  transform: rotate(180deg);
}

.sidebar-nav.collapsed .sidebar-toggle:hover {
  transform: rotate(180deg) scale(1.15);
}

/* Hide toggle on mobile */
@media (max-width: 1023px) {
  .sidebar-toggle {
    display: none;
  }
}

/* ========================================
   HAMBURGER MENU BUTTON
   ======================================== */

.hamburger-menu {
  display: none;
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: var(--spacing-sm);
  border-radius: 8px;
  transition: background 200ms;
  position: relative;
  flex-shrink: 0;
}

.hamburger-menu:hover {
  background: rgba(255, 255, 255, 0.1);
}

.hamburger-menu:active {
  background: rgba(255, 255, 255, 0.15);
}

@media (max-width: 1023px) {
  .hamburger-menu {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* Hamburger icon */
.hamburger-icon {
  width: 24px;
  height: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
}

.hamburger-line {
  width: 100%;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform 300ms var(--sidebar-transition-easing),
              opacity 300ms var(--sidebar-transition-easing);
  transform-origin: center;
}

/* Animated hamburger when active */
.hamburger-menu.active .hamburger-line:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}

.hamburger-menu.active .hamburger-line:nth-child(2) {
  opacity: 0;
}

.hamburger-menu.active .hamburger-line:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

/* ========================================
   SECTION DIVIDERS
   ======================================== */

.sidebar-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--sidebar-border-color), transparent);
  margin: var(--spacing-base) var(--spacing-md);
}

.sidebar-section-title {
  padding: var(--spacing-xs) var(--spacing-md) var(--spacing-sm);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

/* Keyboard focus styles */
.sidebar-nav-item:focus,
.sidebar-category-toggle:focus,
.sidebar-submenu-item:focus,
.sidebar-create-btn:focus,
.sidebar-user:focus,
.sidebar-connect:focus {
  outline: 2px solid var(--sidebar-gradient-purple);
  outline-offset: 2px;
}

/* Skip to main content link */
.skip-to-main {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--sidebar-gradient-purple);
  color: #fff;
  padding: var(--spacing-sm) var(--spacing-md);
  text-decoration: none;
  border-radius: 8px;
  z-index: 10000;
  transition: top 200ms;
  font-weight: var(--font-weight-semibold);
}

.skip-to-main:focus {
  top: 8px;
}

/* ========================================
   ANIMATIONS
   ======================================== */

/* Slide in animation for mobile */
@keyframes slideInFromLeft {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

.sidebar-nav.animating-in {
  animation: slideInFromLeft var(--sidebar-transition-speed) var(--sidebar-transition-easing);
}

/* Fade in for overlay */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.sidebar-overlay.animating-in {
  animation: fadeIn var(--sidebar-transition-speed) var(--sidebar-transition-easing);
}

/* ========================================
   REDUCED MOTION
   ======================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
  .sidebar-nav,
  .sidebar-overlay,
  .hamburger-menu {
    display: none !important;
  }

  body.has-sidebar .main-content {
    margin-left: 0 !important;
  }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

.sidebar-hidden {
  transform: translateX(-100%) !important;
}

.sidebar-visible {
  transform: translateX(0) !important;
}

/* Prevent body scroll when sidebar is open on mobile */
body.sidebar-open {
  overflow: hidden;
}

@media (min-width: 1024px) {
  body.sidebar-open {
    overflow: auto;
  }
}

/* ========================================
   PERFORMANCE OPTIMIZATIONS
   ======================================== */

/* Force GPU acceleration for smoother animations */
.sidebar-nav,
.sidebar-nav-item,
.sidebar-create-btn,
.sidebar-toggle {
  -webkit-transform: translateZ(0);
  -moz-transform: translateZ(0);
  -ms-transform: translateZ(0);
  -o-transform: translateZ(0);
  transform: translateZ(0);
}

/* Optimize rendering during animations */
.sidebar-nav.transitioning {
  will-change: width, transform;
}

.sidebar-nav.transitioning .sidebar-nav-item {
  will-change: background, transform;
}
