<?php

use App\Livewire\Forms\LoginForm;
use Illuminate\Support\Facades\Session;
use Livewire\Attributes\Layout;
use Livewire\Volt\Component;

?>

<?php
    $configPlatform = \App\Models\ConfiguracionPlataforma::first();
    $logoPath = null;
    // 1. Logo desde BD (subido en Config > Apariencia)
    // 1a. Logo específico de login (fondo blanco)
    if ($configPlatform && $configPlatform->logo_login_path && file_exists(public_path($configPlatform->logo_login_path))) {
        $logoPath = asset($configPlatform->logo_login_path);
    }
    // 1b. Fallback: logo principal
    elseif ($configPlatform && $configPlatform->logo_path && file_exists(public_path($configPlatform->logo_path))) {
        $logoPath = asset($configPlatform->logo_path);
    }
    // 2. Fallback: archivos estáticos
    if (!$logoPath) {
        foreach (['images/branding/logo.png', 'images/branding/logo.svg', 'images/login/logo.png', 'images/login/logo.svg'] as $p) {
            if (file_exists(public_path($p))) { $logoPath = asset($p); break; }
        }
    }

    $bgImage = null;
    // 1. Fondo desde BD
    if ($configPlatform && $configPlatform->login_bg_path && file_exists(public_path($configPlatform->login_bg_path))) {
        $bgImage = asset($configPlatform->login_bg_path);
    }
    // 2. Fallback: archivos estáticos
    if (!$bgImage) {
        foreach (['images/login/bg-left.jpg', 'images/login/bg-left.png', 'images/login/bg-desktop.jpg', 'images/login/bg-desktop.png'] as $p) {
            if (file_exists(public_path($p))) { $bgImage = asset($p); break; }
        }
    }
?>

<div class="min-h-screen flex" x-data="{ showPassword: false }">

    
    <div class="hidden lg:block lg:w-[65%] xl:w-[68%] relative overflow-hidden">
        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($bgImage): ?>
            <img src="<?php echo e($bgImage); ?>" alt="" class="absolute inset-0 w-full h-full object-cover">
            <div class="absolute bottom-6 left-8 z-10">
                <p class="text-white/70 text-sm drop-shadow-md">&copy; <?php echo e(date('Y')); ?> Singularidad IA.</p>
            </div>
        <?php else: ?>
            <div class="absolute inset-0" style="background: linear-gradient(160deg, #0a1929 0%, #102a43 35%, #1a3a54 60%, #0d2137 100%);"></div>
            <div class="relative z-10 flex flex-col justify-between w-full h-full p-10 xl:p-16">
                <div></div>
                <div class="max-w-lg">
                    <h1 class="font-heading text-3xl xl:text-4xl font-bold text-white leading-tight">
                        Gestión jurídica<br>y cobranzas con<br>
                        <span class="text-emerald-400">trazabilidad total.</span>
                    </h1>
                    <p class="mt-6 text-slate-400 text-base leading-relaxed max-w-md">
                        Control de procesos ejecutivos, generación automática de documentos y seguimiento judicial centralizado.
                    </p>
                </div>
                <p class="text-slate-600 text-sm">&copy; <?php echo e(date('Y')); ?> Singularidad IA.</p>
            </div>
        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
    </div>

    
    <div class="w-full lg:w-[35%] xl:w-[32%] flex flex-col bg-white">

        <div class="flex-1 min-h-[30px]"></div>

        <div class="w-full max-w-sm mx-auto px-6 sm:px-8 lg:px-10">

            
            <div class="mb-8 flex justify-center">
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($logoPath): ?>
                    <img src="<?php echo e($logoPath); ?>" alt="<?php echo e(config('app.name', 'YBER')); ?>" class="h-20 w-auto">
                <?php else: ?>
                    <div class="flex flex-col items-center gap-2">
                        <div class="w-16 h-16 bg-slate-900 rounded-2xl flex items-center justify-center">
                            <svg class="w-9 h-9 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 6l3 1m0 0l-3 9a5.002 5.002 0 006.001 0M6 7l3 9M6 7l6-2m6 2l3-1m-3 1l-3 9a5.002 5.002 0 006.001 0M18 7l3 9m-3-9l-6-2m0-2v2m0 16V5m0 16H9m3 0h3"/>
                            </svg>
                        </div>
                        <span class="text-slate-900 text-2xl font-heading font-bold tracking-wide"><?php echo e(config('app.name', 'YBER')); ?></span>
                    </div>
                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            </div>

            
            <div class="mb-8 text-center">
                <h2 class="font-heading text-2xl xl:text-[1.75rem] font-bold text-slate-900 tracking-tight">
                    Bienvenido
                </h2>
                <p class="mt-1.5 text-slate-400 text-sm">
                    Ingrese sus credenciales para acceder al panel.
                </p>
            </div>

            <?php if (isset($component)) { $__componentOriginal7c1bf3a9346f208f66ee83b06b607fb5 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal7c1bf3a9346f208f66ee83b06b607fb5 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.auth-session-status','data' => ['class' => 'mb-4','status' => session('status')]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('auth-session-status'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['class' => 'mb-4','status' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(session('status'))]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal7c1bf3a9346f208f66ee83b06b607fb5)): ?>
<?php $attributes = $__attributesOriginal7c1bf3a9346f208f66ee83b06b607fb5; ?>
<?php unset($__attributesOriginal7c1bf3a9346f208f66ee83b06b607fb5); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal7c1bf3a9346f208f66ee83b06b607fb5)): ?>
<?php $component = $__componentOriginal7c1bf3a9346f208f66ee83b06b607fb5; ?>
<?php unset($__componentOriginal7c1bf3a9346f208f66ee83b06b607fb5); ?>
<?php endif; ?>

            
            <form wire:submit="login" class="space-y-5">
                <div>
                    <label for="email" class="block text-xs font-semibold text-slate-600 uppercase tracking-wider mb-2">
                        Correo Corporativo
                    </label>
                    <input wire:model="form.email" id="email" type="email" autocomplete="username" required autofocus
                           class="w-full px-4 py-3 rounded-lg border border-slate-200 bg-slate-50 text-slate-900 text-sm placeholder-slate-300 focus:outline-none focus:border-slate-400 focus:ring-2 focus:ring-slate-100 transition-colors duration-200"
                           placeholder="usuario@empresa.com">
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__errorArgs = ['form.email'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                        <p class="mt-2 text-sm text-red-600 flex items-center gap-1.5">
                            <svg class="w-4 h-4 flex-shrink-0" fill="currentColor" viewBox="0 0 20 20">
                                <path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z" clip-rule="evenodd"/>
                            </svg>
                            <?php echo e($message); ?>

                        </p>
                    <?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>
                    <div class="flex items-center justify-between mb-2">
                        <label for="password" class="block text-xs font-semibold text-slate-600 uppercase tracking-wider">Contraseña</label>
                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(Route::has('password.request')): ?>
                            <a href="<?php echo e(route('password.request')); ?>" class="text-xs text-blue-600 hover:text-blue-800 font-medium transition-colors" wire:navigate>¿Olvidó su contraseña?</a>
                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    </div>
                    <div class="relative">
                        <input wire:model="form.password" id="password" :type="showPassword ? 'text' : 'password'" autocomplete="current-password" required
                               class="w-full px-4 py-3 pr-11 rounded-lg border border-slate-200 bg-slate-50 text-slate-900 text-sm placeholder-slate-300 focus:outline-none focus:border-slate-400 focus:ring-2 focus:ring-slate-100 transition-colors duration-200"
                               placeholder="••••••••">
                        <button type="button" @click="showPassword = !showPassword" class="absolute right-3 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600 transition-colors" tabindex="-1">
                            <svg x-show="!showPassword" class="w-4.5 h-4.5" fill="none" stroke="currentColor" viewBox="0 0 24 24" stroke-width="1.5">
                                <path stroke-linecap="round" stroke-linejoin="round" d="M2.036 12.322a1.012 1.012 0 010-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178z"/>
                                <path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/>
                            </svg>
                            <svg x-show="showPassword" x-cloak class="w-4.5 h-4.5" fill="none" stroke="currentColor" viewBox="0 0 24 24" stroke-width="1.5">
                                <path stroke-linecap="round" stroke-linejoin="round" d="M3.98 8.223A10.477 10.477 0 001.934 12C3.226 16.338 7.244 19.5 12 19.5c.993 0 1.953-.138 2.863-.395M6.228 6.228A10.45 10.45 0 0112 4.5c4.756 0 8.773 3.162 10.065 7.498a10.523 10.523 0 01-4.293 5.774M6.228 6.228L3 3m3.228 3.228l3.65 3.65m7.894 7.894L21 21m-3.228-3.228l-3.65-3.65m0 0a3 3 0 10-4.243-4.243m4.242 4.242L9.88 9.88"/>
                            </svg>
                        </button>
                    </div>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__errorArgs = ['form.password'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                        <p class="mt-2 text-sm text-red-600"><?php echo e($message); ?></p>
                    <?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 class="flex items-center">
                    <label class="flex items-center cursor-pointer select-none group">
                        <input wire:model="form.remember" type="checkbox" class="w-4 h-4 rounded border-slate-300 text-slate-800 focus:ring-slate-300 transition">
                        <span class="ml-2.5 text-slate-500 text-sm group-hover:text-slate-700 transition-colors">Recordar sesión</span>
                    </label>
                </div>

                <button type="submit"
                        class="w-full py-3.5 px-6 bg-slate-900 hover:bg-slate-800 active:bg-slate-950 text-white text-sm font-semibold rounded-lg shadow-sm hover:shadow-md transform active:scale-[0.98] transition-all duration-200 flex items-center justify-center gap-2">
                    <span wire:loading.remove wire:target="login">Iniciar Sesión</span>
                    <span wire:loading wire:target="login" class="flex items-center gap-2">
                        <svg class="animate-spin h-4 w-4" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4" fill="none"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"></path></svg>
                        Verificando...
                    </span>
                </button>
            </form>

            <div class="mt-10 pt-6 border-t border-slate-100 text-center">
                <p class="text-slate-300 text-xs">Powered by <span class="font-semibold text-slate-400">Singularidad IA</span></p>
            </div>
        </div>

        <div class="flex-1 min-h-[30px]"></div>

        <div class="pb-6 text-center lg:hidden">
            <p class="text-slate-300 text-xs">Powered by <span class="font-semibold text-slate-400">Singularidad IA</span></p>
        </div>
    </div>

    <div class="lg:hidden fixed inset-0 -z-10 bg-white"></div>
</div><?php /**PATH /home/evolucionamos/public_html/yber-dev/resources/views/livewire/pages/auth/login.blade.php ENDPATH**/ ?>