.user-portal-container {
    min-height: 100vh;
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 50%, #3b82f6 100%);
    position: relative;
    overflow: hidden;
}

// Background Shapes
.background-shapes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 0;
}

.shape {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    animation: float 6s ease-in-out infinite;

    &.shape-1 {
        width: 200px;
        height: 200px;
        top: 10%;
        left: 10%;
        animation-delay: 0s;
    }

    &.shape-2 {
        width: 150px;
        height: 150px;
        top: 60%;
        right: 15%;
        animation-delay: 2s;
    }

    &.shape-3 {
        width: 100px;
        height: 100px;
        bottom: 20%;
        left: 20%;
        animation-delay: 4s;
    }
}

@keyframes float {
    0%,
    100% {
        transform: translateY(0px) rotate(0deg);
    }
    50% {
        transform: translateY(-20px) rotate(180deg);
    }
}

// Main Portal Layout
.portal-layout {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

// Desktop layout - fixed sidebar with scrolling content
@media (min-width: 769px) {
    .portal-layout {
        .sidebar {
            position: fixed;
            top: 0;
            left: 0;
            z-index: 1000;
        }

        .main-content {
            margin-left: 290px; // Account for fixed sidebar width
            flex: 1;
        }
    }

    // When sidebar is collapsed on desktop
    .sidebar.collapsed + .main-content {
        margin-left: 70px;
    }
}

// Sidebar Overlay for Mobile
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

// Sidebar Styles
.sidebar {
    width: 280px;
    height: 100vh;
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-right: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;

    &.collapsed {
        width: 70px;

        .logo-text,
        .nav-section h4,
        .nav-item span,
        .user-details,
        .logout-btn span {
            opacity: 0;
            visibility: hidden;
        }

        .sidebar-footer {
            padding: 1rem 0.5rem;
        }

        .user-info {
            justify-content: center;
        }
    }
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;

    .logo-image {
        height: 40px;
        width: auto;
        //filter: brightness(0) saturate(100%) invert(27%) sepia(51%) saturate(2878%) hue-rotate(346deg) brightness(104%)contrast(97%);
    }

    .logo-text {
        h2 {
            margin: 0;
            font-size: 1.25rem;
            font-weight: 700;
            color: #1e3a8a;
            letter-spacing: -0.01em;
        }

        .tagline {
            font-size: 0.75rem;
            color: #6b7280;
            font-weight: 500;
        }
    }
}

.sidebar-toggle {
    background: none;
    border: none;
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    color: #6b7280;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;

    &:hover {
        background: #f3f4f6;
        color: #1e40af;
    }

    svg {
        width: 20px;
        height: 20px;
    }
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
    max-height: calc(100vh - 200px); // Account for header and footer
}

// Quick search / filter box
.nav-search {
    position: relative;
    display: flex;
    align-items: center;
    margin: 0 1.25rem 1.5rem;

    .nav-search-icon {
        position: absolute;
        left: 0.625rem;
        width: 16px;
        height: 16px;
        color: #9ca3af;
        pointer-events: none;
    }

    .nav-search-input {
        width: 100%;
        padding: 0.5rem 2rem 0.5rem 2rem;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        background: #f9fafb;
        font-size: 0.85rem;
        color: #1f2937;
        transition: all 0.2s ease;

        &::placeholder {
            color: #9ca3af;
        }

        &:focus {
            outline: none;
            border-color: #1e40af;
            background: #ffffff;
            box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
        }
    }

    .nav-search-clear {
        position: absolute;
        right: 0.5rem;
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        padding: 0.25rem;
        cursor: pointer;
        color: #9ca3af;
        border-radius: 4px;
        transition: all 0.2s ease;

        kendo-svgicon {
            width: 14px;
            height: 14px;
        }

        &:hover {
            color: #1e40af;
            background: #f3f4f6;
        }
    }
}

.nav-section {
    margin-bottom: 2rem;

    h4 {
        margin: 0 0 1rem 1.5rem;
        font-size: 0.75rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: #6b7280;
    }
}

// Collapsible finance group
.nav-group {
    margin-bottom: 0.25rem;

    .nav-group-header {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        padding: 0.625rem 1.5rem;
        background: none;
        border: none;
        cursor: pointer;
        color: #4b5563;
        transition: all 0.2s ease;

        .nav-group-title {
            font-size: 0.85rem;
            font-weight: 600;
        }

        .nav-group-chevron {
            width: 16px;
            height: 16px;
            color: #9ca3af;
            transition: transform 0.2s ease;
        }

        &:hover {
            background: rgba(30, 64, 175, 0.06);
            color: #1e40af;
        }

        &.expanded .nav-group-chevron {
            transform: rotate(180deg);
        }
    }

    .nav-group-items {
        padding: 0.125rem 0;
    }
}

// Nested item inside a group — indent the icon to show hierarchy
.nav-item.nav-item-nested {
    padding-left: 2.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: #6b7280;
    text-decoration: none;
    transition: all 0.2s ease;
    position: relative;
    margin: 0.125rem 0;
    // Suppress the grey native tap-flash on touch devices; the active state below
    // is the intended feedback.
    -webkit-tap-highlight-color: transparent;

    // Only apply hover on devices that can truly hover (desktop). On touch, hover
    // styles "stick" after a tap and leave a muddy box on the last-tapped item.
    @media (hover: hover) {
        &:hover {
            background: rgba(30, 64, 175, 0.1);
            color: #1e40af;
        }
    }

    &.active {
        background: rgba(30, 64, 175, 0.15);
        color: #1e40af;
        font-weight: 600;

        &::before {
            content: "";
            position: absolute;
            left: 0;
            top: 0;
            bottom: 0;
            width: 3px;
            background: #1e40af;
        }
    }

    .nav-icon {
        width: 20px;
        height: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;

        svg {
            width: 100%;
            height: 100%;
        }
    }

    span {
        font-size: 0.9rem;
        font-weight: 500;
    }

    .nav-badge {
        background: #ef4444;
        color: white;
        font-size: 0.75rem;
        font-weight: 600;
        padding: 0.25rem 0.5rem;
        border-radius: 10px;
        margin-left: auto;
        min-width: 20px;
        text-align: center;
    }
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;

    .user-avatar {
        width: 40px;
        height: 40px;
        background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 50%, #3b82f6 100%);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        color: white;
        flex-shrink: 0;

        svg {
            width: 20px;
            height: 20px;
        }
    }

    .user-details {
        flex: 1;
        min-width: 0;

        .user-name {
            font-weight: 600;
            color: #1f2937;
            font-size: 0.9rem;
            margin-bottom: 0.125rem;
        }

        .user-email {
            font-size: 0.8rem;
            color: #6b7280;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
    }
}

.logout-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: none;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    font-weight: 500;

    &:hover {
        background: #fef2f2;
        border-color: #fecaca;
        color: #dc2626;
    }

    svg {
        width: 16px;
        height: 16px;
    }
}

// Main Content Area
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    margin: 1rem;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    height: calc(100vh - 2rem);
    max-height: calc(100vh - 2rem);
}

.top-header {
    padding: 1.25rem 2rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.8);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    color: #6b7280;
    transition: all 0.2s ease;

    &:hover {
        background: #f3f4f6;
        color: #1e40af;
    }

    svg {
        width: 20px;
        height: 20px;
    }
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.action-btn {
    position: relative;
    background: none;
    border: none;
    padding: 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    color: #6b7280;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;

    &:hover {
        background: #f3f4f6;
        color: #1e40af;
    }

    svg {
        width: 20px;
        height: 20px;
    }

    .notification-badge {
        position: absolute;
        top: 0.25rem;
        right: 0.25rem;
        background: #ef4444;
        color: white;
        font-size: 0.75rem;
        font-weight: 600;
        padding: 0.125rem 0.375rem;
        border-radius: 10px;
        min-width: 18px;
        text-align: center;
    }
}

.page-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    height: 100%;
    max-height: 100%;
}

// Mobile Responsive
@media (max-width: 768px) {
    .portal-layout {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease;

        &:not(.collapsed) {
            transform: translateX(0);
        }

        &.collapsed {
            transform: translateX(-100%);
        }
    }

    .main-content {
        margin: 0;
        border-radius: 0;
        height: 100vh;
        max-height: 100vh;
    }

    .mobile-menu-btn {
        display: block;
    }

    // The top-header hamburger toggles the drawer on mobile, so the duplicate
    // toggle inside the open drawer header is redundant — hide it.
    .sidebar-toggle {
        display: none;
    }

    .page-content {
        padding: 1rem;
    }

    .top-header {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .page-content {
        padding: 0.75rem;
    }

    .top-header {
        padding: 0.75rem;
    }

    .breadcrumb .breadcrumb-item {
        font-size: 1.1rem;
    }
}

// Desktop sidebar collapsed state
@media (min-width: 769px) {
    .sidebar.collapsed {
        width: 70px;
    }

    .main-content.sidebar-collapsed {
        margin-left: 70px;
    }
}
