/* ============================================
   01-SIDEBAR-ENHANCED
   Professional sidebar styling enhancement
   ============================================ */
@layer base {

  /* =====================
     ======= Enhanced Sidebar =====
     ===================== */

  .sidebar {
    background: linear-gradient(180deg, var(--clr-berry-600) 0%, var(--clr-berry-600) 40%, var(--clr-berry-900) 100%);
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.4);
    border-right: 1px solid var(--white-a10);
  }

  /* Enhanced sidebar top section */
  .sidebar-top {
    backdrop-filter: blur(10px);
    background: var(--clr-berry-400);
  }

  /* Enhanced logo styling */
  .logo-swap {
    background: var(--clr-berry-400);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .sidebar-collapsed .logo-swap:hover {
    background: var(--clr-berry-400);
    transform: scale(1.05);
  }

  /* Enhanced menu items */
  .sidebar a {
    position: relative;
    border-radius: 8px;
    margin: 0.25rem 0.5rem;
    overflow: hidden;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  }

  /* Add subtle left border accent */
  .sidebar a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, transparent, var(--clr-berry-400), transparent);
    opacity: 0;
    transition: opacity 0.25s ease;
  }

  .sidebar a:hover::before {
    opacity: 1;
  }

  /* Enhanced hover state */
  .sidebar a:hover {
    background: var(--white-a08);
    color: var(--clr-white);
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2),
      inset 0 1px 0 var(--white-a10);
  }

  /* Active/current page styling */
  .sidebar a.active {
    background: linear-gradient(90deg, rgba(var(--clr-berry-500-rgb),0.25), var(--white-a06));
    border-left: 3px solid var(--clr-berry-500);
    color: var(--clr-white);
    font-weight: 600;
  }

  /* Icon enhancement */
  .sidebar a .default-icon {
    transition: all 0.25s ease;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
  }

  .sidebar a:hover .default-icon {
    color: var(--clr-berry-400);
    transform: scale(1.1);
  }

  /* Enhanced dropdown styling */
  .sidebar .dropdown {
    margin: 0 0.5rem;
  }

  .sidebar .dropdown-toggle {
    border-radius: 8px;
    margin: 0;
    position: relative;
    background: var(--white-a05);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .sidebar .dropdown-toggle:hover {
    background: var(--white-a12);
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  }

  .sidebar .dropdown-content {
    background: rgba(26, 5, 16, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    margin: 0.25rem 0.5rem;
    padding: 0.25rem;
    border: 1px solid var(--white-a10);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  }

  .sidebar .dropdown-content a {
    margin: 0.125rem;
    font-size: 10.5px;
    padding: 8px 12px;
    border-radius: 6px;
    background: var(--white-a03);
  }

  .sidebar .dropdown-content a:hover {
    background: rgba(var(--clr-berry-400-rgb),0.2);
    transform: translateX(2px);
  }

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

  .sidebar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
  }

  .sidebar::-webkit-scrollbar-thumb {
    background: var(--white-a20);
    border-radius: 3px;
    transition: background 0.2s ease;
  }

  .sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--white-a30);
  }

  /* Collapsed state enhancements */
  .sidebar-collapsed .sidebar {
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.25);
  }

  .sidebar-collapsed .sidebar a {
    margin: 0.25rem 0.5rem;
  }

  .sidebar-collapsed .sidebar a:hover {
    transform: none;
    background: var(--white-a15);
  }

  /* Tooltip for collapsed state */
  .sidebar-collapsed .sidebar a::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(var(--sidebar-collapsed) + 8px);
    top: 50%;
    transform: translateY(-50%) scale(0.95);
    background: var(--clr-berry-800);
    color: var(--clr-white);
    padding: 4px 10px;
    border-radius: 5px;
    font-size: var(--fs-base-s);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--white-a14);
    z-index: var(--z-modal);
  }

  .sidebar-collapsed .sidebar a:hover::after {
    opacity: 1;
    transform: translateY(-50%) scale(1);
  }

  /* Add breathing animation to logo */
  @keyframes subtle-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
  }

  .logo-swap img.base {
    animation: subtle-pulse 3s ease-in-out infinite;
    border-radius: 50px;
  }
  .sidebar-collapsed .logo-swap:hover img.base {
    animation: none;
    opacity: 0;
  }

  /* Focus states for accessibility */
  .sidebar a:focus-visible,
  .sidebar-toggle:focus-visible,
  .logo-swap:focus-visible {
    outline: 2px solid var(--clr-berry-400);
    outline-offset: 2px;
  }

  /* ── Mobile: auto-collapse sidebar ── */
  @media (max-width: 768px) {
    .sidebar {
      width: var(--sidebar-collapsed, 52px);
    }
    .sidebar .nav-label {
      display: none;
    }
    .sidebar .sidebar-logo-text {
      display: none;
    }
  }

  @media (max-width: 480px) {
    .sidebar {
      position: fixed;
      width: var(--sidebar-width, 180px) !important;
      transform: translateX(-100%);
      z-index: var(--z-sidebar, 1040);
      transition: transform 0.25s ease;
      overflow-y: auto !important;
      overflow-x: hidden !important;
      -webkit-overflow-scrolling: touch !important;
      padding-bottom: max(20px, env(safe-area-inset-bottom, 0px)) !important;
    }
    .sidebar a {
      min-height: 44px !important;
      display: flex !important;
      align-items: center !important;
    }
    /* Hide collapse toggle — hamburger handles open/close */
    .sidebar-toggle {
      display: none !important;
    }
    .sidebar.mobile-open {
      transform: translateX(0);
      width: var(--sidebar-width, 180px) !important;
    }
    .sidebar.mobile-open .nav-label {
      display: block !important;
      opacity: 1 !important;
      width: auto !important;
      overflow: visible !important;
    }
    .sidebar.mobile-open .sidebar-logo-text {
      display: block !important;
    }
  }
}
