/* Comprehensive Sidebar Toggle Styles */

/* Sidebar Animation Base */
.sidebar-animated {
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                margin-left 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                width 0.3s ease;
    will-change: transform, margin-left;
}

/* Sidebar States */
.sidebar-open {
    transform: translateX(0);
}

.sidebar-closed {
    transform: translateX(-100%);
}

/* Toggle Button Styles */
.sidebar-toggle-btn {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    z-index: 1000;
}

.sidebar-toggle-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.sidebar-toggle-btn:active {
    transform: scale(0.95);
}

/* Hamburger Icon */
.hamburger-icon {
    width: 20px;
    height: 16px;
    position: relative;
    cursor: pointer;
}

.hamburger-icon .line {
    display: block;
    height: 2px;
    width: 100%;
    background: #ffffff;
    border-radius: 1px;
    position: absolute;
    left: 0;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform-origin: center;
}

.hamburger-icon .line-1 {
    top: 0;
}

.hamburger-icon .line-2 {
    top: 7px;
}

.hamburger-icon .line-3 {
    top: 14px;
}

/* Hamburger Animation - Active State */
.hamburger-icon.active .line-1 {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger-icon.active .line-2 {
    opacity: 0;
    transform: scaleX(0);
}

.hamburger-icon.active .line-3 {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* Header Toggle Button */
.header-toggle-btn {
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.header-toggle-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Sidebar Close Button */
.sidebar-close-btn {
    transition: all 0.2s ease;
    z-index: 10;
}

.sidebar-close-btn:hover {
    transform: scale(1.1);
}

.sidebar-close-btn:active {
    transform: scale(0.9);
}

/* Sidebar Overlay */
.sidebar-overlay {
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

/* Resize Handle */
.sidebar-resize-handle {
    transition: all 0.2s ease;
    z-index: 10;
}

.sidebar-resize-handle:hover {
    width: 4px;
    background: var(--primary-accent);
}

.sidebar-resize-handle:active {
    background: var(--secondary-accent);
}

/* Main Content Transitions */
.main-content {
    transition: margin-left 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: margin-left;
}

/* Responsive Behavior */
@media (max-width: 1023px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 45;
        transform: translateX(-100%);
    }
    
    .sidebar-open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0 !important;
    }
    
    .sidebar-toggle-btn {
        display: flex;
    }
    
    .header-toggle-btn {
        display: none !important;
    }
    
    .sidebar-resize-handle {
        display: none;
    }
}

@media (min-width: 1024px) {
    .sidebar {
        position: relative;
        transform: none;
    }
    
    .sidebar-closed {
        margin-left: -280px;
    }
    
    .sidebar-toggle-btn {
        display: none;
    }
    
    .sidebar-overlay {
        display: none;
    }
    
    .sidebar-close-btn {
        display: none;
    }
}

/* Animation Enhancements */
@keyframes slideInFromLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutToLeft {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(-100%);
        opacity: 0;
    }
}

.sidebar.animate-in {
    animation: slideInFromLeft 0.3s ease-out;
}

.sidebar.animate-out {
    animation: slideOutToLeft 0.3s ease-in;
}

/* Focus States for Accessibility */
.sidebar-toggle-btn:focus {
    outline: 2px solid var(--primary-accent);
    outline-offset: 2px;
}

.sidebar-close-btn:focus {
    outline: 2px solid var(--primary-accent);
    outline-offset: 2px;
}

.header-toggle-btn:focus {
    outline: 2px solid var(--primary-accent);
    outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .hamburger-icon .line {
        background: currentColor;
        height: 3px;
    }
    
    .sidebar-toggle-btn {
        border: 2px solid currentColor;
    }
    
    .sidebar-overlay {
        background: rgba(0, 0, 0, 0.8);
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .sidebar-animated,
    .main-content,
    .sidebar-toggle-btn,
    .hamburger-icon .line,
    .sidebar-overlay {
        transition: none !important;
        animation: none !important;
    }
    
    .sidebar-toggle-btn:hover {
        transform: none;
    }
}

/* Dark/Light Theme Adjustments */
.light-theme .sidebar-toggle-btn {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.1);
    color: #1f2937;
}

.light-theme .hamburger-icon .line {
    background: #1f2937;
}

.light-theme .sidebar-overlay {
    background: rgba(255, 255, 255, 0.8);
}

.dark-theme .sidebar-toggle-btn {
    background: rgba(26, 27, 35, 0.9);
    border-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.dark-theme .hamburger-icon .line {
    background: #ffffff;
}

.dark-theme .sidebar-overlay {
    background: rgba(0, 0, 0, 0.6);
}

/* Loading State */
.sidebar-loading {
    pointer-events: none;
    opacity: 0.7;
}

.sidebar-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top: 2px solid var(--primary-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Sidebar Width Variants */
.sidebar-narrow {
    width: 200px !important;
}

.sidebar-normal {
    width: 280px !important;
}

.sidebar-wide {
    width: 350px !important;
}

/* Mini Sidebar Mode */
.sidebar-mini {
    width: 60px !important;
    overflow: hidden;
}

.sidebar-mini .nav-item span {
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.2s ease;
}

.sidebar-mini:hover {
    width: 280px !important;
}

.sidebar-mini:hover .nav-item span {
    opacity: 1;
    transform: translateX(0);
}

/* Sidebar Sections Collapse */
.sidebar-section.collapsed .nav-section-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.sidebar-section:not(.collapsed) .nav-section-content {
    max-height: 1000px;
    transition: max-height 0.3s ease;
}

/* Sidebar Search Integration */
.sidebar-search {
    position: sticky;
    top: 0;
    background: inherit;
    z-index: 10;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-search input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    background: var(--surface-bg);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.sidebar-search input:focus {
    outline: none;
    border-color: var(--primary-accent);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Navigation Item Enhancements */
.nav-item {
    position: relative;
    transition: all 0.2s ease;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary-accent);
    transform: scaleY(0);
    transition: transform 0.2s ease;
}

.nav-item.active::before,
.nav-item:hover::before {
    transform: scaleY(1);
}

/* Tooltip for Mini Sidebar */
.sidebar-mini .nav-item {
    position: relative;
}

.sidebar-mini .nav-item:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    white-space: nowrap;
    z-index: 1000;
    margin-left: 0.5rem;
    opacity: 0;
    animation: tooltipFadeIn 0.2s ease-out forwards;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateY(-50%) translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }
}

/* Print Styles */
@media print {
    .sidebar-toggle-btn,
    .sidebar-overlay,
    .sidebar-close-btn,
    .header-toggle-btn {
        display: none !important;
    }
    
    .sidebar {
        position: static !important;
        transform: none !important;
        width: auto !important;
        height: auto !important;
    }
    
    .main-content {
        margin-left: 0 !important;
    }
}

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

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

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

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

/* Sidebar Footer Enhancements */
.sidebar-footer {
    margin-top: auto;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Collapsible Sidebar Sections */
.nav-section-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-section-toggle:hover {
    color: var(--text-primary);
    background: var(--surface-bg);
}

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

.nav-section.collapsed .nav-section-toggle i {
    transform: rotate(-90deg);
}