<?php
session_start();
require 'db.php';

if (!isset($_SESSION['user_id'])) {
    header("Location: giris.php");
    exit;
}

$user_id = $_SESSION['user_id'];

// Ürünleri veritabanından çek
$stmt = $pdo->query("SELECT * FROM products WHERE status = 1 ORDER BY price DESC");
$products = $stmt->fetchAll();

?>
<!DOCTYPE html>
<html lang="tr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
	 <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    <title>Ana Sayfa</title>
    <style>
        body {
            margin: 0;
            font-family: 'Arial', sans-serif;
            background-color: #f4f4f4;
            color: #333;
			padding-bottom: 60px; /* Footer yüksekliğine göre ayarlayın */
        }
        header {
            background-color: #fff;
            color: #333;
            text-align: center;
            padding: 30px;
        }
        header h1 {
            margin: 0;
            font-size: 24px;
        }
        
        a {
    text-decoration:none;
    color:#459D7A;
    
}
		
		.top-right {
            position: absolute;
            right: 25px;
            top: 40px;
        }

        .material-icons {
            cursor: pointer;
			
        }
		
		.material-icons:active {
            cursor: pointer;
			color: #459D7A
        }
		
        .footer-menu {
            display: flex;
            justify-content: space-around;
            padding: 20px 0;
            background-color: #fff;
            position: fixed;
            bottom: 0;
            width: 100%;
            box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
        }
		.active {
			font-weight:600;
            color: #459D7A !important;
			
        }
        .footer-menu a {
            text-align: center;
            flex-grow: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            text-decoration: none;
            color: #333;
        }
		
        .footer-menu a i {
            font-size: 24px; /* İkon boyutu */
        }
        .footer-menu a span {
            font-size: 12px;
            margin-top: 4px;
			
        }
	.product-container {
    padding: 20px;
    width: 100%; /* Konteynerin genişliği */
    max-width: 350px; /* Maksimum genişlik */
    margin: 0 auto; /* Merkezde konumlandırmak için */
}

.product {
    display: flex;
    align-items: center;
    background-color: #fff;
    margin-bottom: 20px;
    border: 1px solid #ddd;
    border-radius: 10px;
    width: 100%; /* Ürünlerin genişliği */
    box-shadow: 0 2px 5px rgba(0,0,0,0.1); /* Gölge ekleme */
}

.product-image {
    width: 150px; /* Resim genişliği */
    height: 150px; /* Resim yüksekliği */
    object-fit: cover; /* Resmin kutuya sığmasını sağlar */
    margin-right: 20px; /* Resim ile detaylar arası boşluk */
}

.product-details {
    flex-grow: 1; /* Kalan alanı doldur */
    padding: 10px 20px;
}

.product-title,
.product-description,
.product-price {
    margin: 5px 0;
}

    </style>

</head>
<body>

<header>
    <div class="top-right">
        <i class="material-icons">notifications</i>
    </div>
    <div>...</div> <!-- Diğer kullanıcı bilgileri ve bildirim simgesi için yer -->
</header>

<div class="product-container">
    <?php foreach ($products as $product): ?>
        <div class="product">
             <a href="<?php echo htmlspecialchars($product['urun_url']); ?>" target="_blank" class="product">
            <img src="<?php echo htmlspecialchars($product['image_url']); ?>" alt="<?php echo htmlspecialchars($product['name']); ?>" class="product-image">
            <div class="product-details">
                <h3 class="product-title"><?php echo htmlspecialchars($product['name']); ?></h3>
                <p class="product-description"><?php echo htmlspecialchars($product['description']); ?></p>
                <p class="product-price"><?php echo htmlspecialchars($product['price']); ?> TL</p>
            </div>
            </a>
        </div>
    <?php endforeach; ?>
</div>

<div class="footer-menu">
    <a href="dashboard.php">
        <i class="material-icons">home</i>
        <span>Ana Sayfa</span>
    </a>
    <a href="sale_list.php">
        <i class="material-icons">monetization_on</i>
        <span>Satışlar</span>
    </a>
    <a href="profil.php">
        <i class="material-icons">person</i>
        <span>Profil</span>
    </a>
</div>

</body>
</html>

