Index: components/BuildCard.tsx
===================================================================
--- components/BuildCard.tsx	(revision 1bf6e1f519ad45c39ba56ccdc473328a666f1335)
+++ components/BuildCard.tsx	(revision 1bf6e1f519ad45c39ba56ccdc473328a666f1335)
@@ -0,0 +1,45 @@
+import React from 'react';
+import { Card, CardMedia, CardContent, Typography, Box, Chip } from '@mui/material';
+import StarIcon from '@mui/icons-material/Star';
+import PersonIcon from '@mui/icons-material/Person';
+
+export default function BuildCard({ build, onClick }: { build: any, onClick: () => void }) {
+    const formattedPrice = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(build.total_price || 0);
+
+    return (
+        <Card
+            sx={{ height: '100%', display: 'flex', flexDirection: 'column', cursor: 'pointer', transition: 'all 0.2s', '&:hover': { transform: 'translateY(-4px)', boxShadow: 6 } }}
+            onClick={onClick}
+        >
+            <CardMedia
+                component="img"
+                height="160"
+                image={build.img_url || "https://placehold.co/600x400?text=PC+Build"}
+                alt={build.name}
+            />
+            <CardContent sx={{ flexGrow: 1, pb: 1 }}>
+                <Typography gutterBottom variant="h6" noWrap title={build.name}>
+                    {build.name}
+                </Typography>
+
+                {/*Ne se renderira user-ot*/}
+                <Box sx={{ display: 'flex', alignItems: 'center', mb: 1, color: 'text.secondary' }}>
+                {/*    <PersonIcon sx={{ fontSize: 16, mr: 0.5 }} />*/}
+                {/*    <Typography variant="caption">{build.user || 'Unknown'}</Typography>*/}
+                    <Typography variant="h6" gutterBottom noWrap title={build.cpu}>{build.cpu}</Typography>
+                    <Typography variant="h6" gutterBottom noWrap title={build.gpu}>{build.gpu}</Typography>
+                </Box>
+
+                <Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mt: 'auto' }}>
+                    <Chip label={formattedPrice} size="small" color="primary" variant="outlined" />
+                    <Box sx={{ display: 'flex', alignItems: 'center' }}>
+                        <StarIcon fontSize="small" sx={{ color: '#faaf00', mr: 0.5 }} />
+                        <Typography variant="body2" fontWeight="bold">
+                            {Number(build.avg_rating || 5).toFixed(1)}
+                        </Typography>
+                    </Box>
+                </Box>
+            </CardContent>
+        </Card>
+    );
+}
Index: components/BuildDetailsDialog.tsx
===================================================================
--- components/BuildDetailsDialog.tsx	(revision 1bf6e1f519ad45c39ba56ccdc473328a666f1335)
+++ components/BuildDetailsDialog.tsx	(revision 1bf6e1f519ad45c39ba56ccdc473328a666f1335)
@@ -0,0 +1,213 @@
+import React, { useEffect, useState } from 'react';
+import {
+    Dialog, DialogTitle, DialogContent, Button, Grid, Box, Typography,
+    IconButton, Tab, Tabs, Table, TableBody, TableCell, TableRow, Rating, TextField, Avatar, Divider, Chip, CardMedia
+} from '@mui/material';
+import CloseIcon from '@mui/icons-material/Close';
+import AutoFixHighIcon from '@mui/icons-material/AutoFixHigh';
+import FavoriteIcon from '@mui/icons-material/Favorite';
+import FavoriteBorderIcon from '@mui/icons-material/FavoriteBorder';
+import { onGetBuildDetails, onSetReview, onToggleFavorite } from '../pages/+Layout.telefunc';
+import PersonIcon from "@mui/icons-material/Person";
+
+const formatPrice = (price: any) => new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(Number(price) || 0);
+
+export default function BuildDetailsDialog({ open, buildId, onClose, onClone, currentUser }: any) {
+    const [details, setDetails] = useState<any>(null);
+    const [loading, setLoading] = useState(false);
+    const [tabIndex, setTabIndex] = useState(0);
+
+    const [reviewText, setReviewText] = useState("");
+    const [ratingVal, setRatingVal] = useState(5);
+
+    useEffect(() => {
+        if (open && buildId) {
+            setLoading(true);
+            onGetBuildDetails({ buildId })
+                .then(data => {
+                    setDetails(data);
+                    if (data.userRating) setRatingVal(data.userRating);
+                    if (data.userReview) setReviewText(data.userReview);
+                })
+                .finally(() => setLoading(false));
+        }
+    }, [open, buildId]);
+
+    const handleFavorite = async () => {
+        if (!currentUser) return alert("Please login to favorite builds.");
+        const res = await onToggleFavorite({ buildId });
+        setDetails((prev: any) => ({ ...prev, isFavorite: res }));
+    };
+
+    const handleSubmitReview = async () => {
+        if (!currentUser) return alert("Please login to review.");
+        await onSetReview({ buildId, content: reviewText });
+
+        const refreshed = await onGetBuildDetails({ buildId });
+        setDetails(refreshed);
+    };
+
+    if (!open) return null;
+
+    // @ts-ignore
+    return (
+        <Dialog open={open} onClose={onClose} maxWidth="md" fullWidth scroll="paper">
+            {loading || !details ? (
+                <Box sx={{ p: 5, textAlign: 'center' }}>Loading Forge Schematics...</Box>
+            ) : (
+                <>
+                    <DialogTitle sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', bgcolor: '#ff8201' }}>
+                        <Box>
+                            <Typography variant="h5" fontWeight="bold">{details.name}</Typography>
+                            <Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
+                                <PersonIcon sx={{ fontSize: 16 }} />
+                                <Typography variant="subtitle2" color="text.secondary" fontWeight="bold">
+                                    by {details.creator}
+                                </Typography>
+                                <Chip label={formatPrice(details.totalPrice)} size="small" color="primary" variant="outlined" />
+                            </Box>
+                        </Box>
+                        <IconButton onClick={onClose}><CloseIcon /></IconButton>
+                    </DialogTitle>
+
+                    <DialogContent sx={{ p: 0 }}>
+                        <Box sx={{ borderBottom: 1, borderColor: 'divider', px: 2, bgcolor: 'primary', position: 'sticky', top: 0, zIndex: 1 }}>
+                            <Tabs value={tabIndex} onChange={(_, v) => setTabIndex(v)}>
+                                <Tab label="Specs" />
+                                <Tab label={`Reviews (${details.ratingStatistics.ratingCount})`} />
+                            </Tabs>
+                        </Box>
+
+                        <Box sx={{ p: 3 }}>
+                            {tabIndex === 0 && (
+                                <Grid container spacing={4}>
+                                    <Grid item xs={12} md={8}>
+                                        <Table size="small">
+                                            <TableBody>
+                                                {details.components.map((comp: any) => (
+                                                    <TableRow key={comp.id}>
+                                                        <TableCell sx={{ width: 50 }}>
+                                                            {/*<Avatar*/}
+                                                            {/*    src={comp.img_url || undefined}*/}
+                                                            {/*    variant="rounded"*/}
+                                                            {/*    sx={{ width: 40, height: 40, bgcolor: '#ff8201' }}*/}
+                                                            {/*>*/}
+                                                            {/*    {comp.type?.[0]?.toUpperCase()}*/}
+                                                            {/*</Avatar>*/}
+                                                            {/*<PersonIcon sx={{ fontSize: 16 }} />*/}
+                                                            <CardMedia
+                                                                component="img"
+                                                                height="50"
+                                                                width="50"
+                                                                image={"https://placehold.co/400x400?text=CPU"}
+
+                                                            />
+                                                        </TableCell>
+                                                        <TableCell>
+                                                            <Typography variant="body2" color="text.secondary" sx={{ fontSize: '0.75rem', textTransform: 'uppercase' }}>
+                                                                {comp.type}
+                                                            </Typography>
+                                                            <Typography variant="body1" fontWeight="500">
+                                                                {comp.brand} {comp.name}
+                                                            </Typography>
+                                                        </TableCell>
+                                                        <TableCell align="right" sx={{ fontWeight: 'bold', color: '#ff8201' }}>
+                                                            {formatPrice(comp.price)}
+                                                        </TableCell>
+                                                    </TableRow>
+                                                ))}
+                                                <TableRow sx={{ bgcolor: '#424343' }}>
+                                                    <TableCell colSpan={2} sx={{ fontWeight: 'bold', color: '#ff8201' }}>TOTAL</TableCell>
+                                                    <TableCell align="right" sx={{ fontWeight: 'bold', fontSize: '1.1rem', color: 'primary.main' }}>
+                                                        {formatPrice(details.totalPrice)}
+                                                    </TableCell>
+                                                </TableRow>
+                                            </TableBody>
+                                        </Table>
+                                    </Grid>
+
+                                    <Grid item xs={12} md={4}>
+                                        <Box sx={{ bgcolor: '#424343', p: 2, borderRadius: 2, mb: 2 }}>
+                                            <Typography color="primary.main" gutterBottom fontWeight="bold">Builder's Notes</Typography>
+                                            <Typography color="primary.main" variant="body2" sx={{ fontStyle: 'italic' }}>
+                                                "{details.description || "No notes provided."}"
+                                            </Typography>
+                                        </Box>
+
+                                        <Box sx={{ display: 'flex', flexDirection: 'column', gap: 1 }}>
+                                            <Button
+                                                variant="contained"
+                                                color="primary"
+                                                size="large"
+                                                startIcon={<AutoFixHighIcon />}
+                                                onClick={() => onClone({ buildId: details.id })}
+                                            >
+                                                Clone & Edit
+                                            </Button>
+                                            <Button
+                                                variant={details.isFavorite ? "contained" : "outlined"}
+                                                color={details.isFavorite ? "error" : "primary"}
+                                                startIcon={details.isFavorite ? <FavoriteIcon /> : <FavoriteBorderIcon />}
+                                                onClick={handleFavorite}
+                                            >
+                                                {details.isFavorite ? "Favorited" : "Add to Favorites"}
+                                            </Button>
+                                        </Box>
+                                    </Grid>
+                                </Grid>
+                            )}
+
+                            {tabIndex === 1 && (
+                                <Box>
+                                    <Box sx={{ display: 'flex', alignItems: 'center', gap: 2, mb: 4, p: 2, bgcolor: '#5e5e5e', borderRadius: 2 }}>
+                                        <Typography variant="h3" fontWeight="bold">{details.ratingStatistics.averageRating.toFixed(1)}</Typography>
+                                        <Box>
+                                            <Rating value={details.ratingStatistics.averageRating} readOnly precision={0.5} />
+                                            <Typography variant="body2" color="text.secondary">{details.ratingStatistics.ratingCount} ratings</Typography>
+                                        </Box>
+                                    </Box>
+
+                                    {currentUser && (
+                                        <Box sx={{ mb: 4, p: 2, border: '1px solid #ddd', borderRadius: 2 }}>
+                                            <Typography variant="subtitle2" gutterBottom>Your Review</Typography>
+                                            <Box sx={{ display: 'flex', alignItems: 'center', mb: 1 }}>
+                                                <Rating value={ratingVal} onChange={(_, v) => setRatingVal(v || 5)} />
+                                            </Box>
+                                            <TextField
+                                                fullWidth
+                                                multiline
+                                                rows={2}
+                                                placeholder="Share your thoughts on this build..."
+                                                value={reviewText}
+                                                onChange={(e) => setReviewText(e.target.value)}
+                                                sx={{ mb: 1 }}
+                                            />
+                                            <Button size="small" variant="contained" onClick={handleSubmitReview}>
+                                                Submit Review
+                                            </Button>
+                                        </Box>
+                                    )}
+
+                                    <Box sx={{ display: 'flex', flexDirection: 'column', gap: 2}}>
+                                        {details.reviews.map((rev: any, i: number) => (
+                                            <Box key={i} sx={{ pb: 2, borderBottom: '1px solid #eee'}}>
+                                                <Box sx={{ display: 'flex', justifyContent: 'space-between', mb: 0.5 }}>
+                                                    <Typography fontWeight="bold" variant="body2">{rev.username}</Typography>
+                                                    <Typography variant="caption" color="text.secondary">{rev.createdAt}</Typography>
+                                                </Box>
+                                                <Typography variant="body2">{rev.content}</Typography>
+                                            </Box>
+                                        ))}
+                                        {details.reviews.length === 0 && (
+                                            <Typography color="text.secondary" align="center">No reviews yet. Be the first!</Typography>
+                                        )}
+                                    </Box>
+                                </Box>
+                            )}
+                        </Box>
+                    </DialogContent>
+                </>
+            )}
+        </Dialog>
+    );
+}
Index: components/Navbar.tsx
===================================================================
--- components/Navbar.tsx	(revision 76b980b0450fc6309a3fe5f6150046d819eb6404)
+++ components/Navbar.tsx	(revision 1bf6e1f519ad45c39ba56ccdc473328a666f1335)
@@ -71,6 +71,6 @@
                     {auth?.isLoggedIn ? (
                         <>
-                            <Button color="inherit" href="/dashboard/user">{auth.username}</Button>
-                            <Button color="inherit" onClick={handleLogout}>Logout</Button>
+                            <Button sx={onHoverNav} color="inherit" href="/dashboard/user">{auth.username}</Button>
+                            <Button sx={onHoverNav} color="inherit" onClick={handleLogout}>Logout</Button>
                         </>
                     ) : (
Index: database/drizzle/queries/builds.ts
===================================================================
--- database/drizzle/queries/builds.ts	(revision 76b980b0450fc6309a3fe5f6150046d819eb6404)
+++ database/drizzle/queries/builds.ts	(revision 1bf6e1f519ad45c39ba56ccdc473328a666f1335)
@@ -143,4 +143,5 @@
         )
         .groupBy(
+            buildsTable.id,
             buildsTable.userId,
             buildsTable.name,
Index: pages/auth/login/+Page.tsx
===================================================================
--- pages/auth/login/+Page.tsx	(revision 76b980b0450fc6309a3fe5f6150046d819eb6404)
+++ pages/auth/login/+Page.tsx	(revision 1bf6e1f519ad45c39ba56ccdc473328a666f1335)
@@ -26,5 +26,5 @@
             setError("Invalid username or password");
         } else {
-            window.location.href = "/dashboard/user";
+            window.location.href = "/";
         }
     };
Index: pages/completed-builds/+Page.tsx
===================================================================
--- pages/completed-builds/+Page.tsx	(revision 1bf6e1f519ad45c39ba56ccdc473328a666f1335)
+++ pages/completed-builds/+Page.tsx	(revision 1bf6e1f519ad45c39ba56ccdc473328a666f1335)
@@ -0,0 +1,189 @@
+import React, { useEffect, useState } from 'react';
+import {
+    Container, Grid, Box, Typography, TextField, MenuItem, Select,
+    Slider, Button, Paper, InputAdornment
+} from '@mui/material';
+import SearchIcon from '@mui/icons-material/Search';
+import FilterListIcon from '@mui/icons-material/FilterList';
+
+import BuildCard from '../../components/BuildCard';
+import BuildDetailsDialog from '../../components/BuildDetailsDialog';
+
+import { onGetApprovedBuilds, onCloneBuild, onGetAuthState } from '../+Layout.telefunc';
+
+export default function CompletedBuildsPage() {
+    const [builds, setBuilds] = useState<any[]>([]);
+    const [loading, setLoading] = useState(true);
+    const [userId, setUserId] = useState<number | null>(null);
+    const [selectedBuildId, setSelectedBuildId] = useState<number | null>(null);
+
+    const [sortBy, setSortBy] = useState('price_asc');
+    const [priceRange, setPriceRange] = useState<number[]>([0, 5000]);
+    const [searchQuery, setSearchQuery] = useState("");
+
+    const loadBuilds = async () => {
+        setLoading(true);
+        try {
+            const [userData, data] = await Promise.all([
+                onGetAuthState(),
+                onGetApprovedBuilds({ q: searchQuery })
+            ]);
+            setUserId(userData.userId);
+
+            let sortedData = [...data];
+
+            switch (sortBy) {
+                case 'price_asc':
+                    sortedData.sort((a, b) => Number(a.total_price) - Number(b.total_price));
+                    break;
+                case 'price_desc':
+                    sortedData.sort((a, b) => Number(b.total_price) - Number(a.total_price));
+                    break;
+                case 'rating_desc':
+                    sortedData.sort((a, b) => (Number(b.avgRating) || 0) - (Number(a.avgRating) || 0));
+                    break;
+                case 'oldest':
+                    sortedData.sort((a, b) => new Date(a.created_at).getTime() - new Date(b.created_at).getTime());
+                    break;
+                case 'newest':
+                default:
+                    sortedData.sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime());
+                    break;
+            }
+
+            sortedData = sortedData.filter(b => {
+                const price = Number(b.total_price);
+                return price >= priceRange[0] && price <= priceRange[1];
+            });
+
+            setBuilds(sortedData);
+        } finally {
+            setLoading(false);
+        }
+    };
+
+    useEffect(() => {
+        loadBuilds();
+    }, [sortBy, priceRange, searchQuery]);
+
+    useEffect(() => {
+        loadBuilds();
+    }, [sortBy, searchQuery]);
+
+    const handleClone = async (buildId: number) => {
+        if (!userId) return alert("Please login to clone builds!");
+        if (confirm(`Clone this build?`)) {
+            await onCloneBuild({ buildId });
+            alert("Build cloned!");
+            setSelectedBuildId(null);
+        }
+    };
+
+    return (
+        <Container maxWidth="xl" sx={{ mt: 4, mb: 10 }}>
+            <Typography variant="h4" fontWeight="bold" gutterBottom>Completed Builds</Typography>
+            <Typography color="text.secondary" sx={{ mb: 4 }}>
+                Browse community configurations. Filter by price, components, or popularity.
+            </Typography>
+
+            <Grid container spacing={4}>
+                <Grid item xs={12} md={3}>
+                    <Paper variant="outlined" sx={{ p: 3, position: 'sticky', top: 20 }}>
+                        <Box sx={{ display: 'flex', alignItems: 'center', mb: 2 }}>
+                            <FilterListIcon sx={{ mr: 1 }} />
+                            <Typography variant="h6" fontWeight="bold">Filters</Typography>
+                        </Box>
+
+                        <TextField
+                            fullWidth
+                            size="small"
+                            placeholder="Search builds..."
+                            value={searchQuery}
+                            onChange={(e) => setSearchQuery(e.target.value)}
+                            InputProps={{
+                                startAdornment: <InputAdornment position="start"><SearchIcon /></InputAdornment>,
+                            }}
+                            sx={{ mb: 3 }}
+                        />
+
+                        <Typography gutterBottom fontWeight="bold">Price Range</Typography>
+                        <Box sx={{ px: 1, mb: 3 }}>
+                            <Slider
+                                value={priceRange}
+                                onChange={(_, newValue) => setPriceRange(newValue as number[])}
+                                valueLabelDisplay="auto"
+                                min={0}
+                                max={5000}
+                                step={100}
+                            />
+                            <Box sx={{ display: 'flex', justifyContent: 'space-between', mt: 1 }}>
+                                <Typography variant="caption">${priceRange[0]}</Typography>
+                                <Typography variant="caption">${priceRange[1]}+</Typography>
+                            </Box>
+                        </Box>
+
+                        <Button variant="contained" fullWidth onClick={loadBuilds}>
+                            Apply Filters
+                        </Button>
+                    </Paper>
+                </Grid>
+
+                <Grid item xs={12} md={9}>
+                    {/* Toolbar */}
+                    <Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mb: 3 }}>
+                        <Typography fontWeight="bold">{builds.length} Builds Found</Typography>
+
+                        <Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
+                            <Typography variant="body2" color="text.secondary">Sort by:</Typography>
+                            <Select
+                                size="small"
+                                value={sortBy}
+                                onChange={(e) => setSortBy(e.target.value)}
+                                sx={{ minWidth: 150, bgcolor: 'background.paper' }}
+                            >
+                                <MenuItem value="newest">Newest First</MenuItem>
+                                <MenuItem value="oldest">Oldest First</MenuItem>
+                                <MenuItem value="price_desc">Price: High to Low</MenuItem>
+                                <MenuItem value="price_asc">Price: Low to High</MenuItem>
+                                <MenuItem value="rating_desc">Highest Rated</MenuItem>
+                            </Select>
+                        </Box>
+                    </Box>
+
+                    {loading ? (
+                        <Box sx={{ p: 5, textAlign: 'center' }}>Loading...</Box>
+                    ) : (
+                        <Grid container spacing={3}>
+                            {builds.map((build) => (
+                                <Grid item xs={12} sm={6} lg={4} key={build.id} sx={{ display: 'flex' }}>
+                                    <Box sx={{ width: '100%' }}>
+                                        <BuildCard
+                                            build={build}
+                                            onClick={() => setSelectedBuildId(build.id)}
+                                        />
+                                    </Box>
+                                </Grid>
+                            ))}
+                            {builds.length === 0 && (
+                                <Grid item xs={12}>
+                                    <Box sx={{ p: 5, textAlign: 'center', bgcolor: '#f5f5f5', borderRadius: 2 }}>
+                                        <Typography>No builds found matching your filters.</Typography>
+                                    </Box>
+                                </Grid>
+                            )}
+                        </Grid>
+                    )}
+                </Grid>
+            </Grid>
+
+            <BuildDetailsDialog
+                open={!!selectedBuildId}
+                buildId={selectedBuildId}
+                currentUser={userId}
+                onClose={() => setSelectedBuildId(null)}
+                onClone={handleClone}
+            />
+        </Container>
+    );
+}
+
Index: pages/forge/+Page.tsx
===================================================================
--- pages/forge/+Page.tsx	(revision 1bf6e1f519ad45c39ba56ccdc473328a666f1335)
+++ pages/forge/+Page.tsx	(revision 1bf6e1f519ad45c39ba56ccdc473328a666f1335)
@@ -0,0 +1,5 @@
+export default function ForgePage(){
+    return (
+        <h1>Test Forge Page</h1>
+    )
+}
Index: pages/index/+Page.tsx
===================================================================
--- pages/index/+Page.tsx	(revision 76b980b0450fc6309a3fe5f6150046d819eb6404)
+++ pages/index/+Page.tsx	(revision 1bf6e1f519ad45c39ba56ccdc473328a666f1335)
@@ -1,38 +1,30 @@
 import React, { useEffect, useState } from 'react';
 import {
-    Container, Box, Typography, Button, Grid, Card, CardMedia, CardContent,
-    CardActions, Chip, Rating, Dialog, DialogTitle, DialogContent, DialogActions,
-    IconButton, Divider
+    Container, Box, Typography, Button, Grid, IconButton, Dialog, DialogTitle, DialogContent
 } from '@mui/material';
 import CloseIcon from '@mui/icons-material/Close';
 import AutoFixHighIcon from '@mui/icons-material/AutoFixHigh';
-import CommentIcon from '@mui/icons-material/Comment';
-import StarIcon from '@mui/icons-material/Star';
-import HardwareIcon from '@mui/icons-material/Memory';
-import ListIcon from '@mui/icons-material/List'; // Icon for "Show All"
+import ListIcon from '@mui/icons-material/List';
 
-// --- PLACEHOLDER ASSETS ---
-const PLACEHOLDER_IMG = "https://placehold.co/600x400?text=Gaming+PC";
+import BuildDetailsDialog from '../../components/BuildDetailsDialog';
+import BuildCard from '../../components/BuildCard';
 
-import { onGetHighestRankedBuilds, onCloneBuild } from './buildCards.telefunc';
-import {onGetApprovedBuilds, onGetAuthState} from '../+Layout.telefunc';
-import {getAuthState} from "../../server/telefunc/ctx"; //
+import { onGetApprovedBuilds, onGetAuthState, onCloneBuild } from '../+Layout.telefunc';
 
 export default function HomePage() {
     const [data, setData] = useState<any>(null);
-    const [selectedBuild, setSelectedBuild] = useState<any>(null); // For Detail Popup
-    const [openDetailPopup, setOpenDetailPopup] = useState(false);
 
-    // NEW: Popup for "All Top Ranked Builds"
+    const [selectedBuildId, setSelectedBuildId] = useState<number | null>(null);
+
     const [openRankedPopup, setOpenRankedPopup] = useState(false);
 
     useEffect(() => {
-        async function loadSite(){
-            try{
+        async function loadSite() {
+            try {
                 const [
-                    authData, highestRankedBuilds, commnityBuilds
+                    authData, highestRankedBuilds, communityBuilds
                 ] = await Promise.all([
                     onGetAuthState(),
-                    onGetHighestRankedBuilds({ limit: 3 }),
+                    onGetApprovedBuilds({ limit: 3 , sort: 'rating_desc' }),
                     onGetApprovedBuilds({ limit: 12 })
                 ]);
@@ -42,26 +34,19 @@
                     userId: authData.userId,
                     prebuilts: highestRankedBuilds,
-                    communityBuilds: commnityBuilds
+                    communityBuilds: communityBuilds
                 });
             } catch (error) {
                 console.error("Error loading homepage data:", error);
             }
-    }
+        }
+        loadSite();
+    }, []);
 
-    loadSite();
-}, []);
-
-    // Open Build Details
-    const handleCardClick = (build: any) => {
-        setSelectedBuild(build);
-        setOpenDetailPopup(true);
-    };
-
-    const handleClone = async () => {
+    const handleCloneWrapper = async (buildId: number) => {
         if (!data?.isLoggedIn) return alert("Please login to clone builds!");
-        if (confirm(`Clone "${selectedBuild.name}" to your dashboard?`)) {
-            await onCloneBuild({ buildId: selectedBuild.id });
+        if (confirm(`Clone this build to your dashboard?`)) {
+            await onCloneBuild({ buildId });
             alert("Build cloned! Check your dashboard.");
-            setOpenDetailPopup(false);
+            setSelectedBuildId(null);
         }
     };
@@ -74,16 +59,16 @@
                 position: 'relative', height: '500px',
                 display: 'flex', alignItems: 'center', justifyContent: 'center', color: 'white',
-                '&::before': { content: '""', position: 'absolute', top: 0, left: 0, width: '100%', height: '100%', backgroundColor: 'rgba(0,0,0,0.6)' }
+                '&::before': {
+                    content: '""', position: 'absolute', top: 0, left: 0, width: '100%', height: '100%',
+                    backgroundColor: 'rgba(0,0,0,0.6)'
+                }
             }}>
                 <Box sx={{ position: 'relative', textAlign: 'center', zIndex: 1, p: 2 }}>
                     <Typography variant="h2" fontWeight="bold" gutterBottom>Forge Your Ultimate Machine</Typography>
-                    <Typography variant="h5" sx={{ maxWidth: '800px', mx: 'auto' }}>
+                    <Typography variant="h5" sx={{ maxWidth: '800px', mx: 'auto', mb: 1 }}>
                         Build, share, discuss, and discover custom PC configurations.
                     </Typography>
-                    <Typography variant="h5" sx={{ mb: 1, maxWidth: '800px', mx: 'auto' }}>
-                        Join the community today.
-                    </Typography>
-
-                    <Button variant="contained" size="large" href="/forger" startIcon={<AutoFixHighIcon />} sx={{ fontSize: '1.2rem', px: 4, py: 1.5 }}>
+                    <Button variant="contained" size="large" href="/forger" startIcon={<AutoFixHighIcon />}
+                            sx={{ fontSize: '1.2rem', px: 4, py: 1.5, mt: 2 }}>
                         Start Forging
                     </Button>
@@ -92,37 +77,42 @@
 
             <Container maxWidth="xl" sx={{ mt: 6, mb: 10 }}>
-                <Box sx={{ mb: 4, borderLeft: '5px solid #ff8201', pl: 2, display: 'flex', justifyContent: 'space-between', alignItems: 'end' }}>
+                <Box sx={{
+                    mb: 4, borderLeft: '5px solid #ff8201', pl: 2,
+                    display: 'flex', justifyContent: 'space-between', alignItems: 'end'
+                }}>
                     <Box>
                         <Typography variant="h4" fontWeight="bold">Hall of Fame</Typography>
-                        <Typography variant="subtitle1" color="text.secondary">The highest rated configurations from across the community.</Typography>
+                        <Typography variant="subtitle1" color="text.secondary">
+                            The highest rated configurations from across the community.
+                        </Typography>
                     </Box>
-                    <Button
-                        variant="outlined"
-                        startIcon={<ListIcon />}
-                        onClick={() => setOpenRankedPopup(true)}
-                    >
+                    <Button variant="outlined" startIcon={<ListIcon />} onClick={() => setOpenRankedPopup(true)}>
                         Show All Top Ranked
                     </Button>
                 </Box>
 
-                <Grid container spacing={3} sx={{ mb: 8 }}>
-                    <Grid item xs={12} md={3}>
-                        <Box sx={{
-                            height: '100%', p: 3, bgcolor: '#ff8201', color: 'black', borderRadius: 2,
-                            display: 'flex', flexDirection: 'column', justifyContent: 'center'
-                        }}>
-                            <Typography color={'black'} variant="h4" fontWeight="bold" gutterBottom>The Elite</Typography>
-                            <Typography fontWeight={'bold'}>
-                                These 3 builds represent the pinnacle of performance and looks as voted by the PC Forge community.
-                            </Typography>
-                        </Box>
-                    </Grid>
+                <Grid container spacing={2} sx={{ mb: 8, alignItems: 'stretch' }}>
+                    {/*<Grid item xs={12} md={3} sx={{ display: 'flex' }}>*/}
+                    {/*    <Box sx={{*/}
+                    {/*        width: '100%', p: 3, bgcolor: '#ff8201', color: 'black', borderRadius: 2,*/}
+                    {/*        display: 'flex', flexDirection: 'column', justifyContent: 'center'*/}
+                    {/*    }}>*/}
+                    {/*        <Typography color={'black'} variant="h5" fontWeight="bold" gutterBottom>The Elite</Typography>*/}
+                    {/*        <Typography variant="body1" fontWeight="bold">The top 3 community-voted builds.</Typography>*/}
+                    {/*    </Box>*/}
+                    {/*</Grid>*/}
 
-                    {data.prebuilts.map((build: any) => (
-                        <Grid item xs={12} sm={6} md={3} key={build.id}>
-                            <BuildCard build={build} onClick={() => handleCardClick(build)} />
+                    {data.prebuilts.slice(0, 3).map((build: any) => (
+                        <Grid item xs={12} sm={6} md={3} key={build.id} sx={{ display: 'flex' }}>
+                            <Box sx={{ width: '100%' }}>
+                                <BuildCard
+                                    build={build}
+                                    onClick={() => setSelectedBuildId(build.id)}
+                                />
+                            </Box>
                         </Grid>
                     ))}
                 </Grid>
+
 
                 <SectionHeader title="Community Forge" subtitle="Fresh builds from users around the world."/>
@@ -130,5 +120,8 @@
                     {data.communityBuilds.map((build: any) => (
                         <Grid item xs={12} sm={6} md={3} key={build.id}>
-                            <BuildCard build={build} onClick={() => handleCardClick(build)} />
+                            <BuildCard
+                                build={build}
+                                onClick={() => setSelectedBuildId(build.id)}
+                            />
                         </Grid>
                     ))}
@@ -138,56 +131,14 @@
                     <Button variant="outlined" size="large" href="/completed-builds">View All Community Builds</Button>
                 </Box>
-
             </Container>
 
-            <Dialog open={openDetailPopup} onClose={() => setOpenDetailPopup(false)} maxWidth="md" fullWidth>
-                {selectedBuild && (
-                    <>
-                        <DialogTitle sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
-                            <Box>
-                                <Typography variant="h5" fontWeight="bold">{selectedBuild.name}</Typography>
-                                <Typography variant="subtitle2" color="text.secondary">By {selectedBuild.username || "Unknown"}</Typography>
-                            </Box>
-                            <IconButton onClick={() => setOpenDetailPopup(false)}><CloseIcon /></IconButton>
-                        </DialogTitle>
 
-                        <DialogContent dividers>
-                            <Grid container spacing={4}>
-                                <Grid item xs={12} md={6}>
-                                    <Box component="img" src={selectedBuild.imageUrl || PLACEHOLDER_IMG} sx={{ width: '100%', borderRadius: 2, mb: 2 }} />
-                                    <Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
-                                        <Rating value={Number(selectedBuild.avgRating) || 0} readOnly precision={0.5} />
-                                        <Typography>({selectedBuild.ratingCount || 0} reviews)</Typography>
-                                    </Box>
-                                </Grid>
-                                <Grid item xs={12} md={6}>
-                                    <Typography variant="h6" gutterBottom>Build Specs</Typography>
-                                    <ComponentRow name="CPU" value="Intel Core i9-13900K" /> {/* Placeholder */}
-                                    <ComponentRow name="GPU" value="NVIDIA RTX 4090" />    {/* Placeholder */}
-
-                                    <Box sx={{ mt: 4, bgcolor: '#f5f5f5', p: 2, borderRadius: 1 }}>
-                                        <Typography variant="subtitle2" fontWeight="bold">Actions</Typography>
-                                        <Box sx={{ display: 'flex', gap: 1, mt: 1 }}>
-                                            <Button size="small" variant="outlined" startIcon={<StarIcon />}>Rate</Button>
-                                            <Button size="small" variant="outlined" startIcon={<CommentIcon />}>Review</Button>
-                                        </Box>
-                                    </Box>
-                                </Grid>
-                            </Grid>
-                        </DialogContent>
-
-                        <DialogActions sx={{ p: 2 }}>
-                            {data.userId === selectedBuild.userId ? (
-                                <Button variant="contained" href={`/forger?edit=${selectedBuild.id}`}>Edit</Button>
-                            ) : (
-                                <Button variant="contained" color="secondary" startIcon={<AutoFixHighIcon />} onClick={null}>
-                                    Clone & Edit
-                                </Button>
-                            )}
-                            <Button href={`/build/${selectedBuild.id}`}>View Full Details</Button>
-                        </DialogActions>
-                    </>
-                )}
-            </Dialog>
+            <BuildDetailsDialog
+                open={!!selectedBuildId}
+                buildId={selectedBuildId}
+                currentUser={data.userId}
+                onClose={() => setSelectedBuildId(null)}
+                onClone={handleCloneWrapper}
+            />
 
 
@@ -199,11 +150,13 @@
                 <DialogContent dividers>
                     <Grid container spacing={3}>
-
                         {data.prebuilts.concat(data.communityBuilds).map((build: any) => (
                             <Grid item xs={12} sm={6} md={3} key={`popup-${build.id}`}>
-                                <BuildCard build={build} onClick={() => {
-                                    setOpenRankedPopup(false);
-                                    handleCardClick(build);
-                                }} />
+                                <BuildCard
+                                    build={build}
+                                    onClick={() => {
+                                        setOpenRankedPopup(false);
+                                        setSelectedBuildId(build.id); // Open details from popup
+                                    }}
+                                />
                             </Grid>
                         ))}
@@ -224,32 +177,2 @@
     );
 }
-
-function BuildCard({ build, onClick }: { build: any, onClick: () => void }) {
-    return (
-        <Card sx={{ height: '100%', display: 'flex', flexDirection: 'column', cursor: 'pointer', transition: 'all 0.2s', '&:hover': { transform: 'translateY(-4px)', boxShadow: 6 } }} onClick={onClick}>
-            <CardMedia component="img" height="160" image={build.imageUrl || PLACEHOLDER_IMG} alt={build.name} />
-            <CardContent sx={{ flexGrow: 1, pb: 1 }}>
-                <Typography gutterBottom variant="h6" noWrap>{build.name}</Typography>
-
-                <Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mt: 1 }}>
-                    <Box sx={{ display: 'flex', alignItems: 'center', px: 1, borderRadius: 1 }}>
-                        <StarIcon fontSize="small" sx={{ color: '#faaf00', mr: 0.5 }} />
-                        <Typography variant="body2" fontWeight="bold">{Number(build.avgRating || 0).toFixed(1)}</Typography>
-                    </Box>
-                    <Typography variant="caption" color="text.secondary">
-                        {build.commentCount || 0} reviews
-                    </Typography>
-                </Box>
-            </CardContent>
-        </Card>
-    );
-}
-
-function ComponentRow({ name, value }: { name: string, value: string }) {
-    return (
-        <Box sx={{ display: 'flex', justifyContent: 'space-between', py: 1, borderBottom: '1px solid #eee' }}>
-            <Typography variant="body2" color="text.secondary">{name}</Typography>
-            <Typography variant="body2" fontWeight="bold">{value}</Typography>
-        </Box>
-    );
-}
