/* Sidebar Layout - Sticky Header with Scrollable Menu */

.nav-sidebar .nav-link {
    position: relative;
    display: flex;
    align-items: center;
}

.pin-toggle { 
    opacity: 0;
    transition: opacity 0.2s ease, color 0.2s ease;
    padding: 2px 6px;
    background: transparent;
    border: none;
    color: #6c757d;
    cursor: pointer;
    margin-left: auto;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.nav-sidebar .nav-link:hover .pin-toggle,
.nav-sidebar .nav-link:focus-within .pin-toggle,
.pin-toggle.is-pinned,
.pin-toggle:focus {
    opacity: 1;
}

.pin-toggle:hover {
    color: #ffc107;
}

.pin-toggle.is-pinned,
.pin-toggle.pinned i {
    color: #f39c12;
}

.pin-toggle.is-pinned i {
    transform: rotate(35deg);
}

.pin-toggle i {
    transition: transform 0.2s ease;
}

/* Main sidebar structure */
.main-sidebar {
    display: flex !important;
    flex-direction: column !important;
    height: 100vh !important;
    overflow: hidden !important;
    position: fixed !important;
}

/* Sticky header section - logo, user, search, and pinned items */
.sidebar-sticky-header {
    flex-shrink: 0;
    background-color: #343a40;
    z-index: 30;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

/* Brand/logo link styling */
.sidebar-sticky-header .brand-link {
    display: flex;
    align-items: center;
    padding: 0.8125rem 0.5rem;
    font-size: 1.25rem;
    line-height: 1.5;
    white-space: nowrap;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* User panel in sticky header */
.sidebar-sticky-header .user-panel {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-sticky-header .user-panel .image {
    padding-left: 0.4rem;
}

.sidebar-sticky-header .user-panel .info {
    padding-left: 0.75rem;
}

/* Search box in sticky header */
.sidebar-sticky-header .sidebar-search-wrapper {
    padding: 0.5rem 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-sticky-header .sidebar-search-wrapper .input-group {
    width: 100%;
}

/* Pinned section in sticky header */
.sidebar-sticky-header .pinned-section {
    padding: 0;
}

.sidebar-sticky-header .pinned-header-label {
    padding: 0.5rem 1rem 0.25rem 1rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.6);
    margin: 0;
}

.sidebar-sticky-header .pinned-items-list {
    margin: 0;
    padding: 0 0 0.5rem 0;
}

.sidebar-sticky-header .pinned-items-list .nav-item {
    margin: 0;
}

.sidebar-sticky-header .pinned-items-list .nav-link {
    padding: 0.5rem 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.sidebar-sticky-header .pinned-items-list .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.sidebar-sticky-header .pinned-items-list .pin-toggle {
    opacity: 0.8;
}

.sidebar-sticky-header .pinned-items-list .nav-link:hover .pin-toggle,
.sidebar-sticky-header .pinned-items-list .pin-toggle.is-pinned,
.sidebar-sticky-header .pinned-items-list .pin-toggle:focus {
    opacity: 1;
}

/* Only show border when pinned section has content */
.sidebar-sticky-header .pinned-section:not(:empty) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

/* Hide border when no pinned items */
.sidebar-sticky-header .pinned-section:has(#pinned-header[style*="display:none"]),
.sidebar-sticky-header .pinned-section:has(#pinned-header[style*="display: none"]) {
    border-bottom: none;
}

/* Scrollable sidebar menu section */
.main-sidebar .sidebar {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    scroll-behavior: auto;
    -webkit-overflow-scrolling: touch;
}

/* Navigation menu styling */
.main-sidebar .sidebar > nav {
    padding-bottom: 1rem;
}

/* Scrollbar styling for sidebar */
.main-sidebar .sidebar::-webkit-scrollbar {
    width: 6px;
}

.main-sidebar .sidebar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.main-sidebar .sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.main-sidebar .sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Dark mode support */
.dark-mode .sidebar-sticky-header {
    background-color: #1e2738;
}

.dark-mode .sidebar-sticky-header .brand-link,
.dark-mode .sidebar-sticky-header .user-panel,
.dark-mode .sidebar-sticky-header .sidebar-search-wrapper,
.dark-mode .sidebar-sticky-header .pinned-section {
    border-color: rgba(255, 255, 255, 0.1);
}

/* Sidebar collapsed state adjustments */
.sidebar-collapse .sidebar-sticky-header .user-panel .info,
.sidebar-collapse .sidebar-sticky-header .sidebar-search-wrapper,
.sidebar-collapse .sidebar-sticky-header .pinned-header-label {
    display: none;
}

.sidebar-collapse .sidebar-sticky-header .pinned-items-list .nav-link p {
    display: none;
}

/* Ensure proper stacking on mobile */
@media (max-width: 991.98px) {
    .main-sidebar {
        height: 100%;
    }
    
    .sidebar-sticky-header {
        flex-shrink: 0;
    }
}
