/* Sidebar Styles for Bootstrap 5 */

.sidebar {
	position: fixed;
	top: 56px;
	left: 0;
	z-index: 999;
	padding: 20px 0;
	overflow-y: auto;
	overflow-x: visible;
	background-color: #212529;
	height: calc(100vh - 56px);
	width: 25%;
}

/* Sidebar Menu Items */
.sidebar-main {
	list-style: none;
	padding-left: 0;
}

.sidebar-main .list-group-item {
	border: 1px solid #1a1d20;
	border-bottom: none;
	border-radius: 0;
	padding: 10px 15px;
	margin-bottom: 0;
}

/* Remove top border from first menu item */
.sidebar-main .list-group-item:first-child {
	border-top: none;
}

/* Add bottom border only to the last main menu item */
.sidebar-main .list-group-item:last-child {
	border-bottom: 1px solid #1a1d20;
}

/* Remove the duplicate border-bottom rule for Tools */
a[href="#sub_setting"].list-group-item {
	border-bottom: 1px solid #1a1d20;
}

.sidebar-main .list-group-item:hover {
	background-color: rgba(255, 255, 255, 0.1);
}

/* Collapse Submenu */
.sidebar-submenu {
	padding-left: 0;
	padding-top: 0;
	padding-bottom: 0;
	margin-top: 0;
	margin-bottom: 0;
	border-bottom: 1px solid #1a1d20;
}

.sidebar-submenu .list-group-item {
	border: 1px solid #1a1d20;
	border-bottom: none;
	border-radius: 0;
	padding: 8px 15px;
	padding-left: 40px;
	font-size: 0.9rem;
	margin: 0;
}

/* Remove top border from first submenu item */
.sidebar-submenu .list-group-item:first-child {
	border-top: none;
}

/* Restore border-top for first direct links (not inside dropend) */
.sidebar-submenu > a.list-group-item:first-of-type {
	border-top: 1px solid #1a1d20;
}

/* Remove top border from first direct link of last main menu item submenu (Tasks in Tools) */
#sub_setting > a.list-group-item:first-of-type {
	border-top: none;
}

/* Restore top border for items inside dropend (e.g., Azienda, Dipendente, Committente) */
.sidebar-submenu .dropend > a.list-group-item {
	border-top: 1px solid #1a1d20;
}

/* Don't add bottom border to last submenu item - border is on container */
.sidebar-submenu .list-group-item:last-child {
	border-bottom: none;
}

/* Remove top border from menu item that follows a submenu to avoid double lines */
.sidebar-submenu + a.list-group-item {
	border-top: none;
}

.sidebar-submenu .list-group-item:hover {
	border-left-color: #0d6efd;
	background-color: rgba(255, 255, 255, 0.05);
}

/* Dropdown Menu in Sidebar */
.sidebar .dropend {
	position: relative;
	overflow: visible;
}

.sidebar .dropend > .dropdown-menu {
	position: fixed !important;
	z-index: 2000 !important;
}

.sidebar .dropdown-menu {
	background-color: #343a40;
	border: 1px solid #495057;
	border-top: none;
	min-width: 180px;
}

.sidebar .dropdown-item {
	color: #e9ecef;
	padding: 0.5rem 1rem;
}

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

/* Media queries for responsive dropdown positioning */
@media (min-width: 768px) {
	.sidebar {
		width: 16.666%;
	}
}

@media (max-width: 767px) {
	.sidebar {
		display: none;
	}
}

.sidebar .dropdown-item.active,
.sidebar .dropdown-item:active {
	background-color: #0d6efd;
	color: #fff;
}

/* Fix for nested dropdowns display */
.sidebar .dropend {
	position: relative;
}

/* Ensure Bootstrap navbar doesn't cover sidebar content */
@media (min-width: 576px) {
	.sidebar {
		width: 25%;
		padding-top: 80px; /* Account for fixed navbar */
		max-height: calc(100vh - 80px);
		box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.1);
	}
}

@media (min-width: 768px) {
	.sidebar {
		width: 16.66667%;
	}
}

@media (min-width: 992px) {
	.sidebar {
		width: 16.66667%;
	}
}
