/* Desktop Navigation - Sidebar for ≥1024px screens */

/* ===== DESKTOP SIDEBAR CONTAINER ===== */

.desktop-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: var(--sidebar-width, 240px);
    background: var(--modern-card-background);
    border-right: 1px solid var(--brokerly-border-light);
    display: none;
    /* Hidden by default */
    flex-direction: column;
    z-index: 1000;
    transition: width var(--sidebar-transition, 0.3s ease);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition: width var(--sidebar-transition, 0.3s ease),
        opacity 0.3s ease,
        visibility 0.3s ease;
}

.desktop-sidebar.collapsed {
    width: var(--sidebar-width-collapsed, 80px);
}

/* ===== SIDEBAR HEADER ===== */

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 16px;
    border-bottom: 1px solid var(--brokerly-border-light);
    min-height: 72px;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
    transition: opacity 0.2s ease;
}

.sidebar-logo img {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    flex-shrink: 0;
}

.sidebar-logo-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--brokerly-text-primary);
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.desktop-sidebar.collapsed .sidebar-logo-text {
    opacity: 0;
    width: 0;
}

/* ===== SIDEBAR NAVIGATION ===== */

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 12px;
}

.sidebar-nav-group+.sidebar-nav-group {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--brokerly-border-light);
}

/* ===== SIDEBAR NAV ITEMS ===== */

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 16px;
    /* Increased from 12px */
    min-height: 52px;
    /* Added min-height for consistent sizing */
    border-radius: 12px;
    color: var(--brokerly-text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    font-size: 16px;
    /* Increased from 15px */
    font-weight: 500;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.sidebar-nav-item:hover {
    background: var(--brokerly-primary-light);
    color: var(--brokerly-primary);
    transform: translateX(2px);
}

.sidebar-nav-item.active {
    background: var(--brokerly-primary);
    color: white;
}

.sidebar-nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 24px;
    background: white;
    border-radius: 0 4px 4px 0;
}

/* Nav item icon */
.sidebar-nav-item-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-nav-item-icon svg {
    width: 24px;
    height: 24px;
}

/* Nav item label */
.sidebar-nav-item-label {
    flex: 1;
    text-align: left;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.desktop-sidebar.collapsed .sidebar-nav-item-label {
    opacity: 0;
    width: 0;
}

/* Nav item indicator (for side panels) */
.sidebar-nav-item-indicator {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.3;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.sidebar-nav-item:hover .sidebar-nav-item-indicator {
    opacity: 0.7;
    transform: translateX(2px);
}

.sidebar-nav-item.active .sidebar-nav-item-indicator {
    opacity: 1;
}

.desktop-sidebar.collapsed .sidebar-nav-item-indicator {
    opacity: 0;
    width: 0;
    margin: 0;
}

/* Nav item badge (for notifications, etc) */
.sidebar-nav-item-badge {
    background: var(--brokerly-accent);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.desktop-sidebar.collapsed .sidebar-nav-item-badge {
    opacity: 0;
    width: 0;
}

/* ===== SIDEBAR FOOTER / COLLAPSE BUTTON ===== */

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid var(--brokerly-border-light);
}

.sidebar-collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    background: transparent;
    border: 1px solid var(--brokerly-border-light);
    color: var(--brokerly-text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
}

.sidebar-collapse-btn:hover {
    background: var(--brokerly-primary-light);
    color: var(--brokerly-primary);
    border-color: var(--brokerly-primary);
}

.sidebar-collapse-icon {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

.desktop-sidebar.collapsed .sidebar-collapse-icon {
    transform: rotate(180deg);
}

.sidebar-collapse-label {
    opacity: 1;
    transition: opacity 0.2s ease;
}

.desktop-sidebar.collapsed .sidebar-collapse-label {
    opacity: 0;
    width: 0;
}

/* ===== MAIN CONTENT ADJUSTMENT ===== */

/* Content stays centered - sidebar is positioned fixed and doesn't push content */
.app-container.desktop-nav-active {
    /* No margin needed - sidebar is fixed position and overlays */
    max-width: 100%;
}

/* ===== TOUCH MODE TOGGLE ===== */

.touch-mode-toggle {
    display: none;
    /* Hidden on mobile/tablet */
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    background: var(--modern-card-background);
    border: 1px solid var(--brokerly-border-light);
    color: var(--brokerly-text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.touch-mode-toggle:hover {
    background: var(--brokerly-primary-light);
    color: var(--brokerly-primary);
    border-color: var(--brokerly-primary);
}

.touch-mode-toggle.active {
    background: var(--brokerly-primary);
    color: white;
    border-color: var(--brokerly-primary);
}

.touch-mode-toggle-icon {
    width: 16px;
    height: 16px;
}

/* ===== RESPONSIVE BREAKPOINTS ===== */

/* Small Desktop: Show sidebar (collapsible) - ONLY when main app is active */
@media (min-width: 1024px) {

    /* Sidebar only shows when main app is active (not during onboarding) */
    body.main-app-active .desktop-sidebar {
        display: flex;
        opacity: 1;
        visibility: visible;
    }

    body.main-app-active .touch-mode-toggle {
        display: flex;
    }

    /* Hide bottom tabs by default on desktop when main app is active */
    body.main-app-active .tab-navigation {
        display: none;
    }

    /* Show bottom tabs if touch mode is active (only in main app) */
    body.main-app-active .app-container.touch-mode .tab-navigation {
        display: flex;
    }

    body.main-app-active .app-container.touch-mode .desktop-sidebar {
        display: none;
        opacity: 0;
        visibility: hidden;
    }

    body.main-app-active .app-container.touch-mode {
        margin-left: 0 !important;
    }

    /* Adjust view content padding when sidebar is active */
    body.main-app-active .app-container.desktop-nav-active .view {
        padding-bottom: 16px;
        /* Remove extra padding for bottom tabs */
    }
}

/* Large Desktop: Default expanded sidebar */
@media (min-width: 1280px) {
    .desktop-sidebar {
        width: var(--sidebar-width, 240px);
    }
}

/* ===== ACCESSIBILITY ===== */

/* Focus states for keyboard navigation */
.sidebar-nav-item:focus,
.sidebar-collapse-btn:focus,
.touch-mode-toggle:focus {
    outline: 2px solid var(--brokerly-primary);
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {

    .desktop-sidebar,
    .sidebar-nav-item,
    .sidebar-collapse-icon,
    .app-container.desktop-nav-active {
        transition: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .desktop-sidebar {
        border-right: 2px solid var(--brokerly-text-primary);
    }

    .sidebar-nav-item.active {
        border: 2px solid var(--brokerly-text-primary);
    }
}

/* ===== SMOOTH SCROLLING ===== */

.sidebar-nav {
    scrollbar-width: thin;
    scrollbar-color: var(--brokerly-border-light) transparent;
}

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

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

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--brokerly-border-light);
    border-radius: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: var(--brokerly-text-tertiary);
}

/* ===== TOOLTIP FOR COLLAPSED STATE ===== */

.sidebar-nav-item[data-tooltip] {
    position: relative;
}

.desktop-sidebar.collapsed .sidebar-nav-item::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%) scale(0);
    background: var(--brokerly-text-primary);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 1001;
}

.desktop-sidebar.collapsed .sidebar-nav-item:hover::after {
    transform: translateY(-50%) scale(1);
    opacity: 1;
}