<?php ob_start(); ?>

<div class="max-w-4xl">
    <div class="mb-6">
        <a href="<?= BASE_URL ?>/super-admin/entreprises" class="text-indigo-600 hover:text-indigo-800">
            <i class="fas fa-arrow-left mr-2"></i>Retour aux entreprises
        </a>
    </div>
    
    <div class="bg-white rounded-xl shadow-sm border border-gray-100">
        <div class="p-6 border-b border-gray-100">
            <h3 class="text-lg font-semibold text-gray-800">
                <i class="fas fa-building mr-2 text-indigo-600"></i>Nouvelle Entreprise
            </h3>
        </div>
        
        <form action="<?= BASE_URL ?>/super-admin/entreprises/store" method="POST" class="p-6">
            <input type="hidden" name="csrf_token" value="<?= $csrf_token ?>">
            
            <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                <!-- Informations entreprise -->
                <div class="md:col-span-2">
                    <h4 class="text-md font-medium text-gray-700 mb-4 pb-2 border-b">
                        <i class="fas fa-info-circle mr-2"></i>Informations générales
                    </h4>
                </div>
                
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-2">Nom de l'entreprise *</label>
                    <input type="text" name="nom" required
                           class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent">
                </div>
                
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-2">Secteur d'activité</label>
                    <input type="text" name="secteur"
                           class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent"
                           placeholder="Ex: Télécommunications, Banque...">
                </div>
                
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-2">Pays</label>
                    <input type="text" name="pays" value="Mali"
                           class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent">
                </div>
                
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-2">Région</label>
                    <input type="text" name="region"
                           class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent"
                           placeholder="Ex: Bamako, Sikasso...">
                </div>
                
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-2">Email</label>
                    <input type="email" name="email"
                           class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent">
                </div>
                
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-2">Téléphone</label>
                    <input type="text" name="telephone"
                           class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent"
                           placeholder="+223 XX XX XX XX">
                </div>
                
                <div class="md:col-span-2">
                    <label class="block text-sm font-medium text-gray-700 mb-2">Adresse</label>
                    <textarea name="adresse" rows="2"
                              class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent"></textarea>
                </div>
                
                <!-- Configuration -->
                <div class="md:col-span-2 mt-4">
                    <h4 class="text-md font-medium text-gray-700 mb-4 pb-2 border-b">
                        <i class="fas fa-cog mr-2"></i>Configuration
                    </h4>
                </div>
                
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-2">Type d'abonnement</label>
                    <select name="type_abonnement" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent">
                        <?php foreach ($abonnements as $key => $label): ?>
                            <option value="<?= $key ?>"><?= $label ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
                
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-2">Nombre max d'agents</label>
                    <input type="number" name="max_agents" value="5" min="1" max="100"
                           class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent">
                </div>
                
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-2">Langues activées</label>
                    <div class="space-y-2">
                        <?php foreach ($langues as $code => $nom): ?>
                        <label class="flex items-center">
                            <input type="checkbox" name="langues[]" value="<?= $code ?>" <?= $code === 'fr' ? 'checked' : '' ?>
                                   class="rounded border-gray-300 text-indigo-600 focus:ring-indigo-500">
                            <span class="ml-2 text-gray-700"><?= $nom ?></span>
                        </label>
                        <?php endforeach; ?>
                    </div>
                </div>
                
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-2">Canaux activés</label>
                    <div class="space-y-2">
                        <?php foreach ($canaux as $code => $nom): ?>
                        <label class="flex items-center">
                            <input type="checkbox" name="canaux[]" value="<?= $code ?>" <?= $code === 'web' ? 'checked' : '' ?>
                                   class="rounded border-gray-300 text-indigo-600 focus:ring-indigo-500">
                            <span class="ml-2 text-gray-700"><?= $nom ?></span>
                        </label>
                        <?php endforeach; ?>
                    </div>
                </div>
                
                <!-- Admin entreprise -->
                <div class="md:col-span-2 mt-4">
                    <h4 class="text-md font-medium text-gray-700 mb-4 pb-2 border-b">
                        <i class="fas fa-user-shield mr-2"></i>Administrateur de l'entreprise
                    </h4>
                </div>
                
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-2">Email admin</label>
                    <input type="email" name="admin_email"
                           class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent">
                </div>
                
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-2">Mot de passe admin</label>
                    <input type="password" name="admin_password" value="changeme123"
                           class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent">
                </div>
                
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-2">Nom admin</label>
                    <input type="text" name="admin_nom"
                           class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent">
                </div>
                
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-2">Prénom admin</label>
                    <input type="text" name="admin_prenom"
                           class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent">
                </div>
            </div>
            
            <div class="mt-8 flex justify-end space-x-4">
                <a href="<?= BASE_URL ?>/super-admin/entreprises" class="px-6 py-2 border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50 transition">
                    Annuler
                </a>
                <button type="submit" class="px-6 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 transition flex items-center">
                    <i class="fas fa-save mr-2"></i>Créer l'entreprise
                </button>
            </div>
        </form>
    </div>
</div>

<?php 
$content = ob_get_clean();
$title = 'Nouvelle entreprise - ' . APP_NAME;
$pageTitle = 'Créer une entreprise';
include VIEWS_PATH . '/layouts/main.php';
?>
