/* Hide toggle button on desktop */
.sidebar-nav li.sidebar-toggle {
  display: none;
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed !important;
    left: 0;
    top: 0;
    height: 100vh;
    width: 40px !important;
    z-index: 1000;
    background-color: #f5f5e8;
    overflow: hidden;
    transition: width 0.25s ease;
    box-shadow: 2px 0 6px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
  }

  .sidebar.sidebar-open {
    width: 14rem !important;
  }

  .main-wrapper {
    margin-left: 48px;
  }

  .sidebar-nav {
    flex-grow: 1;
    overflow-y: auto;
    padding-top: 10px;
  }

  .sidebar-nav li {
    justify-content: center;
    margin-bottom: 10px;
  }

  .sidebar-nav li::before {
    display: none !important;
  }

  .sidebar-nav a {
    display: block;
    width: 24px;
    height: 24px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    white-space: nowrap;
    overflow: hidden;
  }

  .sidebar:not(.sidebar-open) .sidebar-nav a {
    font-size: 0;
    color: transparent;
  }

  /* Per-item icons (collapsed state) */
  .sidebar-nav li:nth-child(1) a { background-image: url('../images/bootstrap-icons-1.13.1/house.svg'); }
  .sidebar-nav li:nth-child(2) a { background-image: url('../images/bootstrap-icons-1.13.1/yin-yang.svg'); }
  .sidebar-nav li:nth-child(3) a { background-image: url('../images/bootstrap-icons-1.13.1/clipboard2-pulse.svg'); }
  .sidebar-nav li:nth-child(4) a { background-image: url('../images/bootstrap-icons-1.13.1/plug.svg'); }
  .sidebar-nav li:nth-child(5) a { background-image: url('../images/bootstrap-icons-1.13.1/diagram-2.svg'); }
  .sidebar-nav li:nth-child(6) a { background-image: url('../images/bootstrap-icons-1.13.1/person-arms-up.svg'); }
  .sidebar-nav li:nth-child(7) a { background-image: url('../images/bootstrap-icons-1.13.1/camera.svg'); }
  .sidebar-nav li:nth-child(8) a { background-image: url('../images/bootstrap-icons-1.13.1/envelope.svg'); }

  /* Expanded state */
  .sidebar.sidebar-open .sidebar-nav li {
    justify-content: flex-start;
    padding-left: 8px;
  }

  .sidebar.sidebar-open .sidebar-nav li::before {
    display: inline-block !important;
  }

  .sidebar.sidebar-open .sidebar-nav li.sidebar-toggle::before {
    display: none !important;
  }

  .sidebar.sidebar-open .sidebar-nav a {
    width: auto;
    height: auto;
    font-size: 0.9rem;
    color: black;
    background-image: none;
  }

  /* Toggle button */
  .sidebar-nav li.sidebar-toggle {
    display: flex;
    justify-content: center;
    padding: 10px 0;
    border-top: 1px solid #ccc;
    flex-shrink: 0;
  }

  .sidebar-toggle a {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 28px !important;
    height: 28px !important;
    font-size: 0.85rem !important;
    font-weight: bold;
    color: black !important;
    background-image: none !important;
    text-decoration: none;
    border: 1px solid #aaa;
    border-radius: 3px;
  }

  .sidebar.sidebar-open .sidebar-toggle {
    justify-content: flex-end;
    padding-right: 8px;
  }

  .sidebar.sidebar-open .sidebar-toggle a {
    width: auto !important;
    padding: 3px 8px;
  }
}
