/*
 * © 2025 Milos Saric. All rights reserved.
 * Sidebar Styles for Learning Projects
 * Clean, modern Apple-inspired design
 */

:root {
  --sidebar-width: 280px;
  --sidebar-collapsed-width: 60px;
  --sidebar-bg: rgba(255, 255, 255, 0.95);
  --sidebar-border: rgba(0, 0, 0, 0.05);
  --sidebar-text: #1d1d1f;
  --sidebar-text-secondary: #86868b;
  --sidebar-hover: rgba(0, 0, 0, 0.05);
  --sidebar-active: #007aff;
  --sidebar-active-bg: rgba(0, 122, 255, 0.1);
  --sidebar-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  --sidebar-backdrop: rgba(0, 0, 0, 0.4);
  --transition-smooth: 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --transition-fast: 0.2s ease;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --sidebar-bg: rgba(28, 28, 30, 0.95);
    --sidebar-border: rgba(255, 255, 255, 0.1);
    --sidebar-text: #ffffff;
    --sidebar-text-secondary: #98989d;
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --sidebar-active-bg: rgba(0, 122, 255, 0.2);
    --sidebar-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --sidebar-backdrop: rgba(0, 0, 0, 0.6);
  }
}

/* Sidebar Container */
.projects-sidebar {
  position: fixed;
  top: 45px; /* Perfect alignment with header bottom */
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - 48px); /* Adjusted height accordingly */
  background: var(--sidebar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--sidebar-border);
  box-shadow: var(--sidebar-shadow);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: all var(--transition-smooth);
  overflow: hidden;
}

/* Sidebar Header */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 1.5rem 1rem;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--sidebar-text);
  margin: 0;
  letter-spacing: -0.01em;
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--sidebar-text-secondary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 6px;
  transition: all var(--transition-fast);
}

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

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.5rem 0;
  scrollbar-width: thin;
  scrollbar-color: var(--sidebar-text-secondary) transparent;
}

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

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

.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--sidebar-text-secondary);
  border-radius: 2px;
}

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

/* Navigation Sections */
.nav-section {
  margin-bottom: 2rem;
}

.nav-section h4 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--sidebar-text-secondary);
  margin: 0 0 0.75rem 0;
  padding: 0 1.5rem;
}

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

.nav-section li {
  margin: 0;
}

.nav-section a {
  display: flex;
  align-items: center;
  padding: 0.75rem 1.5rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 400;
  transition: all var(--transition-fast);
  border-radius: 0;
  position: relative;
  line-height: 1.4;
}

.nav-section a:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
}

.nav-section a.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active);
  font-weight: 500;
}

.nav-section a.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--sidebar-active);
}

.nav-section a.completed {
  color: var(--sidebar-text-secondary);
}

.nav-section a.completed::after {
  content: '✓';
  margin-left: auto;
  color: #30d158;
  font-weight: 600;
  font-size: 0.875rem;
}

/* Sidebar Footer */
.sidebar-footer {
  flex-shrink: 0;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--sidebar-border);
}

.collapse-btn {
  width: 100%;
  background: none;
  border: none;
  color: var(--sidebar-text-secondary);
  cursor: pointer;
  padding: 0.75rem;
  border-radius: 8px;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 500;
}

.collapse-btn:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
}

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

.projects-sidebar.collapsed .sidebar-header h3 {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-20px);
}

.projects-sidebar.collapsed .nav-section h4 {
  opacity: 0;
  pointer-events: none;
}

.projects-sidebar.collapsed .nav-section a {
  padding: 0.75rem;
  justify-content: center;
  position: relative;
}

.projects-sidebar.collapsed .nav-section a span {
  opacity: 0;
  pointer-events: none;
}

.projects-sidebar.collapsed .sidebar-header {
  padding: 1rem 0.75rem;
  justify-content: center;
}

.projects-sidebar.collapsed .sidebar-footer {
  padding: 1rem 0.75rem;
}

/* Tooltip for collapsed items */
.projects-sidebar.collapsed .nav-section a:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  background: var(--sidebar-text);
  color: var(--sidebar-bg);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
  white-space: nowrap;
  z-index: 1001;
  margin-left: 0.5rem;
  box-shadow: var(--sidebar-shadow);
}

/* Hide all header sidebar toggles - sidebar should only be controlled from within sidebar itself */
.site-header .sidebar-toggle,
.main-nav .sidebar-toggle,
.nav-left .sidebar-toggle {
  display: none !important;
}

/* Content sections that should be pushed by sidebar */
.hero-section,
.notebook-section,
.site-footer {
  transition: margin-left var(--transition-smooth);
}

/* Only apply margin when sidebar is visible and not on mobile */
@media (min-width: 769px) {
  .hero-section,
  .notebook-section,
  .site-footer {
    margin-left: var(--sidebar-width);
  }
  
  body.sidebar-collapsed .hero-section,
  body.sidebar-collapsed .notebook-section,
  body.sidebar-collapsed .site-footer {
    margin-left: var(--sidebar-collapsed-width);
  }
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--sidebar-backdrop);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-smooth);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

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

/* Mobile Responsive */
@media (max-width: 768px) {
  .projects-sidebar {
    transform: translateX(-100%);
    top: 60px; /* Adjusted for mobile header */
    height: calc(100vh - 60px);
    width: 280px;
    box-shadow: none;
  }

  .projects-sidebar.open {
    transform: translateX(0);
    box-shadow: var(--sidebar-shadow);
  }

  .hero-section,
  .notebook-section,
  .site-footer {
    margin-left: 0 !important;
  }

  .sidebar-toggle.mobile-only {
    display: block;
  }

  .collapse-btn {
    display: none;
  }

  /* Show mobile toggle in header */
  .sidebar-toggle.desktop-only {
    display: none;
  }

  /* Ensure sidebar doesn't collapse on mobile */
  .projects-sidebar.collapsed {
    width: 280px;
  }
  
  .projects-sidebar.collapsed .sidebar-header h3,
  .projects-sidebar.collapsed .nav-section h4,
  .projects-sidebar.collapsed .nav-section a {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (min-width: 769px) {
  .sidebar-toggle.mobile-only {
    display: none;
  }

  .sidebar-toggle.desktop-only {
    display: none !important; /* Hide all sidebar toggles in header */
  }
}

/* Tablet Responsive */
@media (max-width: 1024px) and (min-width: 769px) {
  :root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 50px;
  }

  .sidebar-header {
    padding: 1.25rem 1.25rem 0.75rem;
  }

  .sidebar-header h3 {
    font-size: 1.125rem;
  }

  .nav-section a {
    padding: 0.6rem 1.25rem;
    font-size: 0.9rem;
  }

  .nav-section h4 {
    padding: 0 1.25rem;
    font-size: 0.7rem;
  }
}

/* Large Screens */
@media (min-width: 1440px) {
  :root {
    --sidebar-width: 320px;
  }

  .sidebar-header {
    padding: 2rem 2rem 1.25rem;
  }

  .sidebar-header h3 {
    font-size: 1.375rem;
  }

  .nav-section a {
    padding: 0.875rem 2rem;
    font-size: 1rem;
  }

  .nav-section h4 {
    padding: 0 2rem;
  }

  .sidebar-footer {
    padding: 1.25rem 2rem;
  }
}

/* Loading State */
.projects-sidebar.loading {
  pointer-events: none;
}

.projects-sidebar.loading .nav-section a {
  opacity: 0.5;
}

/* Hover Effects */
@media (hover: hover) {
  .nav-section a:hover {
    transform: translateX(2px);
  }

  .projects-sidebar.collapsed .nav-section a:hover {
    transform: none;
  }
}

/* Focus States */
.nav-section a:focus,
.sidebar-toggle:focus,
.collapse-btn:focus {
  outline: 2px solid var(--sidebar-active);
  outline-offset: -2px;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .projects-sidebar,
  .main-content,
  .sidebar-overlay,
  .nav-section a,
  .sidebar-toggle,
  .collapse-btn {
    transition: none !important;
  }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  :root {
    --sidebar-border: #000000;
    --sidebar-hover: rgba(0, 0, 0, 0.1);
    --sidebar-active-bg: #000000;
    --sidebar-active: #ffffff;
  }
}

/* Print Styles */
@media print {
  .projects-sidebar,
  .sidebar-overlay {
    display: none !important;
  }

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