<div class="container-fluid mtb15 no-fluid">
    <div class="row sm-gutters">
      <div class="col-md-3">
        <div class="market-pairs">
          <div class="input-group">
            <div class="input-group-prepend">
              <span class="input-group-text" id="inputGroup-sizing-sm"><i class="icon ion-md-search"></i></span>
            </div>
            <input type="text" class="form-control" placeholder="Search" aria-describedby="inputGroup-sizing-sm">
          </div>
          <!--[if BLOCK]><![endif]--><?php if(empty($search)): ?>
          <ul class="nav nav-pills" role="tablist">
            <!--[if BLOCK]><![endif]--><?php $__currentLoopData = $currencyTypes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $currencyType): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
              <li class="nav-item">
                <!--[if BLOCK]><![endif]--><?php if($currencyType->code == $currentCurrencyTypeCode): ?>
                  <a class="nav-link active" data-toggle="pill" href="#<?php echo e($currencyType->code); ?>" role="tab" aria-selected="true" wire:click="clickCurrencyType('<?php echo e($currencyType->code); ?>')"><?php echo e($currencyType->name); ?></a>
                <?php else: ?>
                  <a class="nav-link" data-toggle="pill" href="#<?php echo e($currencyType->code); ?>" role="tab" aria-selected="true" wire:click="clickCurrencyType('<?php echo e($currencyType->code); ?>')"><?php echo e($currencyType->name); ?></a>
                <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
              </li>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><!--[if ENDBLOCK]><![endif]-->
          </ul>
          <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
          <div class="tab-content">
            <!--[if BLOCK]><![endif]--><?php if(!empty($search)): ?>
              <div class="table-responsive">
                <table class="table">
                  <thead>
                    <tr>
                      <th>Symbol</th>
                      <th>Bid</th>
                      <th>Ask</th>
                    </tr>
                  </thead>
                  <tbody>
                    <!--[if BLOCK]><![endif]--><?php $__currentLoopData = $filteredCurrencies; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $currency): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                      <tr wire:click="clickCurrency(<?php echo e($currency->id); ?>)" class="currency-row">
                        <td width="40%">
                          <!--[if BLOCK]><![endif]--><?php if($currency->iconExists()): ?>
                              <img src="<?php echo e($currency->getIconUrl()); ?>" class="asset-image <?php echo e($currency->type->code); ?>"/>
                          <?php else: ?>
                              <div class="containera">
                                  <span class="responsive_headline"><?php echo e($currency->name[0]); ?></span>
                              </div>
                          <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
                          <span><?php echo e($currency->name); ?></span>
                        </td>
                        
                        <td width="40%" class="<?php echo e($currency->has_bid_changed ? ($currency->old_bid < $currency->bid ? 'price-up' : 'price-down') : ''); ?>"><?php echo e($currency->formatted_bid); ?></td>
                        <td width="40%" class="<?php echo e($currency->has_ask_changed ? ($currency->old_ask < $currency->ask ? 'price-up' : 'price-down') : ''); ?>"><?php echo e($currency->formatted_ask); ?></td>
                      </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><!--[if ENDBLOCK]><![endif]-->
                  </tbody>
                </table>
              </div>
            <?php else: ?>
              <!--[if BLOCK]><![endif]--><?php $__currentLoopData = $currencyTypes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $currencyType): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <!--[if BLOCK]><![endif]--><?php if($currencyType->code == $currentCurrencyTypeCode): ?>
                  <div class="tab-pane fade show active" id="<?php echo e($currencyType->code); ?>" role="tabpanel">
                <?php else: ?>
                  <div class="tab-pane fade show" id="<?php echo e($currencyType->code); ?>" role="tabpanel">
                <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
                  <div class="table-responsive">
                    <table class="table">
                      <thead>
                        <tr>
                          <th>Symbol</th>
                          <th>Bid</th>
                          <th>Ask</th>
                        </tr>
                      </thead>
                      <tbody>
                        <!--[if BLOCK]><![endif]--><?php $__currentLoopData = $currencyType->currencies; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $currency): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                          <tr wire:click="clickCurrency(<?php echo e($currency->id); ?>)" class="currency-row">
                            <td width="40%">
                              <!--[if BLOCK]><![endif]--><?php if($currency->iconExists()): ?>
                                  <img src="<?php echo e($currency->getIconUrl()); ?>" class="asset-image <?php echo e($currency->type->code); ?>"/>
                              <?php else: ?>
                                  <div class="containera">
                                      <span class="responsive_headline"><?php echo e($currency->name[0]); ?></span>
                                  </div>
                              <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
                              <span><?php echo e($currency->name); ?></span>
                            </td>
                            <td width="40%">
                              <?php
$__split = function ($name, $params = []) {
    return [$name, $params];
};
[$__name, $__params] = $__split('real-time-property', ['model' => $currency,'property' => 'formatted_bid','showClass' => 'bid-price']);

$__html = app('livewire')->mount($__name, $__params, 'bid-'.e($currency->id).'', $__slots ?? [], get_defined_vars());

echo $__html;

unset($__html);
unset($__name);
unset($__params);
unset($__split);
if (isset($__slots)) unset($__slots);
?>
                            </td>
                            <td width="40%">
                              <?php
$__split = function ($name, $params = []) {
    return [$name, $params];
};
[$__name, $__params] = $__split('real-time-property', ['model' => $currency,'property' => 'formatted_ask','showClass' => 'ask-price']);

$__html = app('livewire')->mount($__name, $__params, 'ask-'.e($currency->id).'', $__slots ?? [], get_defined_vars());

echo $__html;

unset($__html);
unset($__name);
unset($__params);
unset($__split);
if (isset($__slots)) unset($__slots);
?>
                            </td>
                          </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><!--[if ENDBLOCK]><![endif]-->
                      </tbody>
                    </table>
                  </div>
                </div>
              <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><!--[if ENDBLOCK]><![endif]-->
            <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
          </div>
        </div>
      </div>
      <div class="col-12 col-md-7">
        <div class="main-chart dark-variant">
          <!-- TradingView Widget BEGIN -->
          <div class="tradingview-widget-container">
            <div id="tradingview_e8033" style="height: 100%;" wire:ignore></div>
          </div>
          <!-- TradingView Widget END -->
        </div>
        
        <div class="market-history market-order">
          <ul class="nav nav-pills" role="tablist" wire:ignore>
            <li class="nav-item">
              <a class="nav-link <?php echo e($this->currentTab === 'open-orders' ? 'active' : ''); ?>" 
                 data-toggle="pill" 
                 href="#open-orders" 
                 role="tab" 
                 aria-selected="<?php echo e($this->currentTab === 'open-orders' ? 'true' : 'false'); ?>"
                 wire:click="switchTab('open-orders')">
                Open Orders
              </a>
            </li>
            <li class="nav-item">
              <a class="nav-link <?php echo e($this->currentTab === 'closed-orders' ? 'active' : ''); ?>" 
                 data-toggle="pill" 
                 href="#closed-orders" 
                 role="tab" 
                 aria-selected="<?php echo e($this->currentTab === 'closed-orders' ? 'true' : 'false'); ?>"
                 wire:click="switchTab('closed-orders')">
                Closed Orders
              </a>
            </li>
          </ul>
          <div class="tab-content">
            <div class="tab-pane fade <?php echo e($this->currentTab === 'open-orders' ? 'show active' : ''); ?>" 
                 id="open-orders" 
                 role="tabpanel">
              <div class="orders-container">
                <div class="card-body table-responsive p-0">
                  <table class="table table-hover text-nowrap">
                    <thead>
                        <tr>
                            <th>Symbol</th>
                            <th>Type</th>
                            <th>Volume</th>
                            <th>Open Price</th>
                            <th>Current Price</th>
                            <th>Take Profit</th>
                            <th>Stop Loss</th>
                            <th>Open Time</th>
                            <th>P/L</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                        <!--[if BLOCK]><![endif]--><?php $__empty_1 = true; $__currentLoopData = $openOrders; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $order): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <tr>
                                <td class="order-currency">
                                  <!--[if BLOCK]><![endif]--><?php if($order->currency->iconExists()): ?>
                                      <img src="<?php echo e($order->currency->getIconUrl()); ?>" class="asset-image <?php echo e($order->currency->type->code); ?>"/>
                                  <?php else: ?>
                                      <div class="containera">
                                          <span class="responsive_headline"><?php echo e($order->currency->name[0]); ?></span>
                                      </div>
                                  <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
                                  <?php echo e($order->currency->name); ?>

                                </td>
                                <td>
                                    <div class="text-left <?php echo e($order->side === 'buy' ? 'text-success' : 'text-danger'); ?>" style="flex: 1;"><?php echo e(strtoupper($order->side)); ?></div>
                                </td>
                                <td><?php echo e($order->formatted_volume); ?></td>
                                <td><?php echo e($order->formatted_open_price); ?></td>
                                <td>
                                  <!--[if BLOCK]><![endif]--><?php if($order->side == 'buy'): ?>
                                    <?php
$__split = function ($name, $params = []) {
    return [$name, $params];
};
[$__name, $__params] = $__split('real-time-property', ['model' => $order->currency,'property' => 'formatted_bid']);

$__html = app('livewire')->mount($__name, $__params, 'order-bid-'.e($order->id).'', $__slots ?? [], get_defined_vars());

echo $__html;

unset($__html);
unset($__name);
unset($__params);
unset($__split);
if (isset($__slots)) unset($__slots);
?>
                                  <?php else: ?>
                                    <?php
$__split = function ($name, $params = []) {
    return [$name, $params];
};
[$__name, $__params] = $__split('real-time-property', ['model' => $order->currency,'property' => 'formatted_ask']);

$__html = app('livewire')->mount($__name, $__params, 'order-ask-'.e($order->id).'', $__slots ?? [], get_defined_vars());

echo $__html;

unset($__html);
unset($__name);
unset($__params);
unset($__split);
if (isset($__slots)) unset($__slots);
?>
                                  <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
                                </td>
                                <td>
                                <!--[if BLOCK]><![endif]--><?php if(!$order->take_profit): ?>
                                <button class="btn btn-sm btn-primary btn-take-profit" wire:click="openTakeProfitModal(<?php echo e($order->id); ?>)">
                                  Add TP
                                </button>
                                <?php else: ?>
                                  <?php echo e($order->formatted_take_profit); ?>

                                <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
                                </td>
                                <td>
                                  <!--[if BLOCK]><![endif]--><?php if(!$order->stop_loss): ?>
                                    <button class="btn btn-sm btn-danger btn-stop-loss" wire:click="openStopLossModal(<?php echo e($order->id); ?>)">
                                      Add SL
                                    </button>
                                  <?php else: ?>
                                    <?php echo e($order->formatted_stop_loss); ?>

                                  <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
                                </td>
                                <td>
                                  <?php echo e($order->created_at ? $order->created_at->format('Y-m-d H:i') : '-'); ?>

                                </td>
                                <td>
                                  <?php
$__split = function ($name, $params = []) {
    return [$name, $params];
};
[$__name, $__params] = $__split('real-time-property', ['model' => $order,'property' => 'getFormattedPl','showClass' => 'order-pl']);

$__html = app('livewire')->mount($__name, $__params, 'order-pl-'.e($order->id).'', $__slots ?? [], get_defined_vars());

echo $__html;

unset($__html);
unset($__name);
unset($__params);
unset($__split);
if (isset($__slots)) unset($__slots);
?>
                                </td>
                                <td>
                                  <button class="btn btn-sm btn-primary btn-close-order" wire:click="confirmCloseOrder(<?php echo e($order->id); ?>)">
                                    Close
                                  </button>
                                </td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <tr>
                                <td colspan="10" class="text-center">No orders found</td>
                            </tr>
                        <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
                    </tbody>
                  </table>
                </div>
              </div>
            </div>
            <div class="tab-pane fade <?php echo e($this->currentTab === 'closed-orders' ? 'show active' : ''); ?>" 
                 id="closed-orders" 
                 role="tabpanel">
              <div class="orders-container" style="max-height: 300px; overflow-y: auto;">
              <div class="card-body table-responsive p-0">
                  <table class="table table-hover text-nowrap">
                    <thead>
                        <tr>
                            <th>Symbol</th>
                            <th>Type</th>
                            <th>Volume</th>
                            <th>Open Price</th>
                            <th>Close Price</th>
                            <th>Take Profit</th>
                            <th>Stop Loss</th>
                            <th>Open Time</th>
                            <th>Close Time</th>
                            <th>P/L</th>
                        </tr>
                    </thead>
                    <tbody>
                        <!--[if BLOCK]><![endif]--><?php $__empty_1 = true; $__currentLoopData = $closedOrders; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $closedOrder): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <tr>
                                <td class="order-currency">
                                  <!--[if BLOCK]><![endif]--><?php if($closedOrder->currency->iconExists()): ?>
                                      <img src="<?php echo e($closedOrder->currency->getIconUrl()); ?>" class="asset-image <?php echo e($closedOrder->currency->type->code); ?>"/>
                                  <?php else: ?>
                                      <div class="containera">
                                          <span class="responsive_headline"><?php echo e($closedOrder->currency->name[0]); ?></span>
                                      </div>
                                  <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
                                  <?php echo e($closedOrder->currency->name); ?>

                                </td>
                                <td>
                                    <div class="text-left <?php echo e($closedOrder->side === 'buy' ? 'text-success' : 'text-danger'); ?>" style="flex: 1;"><?php echo e(strtoupper($closedOrder->side)); ?></div>
                                </td>
                                <td><?php echo e($closedOrder->formatted_volume); ?></td>
                                <td><?php echo e($closedOrder->formatted_open_price); ?></td>
                                <td>
                                  <?php echo e($closedOrder->formatted_close_price); ?>

                                </td>
                                <td>
                                  <?php echo e($closedOrder->formatted_take_profit); ?>

                                </td>
                                <td>
                                  <?php echo e($closedOrder->formatted_stop_loss); ?>

                                </td>
                                <td>
                                  <?php echo e($closedOrder->created_at ? $closedOrder->created_at->format('Y-m-d H:i') : '-'); ?>

                                </td>
                                <td>
                                  <?php echo e($closedOrder->close_time ? $closedOrder->close_time->format('Y-m-d H:i') : '-'); ?>

                                </td>
                                <td>
                                  <span class="<?php echo e($closedOrder->getPLStatus()); ?>"><?php echo e($closedOrder->getFormattedPL()); ?></span>
                                </td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <tr>
                                <td colspan="10" class="text-center">No orders found</td>
                            </tr>
                        <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
                    </tbody>
                  </table>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="col-12 col-md-2">
        <div class="market-trade">
          <div class="card-title market-trade-header col-md-12">
            <!--[if BLOCK]><![endif]--><?php if($currentCurrency->iconExists()): ?>
                <img src="<?php echo e($currentCurrency->getIconUrl()); ?>" class="asset-image <?php echo e($currentCurrency->type->code); ?>"/>
            <?php else: ?>
                <div class="containera">
                    <span class="responsive_headline"><?php echo e($currentCurrency->name[0]); ?></span>
                </div>
            <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
            <span><?php echo e($currentCurrency->name); ?></span>
          </div>
          <div class="market-trade-content col-md-12" id="pills-trade-limit">
            <div class="d-flex justify-content-between">
              <div class="market-trade-buy">
                <button class="btn buy <?php echo e($orderType === 'buy' ? 'selected' : ''); ?>" wire:click="clickOrderTypeButton('buy')">
                  <span>Buy @</span> <?php
$__split = function ($name, $params = []) {
    return [$name, $params];
};
[$__name, $__params] = $__split('real-time-property', ['model' => $currentCurrency,'property' => 'formatted_bid']);

$__html = app('livewire')->mount($__name, $__params, 'order-bid-'.e($currentCurrency->id).'', $__slots ?? [], get_defined_vars());

echo $__html;

unset($__html);
unset($__name);
unset($__params);
unset($__split);
if (isset($__slots)) unset($__slots);
?>
                </button>
              </div>
              <div class="market-trade-sell">
                <button type="submit" class="btn sell <?php echo e($orderType === 'sell' ? 'selected' : ''); ?>" wire:click="clickOrderTypeButton('sell')">
                  <span>Sell @</span> <?php
$__split = function ($name, $params = []) {
    return [$name, $params];
};
[$__name, $__params] = $__split('real-time-property', ['model' => $currentCurrency,'property' => 'formatted_ask']);

$__html = app('livewire')->mount($__name, $__params, 'order-ask-'.e($currentCurrency->id).'', $__slots ?? [], get_defined_vars());

echo $__html;

unset($__html);
unset($__name);
unset($__params);
unset($__split);
if (isset($__slots)) unset($__slots);
?>
                </button>
              </div>
            </div>
          
          <div class="market-trade-form">
              <div class="input-group">
                <input type="number" 
                       class="form-control" 
                       placeholder="Volume" 
                       required 
                       wire:model.live="volume" 
                       step="0.1" 
                       min="0.1" />
                <div class="input-group-append">
                  <span class="input-group-text">Lots</span>
                  <button class="btn btn-outline-secondary" type="button" wire:click="decrementVolume">-</button>
                  <button class="btn btn-outline-secondary" type="button" wire:click="incrementVolume">+</button>
                </div> 
              </div>
              <!--[if BLOCK]><![endif]--><?php if($orderType && $this->margin > auth()->user()->calculateFreeMargin()): ?>
                <div class="text-danger">
                  Insufficient free margin.
                </div>
              <?php endif; ?><!--[if ENDBLOCK]><![endif]-->

              <div class="input-group">
                <input type="number" 
                       class="form-control" 
                       placeholder="Take Profit" 
                       step="0.01" 
                       wire:model.live="takeProfit"
                       oninput="this.value = Math.max(this.value, this.min)"/>
                <div class="input-group-append">
                  <span class="input-group-text">Price</span>
                  <button class="btn btn-outline-secondary" type="button" wire:click="decrementTakeProfit">-</button>
                  <button class="btn btn-outline-secondary" type="button" wire:click="incrementTakeProfit">+</button>
                </div> 
              </div>
              <!--[if BLOCK]><![endif]--><?php if($orderType): ?>
                <!--[if BLOCK]><![endif]--><?php if($orderType === 'buy' && $takeProfit && $takeProfit <= $currentCurrency->ask): ?>
                  <div class="text-danger">
                    Min <?php
$__split = function ($name, $params = []) {
    return [$name, $params];
};
[$__name, $__params] = $__split('real-time-property', ['model' => $currentCurrency,'property' => 'formatted_ask']);

$__html = app('livewire')->mount($__name, $__params, 'order-take-profit-min-ask-'.e($currentCurrency->id).'', $__slots ?? [], get_defined_vars());

echo $__html;

unset($__html);
unset($__name);
unset($__params);
unset($__split);
if (isset($__slots)) unset($__slots);
?>
                  </div>
                <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
                <!--[if BLOCK]><![endif]--><?php if($orderType === 'sell' && $takeProfit && $takeProfit >= $currentCurrency->bid): ?>
                  <div class="text-danger">
                    Max <?php
$__split = function ($name, $params = []) {
    return [$name, $params];
};
[$__name, $__params] = $__split('real-time-property', ['model' => $currentCurrency,'property' => 'formatted_bid']);

$__html = app('livewire')->mount($__name, $__params, 'order-take-profit-max-bid-'.e($currentCurrency->id).'', $__slots ?? [], get_defined_vars());

echo $__html;

unset($__html);
unset($__name);
unset($__params);
unset($__split);
if (isset($__slots)) unset($__slots);
?>
                  </div>
                <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
              <?php endif; ?><!--[if ENDBLOCK]><![endif]-->

              <div class="input-group">
                <input type="number" class="form-control" placeholder="Stop Loss" step="0.01" wire:model.live="stopLoss" />
                <div class="input-group-append">
                  <span class="input-group-text">Price</span>
                  <button class="btn btn-outline-secondary" type="button" wire:click="decrementStopLoss">-</button>
                  <button class="btn btn-outline-secondary" type="button" wire:click="incrementStopLoss">+</button>
                </div> 
              </div>
              <!--[if BLOCK]><![endif]--><?php if($orderType): ?>
                <!--[if BLOCK]><![endif]--><?php if($orderType === 'buy' && $stopLoss && $stopLoss >= $currentCurrency->ask): ?>
                  <div class="text-danger">
                    Max <?php
$__split = function ($name, $params = []) {
    return [$name, $params];
};
[$__name, $__params] = $__split('real-time-property', ['model' => $currentCurrency,'property' => 'formatted_ask']);

$__html = app('livewire')->mount($__name, $__params, 'order-stop-loss-max-ask-'.e($currentCurrency->id).'', $__slots ?? [], get_defined_vars());

echo $__html;

unset($__html);
unset($__name);
unset($__params);
unset($__split);
if (isset($__slots)) unset($__slots);
?>
                  </div>
                <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
                <!--[if BLOCK]><![endif]--><?php if($orderType === 'sell' && $stopLoss && $stopLoss <= $currentCurrency->bid): ?>
                  <div class="text-danger">
                    Min <?php
$__split = function ($name, $params = []) {
    return [$name, $params];
};
[$__name, $__params] = $__split('real-time-property', ['model' => $currentCurrency,'property' => 'formatted_bid']);

$__html = app('livewire')->mount($__name, $__params, 'order-stop-loss-min-bid-'.e($currentCurrency->id).'', $__slots ?? [], get_defined_vars());

echo $__html;

unset($__html);
unset($__name);
unset($__params);
unset($__split);
if (isset($__slots)) unset($__slots);
?>
                  </div>
                <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
              <?php endif; ?><!--[if ENDBLOCK]><![endif]-->

              <!--[if BLOCK]><![endif]--><?php if($orderType): ?>
                <div class="d-flex flex-column gap-2">
                  <button class="btn <?php echo e($orderType); ?> selected" wire:click="clickConfirmOrder()" <?php if(!$this->canPlaceOrder()): ?> disabled <?php endif; ?>>
                    Confirm <?php echo e($orderType); ?> <?php echo e($volume); ?> lots
                  </button>
                  <button class="btn btn-outline-secondary mt-2" wire:click="clickOrderTypeButton('')">
                    Cancel
                  </button>
                </div>
              <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
            </div>
            <!--[if BLOCK]><![endif]--><?php if($orderType): ?>
            <div class="market-trade-summary mt-3">
              <div class="d-flex justify-content-between">
                <span>Fees:</span>
                <span>
                  ≈ $<?php echo e(number_format($this->fees, 2)); ?>

                </span>
              </div>
              <div class="d-flex justify-content-between">
                <span>Leverage:</span>
                <span>1:<?php echo e($currentCurrency->leverage); ?></span>
              </div>
              <div class="d-flex justify-content-between">
                <span>Required Margin:</span>
                <span>$<?php echo e(number_format($this->margin, 2)); ?></span>
              </div>
              <div class="more-details" <?php if($showMoreDetails): ?> style="display: block;" <?php else: ?> style="display: none;" <?php endif; ?>>
                <div class="d-flex justify-content-between">
                  <span>Pip Value:</span>
                  <span>$<?php echo e(number_format($this->pipValue, 2)); ?></span>
                </div>
                <div class="d-flex justify-content-between">
                  <span>Volume (Units):</span>
                  <span><?php echo e(number_format($this->volumeInUnits, 2)); ?> <?php echo e($currentCurrency->code); ?></span>
                </div>
                <div class="d-flex justify-content-between">
                  <span>Volume (USD):</span>
                  <span>$<?php echo e(number_format($this->volumeInUsd, 2)); ?></span>
                </div>
              </div>
              <div class="text-left my-2">
                <button class="btn btn-sm btn-outline-secondary" wire:click="$toggle('showMoreDetails')">
                  <?php echo e($showMoreDetails ? 'Less' : 'More'); ?>

                </button>
              </div>
            </div>
            <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
        </div>
      </div>
      <div class="col-md-3">
      </div>
      <div class="col-md-9">
      </div>
    </div>
  </div>
        <?php
        $__scriptKey = '2419806505-0';
        ob_start();
    ?>
    <script>
        // document.addEventListener('livewire:initialized', () => {
            // Initialize the first chart
            initializeTradingViewChart(<?php echo \Illuminate\Support\Js::from($this->currentCurrency->chart_code)->toHtml() ?>);
            
            $wire.on('currency-changed', (event) => {
                initializeTradingViewChart(event.currentCurrency.chart_code);
            });

            // Remove tab parameter from URL when currency is selected from market tab
            $wire.on('remove-tab-parameter', () => {
                const url = new URL(window.location);
                url.searchParams.delete('tab');
                window.history.pushState({}, '', url);
                // Update footer active state
                if (typeof updateFooterActiveTab === 'function') {
                    updateFooterActiveTab();
                }
            });
        // });

        function initializeTradingViewChart(symbol) {
            // Initialize new widget
            window.tradingViewWidget = new TradingView.widget({
                    "width": "100%",
                    "height": 550,
                    "symbol": symbol,
                    "interval": "D",
                    "timezone": "Etc/UTC",
                    "theme": "dark",
                    "style": "3",
                    "locale": "en",
                    "toolbar_bg": "#f1f3f6",
                    "enable_publishing": false,
                    "withdateranges": true,
                    "hide_side_toolbar": false,
                    "allow_symbol_change": true,
                    "show_popup_button": true,
                    "popup_width": "1000",
                    "popup_height": "650",
                    "hide_volume": true,
                    "container_id": "tradingview_e8033",
                    "loading_screen": {
                        "backgroundColor": "transparent"
                    },
                    "overrides": {
                        "paneProperties.backgroundGradientStartColor": "#020024",
                        "paneProperties.backgroundGradientEndColor": "#4f485e",
                    },
                });
        }
    </script>
        <?php
        $__output = ob_get_clean();

        \Livewire\store($this)->push('scripts', $__output, $__scriptKey)
    ?>

<!-- Take Profit / Stop Loss Modal -->
<!--[if BLOCK]><![endif]--><?php if($selectedOrder): ?>
<div class="modal fade show" style="display: block;" tabindex="-1" role="dialog"  data-bs-theme="dark">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">
          <!--[if BLOCK]><![endif]--><?php if($modalType == 'take_profit'): ?>
            Set Take Profit for <?php echo e($selectedOrder->currency->name); ?>

          <?php else: ?>
            Set Stop Loss for <?php echo e($selectedOrder->currency->name); ?>

          <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
        </h5>
        <button type="button" class="close" wire:click="closeModal">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <div class="form-group">
          <label for="price">
            <!--[if BLOCK]><![endif]--><?php if($modalType == 'take_profit'): ?>
              Take Profit Price
            <?php else: ?>
              Stop Loss Price
            <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
          </label>
          <div class="input-group">
            <input type="number" 
                   class="form-control" 
                   id="price" 
                   wire:model="<?php echo e($modalType == 'take_profit' ? 'newTakeProfit' : 'newStopLoss'); ?>" 
                   step="0.01" 
                   min="0">
            <div class="input-group-append">
              <span class="input-group-text">USD</span>
            </div>
          </div>
          
          <!--[if BLOCK]><![endif]--><?php if($selectedOrder->side === 'buy' && $newTakeProfit && $newTakeProfit <= $selectedOrder->currency->ask): ?>
            <div class="text-danger">
              Min <?php echo e($selectedOrder->currency->formatted_ask); ?>

            </div>
          <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
          <!--[if BLOCK]><![endif]--><?php if($selectedOrder->side === 'sell' && $newTakeProfit && $newTakeProfit >= $selectedOrder->currency->bid): ?>
            <div class="text-danger">
              Max <?php echo e($selectedOrder->currency->formatted_bid); ?>

            </div>
          <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
          
          <!--[if BLOCK]><![endif]--><?php if($selectedOrder->side === 'buy' && $newStopLoss && $newStopLoss >= $selectedOrder->currency->ask): ?>
            <div class="text-danger">
              Max <?php echo e($selectedOrder->currency->formatted_ask); ?>

            </div>
          <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
          <!--[if BLOCK]><![endif]--><?php if($selectedOrder->side === 'sell' && $newStopLoss && $newStopLoss <= $selectedOrder->currency->bid): ?>
            <div class="text-danger">
              Min <?php echo e($selectedOrder->currency->formatted_bid); ?>

            </div>
          <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
          
          <!--[if BLOCK]><![endif]--><?php if($modalType == 'take_profit'): ?>
            <!--[if BLOCK]><![endif]--><?php $__errorArgs = ['newTakeProfit'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <span class="text-danger"><?php echo e($message); ?></span> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?><!--[if ENDBLOCK]><![endif]-->
          <?php else: ?>
            <!--[if BLOCK]><![endif]--><?php $__errorArgs = ['newStopLoss'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <span class="text-danger"><?php echo e($message); ?></span> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?><!--[if ENDBLOCK]><![endif]-->
          <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" wire:click="closeModal">Cancel</button>
        <button type="button" class="btn btn-primary" wire:click="<?php echo e($modalType == 'take_profit' ? 'updateTakeProfit' : 'updateStopLoss'); ?>" <?php if(!$this->canUpdateSelectedOrder()): ?> disabled <?php endif; ?>>
          Save
        </button>
      </div>
    </div>
  </div>
</div>
<div class="modal-backdrop fade show"></div>
<?php endif; ?><!--[if ENDBLOCK]><![endif]-->

<!-- Close Order Confirmation Modal -->
<!--[if BLOCK]><![endif]--><?php if($showCloseOrderModal): ?>
<div class="modal fade show" style="display: block;" tabindex="-1" role="dialog">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">Confirm Close Order</h5>
        <button type="button" class="close" wire:click="cancelCloseOrder">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <p>Are you sure you want to close this order?</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" wire:click="cancelCloseOrder">Cancel</button>
        <button type="button" class="btn btn-danger" wire:click="closeOrderConfirmed">Close Order</button>
      </div>
    </div>
  </div>
</div>
<div class="modal-backdrop fade show"></div>
<?php endif; ?><!--[if ENDBLOCK]><![endif]-->

<!-- Edit Order Modal -->
<!--[if BLOCK]><![endif]--><?php if($showEditOrderModal): ?>
<div class="modal fade show" style="display: block;" tabindex="-1" role="dialog" data-bs-theme="dark">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">
          Edit Order - <?php echo e($editingOrder->currency->name); ?>

        </h5>
        <button type="button" class="close" wire:click="closeEditOrderModal">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <div class="form-group">
          <label for="editTakeProfit">Take Profit</label>
          <div class="input-group">
            <input type="number" 
                   class="form-control" 
                   id="editTakeProfit" 
                   wire:model.live="editTakeProfit" 
                   step="0.01" 
                   min="0">
            <div class="input-group-append">
              <span class="input-group-text">USD</span>
            </div>
          </div>
          
          
          <!--[if BLOCK]><![endif]--><?php if($editingOrder->side === 'buy' && $editTakeProfit && $editTakeProfit <= $editingOrder->currency->ask): ?>
            <div class="text-danger">
              Min <?php echo e($editingOrder->currency->formatted_ask); ?>

            </div>
          <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
          <!--[if BLOCK]><![endif]--><?php if($editingOrder->side === 'sell' && $editTakeProfit && $editTakeProfit >= $editingOrder->currency->bid): ?>
            <div class="text-danger">
              Max <?php echo e($editingOrder->currency->formatted_bid); ?>

            </div>
          <?php endif; ?><!--[if ENDBLOCK]><![endif]-->

        <div class="form-group">
          <label for="editStopLoss">Stop Loss</label>
          <div class="input-group">
            <input type="number" 
                   class="form-control" 
                   id="editStopLoss" 
                   wire:model.live="editStopLoss" 
                   step="0.01" 
                   min="0">
            <div class="input-group-append">
              <span class="input-group-text">USD</span>
            </div>
          </div>
          <!--[if BLOCK]><![endif]--><?php if($editingOrder->side === 'buy' && $editStopLoss && $editStopLoss >= $editingOrder->currency->ask): ?>
            <div class="text-danger">
              Max <?php echo e($editingOrder->currency->formatted_ask); ?>

            </div>
          <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
          <!--[if BLOCK]><![endif]--><?php if($editingOrder->side === 'sell' && $editStopLoss && $editStopLoss <= $editingOrder->currency->bid): ?>
            <div class="text-danger">
              Min <?php echo e($editingOrder->currency->formatted_bid); ?>

            </div>
          <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
        </div>
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" wire:click="closeEditOrderModal">Cancel</button>
        <button type="button" class="btn btn-primary" wire:click="updateOrder" <?php if(!$this->canUpdateOrder()): ?> disabled <?php endif; ?>>Save changes</button>
      </div>
    </div>
  </div>
</div>
<div class="modal-backdrop fade show"></div>
<?php endif; ?><!--[if ENDBLOCK]><![endif]-->
</div><?php /**PATH C:\Users\indri\prjct\webtrader12-01\webtrader\resources\views/livewire/dashboard.blade.php ENDPATH**/ ?>