<?php $__env->startSection('title', $name . ' - FIN-ANALYSIS PRO'); ?>
<?php $__env->startSection('content'); ?>
<div class="max-w-5xl mx-auto">

    
    <div style="display:flex;align-items:center;gap:6px;font-size:.875rem;color:#64748B;margin-bottom:1.5rem">
        <a href="<?php echo e(route('companies.index')); ?>" style="color:#1A56DB;text-decoration:none;font-weight:500">Perusahaan</a>
        <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>
        <span style="color:#1E293B;font-weight:600"><?php echo e($name); ?></span>
    </div>

    
    <div style="display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:1rem;margin-bottom:1.5rem">
        <div style="display:flex;align-items:center;gap:12px">
            <div style="width:50px;height:50px;border-radius:12px;background:linear-gradient(135deg,#1A56DB,#06B6D4);display:flex;align-items:center;justify-content:center;color:white;font-weight:800;font-size:1.25rem;flex-shrink:0">
                <?php echo e(strtoupper(substr($name, 0, 1))); ?>

            </div>
            <div>
                <h1 class="page-title" style="margin-bottom:2px"><?php echo e($name); ?></h1>
                <p class="page-subtitle"><?php echo e($latest->business_field); ?></p>
            </div>
        </div>
        <div style="display:flex;gap:.75rem;flex-wrap:wrap">
            <a href="<?php echo e(route('companies.edit', urlencode($name))); ?>" class="btn btn-secondary btn-sm">
                <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>
                Edit
            </a>
            <a href="<?php echo e(route('analysis.step1')); ?>" class="btn btn-primary btn-sm">
                <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>
                Analisis Baru
            </a>
        </div>
    </div>

    
    <div style="display:grid;grid-template-columns:repeat(4,1fr);gap:1rem;margin-bottom:1.5rem">
        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = [
            ['Total Analisis',    $summary['total'],                              '#DBEAFE','#1A56DB'],
            ['Rata-rata Z-Score', number_format($summary['avg_zscore'] ?? 0,3),   '#EDE9FE','#7C3AED'],
            ['Z-Score Tertinggi', number_format($summary['max_zscore'] ?? 0,3),   '#D1FAE5','#059669'],
            ['Z-Score Terendah',  number_format($summary['min_zscore'] ?? 0,3),   '#FEE2E2','#DC2626'],
        ]; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as [$label,$val,$bg,$color]): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
        <div class="card" style="padding:1rem;text-align:center">
            <div style="font-size:.75rem;color:#64748B;margin-bottom:.25rem"><?php echo e($label); ?></div>
            <div style="font-size:1.5rem;font-weight:800;color:<?php echo e($color); ?>"><?php echo e($val); ?></div>
        </div>
        <?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>

    
    <div class="card" style="margin-bottom:1.5rem;padding:1.25rem">
        <div style="font-size:.8rem;font-weight:700;color:#64748B;text-transform:uppercase;letter-spacing:.04em;margin-bottom:1rem">Distribusi Kategori</div>
        <div style="display:flex;gap:1.5rem;flex-wrap:wrap">
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = [
                ['Zona Aman',     $summary['safe'],     '#D1FAE5','#065F46'],
                ['Zona Waspada',  $summary['grey'],     '#FEF3C7','#92400E'],
                ['Zona Berbahaya',$summary['distress'], '#FEE2E2','#991B1B'],
            ]; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as [$label,$count,$bg,$color]): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
            <div style="display:flex;align-items:center;gap:8px">
                <div style="width:38px;height:38px;border-radius:8px;background:<?php echo e($bg); ?>;display:flex;align-items:center;justify-content:center;font-size:1rem;font-weight:800;color:<?php echo e($color); ?>">
                    <?php echo e($count); ?>

                </div>
                <span style="font-size:.875rem;color:#64748B"><?php echo e($label); ?></span>
            </div>
            <?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>
    </div>

    
    <div class="card">
        <div style="font-size:.8rem;font-weight:700;color:#64748B;text-transform:uppercase;letter-spacing:.04em;margin-bottom:1.25rem">
            Riwayat Analisis (<?php echo e($analyses->count()); ?>)
        </div>
        <div class="table-wrapper">
            <table class="table">
                <thead>
                    <tr>
                        <th>Periode</th>
                        <th>Mata Uang</th>
                        <th style="text-align:right">Z-Score</th>
                        <th style="text-align:center">Kategori</th>
                        <th>Tanggal</th>
                        <th style="text-align:center">Aksi</th>
                    </tr>
                </thead>
                <tbody>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = $analyses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $a): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                    <?php
                        $badge = match($a->z_category) {
                            'safe'     => ['bg'=>'#D1FAE5','color'=>'#065F46','label'=>'Aman'],
                            'grey'     => ['bg'=>'#FEF3C7','color'=>'#92400E','label'=>'Waspada'],
                            'distress' => ['bg'=>'#FEE2E2','color'=>'#991B1B','label'=>'Berbahaya'],
                            default    => ['bg'=>'#DBEAFE','color'=>'#1E40AF','label'=>'-'],
                        };
                    ?>
                    <tr>
                        <td style="font-weight:600"><?php echo e($a->period); ?></td>
                        <td style="color:#64748B"><?php echo e($a->currency); ?></td>
                        <td style="text-align:right;font-weight:700;font-family:monospace;color:<?php echo e($a->z_category==='safe'?'#059669':($a->z_category==='grey'?'#D97706':'#DC2626')); ?>">
                            <?php echo e(number_format($a->z_score, 4)); ?>

                        </td>
                        <td style="text-align:center">
                            <span style="background:<?php echo e($badge['bg']); ?>;color:<?php echo e($badge['color']); ?>;padding:3px 10px;border-radius:20px;font-size:.75rem;font-weight:700">
                                <?php echo e($badge['label']); ?>

                            </span>
                        </td>
                        <td style="font-size:.8125rem;color:#64748B"><?php echo e($a->created_at->format('d/m/Y H:i')); ?></td>
                        <td style="text-align:center">
                            <div style="display:flex;align-items:center;justify-content:center;gap:10px">
                                <a href="<?php echo e(route('history.show', $a->id)); ?>" style="color:#1A56DB" title="Detail">
                                    <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>
                                </a>
                                <a href="<?php echo e(route('report.preview', $a->id)); ?>" target="_blank" style="color:#059669" title="Preview PDF">
                                    <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>
                                </a>
                                <a href="<?php echo e(route('report.download', $a->id)); ?>" style="color:#7C3AED" title="Unduh PDF">
                                    <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
                                </a>
                            </div>
                        </td>
                    </tr>
                    <?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; ?>
                </tbody>
            </table>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/roky/projects/V1/resources/views/companies/show.blade.php ENDPATH**/ ?>