:root {
  --sidebar-width: 240px;
  --sidebar-bg: #0f0f0f;
  --sidebar-border: #222222;
  --sidebar-text: #d0d0d0;
  --sidebar-text-secondary: #666666;
  --sidebar-hover-bg: #1a1a1a;
  --sidebar-active-bg: rgba(163, 230, 53, 0.1);
  --sidebar-active-text: #a3e635;
  --sidebar-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.5), 0 1px 3px 1px rgba(0, 0, 0, 0.3);
  --header-height: 64px;
  --transition-speed: 0.3s;
}

/* Body Layout with Sidebar */
body.has-sidebar {
  margin: 0;
  padding: 0;
}

/* Main Content Wrapper */
.content-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left var(--transition-speed) ease;
}

/* Mobile: Full width content */
@media (max-width: 767px) {
  .content-wrapper {
    margin-left: 0;
  }
}

/* Sidebar Container */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform var(--transition-speed) ease;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Sidebar Header */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  min-height: var(--header-height);
  position: relative;
}

.sidebar-logo {
  height: 64px;
  max-width: 360px;
  object-fit: contain;
  display: block;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.sidebar-title {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 20px;
  font-weight: 600;
  color: var(--sidebar-text);
  margin: 0;
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: var(--sidebar-text-secondary);
  border-radius: 50%;
  transition: background-color 0.2s;
}

.sidebar-close:hover {
  background-color: var(--sidebar-hover-bg);
}

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}

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

.sidebar-item {
  margin: 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  transition: background-color 0.2s, color 0.2s;
  border-radius: 0 4px 4px 0;
  margin: 2px 8px 2px 0;
  gap: 12px;
}

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

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

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

.sidebar-link.active .sidebar-icon {
  stroke: var(--sidebar-active-text);
}

.sidebar-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-user-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 8px;
  color: var(--sidebar-text-secondary);
  font-size: 14px;
  transition: background-color 0.2s;
  flex: 1;
  min-width: 0;
}

.sidebar-guest-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-user.sidebar-guest {
  cursor: default;
}

.sidebar-user.sidebar-guest:hover {
  background-color: transparent;
}

.sidebar-user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  color: var(--sidebar-text);
}

.sidebar-logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: var(--sidebar-text-secondary);
  border-radius: 4px;
  transition: background-color 0.2s, color 0.2s;
  flex-shrink: 0;
}

.sidebar-logout-btn:hover {
  background-color: var(--sidebar-hover-bg);
  color: var(--sidebar-danger, #ef4444);
}

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

.sidebar-login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  background-color: #a3e635;
  color: #0c0c0c;
  border: none;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
  box-shadow: none;
}

.sidebar-login-btn:hover {
  background-color: #b8f042;
  box-shadow: 2px 2px 0 rgba(163, 230, 53, 0.3);
}

.sidebar-login-btn:active {
  transform: scale(0.98);
}

.sidebar-login-btn svg {
  width: 16px;
  height: 16px;
  stroke-width: 2.5;
}

/* Hamburger Toggle Button (Mobile) */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 1100;
  background-color: var(--sidebar-bg);
  border: 1px solid var(--sidebar-border);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  box-shadow: var(--sidebar-shadow);
  width: 44px;
  height: 44px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  transition: transform 0.2s;
}

.sidebar-toggle:hover {
  transform: scale(1.05);
}

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

.hamburger-line {
  display: block;
  width: 20px;
  height: 2px;
  background-color: var(--sidebar-text);
  border-radius: 2px;
  transition: all 0.3s ease;
}

/* Sidebar Overlay (Mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 999;
  opacity: 0;
  transition: opacity var(--transition-speed) ease;
}

/* Mobile Styles */
@media (max-width: 767px) {
  /* Show hamburger button */
  .sidebar-toggle {
    display: flex;
  }
  
  /* Show close button in sidebar */
  .sidebar-close {
    display: block;
  }
  
  /* Hide sidebar by default */
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--sidebar-shadow);
  }
  
  /* Show sidebar when active */
  .sidebar.active {
    transform: translateX(0);
  }
  
  /* Show overlay when sidebar is active */
  .sidebar-overlay.active {
    display: block;
    opacity: 1;
  }
  
  /* Animate hamburger to X when sidebar is open */
  .sidebar-toggle.active .hamburger-line:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
  }
  
  .sidebar-toggle.active .hamburger-line:nth-child(2) {
    opacity: 0;
  }
  
  .sidebar-toggle.active .hamburger-line:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
  }
}

/* Tablet Adjustments */
@media (min-width: 768px) and (max-width: 1024px) {
  :root {
    --sidebar-width: 220px;
  }
  
  .sidebar-title {
    font-size: 18px;
  }
  
  .sidebar-link {
    font-size: 13px;
    padding: 8px 12px;
  }
}

/* Scrollbar Styling for Sidebar */
.sidebar::-webkit-scrollbar {
  width: 6px;
}

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

.sidebar::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: #444;
}

/* Smooth Scrolling */
.sidebar-nav {
  scroll-behavior: smooth;
}

/* Focus States for Accessibility */
.sidebar-link:focus,
.sidebar-toggle:focus,
.sidebar-close:focus {
  outline: 2px solid var(--sidebar-active-text);
  outline-offset: 2px;
}

/* Print Styles */
@media print {
  .sidebar,
  .sidebar-toggle,
  .sidebar-overlay {
    display: none !important;
  }
  
  .content-wrapper {
    margin-left: 0 !important;
  }
}

@keyframes slideInFromLeft {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .sidebar-toggle,
  .sidebar-link,
  .sidebar-overlay,
  .content-wrapper,
  .hamburger-line {
    animation: none;
    transition: none;
  }
}
