<div>
    
    <div class="w-full flex items-center mb-8">
        <a href="<?php echo e(route('products.show', $product)); ?>"
            class="flex rounded-lg bg-white border border-gray-200 px-4 py-2 text-gray-700 hover:bg-gray-100 font-bold">
            <img src="<?php echo e(asset('vendor/blade-untitledui-icons/arrow-narrow-left.svg')); ?>" alt="Volver" class="w-6 h-6">
            <span class="ml-2">Volver</span>
        </a>
        <div class="ml-4 flex items-center text-sm text-gray-500">
            <a href="<?php echo e(route('products.scss-cdn.index', $product)); ?>"
               class="text-orange-600 hover:text-orange-800">
                Bundles SCSS CDN
            </a>
            <span class="mx-2">/</span>
            <span class="text-gray-700 font-semibold">Bundle <?php echo e($bundle->version); ?></span>
        </div>
    </div>

    
    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(session()->has('success')): ?>
        <div class="mb-4 rounded bg-green-100 px-4 py-2 text-green-700">
            <?php echo e(session('success')); ?>

        </div>
    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

    <?php if(session()->has('error')): ?>
        <div class="mb-4 rounded bg-red-100 px-4 py-2 text-red-700">
            <?php echo e(session('error')); ?>

        </div>
    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

    
    <div class="w-full flex flex-wrap items-center justify-between rounded-lg bg-white border border-gray-200 px-8 py-4 mb-6">
        <div class="w-full flex items-center justify-between">
            <div class="flex items-center gap-4">
                <div>
                    <h1 class="text-4xl font-bold">Bundle <?php echo e($bundle->version); ?></h1>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($bundle->description): ?>
                        <p class="mt-2 text-gray-600"><?php echo e($bundle->description); ?></p>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    <div class="mt-2 text-sm text-gray-500">
                        <span>Creado por: <span class="font-semibold text-gray-700"><?php echo e($bundle->creator?->name ?? 'N/A'); ?></span></span>
                        <span class="mx-2">•</span>
                        <span>Fecha: <span class="font-semibold text-gray-700"><?php echo e($bundle->created_at->format('Y-m-d H:i')); ?></span></span>
                    </div>
                </div>
            </div>
            <div class="flex items-center gap-2">
                <button wire:click="duplicateBundle"
                        wire:confirm="¿Seguro que deseas duplicar este bundle? Se creará un nuevo bundle con todos los archivos."
                        class="flex items-center rounded-lg bg-green-600 px-4 py-2 text-white hover:bg-green-700 font-semibold">
                    <img src="<?php echo e(asset('vendor/blade-untitledui-icons/copy.svg')); ?>" alt="Duplicar" class="w-5 h-5 mr-2 svg-fill-white">
                    Duplicar bundle
                </button>
                <a href="<?php echo e(route('products.scss-cdn.bundle.edit', [$product, $bundle])); ?>"
                   class="flex items-center rounded-lg bg-orange-600 px-4 py-2 text-white hover:bg-orange-700 font-semibold">
                    <img src="<?php echo e(asset('vendor/blade-untitledui-icons/pencil.svg')); ?>" alt="Editar" class="w-5 h-5 mr-2 svg-fill-white">
                    Editar bundle
                </a>
            </div>
        </div>
    </div>

    
    <div class="mb-6 flex items-center justify-between">
        <h2 class="text-2xl font-bold">Archivos (<?php echo e($files->count()); ?>)</h2>
        <div class="flex items-center gap-2">
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(!empty($selectedFiles)): ?>
                <button wire:click="deleteSelectedFiles"
                        wire:confirm="¿Seguro que deseas eliminar los <?php echo e(count($selectedFiles)); ?> archivo(s) seleccionado(s)?"
                        class="flex items-center rounded-lg bg-red-600 px-4 py-2 text-white hover:bg-red-700 font-semibold">
                    <img src="<?php echo e(asset('vendor/blade-untitledui-icons/trash.svg')); ?>" alt="Eliminar" class="w-5 h-5 mr-2 svg-fill-white">
                    Eliminar seleccionados (<?php echo e(count($selectedFiles)); ?>)
                </button>
            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            <label class="flex items-center gap-2 text-sm text-gray-600 cursor-pointer px-4 py-2 rounded-lg border border-gray-200 hover:bg-gray-50">
                <input type="checkbox"
                       wire:model.live="makeAllServable"
                       class="rounded">
                <span>Marcar todos como servibles</span>
            </label>
            <a href="<?php echo e(route('products.scss-cdn.bundle.upload', [$product, $bundle])); ?>"
               class="flex items-center rounded-lg bg-green-600 px-4 py-2 text-white hover:bg-green-700 font-semibold">
                <img src="<?php echo e(asset('vendor/blade-untitledui-icons/upload.svg')); ?>" alt="Subir" class="w-5 h-5 mr-2 svg-fill-white">
                Subir ZIP
            </a>
        </div>
    </div>

    
    <div class="rounded-lg bg-white border border-gray-200 overflow-hidden mb-6">
        <div class="px-6 py-4 border-b border-gray-200 bg-gray-50">
            <h3 class="text-lg font-semibold">Estructura de archivos</h3>
        </div>
        <div class="overflow-x-auto">
            <table class="min-w-full text-sm">
                <thead class="bg-gray-100 text-xs uppercase text-gray-600">
                <tr>
                    <th class="px-4 py-3 text-left w-12">
                        <input type="checkbox"
                               wire:model.live="selectAll"
                               class="rounded"
                               title="Seleccionar todos para borrado">
                    </th>
                    <th class="px-4 py-3 text-left">Ruta del archivo</th>
                    <th class="px-4 py-3 text-left w-32">Servible</th>
                    <th class="px-4 py-3 text-right">Acciones</th>
                </tr>
                </thead>
                <tbody class="divide-y">
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $files; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $file): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr class="hover:bg-gray-50">
                        <td class="px-4 py-3">
                            <input type="checkbox"
                                   wire:click="toggleSelectFile(<?php echo e($file->id); ?>)"
                                   <?php echo e(in_array($file->id, $selectedFiles) ? 'checked' : ''); ?>

                                   class="rounded">
                        </td>
                        <td class="px-4 py-3 font-mono font-semibold text-gray-900"><?php echo e($file->relative_path); ?></td>
                        <td class="px-4 py-3">
                            <label class="flex items-center cursor-pointer" title="Marcar como servible (se servirá cuando Moodle solicite con action 'scss')">
                                <input type="checkbox"
                                       wire:click="toggleServable(<?php echo e($file->id); ?>)"
                                       <?php echo e($file->is_servable ? 'checked' : ''); ?>

                                       class="rounded">
                                <span class="ml-2 text-xs font-semibold <?php echo e($file->is_servable ? 'text-green-600' : 'text-gray-500'); ?>">
                                    <?php echo e($file->is_servable ? 'Sí' : 'No'); ?>

                                </span>
                            </label>
                        </td>
                        <td class="px-4 py-3 text-right">
                            <div class="flex items-center justify-end gap-2">
                                <a href="<?php echo e(route('products.scss-cdn.file.edit', [$product, $bundle, $file])); ?>"
                                   class="text-orange-600 hover:text-orange-800 text-xs font-semibold">
                                    Editar
                                </a>
                                <button wire:click="deleteFile(<?php echo e($file->id); ?>)"
                                        wire:confirm="¿Seguro que deseas eliminar este archivo?"
                                        class="text-red-600 hover:text-red-800 text-xs font-semibold">
                                    Eliminar
                                </button>
                            </div>
                        </td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                </tbody>
            </table>
        </div>
    </div>

    
    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($servableFiles->count() > 0): ?>
        <div class="rounded-lg bg-white border border-gray-200 overflow-hidden">
            <div class="px-6 py-4 border-b border-gray-200 bg-gray-50">
                <h3 class="text-lg font-semibold">Archivos servibles (<?php echo e($servableFiles->count()); ?>)</h3>
            </div>
            <div class="p-6">
                <div class="space-y-3">
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $servableFiles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $file): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <div class="rounded-lg border border-gray-200 p-4 hover:bg-gray-50">
                            <div class="mb-2 font-mono text-sm font-semibold text-gray-900"><?php echo e($file->relative_path); ?></div>
                            <div class="text-xs text-gray-600 space-y-1">
                                <div>URL: <a href="<?php echo e($this->getFileUrl($file->id)); ?>" target="_blank" class="text-orange-600 hover:underline break-all"><?php echo e($this->getFileUrl($file->id)); ?></a></div>
                                <?php
                                    $fileContent = \App\Services\ScssCdn\ScssCdnStorageService::getFile($product, $bundle, $file->relative_path);
                                    $fileSize = $fileContent ? strlen($fileContent) : 0;
                                ?>
                                <div>Tamaño: <?php echo e(number_format($fileSize, 0, ',', '.')); ?> bytes</div>
                            </div>
                        </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                </div>
            </div>
        </div>
    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
</div><?php /**PATH /var/www/html/resources/views/livewire/scss-cdn/bundle-show.blade.php ENDPATH**/ ?>