@layer components {
  nav.sidebar,
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 260px;
    height: 100vh;
    background-color: #ffffff;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    z-index: 40;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    overflow-x: hidden;
  }

  /* Sidebar Brand Header */
  .sidebar-brand {
    height: var(--toolbar-height);
    padding: 0 20px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
  }

  .brand-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #0f172a;
  }

  .brand-logo {
    height: 32px;
    width: auto;
    border-radius: 6px;
  }

  .brand-info {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .brand-title {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.02em;
  }

  .brand-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 6px;
    background-color: #eef2ff;
    color: #4f46e5;
    letter-spacing: 0.05em;
  }

  /* User Card */
  .sidebar-user {
    margin: 14px 14px 8px 14px;
    padding: 10px 12px;
    background-color: #f8fafc;
    border: 1px solid #f1f5f9;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
  }

  .user-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .user-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
  }

  .user-name {
    font-size: 13px;
    font-weight: 600;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .user-email {
    font-size: 11px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Navigation Menu */
  .sidebar-menu {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex-grow: 1;
  }

  .menu-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    padding: 8px 10px 4px 10px;
  }

  .menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #475569;
    text-decoration: none;
    transition: all 0.15s ease;
    position: relative;
  }

  .menu-item:hover {
    background-color: #f1f5f9;
    color: #0f172a;
    text-decoration: none;
  }

  .menu-item.selected {
    background-color: #eef2ff;
    color: #4338ca;
    font-weight: 600;
  }

  .menu-item.selected::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 3px;
    background-color: #4f46e5;
    border-radius: 0 4px 4px 0;
  }

  .menu-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: inherit;
  }

  .menu-label {
    flex: 1;
  }

  /* Sidebar Footer */
  .sidebar-footer {
    padding: 14px;
    border-top: 1px solid #f1f5f9;
    flex-shrink: 0;
  }

  .theme-toggle-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    background: transparent;
    border: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: all 0.15s ease;
    margin-bottom: 4px;
  }

  .theme-toggle-link:hover {
    background-color: #f1f5f9;
    color: #0f172a;
  }

  .signout-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    text-decoration: none;
    transition: all 0.15s ease;
  }

  .signout-link:hover {
    background-color: #fef2f2;
    color: #dc2626;
    text-decoration: none;
  }

  .signout-link:hover .menu-icon {
    color: #dc2626;
  }

  /* Mobile backdrop and drawer */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    z-index: 35;
    opacity: 0;
    transition: opacity 0.25s ease;
  }

  @media only screen and (max-width: 767px) {
    nav.sidebar,
    .sidebar {
      transform: translateX(-100%);
      box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    }
    
    nav.sidebar.open,
    .sidebar.open {
      transform: translateX(0);
    }
    
    .sidebar-backdrop.open {
      display: block;
      opacity: 1;
    }
  }
}