/* Enhanced Navigation System */

/* Hide old navigation elements first to prevent conflicts */
.sidebar-nav,
.bottom-nav {
    display: none !important;
}

/* Hamburger Button */
.hamburger-btn {
    display: none;
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1002;
    background: var(--color-accent, #1d9bf0);
    border: none;
    border-radius: 8px;
    width: 50px;
    height: 50px;
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.hamburger-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.hamburger-line {
    width: 25px;
    height: 3px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.hamburger-btn.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger-btn.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

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

/* Navigation Overlay */
.nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.nav-overlay.active {
    display: block;
}

/* Main Navigation Container */
.main-navigation {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 200px;
    background: var(--color-panel, #ffffff);
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.1);
    z-index: 1001;
    display: none; /* Hidden by default */
    flex-direction: column;
    transition: transform 0.3s ease;
    border-right: 1px solid var(--color-border, #e1e8ed);
    transform: translateX(-100%);
}

/* Show navigation when active */
.main-navigation.active {
    display: flex;
    transform: translateX(0);
}

/* Navigation Header */
.nav-header {
    padding: 20px;
    border-bottom: 1px solid var(--color-border, #e1e8ed);
    background: linear-gradient(135deg, var(--color-accent, #1d9bf0) 0%, #1a8cd8 100%);
}

.profile-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: white;
    transition: opacity 0.2s ease;
}

.profile-link:hover {
    opacity: 0.9;
}

.profile-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.profile-avatar-icon {
    font-size: 40px;
    opacity: 0.9;
}

.profile-username {
    font-weight: 600;
    font-size: 16px;
}

/* Navigation Modules Container */
.nav-modules-container {
    flex: 1;
    overflow: hidden;
    padding: 10px 0;
}

.nav-modules-list {
    height: 100%;
    overflow-y: auto;
    padding: 0 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--color-accent, #1d9bf0) transparent;
}

.nav-modules-list::-webkit-scrollbar {
    width: 6px;
}

.nav-modules-list::-webkit-scrollbar-track {
    background: transparent;
}

.nav-modules-list::-webkit-scrollbar-thumb {
    background: var(--color-accent, #1d9bf0);
    border-radius: 3px;
}

.nav-modules-list::-webkit-scrollbar-thumb:hover {
    background: var(--color-accent-dark, #1a8cd8);
}

/* Module Items */
.nav-module {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 15px;
    margin: 4px 0;
    border-radius: 12px;
    text-decoration: none;
    color: var(--color-text, #0f1419);
    transition: all 0.2s ease;
    border: 1px solid transparent;
    position: relative;
    cursor: pointer;
}

.nav-module:hover {
    background: var(--color-hover, #f7f9fa);
    border-color: var(--color-accent, #1d9bf0);
    transform: translateX(5px);
}

.nav-module.active {
    background: linear-gradient(135deg, var(--color-accent, #1d9bf0) 0%, #1a8cd8 100%);
    color: white;
    box-shadow: 0 2px 10px rgba(29, 155, 240, 0.3);
}

.nav-module-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.nav-module-disabled:hover {
    background: none;
    border-color: transparent;
    transform: none;
}

.nav-module i {
    font-size: 20px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.module-name {
    font-weight: 500;
    font-size: 15px;
    white-space: nowrap;
}

/* Core vs Optional Module Styling */
.core-module {
    border-left: 3px solid var(--color-accent, #1d9bf0);
}

.optional-module {
    border-left: 3px solid var(--color-secondary, #657786);
    opacity: 0.9;
}

.optional-module:hover {
    opacity: 1;
}

/* Module Color Coding */
.nav-module:nth-child(1) i { color: #ff6b6b; }
.nav-module:nth-child(2) i { color: #4ecdc4; }
.nav-module:nth-child(3) i { color: #45b7d1; }
.nav-module:nth-child(4) i { color: #96ceb4; }
.nav-module:nth-child(5) i { color: #ffd93d; }
.nav-module:nth-child(6) i { color: #6bcf7f; }
.nav-module:nth-child(7) i { color: #ff8e53; }
.nav-module:nth-child(8) i { color: #a8e6cf; }
.nav-module:nth-child(9) i { color: #dda0dd; }
.nav-module:nth-child(10) i { color: #ffb3ba; }

/* Navigation Footer */
.nav-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--color-border, #e1e8ed);
    background: var(--color-background, #ffffff);
}

.nav-footer-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    margin: 4px 0;
    border-radius: 8px;
    text-decoration: none;
    color: var(--color-text, #0f1419);
    transition: all 0.2s ease;
    background: none;
    border: none;
    width: 100%;
    cursor: pointer;
    font-size: 14px;
}

.nav-footer-item:hover {
    background: var(--color-hover, #f7f9fa);
}

.logout-form {
    margin: 0;
    padding: 0;
}

.logout-btn {
    text-align: left;
}

.footer-item-name {
    font-weight: 500;
}

.user-count {
    text-align: center;
    margin-top: 10px;
    padding: 8px;
    background: var(--color-hover, #f7f9fa);
    border-radius: 8px;
    font-size: 12px;
    color: var(--color-text-muted, #657786);
}

.user-count i {
    margin-right: 5px;
}

/* Mobile Bottom Navigation */
.bottom-nav-mobile {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--color-panel, #ffffff);
    border-top: 1px solid var(--color-border, #e1e8ed);
    z-index: 999;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--color-text-muted, #657786);
    transition: all 0.2s ease;
    padding: 8px;
    border-radius: 8px;
    min-width: 50px;
}

.bottom-nav-item:hover,
.bottom-nav-item.active {
    color: var(--color-accent, #1d9bf0);
    background: rgba(29, 155, 240, 0.1);
}

.bottom-nav-item i {
    font-size: 18px;
    margin-bottom: 2px;
}

.bottom-nav-label {
    font-size: 10px;
    font-weight: 500;
}

/* Drag and Drop Styles */
.drag-handle {
    position: absolute;
    left: 5px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted, #666);
    cursor: grab;
    opacity: 0;
    transition: opacity 0.2s ease;
    font-size: 12px;
    z-index: 2;
}

.nav-module:hover .drag-handle {
    opacity: 1;
}

.drag-handle:active {
    cursor: grabbing;
}

.nav-module {
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.nav-module.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    z-index: 1000;
}

.nav-module.drag-over {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(29, 155, 240, 0.3);
    border-left: 3px solid var(--color-accent, #1d9bf0);
}

.nav-module.dragging .drag-handle {
    opacity: 1;
}

/* Navigation Drag Handle */
.nav-drag-handle {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.7);
    cursor: grab;
    font-size: 16px;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.nav-drag-handle:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
}

.nav-drag-handle:active {
    cursor: grabbing;
}

/* Right side navigation positioning */
.main-navigation.nav-right {
    left: auto;
    right: 0;
    transform: translateX(100%);
    border-left: 1px solid var(--color-border, #e1e8ed);
    border-right: none;
    box-shadow: -2px 0 20px rgba(0, 0, 0, 0.1);
}

.main-navigation.nav-right.active {
    transform: translateX(0);
}

.hamburger-btn.hamburger-right {
    left: auto;
    right: 20px;
}

/* Drag feedback animations */
@keyframes dragPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.nav-module.drag-over {
    animation: dragPulse 0.5s ease-in-out;
}

/* Responsive Design */
@media (min-width: 1101px) {
    .main-navigation {
        display: flex;
        transform: translateX(0);
    }
    
    .hamburger-btn {
        display: none;
    }
    
    .bottom-nav-mobile {
        display: none;
    }
    
    /* Adjust content margins for sidebar */
    .content,
    .content2 {
        margin-left: 5px;
    }
}

@media (max-width: 1100px) and (min-width: 769px) {
    .main-navigation {
        display: flex;
        transform: translateX(-100%);
    }
    
    .main-navigation.active {
        transform: translateX(0);
    }
    
    .hamburger-btn {
        display: flex;
    }
    
    .bottom-nav-mobile {
        display: none;
    }
}

@media (max-width: 768px) {
    /* Show mobile navigation elements */
    .hamburger-btn {
        display: flex !important;
    }
    
    .main-navigation {
        display: flex;
        width: 100%;
        max-width: 320px;
        transform: translateX(-100%);
    }
    
    .main-navigation.active {
        transform: translateX(0);
    }
    
    .bottom-nav-mobile {
        display: flex;
    }
    
    /* Adjust content for bottom nav */
    .content,
    .content2 {
        margin-bottom: 60px;
        margin-left: 0;
    }
    
    .drag-handle {
        opacity: 1;
        left: 8px;
        font-size: 14px;
    }
    
    .nav-drag-handle {
        font-size: 18px;
        padding: 8px;
        right: 10px;
    }
    
    .nav-module {
        padding-left: 35px; /* Make room for drag handle */
    }
}

@media (max-width: 480px) {
    .main-navigation {
        width: 100%;
        max-width: 280px;
    }
    
    .nav-header {
        padding: 15px;
    }
    
    .profile-avatar,
    .profile-avatar-icon {
        width: 35px;
        height: 35px;
        font-size: 35px;
    }
    
    .profile-username {
        font-size: 14px;
    }
    
    .nav-module {
        padding: 10px 12px;
        gap: 12px;
    }
    
    .module-name {
        font-size: 14px;
    }
    
    .bottom-nav-item i {
        font-size: 16px;
    }
    
    .bottom-nav-label {
        font-size: 9px;
    }
}

/* Hide old navigation elements */
.sidebar-nav {
    display: none !important;
}

.bottom-nav {
    display: none !important;
}

/* Smooth animations */
@keyframes slideIn {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

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

.main-navigation.slide-in {
    animation: slideIn 0.3s ease;
}

.main-navigation.slide-out {
    animation: slideOut 0.3s ease;
}

/* Focus states for accessibility */
.hamburger-btn:focus,
.nav-module:focus,
.nav-footer-item:focus,
.bottom-nav-item:focus {
    outline: 2px solid var(--color-accent, #1d9bf0);
    outline-offset: 2px;
}

/* Loading state */
.nav-modules-list.loading {
    opacity: 0.6;
    pointer-events: none;
}

.nav-modules-list.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--color-accent, #1d9bf0);
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Mobile drag improvements */
@media (max-width: 768px) {
    .drag-handle {
        opacity: 1;
        left: 8px;
        font-size: 14px;
    }
    
    .nav-drag-handle {
        font-size: 18px;
        padding: 8px;
        right: 10px;
    }
    
    .nav-module {
        padding-left: 35px; /* Make room for drag handle */
    }
}

/* Drag instruction tooltip */
.drag-handle::after {
    content: "Drag to reorder";
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    margin-left: 8px;
    z-index: 1001;
}

.drag-handle:hover::after {
    opacity: 1;
}

.nav-drag-handle::after {
    content: "Drag to move navigation";
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    margin-right: 8px;
    z-index: 1001;
}

.nav-drag-handle:hover::after {
    opacity: 1;
}
