<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Smart Sync Test Results</title>
    <style>
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            margin: 0;
            padding: 20px;
            background-color: #f5f5f5;
        }
        .container {
            max-width: 1200px;
            margin: 0 auto;
            background: white;
            padding: 30px;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        .header {
            border-bottom: 2px solid #007cba;
            padding-bottom: 20px;
            margin-bottom: 30px;
        }
        .header h1 {
            color: #007cba;
            margin: 0;
            font-size: 28px;
        }
        .timestamp {
            color: #666;
            font-size: 14px;
            margin-top: 5px;
        }
        .status-badge {
            display: inline-block;
            padding: 8px 16px;
            border-radius: 20px;
            font-weight: bold;
            font-size: 14px;
            margin-bottom: 20px;
        }
        .status-success {
            background-color: #d4edda;
            color: #155724;
            border: 1px solid #c3e6cb;
        }
        .status-error {
            background-color: #f8d7da;
            color: #721c24;
            border: 1px solid #f5c6cb;
        }
        .info-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
            margin-bottom: 30px;
        }
        .info-card {
            background: #f8f9fa;
            padding: 20px;
            border-radius: 6px;
            border-left: 4px solid #007cba;
        }
        .info-card h3 {
            margin-top: 0;
            color: #495057;
            font-size: 16px;
        }
        .info-card .value {
            font-size: 24px;
            font-weight: bold;
            color: #007cba;
            margin: 10px 0;
        }
        .section {
            margin-bottom: 30px;
        }
        .section h2 {
            color: #495057;
            border-bottom: 1px solid #dee2e6;
            padding-bottom: 10px;
            font-size: 20px;
        }
        .sync-results {
            background: #f8f9fa;
            padding: 20px;
            border-radius: 6px;
            border: 1px solid #dee2e6;
        }
        .sync-results pre {
            margin: 0;
            white-space: pre-wrap;
            word-wrap: break-word;
            font-family: 'Courier New', monospace;
            font-size: 13px;
            line-height: 1.4;
        }
        .error-details {
            background: #f8d7da;
            padding: 20px;
            border-radius: 6px;
            border: 1px solid #f5c6cb;
            margin-bottom: 20px;
        }
        .error-details h4 {
            color: #721c24;
            margin-top: 0;
        }
        .error-details code {
            background: #ffffff;
            padding: 2px 6px;
            border-radius: 3px;
            font-family: 'Courier New', monospace;
        }
        .logs {
            background: #2d3748;
            color: #e2e8f0;
            padding: 20px;
            border-radius: 6px;
            max-height: 400px;
            overflow-y: auto;
            font-family: 'Courier New', monospace;
            font-size: 12px;
            line-height: 1.4;
        }
        .log-entry {
            margin-bottom: 5px;
            padding: 3px 0;
        }
        .log-error {
            color: #fed7d7;
        }
        .log-warning {
            color: #feebc8;
        }
        .log-info {
            color: #bee3f8;
        }
        .actions {
            margin-top: 30px;
            padding-top: 20px;
            border-top: 1px solid #dee2e6;
        }
        .btn {
            display: inline-block;
            padding: 12px 24px;
            margin-right: 10px;
            margin-bottom: 10px;
            border: none;
            border-radius: 6px;
            text-decoration: none;
            font-weight: bold;
            cursor: pointer;
            transition: background-color 0.2s;
        }
        .btn-primary {
            background-color: #007cba;
            color: white;
        }
        .btn-primary:hover {
            background-color: #005a85;
        }
        .btn-secondary {
            background-color: #6c757d;
            color: white;
        }
        .btn-secondary:hover {
            background-color: #545b62;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1>Smart Sync Test Results</h1>
            <div class="timestamp">Executed at: <?php echo e($timestamp); ?></div>
        </div>

        <div class="status-badge <?php echo e($results['success'] ? 'status-success' : 'status-error'); ?>">
            <?php echo e($results['success'] ? '✓ Sync Completed Successfully' : '✗ Sync Failed'); ?>

        </div>

        <div class="info-grid">
            <div class="info-card">
                <h3>Execution Time</h3>
                <div class="value"><?php echo e($results['duration']); ?>s</div>
            </div>
            <div class="info-card">
                <h3>Status</h3>
                <div class="value"><?php echo e($results['success'] ? 'Success' : 'Failed'); ?></div>
            </div>
            <div class="info-card">
                <h3>Triggered By</h3>
                <div class="value"><?php echo e($results['triggered_by']); ?></div>
            </div>
        </div>

        <?php if(isset($results['sync_results'])): ?>
        <div class="section">
            <h2>Sync Results</h2>
            <div class="sync-results">
                <pre><?php echo e(json_encode($results['sync_results'], JSON_PRETTY_PRINT)); ?></pre>
            </div>
        </div>
        <?php endif; ?>

        <?php if(!empty($errors)): ?>
        <div class="section">
            <h2>Errors</h2>
            <?php $__currentLoopData = $errors; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <div class="error-details">
                <h4>Error Details</h4>
                <p><strong>Message:</strong> <?php echo e($error['message']); ?></p>
                <p><strong>File:</strong> <code><?php echo e($error['file']); ?></code></p>
                <p><strong>Line:</strong> <code><?php echo e($error['line']); ?></code></p>
                <?php if(isset($error['trace'])): ?>
                <details>
                    <summary>Stack Trace</summary>
                    <pre style="background: white; padding: 10px; margin-top: 10px; border-radius: 3px; font-size: 11px;"><?php echo e($error['trace']); ?></pre>
                </details>
                <?php endif; ?>
            </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </div>
        <?php endif; ?>

        <?php if(!empty($logs)): ?>
        <div class="section">
            <h2>Recent Smart Sync Logs</h2>
            <div class="logs">
                <?php $__currentLoopData = $logs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $log): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <div class="log-entry <?php if(strpos($log, 'ERROR') !== false): ?> log-error <?php elseif(strpos($log, 'WARNING') !== false): ?> log-warning <?php else: ?> log-info <?php endif; ?>">
                    <?php echo e($log); ?>

                </div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </div>
        </div>
        <?php endif; ?>

        <div class="actions">
            <a href="<?php echo e(route('admin.smart-sync.trigger')); ?>" class="btn btn-primary">Run Sync Again</a>
            <a href="<?php echo e(route('admin.smart-sync.status')); ?>" class="btn btn-secondary">View Pending Changes</a>
            <a href="<?php echo e(url('/admin')); ?>" class="btn btn-secondary">Back to Admin</a>
        </div>
    </div>
</body>
</html>
<?php /**PATH /var/www/html/resources/views/admin/smart-sync-test.blade.php ENDPATH**/ ?>