/* ===========================
   Sidebar Navigation Styles
   Based on Dark Theme Design
   =========================== */

.sidebar {
    width: var(--sidebar-width);
    background: var(--color-dark-blue);
    color: var(--color-white);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
}

.sidebar.collapsed:hover {
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.25);
}

/* Smooth transition for main content when sidebar expands/collapses */
#main-content {
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===========================
   Search Bar
   =========================== */

.sidebar-search {
    padding: var(--spacing-md);
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.sidebar-search i {
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
}

.sidebar-search input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--color-white);
    outline: none;
    font-size: 13px;
    opacity: 1;
    transition: opacity 0.2s ease, width 0.2s ease;
}

.sidebar-search input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.sidebar.collapsed .sidebar-search input {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

/* ===========================
   Navigation Menu
   =========================== */

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--spacing-sm) 0;
}

/* Navigation Items */
.nav-item {
    display: flex;
    align-items: center;
    padding: 12px var(--spacing-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    color: rgba(255, 255, 255, 0.8);
    white-space: nowrap;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--color-white);
}

.nav-item.active {
    background: rgba(74, 144, 226, 0.2);
    color: var(--color-white);
    border-left: 3px solid var(--color-primary-blue);
}

.nav-item i:first-child {
    width: 20px;
    text-align: center;
    margin-right: var(--spacing-md);
    font-size: 16px;
    transition: transform 0.2s ease, font-size 0.2s ease;
}

.sidebar.collapsed .nav-item i:first-child {
    font-size: 18px;
    margin-right: 0;
}

.sidebar.collapsed .nav-item:hover i:first-child {
    transform: scale(1.1);
}

.nav-item span {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.nav-item .toggle-icon {
    margin-left: auto;
    font-size: 12px;
    transition: transform var(--transition-fast), opacity 0.2s ease;
    opacity: 1;
}

.nav-item.expanded .toggle-icon {
    transform: rotate(180deg);
}

.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-item .toggle-icon {
    opacity: 0;
    width: 0;
    overflow: hidden;
    transition: opacity 0.15s ease, width 0.15s ease;
}

/* Submenu */
.submenu {
    max-height: 0;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.2);
    transition: max-height var(--transition-normal);
}

.submenu.expanded {
    max-height: 500px;
}

.submenu-item {
    display: block;
    padding: 10px var(--spacing-md) 10px 52px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    transition: all var(--transition-fast);
    border-left: 2px solid transparent;
}

.submenu-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-white);
    border-left-color: var(--color-primary-blue);
}

.submenu-item.active {
    background: rgba(74, 144, 226, 0.15);
    color: var(--color-primary-blue);
    font-weight: 600;
    border-left-color: var(--color-primary-blue);
}

.sidebar.collapsed .submenu {
    display: none;
}

/* ===========================
   Submenu Popup (for collapsed state)
   =========================== */

.submenu-popup {
    position: fixed;
    left: var(--sidebar-collapsed-width);
    background: var(--color-dark-blue);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: var(--spacing-sm) 0;
    min-width: 200px;
    z-index: 1001;
    display: none;
}

.submenu-popup.active {
    display: block;
}

.submenu-popup .submenu-item {
    padding: 10px var(--spacing-md);
}

/* ===========================
   Sidebar Toggle Button
   =========================== */

.sidebar-toggle {
    position: absolute;
    right: -12px;
    top: 20px;
    width: 24px;
    height: 24px;
    background: var(--color-primary-blue);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-fast);
}

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

.sidebar-toggle i {
    font-size: 12px;
}

.sidebar.collapsed .sidebar-toggle i {
    transform: rotate(180deg);
}

/* ===========================
   Sidebar Footer (Optional)
   =========================== */

.sidebar-footer {
    padding: var(--spacing-md);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
}

.sidebar-footer .nav-item {
    padding: var(--spacing-sm);
}

/* ===========================
   Responsive Adjustments
   =========================== */

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    /* Backdrop for mobile */
    .sidebar-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        display: none;
    }

    .sidebar-backdrop.active {
        display: block;
    }
}

/* ===========================
   Custom Scrollbar for Sidebar
   =========================== */

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

.sidebar-nav::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

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

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

/* ===========================
   Icon Colors for Different Modules
   =========================== */

.nav-item[data-module="contracts"] i:first-child {
    color: #ff9800;
}

.nav-item[data-module="tasks"] i:first-child {
    color: #9c27b0;
}

.nav-item[data-module="sea-shipping"] i:first-child {
    color: #2196f3;
}

.nav-item[data-module="air-shipping"] i:first-child {
    color: #00bcd4;
}

.nav-item[data-module="fleet"] i:first-child {
    color: #4caf50;
}

.nav-item[data-module="customs"] i:first-child {
    color: #f44336;
}

.nav-item[data-module="payment"] i:first-child {
    color: #ffc107;
}

.nav-item[data-module="support"] i:first-child {
    color: #9e9e9e;
}

.nav-item[data-module="reports"] i:first-child {
    color: #3f51b5;
}

.nav-item[data-route="/dashboard"] i {
    color: #4A90E2;
}
