:root{
  --sidebar-width: 240px; /* default expanded sidebar width */
}

/* Sidebar Styles */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  margin: 0;
  padding: 1rem;
  z-index: 10;
  border-right: 1px solid #e5e7eb;
  background: #fafafa;

  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
}

.sidebar.collapsed {
  width: 80px;
}

/* And update the root variable via a class on the body, for example */
body.sidebar-collapsed {
  --sidebar-width: 80px;
}

/* Instead of using display: none, we now animate opacity and max-width for smoother transitions */
.nav-text,
.platform-header,
.company-name,
.user-info {
  transition: opacity 0.3s ease, max-width 0.3s ease;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
}


.sidebar.collapsed .nav-text,
.sidebar.collapsed .platform-header,
.sidebar.collapsed .user-info {
  opacity: 0;
  max-width: 0;
}

/* Ensure the company name remains visible when collapsed */
.sidebar.collapsed .company-name {
  opacity: 1;
  max-width: 100%;
}

.company-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem;
}

/* Add centering for company name when sidebar is collapsed */
.sidebar.collapsed .company-header {
  justify-content: center;
  width: 100%;
  padding-right: 0.8rem; /* Adjust for the toggle button position */
}


.platform-section {
  margin-top: 0.5rem;
}

.platform-header {
  font-size: 0.75rem;
  color: #6b7280;
  text-transform: uppercase;
  padding: 0.5rem;
  margin-bottom: 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 0.375rem;
  color: #374151;
  text-decoration: none;
  margin-bottom: 0.25rem;
  min-height: 40px;
}

.nav-item:hover {
  background-color: #f4f4f5;
}

.nav-item.active {
  background-color: #f4f4f5;
}

.nav-item.more{
  color: #374151ab;
}

/* Toggle Button Styles */
.toggle-button {
  position: absolute;
  right: -12px;
  top: 32px;
  width: 24px;
  height: 24px;
  background-color: white;
  border: 1px solid #e5e7eb;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 0;
  transition: transform 0.3s ease;
}

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

/* Main Content Styles */
.main-content {
  margin-left: var(--sidebar-width);
  padding: 1.4rem;
  padding-top: 1.1rem;
  width: calc(100% - var(--sidebar-width));
  min-height: 100vh;
  transition: margin-left 0.3s ease, width 0.3s ease;
}

.main-content.collapsed {
  margin-left: 80px;
  width: calc(100% - 80px);
}

/* User Menu Styles */
.user-menu {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 13rem;
  margin: 5px;
  z-index: 12;
  background-color: #f8f9fa;
  transition: width 0.3s ease;
}
.user-menu.collapsed {
  width: 80px;
}

.sidebar.collapsed + .main-content + .user-menu {
  width: 70px;
}

.sidebar.collapsed ~ .user-menu .user-button .user-info,
.sidebar.collapsed ~ .user-menu .user-button .lucide.lucide-chevrons-up-down {
  display: none !important;
}

.sidebar.collapsed ~ .user-menu .user-button {
  width: auto;
}

.user-button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem;
  margin: 0.7rem;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 0.375rem;
}

.user-button:hover {
  background-color: #f4f4f5;
}

.user-avatar {
  width: 32px;
  height: 32px;
  background-color: #f4f4f5;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  color: #374151;
  flex-shrink: 0;
}

.user-info {
  text-align: left;
  flex-grow: 1;
  max-width: calc(100% - 45px); /* Limit width to prevent overflow */
  overflow: hidden;
}

.user-name {
  font-size: 0.875rem;
  color: #374151;
}

.user-handle {
  font-size: 0.75rem;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Dropdown Menu */
.dropdown-menu {
  position: fixed; /* Change from absolute to fixed */
  bottom: 10px; /* Adjust to position above user menu */
  left: calc(var(--sidebar-width) + 10px); /* Align with sidebar */
  min-width: 215px; /* Ensure minimum width for content */
  background-color: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.375rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, .1), 0 1px 2px -1px rgba(0, 0, 0, .1);
  display: none;
  padding: 0.5rem 0;
  z-index: 1000; /* Ensure it's above other content */
  transition: left 0.3s ease;
}

/* Adjust user info styles in dropdown */
.dropdown-item.user {
  padding: 0.75rem 1rem;
}

.dropdown-item .user-info {
  max-width: none; /* Remove max-width constraint */
  white-space: normal; /* Allow text to wrap if needed */
  overflow: visible; /* Show overflow content */
}

.dropdown-item .user-handle {
  word-break: break-all; /* Break long email addresses */
  max-width: 180px; /* Provide reasonable max-width */
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Adjust dropdown position when sidebar is collapsed */
.sidebar.collapsed ~ .dropdown-menu {
  left: 80px; /* Align with collapsed sidebar */
}

.sidebar.collapsed .dropdown-menu {
  left: 70px;
  right: auto;
  width: 200px;
}

.dropdown-menu.active {
  display: block;
}

.dropdown-item {
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: #374151;
}

.dropdown-item:hover {
  background-color: #f4f4f5;
  border-radius: 5px;
}

.dropdown-item.user:hover{
   background-color: #fff;
}

.dropdown-item.upgrade {
  color: #2563eb;
}

.not-allowed{
  cursor: not-allowed;
}

.dropdown-divider {
  height: 1px;
  background-color: #f4f4f5;
  margin: 0.25rem 0;
}

/* Hide platform header only when collapsed */
.sidebar.collapsed .platform-header {
  opacity: 0;
  max-height: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, max-height 0.3s ease;
}

/* Nav items rise up with animation on collapse */
.nav-item {
  transform: translateY(0);
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.sidebar.collapsed .nav-item {
  transform: translateY(-35px); /* Rise up */
  width: 40px;
  height: 40px;
  padding: 0;
  gap: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* When sidebar is collapsed, make the active nav-item a square */
.sidebar.collapsed .nav-item:hover,
.sidebar.collapsed .nav-item.active {
  width: 40px;      /* Adjust square size as needed */
  height: 40px;
  padding: 0;
  gap: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

svg.lucide {
  width: 1.1em;
  height: 1.1em;
  vertical-align: bottom;
  stroke-width: 2;
}

