<!DOCTYPE html>
<html lang="fr">
    <head>
        <title>CEDICOM | Enregistrement Commande</title>
        <link href="http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700&subset=all" rel="stylesheet" type="text/css" />
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />

        <style type="text/css">
            body {
                padding: 10px;
                background-color: #f8f9fa !important;
                margin: 0;
                font-family: "Open Sans", Arial, sans-serif;
            }
    
            #main {
                max-width: 500px;
                background-color: #ffffff !important;
                margin: auto;
                padding: 20px;
                border-radius: 8px;
                box-shadow: 0 4px 15px rgba(0,0,0,0.1);
            }

            .title {
                background-color: #0062ff;
                color: #ffffff;
                text-transform: uppercase;
                text-align: center;
                font-weight: bold;
                padding: 12px;
                max-width: 500px;
                margin: 0 auto 20px auto;
                border-radius: 5px;
            }

            /* Section Utilisateur en haut */
            .user-header {
                background-color: #f0f7ff;
                padding: 15px;
                border-radius: 5px;
                margin-bottom: 20px;
                border-left: 5px solid #0062ff;
            }

            .user-info-text {
                font-size: 14px;
                margin: 2px 0;
            }

            .user-points {
                font-weight: bold;
                color: #299a29;
                font-size: 18px;
            }

            /* Formulaire */
            .form-group {
                margin-bottom: 15px;
            }

            label {
                display: block;
                color: #0062ff;
                font-size: 13px;
                font-weight: 600;
                margin-bottom: 5px;
            }

            input, select {
                width: 100%;
                padding: 10px;
                border: 1px solid #ccc;
                border-radius: 4px;
                box-sizing: border-box; /* Important pour le padding */
                font-size: 15px;
            }

            .btn-submit {
                width: 100%;
                background-color: #299a29;
                color: white;
                padding: 12px;
                border: none;
                border-radius: 4px;
                font-size: 16px;
                font-weight: bold;
                cursor: pointer;
                margin-top: 10px;
            }

            .btn-submit:hover {
                background-color: #228022;
            }

            @media screen and (max-width: 600px) {
                #main, .title { width: 100% !important; }
            }
        </style>
    </head>

    <body>
        <div class="title">Validation de Commande</div>

        <div id="main">

            @if(session('success'))
                <div class="alert alert-success">
                    {{ session('success') }}
                </div>
            @endif

            @if(session('error') || $errors->any())
                <div class="alert alert-danger">
                    {{ session('error') ?? 'Veuillez vérifier les informations saisies.' }}
                </div>
            @endif
            <div class="user-header">
                <div class="user-info-text"><strong>Client :</strong> {{$staff->prenom}} {{$staff->nom}}</div>
                <div class="user-info-text"><strong>Email :</strong> {{$staff->email}}</div>
                <div class="user-info-text"><strong>Points actuels :</strong> <span class="user-points">{{$staff->point_accumulé}} pts</span></div>
            </div>

            <form action="{{ route('order.store') }}" method="POST">
                @csrf
                <input type="hidden" name="user_id" value="{{$staff->id}}">

                <div class="form-group">
                    <label>Numéro de Commande</label>
                    <input type="text" name="order_number" placeholder="Ex: CMD-2026-001" required>
                </div>

                <div class="form-group">
                    <label>Choisir le Store</label>
                    <select name="store_id" required>
                        <option value="">-- Sélectionner une boutique --</option>
                        @foreach($stores as $store)
                            <option value="{{$store->id}}">{{$store->nom}}</option>
                        @endforeach
                    </select>
                </div>

                <div class="form-group">
                    <label>Date de la transaction</label>
                    <input type="date" name="order_date" value="{{ date('Y-m-d') }}" required>
                </div>

                <div class="form-group">
                    <label>Montant de la commande (FCFA)</label>
                    <input type="number" name="montant" placeholder="Entrez le montant" required>
                </div>

                <button type="submit" class="btn-submit">ENREGISTRER L'ACHAT</button>
            </form>
        </div>
    </body>
</html>