/* 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: center;
    padding: 20px 16px;
    border-bottom: 1px solid var(--brokerly-border-light);
    min-height: 112px;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    overflow: hidden;
    transition: opacity 0.2s ease;
}

.sidebar-logo-icon-container {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    box-shadow: none;
    overflow: visible;
    flex-shrink: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-logo img {
    height: 58px;
    width: 58px;
    object-fit: cover;
    border-radius: 12px;
    background: #ffffff;
    transition: all 0.3s ease;
}

.desktop-sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 20px 0;
}

.desktop-sidebar.collapsed .sidebar-logo {
    justify-content: center;
    width: 100%;
}

.desktop-sidebar.collapsed .sidebar-logo-icon-container {
    width: 100%;
    height: 58px;
    justify-content: center;
}

.desktop-sidebar.collapsed .sidebar-logo img {
    height: 48px;
    width: 48px;
    object-fit: cover;
    border-radius: 10px;
    background: #ffffff;
}

.sidebar-logo-text {
    font-size: 26px;
    font-weight: 800;
    color: var(--brokerly-text-primary);
    letter-spacing: -0.02em;
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.2s ease;
}

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

/* ===== 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: background 0.2s ease, color 0.2s ease, transform 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(--clive-light);
    color: var(--clive-primary);
    transform: translateX(2px);
}

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

.sidebar-nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 24px;
    background: var(--brokerly-accent-green);
    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);
    display: flex;
    justify-content: center;
}

.sidebar-collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: 44px;
    padding: 0 16px;
    border-radius: 22px;
    background: var(--brokerly-background);
    border: 1px solid var(--brokerly-border-medium);
    color: var(--brokerly-text-secondary);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-card-subtle);
}

.sidebar-collapse-btn:hover {
    background: var(--clive-gradient);
    color: white !important;
    border-color: transparent;
    box-shadow: 0 4px 14px var(--clive-glow);
    transform: translateY(-1px);
}

.desktop-sidebar.collapsed .sidebar-collapse-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    padding: 0;
    margin: 0 auto;
    gap: 0;
    box-shadow: var(--shadow-card-subtle);
}

.desktop-sidebar.collapsed .sidebar-collapse-btn:hover {
    background: var(--clive-gradient);
    color: white !important;
    box-shadow: 0 4px 14px var(--clive-glow);
    transform: translateY(-1px);
}

.sidebar-collapse-icon {
    width: 20px;
    height: 20px;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-collapse-btn:hover .sidebar-collapse-icon {
    transform: translateX(-3px);
}

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

.desktop-sidebar.collapsed .sidebar-collapse-btn:hover .sidebar-collapse-icon {
    transform: rotate(180deg) translateX(-3px);
}

.sidebar-collapse-label {
    opacity: 1;
    transition: opacity 0.2s ease, width 0.2s ease;
    white-space: nowrap;
    display: inline-block;
    overflow: hidden;
}

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

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

/* Content shifts to accommodate sidebar */
.app-container.desktop-nav-active {
    max-width: 100%;
    transition: width var(--sidebar-transition, 0.3s ease), 
                margin-left var(--sidebar-transition, 0.3s ease);
}

/* ===== 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: background 0.2s ease, color 0.2s ease, border-color 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 {
        width: calc(100% - var(--sidebar-width, 240px)) !important;
        margin-left: var(--sidebar-width, 240px) !important;
    }

    body.main-app-active .desktop-sidebar.collapsed ~ .app-container.desktop-nav-active {
        width: calc(100% - var(--sidebar-width-collapsed, 80px)) !important;
        margin-left: var(--sidebar-width-collapsed, 80px) !important;
    }

    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],
.sidebar-collapse-btn[data-tooltip] {
    position: relative;
}

.desktop-sidebar.collapsed .sidebar-nav-item::after,
.desktop-sidebar.collapsed .sidebar-collapse-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%) scale(0);
    background: var(--brokerly-text-primary);
    color: var(--brokerly-background);
    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;
    box-shadow: var(--shadow-card-moderate);
}

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

/* ===== AI TEAM ASSISTANT CUSTOM STYLES ===== */

/* Special slot for AI tab icon in desktop view */
.sidebar-nav-item.ai-tab .sidebar-nav-item-icon {
    width: 36px;
    height: 36px;
    margin-left: -6px;
    margin-right: -6px;
    position: relative;
    overflow: visible;
}

.ai-avatar-tab-desktop {
    position: relative;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.team-avatar-container.mini {
    width: 32px;
    height: 24px;
    position: relative;
    z-index: 2;
}

.team-avatar-container.mini .team-avatar {
    border-radius: 50%;
    border: 1.5px solid var(--modern-card-background);
    position: absolute;
    overflow: hidden;
    background: var(--brokerly-tertiary-background);
    transition: transform var(--transition-normal, 0.2s ease);
}

.team-avatar-container.mini .team-avatar.clive {
    z-index: 1;
    left: 0;
    width: 22px;
    height: 22px;
    top: 1px;
}

.team-avatar-container.mini .team-avatar.clara {
    z-index: 2;
    left: 10px;
    width: 22px;
    height: 22px;
    top: 1px;
    box-shadow: -1.5px 0 6px rgba(0, 0, 0, 0.1);
}

.team-avatar-container.mini .team-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ai-border-gradient-desktop {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: linear-gradient(135deg,
        rgba(255, 111, 97, 0.65) 0%,
        rgba(255, 215, 0, 0.65) 20%,
        rgba(80, 200, 120, 0.65) 40%,
        rgba(0, 158, 217, 0.65) 60%,
        rgba(26, 127, 230, 0.65) 80%,
        rgba(255, 111, 97, 0.65) 100%
    );
    background-size: 200% 200%;
    filter: blur(5px);
    opacity: 0.45;
    z-index: 0;
    animation: rotateGradient 12s linear infinite;
    transition: opacity 0.4s ease, filter 0.4s ease;
}

.sidebar-nav-item.ai-tab.active .ai-border-gradient-desktop {
    opacity: 0.85;
    filter: blur(7px);
    animation: rotateGradient 10s linear infinite;
}

.sidebar-nav-item.ai-tab:hover .ai-border-gradient-desktop {
    opacity: 0.65;
    filter: blur(6px);
}

/* Sidebar Panel Trigger Tabs Custom Active Styling on Desktop */
.sidebar-nav-item.nav-panel-trigger.active {
    background: var(--clive-light) !important;
    color: var(--clive-primary) !important;
}

.sidebar-nav-item.nav-panel-trigger.active::before {
    background: var(--clive-primary) !important;
}

.sidebar-nav-item.nav-panel-trigger.active .sidebar-nav-item-indicator {
    color: var(--clive-primary) !important;
    opacity: 1 !important;
}