:root{
  --sidebar-width: 4rem;
  --border-radius: 0.375rem;
  --bg-sidebar: var(--primary-color);
  --bg-sidebar-hover: #1a50ff;
  --border-sidebar: var(--primary-color);
}

.sidebar {
  background-color: var(--bg-sidebar);
  color: var(--ct-white);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1000;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: .5rem;
  border-right: 1px solid var(--border-sidebar);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.nav-item {
  position: relative;
  height: 3rem;
  padding: 0.7rem;
  font-size: 1.3rem;
  display: grid;
  place-items: center;
  color: var(--ct-white);
  text-decoration: none;
}
.nav-item:hover {
  background-color: var(--bg-sidebar-hover);
}

.tooltip {
  position: absolute;
  left: 100%;
  top: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: max-content;
  min-height: 3rem;
  font-size: 0.85rem;
  color: #fff;
  border-top-right-radius: var(--border-radius);
  border-bottom-right-radius: var(--border-radius);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  z-index: 1000;
}

.tooltip-title {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  height: 3rem;
  font-size: 1rem;
  font-weight: 500;
  background-color: var(--bg-sidebar-hover);
  padding: 0rem 1.2rem;
  text-decoration: none;
  color: var(--ct-white);
}

.tooltip-items {
  background-color: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.8rem 1.2rem;
}
.tooltip-item {
  color: var(--ct-white);
  text-decoration: none;
  transition: transform 0.2s ease-in-out;
}
.tooltip-item:hover {
  transform: translateX(0.2rem);
}
.nav-item:hover .tooltip {
  opacity: 1;
  pointer-events: auto;
}
.link-text {
  display: none;
}

/* Mobile Sidebar Styles */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    width: 250px; /* Expanded width on mobile */
    align-items: flex-start; /* Align items to left */
    overflow-y: auto;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 15px rgba(0,0,0,0.2);
  }

  /* When open, show text */
  .sidebar.open .link-text {
    display: inline-block;
    margin-left: 10px;
    font-size: 1rem;
    font-weight: 500;
  }

  .sidebar.open .nav-item {
    justify-content: flex-start;
    padding-left: 20px;
    width: 100%;
  }

  /* Hide the tooltip container behavior on mobile open */
  .sidebar.open .tooltip {
    position: static;
    opacity: 1;
    pointer-events: auto;
    width: 100%;
    background: transparent;
    display: none; /* Hidden by default, toggle with JS? or show always? */
    padding: 0;
    min-height: auto;
  }

  /* If it is a simple link with tooltip title (Dashboard, Vendas), hide the tooltip because we have link-text */
  .sidebar.open a.nav-item .tooltip {
     display: none !important;
  }

  /* For dropdowns (div.nav-item), we want to show the items */
  .sidebar.open div.nav-item {
      display: flex;
      flex-direction: column;
      height: auto;
      align-items: flex-start;
      padding-top: 1rem;
      padding-bottom: 1rem;
  }
  
  .sidebar.open div.nav-item > i {
      margin-bottom: 0.5rem;
  }
  
  .sidebar.open div.nav-item .link-text {
      margin-bottom: 0.5rem;
      font-weight: bold;
  }

  .sidebar.open div.nav-item .tooltip {
      display: block; /* Show the container */
      padding-left: 2rem;
  }
  
  .sidebar.open .tooltip-title {
      display: none; /* Hide the title in tooltip as we have link-text */
  }
  
  .sidebar.open .tooltip-items {
      background: transparent;
      padding: 0;
      gap: 0.8rem;
  }
  
  .sidebar.open .tooltip-item {
      color: var(--sidebar-fg);
      font-size: 0.9rem;
  }
  
  .sidebar.open .tooltip-item:hover {
      color: #fff;
  }

  /* Reset content margin on mobile */
  .content {
    margin-left: 0;
    padding: 1rem;
    padding-top: 5rem; /* Space for the toggle button */
  }
  
  /* Overlay */
  #sidebar-overlay.show {
      display: block !important;
  }
}


