<?php 
include('../../includes/header.php'); 
include('../../includes/config.php'); 
include('../../includes/footer.php'); 

// Flash messages support
$success_msg = $_SESSION['flash']['supplier_success'] ?? null;
$error_msg = $_SESSION['flash']['supplier_error'] ?? null;
unset($_SESSION['flash']['supplier_success'], $_SESSION['flash']['supplier_error']);
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>Add Supplier - Digital POS</title>
    <link rel="stylesheet" href="../../css/dashboard.css" />
    <style>
        body, html {
            margin: 0; padding: 0;
            font-family: 'Segoe UI', sans-serif;
            background: url('../../images/profile.jpg') no-repeat center center fixed;
            background-size: cover;
            color: white;
        }
        .overlay {
            position: fixed; top: 0; left: 0; width: 100%; height: 100%;
            background: rgba(0,0,0,0.6);
            z-index: -1;
        }
        .content {
            margin: 80px auto;
            max-width: 600px;
            padding: 30px 40px;
            background: rgba(255,255,255,0.08);
            border-radius: 20px;
            backdrop-filter: blur(15px);
            box-shadow: 0 8px 32px rgba(0,0,0,0.5);
        }
        h2 {
            text-align: center;
            margin-bottom: 25px;
            font-weight: 700;
        }
        form label {
            display: block;
            margin-bottom: 6px;
            font-weight: bold;
        }
        form input, form textarea {
            width: 100%;
            padding: 10px;
            margin-bottom: 15px;
            border-radius: 10px;
            border: none;
            background: rgba(255,255,255,0.15);
            color: white;
            font-size: 15px;
            resize: vertical;
        }
        form input::placeholder,
        form textarea::placeholder {
            color: rgba(255,255,255,0.6);
        }
        .submit-btn {
            width: 100%;
            padding: 12px;
            background: #ff6f00;
            border: none;
            border-radius: 25px;
            color: white;
            font-weight: bold;
            font-size: 16px;
            cursor: pointer;
            transition: background 0.3s;
        }
        .submit-btn:hover {
            background: #e65c00;
        }
        .alert-success {
            background-color: #4caf50;
            padding: 12px 20px;
            border-radius: 10px;
            margin-bottom: 20px;
            color: white;
            font-weight: 600;
            text-align: center;
        }
        .alert-error {
            background-color: #b00020;
            padding: 12px 20px;
            border-radius: 10px;
            margin-bottom: 20px;
            color: white;
            font-weight: 600;
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="overlay"></div>

    <div class="content">
        <h2>Add New Supplier</h2>

        <?php if ($success_msg): ?>
            <div class="alert-success"><?= htmlspecialchars($success_msg) ?></div>
        <?php endif; ?>

        <?php if ($error_msg): ?>
            <div class="alert-error"><?= htmlspecialchars($error_msg) ?></div>
        <?php endif; ?>

        <form method="POST" action="../../processes/create_supplier.php" novalidate>
            <label for="supplier_name">Supplier Name <span style="color:#ff6f00">*</span></label>
            <input type="text" id="supplier_name" name="supplier_name" required placeholder="Supplier Name">

            <label for="contact_person">Contact Person</label>
            <input type="text" id="contact_person" name="contact_person" placeholder="Contact Person">

            <label for="phone">Phone</label>
            <input type="text" id="phone" name="phone" placeholder="Phone">

            <label for="email">Email</label>
            <input type="email" id="email" name="email" placeholder="Email">

            <label for="address">Address</label>
            <textarea id="address" name="address" rows="3" placeholder="Address"></textarea>

            <label for="t_pin">Tax Pin (TPIN)</label>
            <input type="text" id="t_pin" name="t_pin" placeholder="Tax Pin (TPIN)">

            <button type="submit" class="submit-btn">Add Supplier</button>
        </form>
    </div>
</body>
</html>
