<div class="space-y-6">
    <div class="bg-white shadow-sm rounded-lg p-6">
        <h3 class="text-lg font-semibold text-gray-800 mb-4">📥 Importar desde Excel/CSV</h3>

        <div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4">
            <div>
                <label class="block text-sm font-medium text-gray-700 mb-1">Tipo de importación</label>
                <select wire:model="tipo" class="w-full border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500">
                    <option value="deudores">Deudores</option>
                    <option value="clientes">Clientes Corporativos</option>
                </select>
            </div>
            <div>
                <label class="block text-sm font-medium text-gray-700 mb-1">Archivo (.xlsx, .csv)</label>
                <input type="file" wire:model="archivo" accept=".xlsx,.xls,.csv"
                    class="w-full text-sm text-gray-500 file:mr-4 file:py-2 file:px-4 file:rounded file:border-0 file:text-sm file:font-semibold file:bg-indigo-50 file:text-indigo-700 hover:file:bg-indigo-100">
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__errorArgs = ['archivo'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <span class="text-red-500 text-xs"><?php echo e($message); ?></span> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            </div>
        </div>

        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($tipo === 'deudores'): ?>
        <div class="text-xs text-gray-500 mb-4 bg-gray-50 p-3 rounded">
            <strong>Columnas esperadas:</strong> tipo_documento, numero_documento (o cc/cedula), nombre_completo (o nombre), email, telefono, direccion_notificacion, ciudad
        </div>
        <?php else: ?>
        <div class="text-xs text-gray-500 mb-4 bg-gray-50 p-3 rounded">
            <strong>Columnas esperadas:</strong> nombre (o razon_social), nit, contacto_nombre, contacto_email, contacto_telefono, plataforma_externa
        </div>
        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

        <div class="flex gap-3">
            <button wire:click="importar" wire:loading.attr="disabled"
                class="px-4 py-2 bg-indigo-600 text-white rounded-md hover:bg-indigo-700 disabled:opacity-50 text-sm font-medium">
                <span wire:loading.remove wire:target="importar">📤 Importar</span>
                <span wire:loading wire:target="importar">⏳ Procesando...</span>
            </button>
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($mostrarResultados): ?>
            <button wire:click="limpiar" class="px-4 py-2 bg-gray-200 text-gray-700 rounded-md hover:bg-gray-300 text-sm">
                🔄 Limpiar
            </button>
            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
        </div>
    </div>

    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($mostrarResultados): ?>
    <div class="bg-white shadow-sm rounded-lg p-6">
        <h4 class="font-semibold text-gray-800 mb-3">Resultados de importación</h4>
        <div class="grid grid-cols-3 gap-4 mb-4">
            <div class="bg-green-50 p-3 rounded text-center">
                <div class="text-2xl font-bold text-green-600"><?php echo e($importados); ?></div>
                <div class="text-xs text-green-700">Importados</div>
            </div>
            <div class="bg-yellow-50 p-3 rounded text-center">
                <div class="text-2xl font-bold text-yellow-600"><?php echo e($duplicados); ?></div>
                <div class="text-xs text-yellow-700">Duplicados</div>
            </div>
            <div class="bg-red-50 p-3 rounded text-center">
                <div class="text-2xl font-bold text-red-600"><?php echo e($errores); ?></div>
                <div class="text-xs text-red-700">Errores</div>
            </div>
        </div>
        <div class="max-h-60 overflow-y-auto space-y-1">
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $resultados; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $r): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <div class="text-xs px-3 py-1 rounded <?php echo e($r['tipo'] === 'ok' ? 'bg-green-50 text-green-800' : ($r['tipo'] === 'dup' ? 'bg-yellow-50 text-yellow-800' : 'bg-red-50 text-red-800')); ?>">
                <?php echo e($r['msg']); ?>

            </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
        </div>
    </div>
    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
</div><?php /**PATH /home/evolucionamos/public_html/yber-dev/resources/views/livewire/import/importador-excel.blade.php ENDPATH**/ ?>