/* General Reset */
body, h1, p, nav, header, footer, ul, li {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Body Styling */
body {
    font-family: Arial, sans-serif;
    background-color: #f9f9f9;
    color: #333;
}

/* Header Styling */
header {
    text-align: center;
    padding: 20px;
    background-color: #f4f4f4;
}

header img {
    max-width: 100%;
    height: auto;
    width: 300px; /* Adjust logo size */
    display: block;
    margin: 0 auto;
}

/* Navigation Styling */
nav {
    text-align: center;
    background-color: #444;
    padding: 15px 0;
}

nav a {
    color: #fff;
    text-decoration: none;
    margin: 0 15px;
    font-size: 1.2rem; /* Larger font size for better visibility */
    font-weight: bold;
}

nav a:hover {
    text-decoration: underline;
    color: #e74c3c; /* Change hover color */
}

/* Scrolling Text Container */
.scrolling-text {
    background-color:#99003; /* Background for scrolling text */
    color: #fff; /* Text color */
    font-size: 1rem;
    overflow: hidden;
    white-space: nowrap;
    position: relative;
    height: 2em; /* Adjust height to fit text and images */
    line-height: 2em; /* Center text vertically */
    display: flex;
    align-items: center; /* Vertically align text and images */
    justify-content: space-between; /* Space elements evenly: left, center, right */
    padding: 0 20px; /* Add padding for better spacing */
}

/* Scrolling Text */
.scrolling-text span {
    display: inline-block;
    animation: scroll 15s linear infinite;
    margin: 0 10px; /* Space between text and images */
}

/* Images on Left and Right */
.scrolling-image {
    width: 24px; /* Adjust size of GIF */
    height: 24px;
    flex-shrink: 0; /* Prevent image shrinking */
    position: relative;
}

/* Scrolling Animation */
@keyframes scroll {
    0% {
        transform: translateX(100%);
    }
    100% {
        transform: translateX(-100%);
    }
}

/* Main Content Styling */
.container {
    max-width: 800px;
    margin: 20px auto;
    padding: 20px;
    text-align: center;
}

/* Pricing and Services List Styling */
ul {
    list-style: none;
    padding: 0;
    margin: 20px 0;
}

ul li {
    font-size: 1.1rem;
    margin: 10px 0;
    text-align: left; /* Left-align list items */
}

/* Footer Styling */
footer {
    text-align: center;
    padding: 10px;
    background: #444;
    color: #fff;
    font-size: 0.8rem;
    margin-top: 20px;
}

<?php
include 'db_connect.php'; // Connect to the database

// Add item to inventory
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['item_name'])) {
    $item_name = $_POST['item_name'];
    $item_description = $_POST['item_description'];
    $rack_number = $_POST['rack_number'];
    $shelf_number = $_POST['shelf_number'];
    $quantity = $_POST['quantity'];
    $misc = $_POST['misc'];

    $stmt = $conn->prepare("INSERT INTO inventory (item_name, item_description, rack_number, shelf_number, quantity, misc) VALUES (?, ?, ?, ?, ?, ?)");
    $stmt->bind_param("sssdis", $item_name, $item_description, $rack_number, $shelf_number, $quantity, $misc);
    $stmt->execute();
    $stmt->close();
    echo "<p>Item added successfully!</p>";
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>EMT35 Inventory Management</title>
    <link rel="stylesheet" href="css/styles.css">
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            margin: 0;
            padding: 0;
        }
        header {
            background-color: #9e0e1f;
            color: white;
            text-align: center;
            padding: 15px 0;
            font-size: 24px;
            border-bottom: 3px solid #8a0c1a;
        }
        .container {
            width: 80%;
            margin: auto;
            padding: 20px;
            background-color: white;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            border-radius: 8px;
        }
        h1 {
            color: #9e0e1f;
            margin-bottom: 10px;
        }
        h2 {
            color: #333;
            font-size: 22px;
        }
        form {
            margin-bottom: 30px;
            display: grid;
            grid-template-columns: 1fr 1fr;
            grid-gap: 10px;
        }
        label {
            font-weight: bold;
            color: #333;
        }
        input[type="text"], input[type="number"], textarea {
            width: 100%;
            padding: 12px;
            border: 1px solid #ccc;
            border-radius: 8px;
            font-size: 16px;
        }
        button {
            background-color: #9e0e1f;
            color: white;
            border: none;
            padding: 12px 20px;
            cursor: pointer;
            font-size: 16px;
            border-radius: 5px;
        }
        button:hover {
            background-color: #8a0c1a;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
            text-align: left;
        }
        table th, table td {
            padding: 12px;
            border: 1px solid #ddd;
            font-size: 16px;
        }
        table th {
            background-color: #9e0e1f;
            color: white;
        }
        .delete-btn {
            background-color: red;
            color: white;
            padding: 5px 12px;
            cursor: pointer;
            border-radius: 5px;
        }
        .delete-btn:hover {
            background-color: darkred;
        }
        .actions {
            display: flex;
            justify-content: center;
            align-items: center;
        }
        .container p {
            font-size: 16px;
            color: #4c4c4c;
        }
    </style>
</head>
<body>
    <header>
        EMT35 Inventory Management
    </header>
    <div class="container">
        <h1>Add New Item</h1>
        <form method="POST" action="inventory.php">
            <label for="item_name">Item Name</label>
            <input type="text" id="item_name" name="item_name" required>
            
            <label for="item_description">Item Description</label>
            <textarea id="item_description" name="item_description" required></textarea>
            
            <label for="rack_number">Rack Number</label>
            <input type="text" id="rack_number" name="rack_number" required>
            
            <label for="shelf_number">Shelf Number</label>
            <input type="text" id="shelf_number" name="shelf_number" required>
            
            <label for="quantity">Quantity</label>
            <input type="number" id="quantity" name="quantity" required>
            
            <label for="misc">Miscellaneous</label>
            <textarea id="misc" name="misc"></textarea>
            
            <button type="submit">Add Item</button>
        </form>

        <h2>Inventory List</h2>
        <?php
        // Retrieve all items from the inventory
        $result = $conn->query("SELECT * FROM inventory");

        if ($result->num_rows > 0) {
            echo "<table>";
            echo "<tr><th>Item Name</th><th>Description</th><th>Rack</th><th>Shelf</th><th>Quantity</th><th>Misc</th><th>Actions</th></tr>";
            
            while ($row = $result->fetch_assoc()) {
                echo "<tr>
                        <td>{$row['item_name']}</td>
                        <td>{$row['item_description']}</td>
                        <td>{$row['rack_number']}</td>
                        <td>{$row['shelf_number']}</td>
                        <td>{$row['quantity']}</td>
                        <td>{$row['misc']}</td>
                        <td class='actions'>
                            <form method='POST' action='delete_item.php'>
                                <input type='hidden' name='item_id' value='{$row['id']}'>
                                <button type='submit' class='delete-btn'>Delete</button>
                            </form>
                        </td>
                    </tr>";
            }
            echo "</table>";
        } else {
            echo "<p>No items found.</p>";
        }
        ?>
    </div>
</body>
</html>
