<?php $__env->startSection('title', 'Daftar Perusahaan - FIN-ANALYSIS PRO'); ?>

<?php $__env->startPush('styles'); ?>
<style>
/* Dark mode for companies page */
.dark .page-title {
    color: #f1f5f9 !important;
}

.dark .page-subtitle {
    color: #cbd5e1 !important;
}

.dark .card {
    background: #1e293b !important;
    border-color: #334155 !important;
    color: #f1f5f9 !important;
}

.dark .card h3 {
    color: #f1f5f9 !important;
}

/* Dark mode for stat boxes and text */
.dark [style*="background:#F8FAFF"],
.dark [style*="background: #F8FAFF"] {
    background-color: #334155 !important;
}

/* Dark mode for text inside stat boxes with F8FAFF background */
.dark div[style*="background:#F8FAFF"] {
    background-color: #334155 !important;
}

.dark div[style*="background:#F8FAFF"] div[style*="color:#64748B"],
.dark div[style*="background:#F8FAFF"] div[style*="color: #64748B"] {
    color: #cbd5e1 !important;
}

.dark div[style*="background:#F8FAFF"] div[style*="color:#1E293B"],
.dark div[style*="background:#F8FAFF"] div[style*="color: #1E293B"] {
    color: #f1f5f9 !important;
}

.dark div[style*="background:#F8FAFF"] div[style*="color:#1A56DB"],
.dark div[style*="background:#F8FAFF"] div[style*="color: #1A56DB"] {
    color: #60a5fa !important;
}

/* Dark mode for specific font sizes in stat boxes */
.dark div[style*="font-size:.7rem;color:#64748B"] {
    color: #cbd5e1 !important;
}

.dark div[style*="font-size:.9375rem;font-weight:800;color:#1A56DB"] {
    color: #60a5fa !important;
}

.dark div[style*="font-size:.9375rem;font-weight:800;color:#1E293B"],
.dark div[style*="font-size:.7rem;font-weight:700;color:#1E293B"] {
    color: #f1f5f9 !important;
}

.dark [style*="color:#64748B"],
.dark [style*="color: #64748B"] {
    color: #cbd5e1 !important;
}

.dark [style*="color:#1E293B"],
.dark [style*="color: #1E293B"] {
    color: #f1f5f9 !important;
}

.dark [style*="color:#1A56DB"],
.dark [style*="color: #1A56DB"] {
    color: #60a5fa !important;
}

.dark [style*="color:#94A3B8"],
.dark [style*="color: #94A3B8"] {
    color: #cbd5e1 !important;
}

/* Dark mode for company name */
.dark div[style*="color:#1E293B;font-size:.9375rem"] {
    color: #f1f5f9 !important;
}

/* Dark mode for business field */
.dark div[style*="font-size:.75rem;color:#64748B"] {
    color: #94a3b8 !important;
}

/* Dark mode for zone badges */
.dark [style*="background:#D1FAE5"],
.dark [style*="background: #D1FAE5"] {
    background-color: #064e3b !important;
    color: #86efac !important;
}

.dark [style*="background:#FEF3C7"],
.dark [style*="background: #FEF3C7"] {
    background-color: #78350f !important;
    color: #fcd34d !important;
}

.dark [style*="background:#FEE2E2"],
.dark [style*="background: #FEE2E2"] {
    background-color: #7f1d1d !important;
    color: #fca5a5 !important;
}

/* Dark mode for buttons */
.dark .btn-primary {
    background-color: #3b82f6 !important;
    color: #ffffff !important;
}

.dark .btn-secondary {
    background-color: #334155 !important;
    color: #f1f5f9 !important;
    border-color: #475569 !important;
}

/* Dark mode for icon */
.dark svg[stroke="#94A3B8"],
.dark svg[stroke="#64748B"] {
    stroke: #cbd5e1 !important;
}

/* Light mode for companies page */
.light .page-title {
    color: #1E293B !important;
}

.light .page-subtitle {
    color: #64748B !important;
}

.light .card {
    background: #ffffff !important;
    border-color: #e2e8f0 !important;
    color: #1E293B !important;
}

.light [style*="color:#1E293B"],
.light [style*="color: #1E293B"] {
    color: #1E293B !important;
}

.light [style*="color:#64748B"],
.light [style*="color: #64748B"] {
    color: #475569 !important;
}

.light [style*="color:#94A3B8"],
.light [style*="color: #94A3B8"] {
    color: #64748B !important;
}

.light [style*="background:#F8FAFF"],
.light [style*="background: #F8FAFF"] {
    background-color: #f8fafc !important;
}

.light [style*="background:#F1F5F9"],
.light [style*="background: #F1F5F9"] {
    background-color: #f1f5f9 !important;
}

/* Light mode for zone badges */
.light [style*="background:#D1FAE5"],
.light [style*="background: #D1FAE5"] {
    background-color: #D1FAE5 !important;
    color: #065F46 !important;
}

.light [style*="background:#FEF3C7"],
.light [style*="background: #FEF3C7"] {
    background-color: #FEF3C7 !important;
    color: #92400E !important;
}

.light [style*="background:#FEE2E2"],
.light [style*="background: #FEE2E2"] {
    background-color: #FEE2E2 !important;
    color: #991B1B !important;
}

/* Light mode - gradients */
.light [style*="background:linear-gradient(135deg,#1A56DB,#06B6D4)"],
.light [style*="background: linear-gradient(135deg,#1A56DB,#06B6D4)"] {
    background: linear-gradient(135deg,#1A56DB,#06B6D4) !important;
}

.light .btn {
    color: inherit !important;
}
</style>
<?php $__env->stopPush(); ?>

<?php $__env->startSection('content'); ?>
<div>
    <div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:2rem;flex-wrap:wrap;gap:1rem">
        <div>
            <h1 class="page-title">Perusahaan</h1>
            <p class="page-subtitle"><?php echo e($companies->count()); ?> perusahaan terdaftar</p>
        </div>
        <a href="<?php echo e(route('analysis.step1')); ?>" class="btn btn-primary">
            <svg width="14" height="14" 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>

    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($companies->isEmpty()): ?>
    <div class="card" style="text-align:center;padding:4rem 2rem">
        <div style="width:56px;height:56px;background:#F1F5F9;border-radius:50%;display:flex;align-items:center;justify-content:center;margin:0 auto 1rem">
            <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#94A3B8" stroke-width="1.5"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/><polyline points="9 22 9 12 15 12 15 22"/></svg>
        </div>
        <h3 style="font-weight:700;color:#1E293B;margin-bottom:.375rem">Belum ada perusahaan</h3>
        <p style="color:#64748B;font-size:.875rem;margin-bottom:1.5rem">Mulai analisis untuk menambahkan perusahaan pertama</p>
        <a href="<?php echo e(route('analysis.step1')); ?>" class="btn btn-primary">Mulai Analisis</a>
    </div>
    <?php else: ?>
    <div style="display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:1.25rem">
        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = $companies; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $company): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
        <?php
            $avgZ = round($company->avg_zscore ?? 0, 3);
            $cat  = $avgZ > 2.9 ? 'safe' : ($avgZ > 1.23 ? 'grey' : 'distress');
            $cs   = [
                'safe'     => ['bg'=>'#D1FAE5','color'=>'#065F46','label'=>'Zona Aman'],
                'grey'     => ['bg'=>'#FEF3C7','color'=>'#92400E','label'=>'Zona Waspada'],
                'distress' => ['bg'=>'#FEE2E2','color'=>'#991B1B','label'=>'Zona Berbahaya'],
            ][$cat];
        ?>
        <div class="card" style="padding:1.5rem">
            
            <div style="display:flex;align-items:flex-start;justify-content:space-between;margin-bottom:1rem">
                <div style="display:flex;align-items:center;gap:10px">
                    <div style="width:42px;height:42px;border-radius:10px;background:linear-gradient(135deg,#1A56DB,#06B6D4);display:flex;align-items:center;justify-content:center;color:white;font-weight:800;font-size:1.1rem;flex-shrink:0">
                        <?php echo e(strtoupper(substr($company->company_name, 0, 1))); ?>

                    </div>
                    <div>
                        <div style="font-weight:700;color:#1E293B;font-size:.9375rem"><?php echo e(Str::limit($company->company_name, 20)); ?></div>
                        <div style="font-size:.75rem;color:#64748B"><?php echo e($company->business_field); ?></div>
                    </div>
                </div>
                <span style="background:<?php echo e($cs['bg']); ?>;color:<?php echo e($cs['color']); ?>;padding:3px 10px;border-radius:20px;font-size:.7rem;font-weight:700;flex-shrink:0">
                    <?php echo e($cs['label']); ?>

                </span>
            </div>

            
            <div style="display:grid;grid-template-columns:1fr 1fr 1fr;gap:.625rem;margin-bottom:1.25rem">
                <div style="background:#F8FAFF;border-radius:8px;padding:.625rem;text-align:center">
                    <div style="font-size:.7rem;color:#64748B;margin-bottom:2px">Rata-rata Z</div>
                    <div style="font-size:.9375rem;font-weight:800;color:#1A56DB"><?php echo e(number_format($avgZ, 3)); ?></div>
                </div>
                <div style="background:#F8FAFF;border-radius:8px;padding:.625rem;text-align:center">
                    <div style="font-size:.7rem;color:#64748B;margin-bottom:2px">Analisis</div>
                    <div style="font-size:.9375rem;font-weight:800;color:#1E293B"><?php echo e($company->total_analyses); ?></div>
                </div>
                <div style="background:#F8FAFF;border-radius:8px;padding:.625rem;text-align:center">
                    <div style="font-size:.7rem;color:#64748B;margin-bottom:2px">Terakhir</div>
                    <div style="font-size:.7rem;font-weight:700;color:#1E293B"><?php echo e(\Carbon\Carbon::parse($company->last_analysis)->format('d/m/Y')); ?></div>
                </div>
            </div>

            
            <div style="display:flex;gap:.5rem">
                <a href="<?php echo e(route('companies.show', urlencode($company->company_name))); ?>"
                   class="btn btn-primary btn-sm" style="flex:1;justify-content:center">
                    <svg width="13" height="13" 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>
                    Detail
                </a>
                <a href="<?php echo e(route('companies.edit', urlencode($company->company_name))); ?>"
                   class="btn btn-secondary btn-sm" title="Edit">
                    <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>
                </a>
                <form action="<?php echo e(route('companies.destroy', urlencode($company->company_name))); ?>" method="POST"
                      onsubmit="return confirm('Hapus semua data <?php echo e(addslashes($company->company_name)); ?>?')">
                    <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
                    <button type="submit" class="btn btn-danger btn-sm" title="Hapus">
                        <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="3 6 5 6 21 6"/><path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"/><path d="M10 11v6"/><path d="M14 11v6"/></svg>
                    </button>
                </form>
            </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>
    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
</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/index.blade.php ENDPATH**/ ?>