/* ======================================================
   SIDEBAR BASE
====================================================== */

#sidebar {
  width: 64px;
  transition: width 0.25s ease;
}

/* Expand on hover (desktop) */
#sidebar:hover {
  width: 240px;
}

/* ======================================================
   LABEL VISIBILITY
====================================================== */

/* Hidden when collapsed */
#sidebar .sidebar-label {
  opacity: 0;
  transform: translateX(-10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
}

/* Visible on expand */
#sidebar:hover .sidebar-label {
  opacity: 1;
  transform: translateX(0);
}

/* ======================================================
   ICONS
====================================================== */

.sidebar-icon {
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  flex-shrink: 0;
  display: block;
}

/* ======================================================
   COLLAPSED STATE (DESKTOP)
====================================================== */

#sidebar:not(:hover) .sidebar-item {
  justify-content: center !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

#sidebar:not(:hover) .sidebar-icon {
  margin-left: auto !important;
  margin-right: auto !important;
}

/* Expanded spacing */
#sidebar:hover .sidebar-item {
  justify-content: flex-start !important;
  padding-left: 12px !important;
  padding-right: 12px !important;
}

/* ======================================================
   PLANS LIST — STYLED ITEMS
====================================================== */

#plans_list_sidebar button {
  display: flex;
  align-items: center;
  gap: 12px;

  padding: 8px 12px;
  border-radius: 10px;

  /* NEW */
  border: 1px solid #e5e7eb;            /* subtle gray border */
  background: #ffffff;

  font-weight: 600;                     /* 🔥 increased boldness */
  font-size: 13px;
  color: #0f172a;

  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    transform 0.15s ease;
}

/* Hover state */
#plans_list_sidebar button:hover {
  background: #f3f6ff;
  border-color: #4f6df5;               /* accent */
  transform: translateX(2px);          /* subtle motion */
}

/* Icon inside plan */
#plans_list_sidebar .sidebar-icon {
  opacity: 0.9;
}

/* Plan label */
#plans_list_sidebar .sidebar-label {
  font-weight: 600;                    /* ensure label stays bold */
  letter-spacing: 0.01em;
}

/* Collapsed sidebar — keep plans clean */
#sidebar:not(:hover) #plans_list_sidebar button {
  border: none;
  background: transparent;
}

/* Mobile — full width cards */
@media (max-width: 768px) {
  #plans_list_sidebar button {
    border-radius: 12px;
  }
}

/* ======================================================
   DESKTOP BEHAVIOR
====================================================== */

@media (min-width: 769px) {
  /* Hide labels & plans when collapsed */
  #sidebar:not(:hover) .sidebar-label,
  #sidebar:not(:hover) #plans_list_sidebar,
  #sidebar:not(:hover) .plans-header {
    display: none !important;
  }

  /* Show on hover */
  #sidebar:hover #plans_list_sidebar,
  #sidebar:hover .plans-header {
    display: block !important;
  }
}

/* ======================================================
   MOBILE BEHAVIOR
====================================================== */

@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    top: 0;
    left: -260px;
    width: 260px !important;
    height: 100vh;
    z-index: 40;
    transition: left 0.3s ease;
  }

  #sidebar.open {
    left: 0;
  }

  /* Disable hover resize on mobile */
  #sidebar:hover {
    width: 260px !important;
  }

  #sidebar.open .sidebar-label {
    display: inline !important;
    opacity: 1 !important;
    transform: none !important;
  }

  #sidebar.open .sidebar-item {
    justify-content: flex-start !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  #sidebar.open .sidebar-icon {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  #sidebar.open #plans_list_sidebar,
  #sidebar.open .plans-header {
    display: block !important;
  }

  /* Dark overlay */
  body.sidebar-open::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 35;
  }
}

/* ======================================================
   NON-PLAN SIDEBAR ACTIONS — NO BORDERS
====================================================== */

/* Remove borders from action buttons */
#sidebar .sidebar-item {
  border: none !important;
  background: transparent;
}

/* Keep hover subtle for actions */
#sidebar .sidebar-item:hover {
  background: #f3f4f6;
}

/* Ensure plans keep their borders */
#plans_list_sidebar .sidebar-item,
#plans_list_sidebar button {
  border: 1px solid #e5e7eb !important;
  background: #ffffff;
}

#sidebar {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 🔑 Allow header+nav container to shrink so nav can scroll */
#sidebar > .p-4:first-child {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0; /* ⭐ CRITICAL */
}

#sidebar nav {
  flex: 1;                     /* ✅ takes remaining height */
  overflow-y: auto;            /* ✅ vertical scrolling */
  overflow-x: hidden;
  padding-bottom: 16px;        /* space above logout */
}

#sidebar nav::-webkit-scrollbar {
  width: 6px;
}

#sidebar nav::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.15);
  border-radius: 6px;
}

#sidebar nav::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.25);
}
/* Keep logout always visible */
#sidebar > .p-4:last-child {
  flex-shrink: 0;
  border-top: 1px solid #e5e7eb;
  background: white;
}
