<?php $__env->startSection('title', 'Planes | Superadmin | Veltrix v2'); ?>

<?php $__env->startPush('styles'); ?>
<style>
:root {
    --pl-indigo:  #4f46e5;
    --pl-indigo2: #6366f1;
    --pl-green:   #10b981;
    --pl-red:     #ef4444;
    --pl-amber:   #f59e0b;
    --pl-gray:    #64748b;
    --pl-border:  #e2e8f0;
    --pl-bg:      #f8fafc;
    --pl-card:    #ffffff;
}

.pl-shell { background: var(--pl-bg); min-height: 100vh; }

/* Header */
.pl-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 28px 32px 0;
}
.pl-header-title { font-size: 1.35rem; font-weight: 700; color: #0f172a; }
.pl-header-sub   { font-size: .82rem; color: var(--pl-gray); margin-top: 2px; }

/* Grid */
.pl-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
    padding: 24px 32px 40px;
}

/* Plan card */
.pl-card {
    background: var(--pl-card);
    border: 1px solid var(--pl-border);
    border-radius: 16px;
    overflow: hidden;
    transition: box-shadow .18s, transform .18s;
    position: relative;
}
.pl-card:hover { box-shadow: 0 8px 28px rgba(0,0,0,.09); transform: translateY(-2px); }
.pl-card.inactive { opacity: .7; }

.pl-card-top {
    padding: 22px 22px 16px;
    border-bottom: 1px solid var(--pl-border);
}
.pl-card-badge {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: .7rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
    padding: 3px 10px; border-radius: 20px; margin-bottom: 10px;
}
.pl-card-badge.active   { background: #d1fae5; color: #065f46; }
.pl-card-badge.inactive { background: #fee2e2; color: #991b1b; }

.pl-card-name  { font-size: 1.15rem; font-weight: 700; color: #0f172a; margin: 0; }
.pl-card-slug  { font-size: .75rem; color: var(--pl-gray); font-family: monospace; }
.pl-card-price { font-size: 1.7rem; font-weight: 800; color: var(--pl-indigo); margin-top: 6px; }
.pl-card-price small { font-size: .8rem; font-weight: 500; color: var(--pl-gray); }

.pl-card-limits {
    display: flex; gap: 12px; flex-wrap: wrap; margin-top: 10px;
}
.pl-limit-chip {
    display: inline-flex; align-items: center; gap: 4px;
    background: #f1f5f9; border-radius: 6px;
    font-size: .72rem; color: #475569; padding: 3px 8px; font-weight: 500;
}

/* Modules */
.pl-card-body  { padding: 16px 22px; }
.pl-mod-title  { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--pl-gray); margin-bottom: 10px; }
.pl-mod-chips  { display: flex; flex-wrap: wrap; gap: 6px; }
.pl-mod-chip {
    display: inline-flex; align-items: center; gap: 5px;
    background: #eef2ff; color: var(--pl-indigo); border-radius: 20px;
    font-size: .72rem; font-weight: 500; padding: 3px 10px;
}
.pl-mod-chip i { font-size: .85rem; }

/* Promos */
.pl-promo-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.pl-promo-chip {
    background: #fef3c7; color: #92400e; border-radius: 20px;
    font-size: .7rem; font-weight: 600; padding: 3px 10px;
}

/* Actions */
.pl-card-foot {
    display: flex; gap: 8px;
    padding: 12px 22px 18px;
    border-top: 1px solid var(--pl-border);
}
.pl-btn-edit {
    flex: 1; text-align: center; font-size: .8rem; font-weight: 600;
    padding: 7px 14px; border-radius: 8px;
    background: #eef2ff; color: var(--pl-indigo);
    text-decoration: none; transition: background .15s;
}
.pl-btn-edit:hover { background: #e0e7ff; color: var(--pl-indigo); }

.pl-btn-del {
    font-size: .8rem; font-weight: 600; padding: 7px 12px; border-radius: 8px;
    background: #fee2e2; color: #b91c1c; border: none; cursor: pointer;
    transition: background .15s;
}
.pl-btn-del:hover { background: #fecaca; }

.pl-subs-badge {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: .72rem; font-weight: 600; color: #475569;
    background: #f1f5f9; padding: 3px 10px; border-radius: 20px;
}

/* Empty state */
.pl-empty {
    text-align: center; padding: 80px 32px;
    color: var(--pl-gray); grid-column: 1 / -1;
}
.pl-empty i { font-size: 3rem; color: #cbd5e1; display: block; margin-bottom: 12px; }
</style>
<?php $__env->stopPush(); ?>

<?php $__env->startSection('topbar_actions'); ?>
    <a href="<?php echo e(route('superadmin.planes.create', [], false)); ?>" class="btn btn-primary btn-sm vx-topbar-action">
        <i class="bx bx-plus me-1"></i>Nuevo plan
    </a>
    <a href="<?php echo e(route('superadmin.index', [], false)); ?>" class="btn btn-outline-secondary btn-sm vx-topbar-action">
        <i class="bx bx-arrow-back me-1"></i>Superadmin
    </a>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
<div class="pl-shell">
    <div class="pl-header">
        <div>
            <div class="pl-header-title">Planes de suscripción</div>
            <div class="pl-header-sub"><?php echo e($planes->count()); ?> planes · gestiona módulos, precios y promociones</div>
        </div>
        <a href="<?php echo e(route('precios', [], false)); ?>" target="_blank" class="btn btn-outline-indigo btn-sm d-flex align-items-center gap-1" style="border-color:#4f46e5;color:#4f46e5">
            <i class="bx bx-link-external"></i> Ver página pública
        </a>
    </div>

    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(session('success')): ?>
        <div class="mx-4 mt-4 alert alert-success"><?php echo e(session('success')); ?></div>
    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(session('error')): ?>
        <div class="mx-4 mt-4 alert alert-danger"><?php echo e(session('error')); ?></div>
    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

    <div class="pl-grid">
        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__empty_1 = true; $__currentLoopData = $planes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $plan): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
            <?php
                $activoModulos = $plan->modulos->pluck('modulo')->all();
                $promos = $plan->promociones->where('activo', true);
            ?>
            <div class="pl-card <?php echo e($plan->activo ? '' : 'inactive'); ?>">
                <div class="pl-card-top">
                    <div class="d-flex align-items-start justify-content-between">
                        <div>
                            <span class="pl-card-badge <?php echo e($plan->activo ? 'active' : 'inactive'); ?>">
                                <i class="bx <?php echo e($plan->activo ? 'bxs-circle' : 'bx-circle'); ?>"></i>
                                <?php echo e($plan->activo ? 'Activo' : 'Inactivo'); ?>

                            </span>
                            <div class="pl-card-name"><?php echo e($plan->nombre); ?></div>
                            <div class="pl-card-slug"><?php echo e($plan->slug); ?></div>
                        </div>
                        <span class="pl-subs-badge">
                            <i class="bx bxs-buildings"></i>
                            <?php echo e($plan->suscripciones_count); ?> empresa<?php echo e($plan->suscripciones_count !== 1 ? 's' : ''); ?>

                        </span>
                    </div>

                    <div class="pl-card-price">
                        <?php echo e(number_format((float) $plan->precio_mensual, 0, ',', '.') === '0' ? 'Gratis' : '$'.number_format((float) $plan->precio_mensual, 0, ',', '.')); ?>

                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if((float) $plan->precio_mensual > 0): ?>
                            <small>/mes</small>
                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    </div>

                    <div class="pl-card-limits">
                        <span class="pl-limit-chip"><i class="bx bxs-user"></i><?php echo e($plan->max_usuarios); ?> usuario<?php echo e($plan->max_usuarios !== 1 ? 's' : ''); ?></span>
                        <span class="pl-limit-chip"><i class="bx bxs-building"></i><?php echo e($plan->max_sucursales); ?> sucursal<?php echo e($plan->max_sucursales !== 1 ? 'es' : ''); ?></span>
                        <span class="pl-limit-chip"><i class="bx bxs-box"></i><?php echo e(number_format($plan->max_productos)); ?> productos</span>
                    </div>
                </div>

                <div class="pl-card-body">
                    <div class="pl-mod-title">Módulos (<?php echo e(count($activoModulos)); ?>)</div>
                    <div class="pl-mod-chips">
                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__empty_2 = true; $__currentLoopData = $activoModulos; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $mod): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_2 = false; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                            <?php $meta = $todosModulos[$mod] ?? null; ?>
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($meta): ?>
                                <span class="pl-mod-chip">
                                    <i class="bx <?php echo e($meta['icono']); ?>"></i>
                                    <?php echo e($meta['label']); ?>

                                </span>
                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_2): ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
                            <span style="font-size:.78rem;color:#94a3b8">Sin módulos asignados</span>
                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    </div>

                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($promos->isNotEmpty()): ?>
                        <div class="pl-promo-row">
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = $promos; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $promo): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                                <span class="pl-promo-chip">
                                    <i class="bx bxs-tag-alt me-1"></i>
                                    <?php echo e($promo->meses); ?> mes<?php echo e($promo->meses !== 1 ? 'es' : ''); ?> — <?php echo e(number_format((float)$promo->descuento_porcentaje, 0)); ?>% dto.
                                </span>
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
                        </div>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                </div>

                <div class="pl-card-foot">
                    <a href="<?php echo e(route('superadmin.planes.edit', $plan, false)); ?>" class="pl-btn-edit">
                        <i class="bx bx-edit-alt me-1"></i>Editar
                    </a>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($plan->suscripciones_count === 0): ?>
                        <form method="POST" action="<?php echo e(route('superadmin.planes.destroy', $plan)); ?>" onsubmit="return confirm('¿Eliminar el plan <?php echo e(addslashes($plan->nombre)); ?>?')">
                            <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
                            <button type="submit" class="pl-btn-del"><i class="bx bx-trash"></i></button>
                        </form>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                </div>
            </div>
        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
            <div class="pl-empty">
                <i class="bx bx-layer"></i>
                <div style="font-weight:600;font-size:1rem;color:#475569;margin-bottom:6px">No hay planes creados</div>
                <a href="<?php echo e(route('superadmin.planes.create')); ?>" class="btn btn-primary btn-sm mt-2">
                    <i class="bx bx-plus me-1"></i>Crear primer plan
                </a>
            </div>
        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /Applications/XAMPP/xamppfiles/htdocs/veltrix-v2/resources/views/modules/superadmin/planes/index.blade.php ENDPATH**/ ?>