
<?php $__env->startSection('title', 'Markets'); ?>
<?php $__env->startSection('content'); ?>
<div class="page-header"><h1>Manage Markets</h1><p>Add, edit, and simulate price movements</p></div>

<div class="md-card" style="margin-bottom:1.5rem">
    <div class="md-card-header">Add New Market</div>
    <div class="md-card-body">
        <form method="POST" action="<?php echo e(route('admin.markets.store')); ?>" class="form-grid">
            <?php echo csrf_field(); ?>
            <div class="form-field"><label>Name</label><input name="name" class="md-input" required></div>
            <div class="form-field"><label>Symbol</label><input name="symbol" class="md-input" required></div>
            <div class="form-field"><label>Price</label><input name="price" type="number" step="0.00000001" class="md-input" required></div>
            <div class="form-field"><label>24h Change %</label><input name="change_24h" type="number" step="0.01" class="md-input" value="0"></div>
            <div class="form-field"><label>Type</label>
                <select name="type" class="md-select"><option value="crypto">Crypto (Coins)</option><option value="commodity">Commodity</option><option value="metal">Metal</option></select>
            </div>
            <div class="form-field"><label>Volatility %</label><input name="volatility" type="number" step="0.01" class="md-input" value="0"></div>
            <div class="form-field"><label>TradingView Symbol</label><input name="tv_symbol" class="md-input" placeholder="BINANCE:BTCUSDT"></div>
            <div class="form-field" style="display:flex;align-items:flex-end"><button class="md-btn md-btn-filled">Add Market</button></div>
        </form>
    </div>
</div>

<div class="md-card" style="margin-bottom:1.5rem">
    <div class="md-card-header">Price Wave / Volatility Control</div>
    <div class="md-card-body">
        <form method="POST" action="<?php echo e(route('admin.markets.wave')); ?>" class="form-grid">
            <?php echo csrf_field(); ?>
            <div class="form-field"><label>Market</label>
                <select name="market_id" class="md-select" required>
                    <?php $__currentLoopData = $markets; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $m): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($m->id); ?>"><?php echo e($m->name); ?> (<?php echo e($m->symbol); ?>)</option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>
            <div class="form-field"><label>Direction</label>
                <select name="direction" class="md-select"><option value="up">Up</option><option value="down">Down</option></select>
            </div>
            <div class="form-field"><label>Percent %</label><input name="percent" type="number" step="0.01" class="md-input" required></div>
            <div class="form-field" style="display:flex;align-items:flex-end"><button class="md-btn md-btn-tonal">Apply Wave</button></div>
        </form>
    </div>
</div>

<div class="md-card">
    <div class="table-wrap">
        <table class="md-table">
            <thead><tr><th>ID</th><th>Name</th><th>Symbol</th><th>Price</th><th>24h</th><th>Type</th><th>Vol%</th><th>Actions</th></tr></thead>
            <tbody>
                <?php $__currentLoopData = $markets; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $market): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <tr>
                    <td><?php echo e($market->id); ?></td>
                    <td><?php echo e($market->name); ?></td>
                    <td><?php echo e($market->symbol); ?></td>
                    <td>$<?php echo e(number_format($market->price, 2)); ?></td>
                    <td style="color:<?php echo e($market->change_24h >= 0 ? 'var(--md-success)' : 'var(--md-error)'); ?>"><?php echo e($market->change_24h); ?>%</td>
                    <td><?php echo e(ucfirst($market->type)); ?></td>
                    <td><?php echo e($market->volatility); ?>%</td>
                    <td class="action-group">
                        <button type="button" class="md-btn md-btn-warning md-btn-sm" onclick="document.getElementById('edit-<?php echo e($market->id); ?>').showModal()">Edit</button>
                        <form action="<?php echo e(route('admin.markets.destroy', $market)); ?>" method="POST" onsubmit="return confirm('Delete market?')"><?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
                            <button class="md-btn md-btn-danger md-btn-sm">Delete</button>
                        </form>
                    </td>
                </tr>
                <dialog id="edit-<?php echo e($market->id); ?>" style="border:none;border-radius:12px;padding:0;max-width:480px;background:var(--md-surface-container);color:var(--md-on-surface)">
                    <form method="POST" action="<?php echo e(route('admin.markets.update', $market)); ?>" style="padding:1.5rem"><?php echo csrf_field(); ?> <?php echo method_field('PUT'); ?>
                        <h3 style="margin-bottom:1rem">Edit <?php echo e($market->symbol); ?></h3>
                        <div class="form-field"><label>Name</label><input name="name" class="md-input" value="<?php echo e($market->name); ?>" required></div>
                        <div class="form-field"><label>Symbol</label><input name="symbol" class="md-input" value="<?php echo e($market->symbol); ?>" required></div>
                        <div class="form-field"><label>Price</label><input name="price" type="number" step="0.00000001" class="md-input" value="<?php echo e($market->price); ?>" required></div>
                        <div class="form-field"><label>24h Change</label><input name="change_24h" type="number" step="0.01" class="md-input" value="<?php echo e($market->change_24h); ?>"></div>
                        <div class="form-field"><label>Type</label>
                            <select name="type" class="md-select">
                                <?php $__currentLoopData = ['crypto'=>'Crypto (Coins)','commodity'=>'Commodity','metal'=>'Metal']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $val => $label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($val); ?>" <?php if($market->type===$val): echo 'selected'; endif; ?>><?php echo e($label); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                        <div class="form-field"><label>Volatility</label><input name="volatility" type="number" step="0.01" class="md-input" value="<?php echo e($market->volatility); ?>"></div>
                        <div style="display:flex;gap:0.5rem;margin-top:1rem">
                            <button type="submit" class="md-btn md-btn-filled">Save</button>
                            <button type="button" class="md-btn md-btn-outline" onclick="this.closest('dialog').close()">Cancel</button>
                        </div>
                    </form>
                </dialog>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </tbody>
        </table>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.admin', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH D:\SkyApps\Projects\Laravel_projects\web3derp\resources\views/admin/markets/index.blade.php ENDPATH**/ ?>