<?php
// header.php - Common Header for all pages

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

$user_role = $_SESSION['role'] ?? 'user';
$full_name = $_SESSION['full_name'] ?? 'User';
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?= $page_title ?? 'Technocool ERP' ?></title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
    <style>
        :root {
            --primary: #a855f7;
            --accent: #c084fc;
            --dark: #0f172a;
            --glass: rgba(15, 23, 42, 0.85);
        }

        * { margin:0; padding:0; box-sizing:border-box; }
        body {
            font-family: 'Inter', system-ui, sans-serif;
            background: linear-gradient(135deg, rgba(0,0,0,0.85), rgba(0,0,0,0.95)), 
                        url('../background.jpeg') center/cover no-repeat fixed;
            color: #f1f5f9;
            min-height: 100vh;
            padding:0px !important;
        }

        /* Top Navigation Bar */
        .top-nav {
            background: var(--glass);
            backdrop-filter: blur(20px);
            border-bottom: 1px solid rgba(255,255,255,0.1);
            position: sticky;
            top: 0;
            z-index: 1000;
            padding: 15px 30px;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .logo {
            font-size: 24px;
            font-weight: 700;
            color: var(--accent);
            text-decoration: none;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .nav-menu {
            display: flex;
            gap: 25px;
            list-style: none;
        }

        .nav-menu a {
            color: #e0e7ff;
            text-decoration: none;
            font-weight: 500;
            padding: 8px 16px;
            border-radius: 8px;
            transition: all 0.3s;
        }

        .nav-menu a:hover,
        .nav-menu a.active {
            background: rgba(168,85,247,0.25);
            color: white;
        }

        .user-info {
            display: flex;
            align-items: center;
            gap: 15px;
        }

        .user-avatar {
            width: 42px;
            height: 42px;
            background: linear-gradient(135deg, var(--primary), var(--accent));
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 700;
            color: white;
        }

        .user-details {
            text-align: right;
        }

        .user-name {
            font-weight: 600;
            font-size: 15px;
        }

        .user-role {
            font-size: 12px;
            opacity: 0.7;
        }

        .main-content {
            padding: 30px;
            max-width: 1400px;
            margin: 0 auto;
        }

        /* Glass card for content */
        .glass-card {
            background: rgba(255,255,255,0.08);
            backdrop-filter: blur(20px);
            border: 1px solid rgba(255,255,255,0.15);
            border-radius: 24px;
            padding: 35px;
            box-shadow: 0 25px 70px rgba(0,0,0,0.6);
        }
    </style>
</head>
<body>

<!-- Top Navigation -->
<nav class="top-nav">
    <?php if ($user_role == 'admin') { ?>
    <a href="https://technocool.any-many.in/admin/dashboard_admin.php" class="logo">
        <i class="fas fa-cogs"></i> TECHNOCOOL
    </a>
    <?php }else { ?>
    <a href="https://technocool.any-many.in/project/dashboard_project_manager.php" class="logo">
        <i class="fas fa-cogs"></i> TECHNOCOOL
    </a>
    <?php } ?>


    <!-- <ul class="nav-menu">
        <li><a href="planning_list.php" <?= basename($_SERVER['PHP_SELF']) == 'planning_list.php' ? 'class="active"' : '' ?>>
            <i class="fas fa-file-invoice"></i> Planning
        </a></li>
        <li><a href="purchase_list.php" <?= basename($_SERVER['PHP_SELF']) == 'purchase_list.php' ? 'class="active"' : '' ?>>
            <i class="fas fa-shopping-cart"></i> Purchase
        </a></li>
        <li><a href="po_list.php" <?= basename($_SERVER['PHP_SELF']) == 'po_list.php' ? 'class="active"' : '' ?>>
            <i class="fas fa-file-contract"></i> PO
        </a></li>
        <li><a href="grn_list.php" <?= basename($_SERVER['PHP_SELF']) == 'grn_list.php' ? 'class="active"' : '' ?>>
            <i class="fas fa-truck-loading"></i> GRN
        </a></li>
        <li><a href="dc_list.php" <?= basename($_SERVER['PHP_SELF']) == 'dc_list.php' ? 'class="active"' : '' ?>>
            <i class="fas fa-truck"></i> Delivery Challan
        </a></li>
    </ul> -->

    <div class="user-info">
        <div class="user-avatar">
            <?= strtoupper(substr($full_name, 0, 1)) ?>
        </div>
        <div class="user-details">
            <div class="user-name"><?= htmlspecialchars($full_name) ?></div>
            <div class="user-role"><?= ucwords(str_replace('_', ' ', $user_role)) ?></div>
        </div>
        <a href="../logout.php" style="color:#fda4af; margin-left:15px;" title="Logout">
            <i class="fas fa-sign-out-alt"></i>
        </a>
    </div>
</nav>

<div class="main-content">