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

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

$user_id = $_SESSION['user_id'];

$stmt = $pdo->prepare("SELECT fullname, username, reference_code FROM users WHERE id = ?");
$stmt->execute([$user_id]);
$user = $stmt->fetch();

?>
<!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;

        }
        header {
            background-color: #fff;
            color: #333;
            text-align: center;
            padding: 20px;
        }
        header h1 {
            margin: 0;
            font-size: 24px;
        }
		
		.top-right {
            position: absolute;
            right: 25px;
            top: 40px;
        }

        .material-icons {
            cursor: pointer;
			
        }
		
		.material-icons:active {
            cursor: pointer;
			color: #459D7A
        }
		
        .menu {
            padding: 20px;
            background-color: #fff;
        }
        .menu-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            grid-gap: 20px;
            padding: 20px 0;
        }
        .menu-item {
            background: #fff;
            border-radius: 10px;
            overflow: hidden;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            text-align: center;
            transition: transform 0.2s ease;
        }
        .menu-item img {
			width: 140px; 
			height: 140px; 
			border-radius: 12px;
			border-width: 3px; 
			border-color: #459D7A;
			border-style: solid;
        }
        .menu-item p {
            margin: 10px 0;
        }
        .menu-item:hover {
            transform: translateY(-5px);
            box-shadow: 0 4px 20px rgba(0,0,0,0.2);
        }
        .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;
			
        }
		
    </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="menu">
	<h4>Merhaba, <?php echo htmlspecialchars($user['fullname']); ?> (<?php echo htmlspecialchars($user['username']); ?>)</h4>
    <h2>MENÜ</h2>
    <div class="menu-grid">
        <div class="menu-item">
		<a href="urunler.php">
            <img src="images/dashboard/urunler.png" alt="Ürünler">
		</a>
            <p>Ürünler</p>
		</a>
        </div>
        <div class="menu-item">
		<a href="sales_report.php">
            <img src="images/dashboard/satis.jpg" alt="Satış Bildir">
		</a>
            <p>Satış Bildir</p>
		
        </div>
        <div class="menu-item">
		<a href="stok-talep.php">
            <img src="images/dashboard/stok.jpg" alt="Stok Talep Et">
		</a>
			<p>Stok Talep Et</p>
		
        </div>
        <div class="menu-item">
		<a href="referans.php">
            <img src="images/dashboard/referans.png" alt="Referanslarım">
		</a>
            <p>Referanslarım</p>
		
        </div>
    </div>
</div>

<div class="footer-menu">
    <a href="dashboard.php" class="active">
        <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>

