

<?php $__env->startSection('isMobile'); ?>
<style>
/* RTP DI BAWAH NAMA GAME */
.rtp-below {
    margin-top: 4px;
    font-size: 11px;
    text-align: left;
}

.rtp-text {
    font-weight: 600;
    color: #666;
}

.rtp-value {
    float: right;
    font-weight: bold;
}

.rtp-bar {
    width: 100%;
    height: 5px;
    background: #e0e0e0;
    border-radius: 3px;
    margin-top: 3px;
    overflow: hidden;
}

.rtp-fill {
    height: 100%;
    width: 0%;
}

/* WARNA */
.rtp-green { background: #28a745; }
.rtp-yellow { background: #ffc107; }
.rtp-red { background: #dc3545; }

/* RTP DI BAWAH GAME – DIBERI JARAK */
.rtp-below {
    margin-top: 6px;
    margin-bottom: 10px;   /* ⬅️ INI PENTING: jarak antar game */
    padding-bottom: 6px;   /* ⬅️ ruang napas */
    font-size: 11px;
    text-align: left;
}

/* baris RTP text */
.rtp-below .rtp-text {
    font-weight: 600;
    color: #bfbfbf;
}

.rtp-below .rtp-value {
    float: right;
    font-weight: bold;
}

/* progress bar */
.rtp-below .rtp-bar {
    width: 100%;
    height: 5px;
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
    margin-top: 4px;       /* ⬅️ jarak text ke bar */
    overflow: hidden;
}

.rtp-below .rtp-fill {
    height: 100%;
    width: 0%;
}


</style>

<div class="content my01">

  <?php echo $__env->make('nav_saldo', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

  
  <div class="container pt-1 sub-games">
    <h3 class="title">SLOTS PROVIDERS</h3>

    <div class="scroll-wrapper row" style="height:72px;">
      <div class="left">
        <button class="prev-btn btn" id="left-button">
          <i class="icon-keyboard_arrow_left"></i>
        </button>
      </div>

      <div class="scroller" style="overflow:hidden;width:100%;">
        <div class="row no-gutters text-center slider-content">
          <div class="col" style="height:72px;">
            <a class="btn-box active" href="/slots/pragmatic-play">
              <img src="https://files.sitestatic.net/images/ppslot.gif?v=1"
                   style="width:70px;height:50px;">
              <h5 class="game-title">PRAGMATIC</h5>
            </a>
          </div>

          <div class="col" style="height:72px;">
            <a class="btn-box" href="/slots/pgsoft">
              <img src="https://files.sitestatic.net/images/pgsoft.gif?v=0.2"
                   style="width:70px;height:50px;">
              <h5 class="game-title">PGSOFT</h5>
            </a>
          </div>

          <div class="col" style="height:72px;">
            <a class="btn-box" href="/slots/joker-gaming">
              <img src="https://files.sitestatic.net/assets/imgs/game_logos/100x70/jk_slot.png?v=0.1"
                   style="width:70px;height:50px;">
              <h5 class="game-title">JOKER</h5>
            </a>
          </div>
          <div class="col" style="height:72px;">
            <a class="btn-box" href="/slots/jili">
              <img src="https://files.sitestatic.net/images/jili.gif"
                   style="width:70px;height:50px;">
              <h5 class="game-title">JILI</h5>
            </a>
          </div>
          <div class="col" style="height:72px;">
            <a class="btn-box" href="/slots/booongo">
              <img src="https://files.sitestatic.net/assets/imgs/game_logos/100x70/booongo_slot.gif?v=0.2"
                   style="width:70px;height:50px;">
              <h5 class="game-title">BNG</h5>
            </a>
          </div>
          <div class="col" style="height:72px;">
            <a class="btn-box" href="/slots/playtech">
              <img src="https://files.sitestatic.net/assets/imgs/game_logos/100x70/pt_slot.png?v=0.2"
                   style="width:70px;height:50px;">
              <h5 class="game-title">PLAYTECH</h5>
            </a>
          </div>
          <div class="col" style="height:72px;">
            <a class="btn-box" href="/slots/wowgaming">
              <img src="https://files.sitestatic.net/assets/imgs/game_logos/100x70/wow_slot.png?v=0.2"
                   style="width:70px;height:50px;">
              <h5 class="game-title">WOW GAMING</h5>
            </a>
          </div>
          <div class="col" style="height:72px;">
            <a class="btn-box" href="/slots/habanero">
              <img src="https://files.sitestatic.net/assets/imgs/game_logos/100x70/hb_slot.png?v=0.2"
                   style="width:70px;height:50px;">
              <h5 class="game-title">HABANERO</h5>
            </a>
          </div>
          <div class="col" style="height:72px;">
            <a class="btn-box" href="/slots/fatpanda">
              <img src="https://files.sitestatic.net/assets/imgs/game_logos/100x70/fatpanda_slot.png?v=0.2"
                   style="width:70px;height:50px;">
              <h5 class="game-title">FATPANDA</h5>
            </a>
          </div>
          <div class="col" style="height:72px;">
            <a class="btn-box" href="/slots/advantplay">
              <img src="https://files.sitestatic.net/assets/imgs/game_logos/100x70/advantplay_slot.png?v=0.2"
                   style="width:70px;height:50px;">
              <h5 class="game-title">ADVANTPLAY</h5>
            </a>
          </div>
          <div class="col" style="height:72px;">
            <a class="btn-box" href="/slots/hacksaw">
              <img src="https://files.sitestatic.net/assets/imgs/game_logos/100x70/hacksaw_slot.png?v=0.2"
                   style="width:70px;height:50px;">
              <h5 class="game-title">HACKSAW</h5>
            </a>
          </div>
          <div class="col" style="height:72px;">
            <a class="btn-box" href="/slots/hacksaw">
              <img src="https://files.sitestatic.net/assets/imgs/game_logos/100x70/cq9_slot.png?v=0.2"
                   style="width:70px;height:50px;">
              <h5 class="game-title">CQ9</h5>
            </a>
          </div>
          
          
        </div>
      </div>

      <div class="right">
        <button class="next-btn btn" id="right-button">
          <i class="icon-keyboard_arrow_right"></i>
        </button>
      </div>
    </div>

    
    <div class="row no-gutters filter mt-2">
      <div class="col-xs-10 text-center">
        <div class="row">
          <div class="col-xs-3">
            <button class="btn btn-clear f" data-filter="NEW">BARU</button>
          </div>
          <div class="col-xs-3">
            <button class="btn btn-clear f" data-filter="TOP">TOP</button>
          </div>
          <div class="col-xs-3">
            <button class="btn btn-clear f active" data-filter="ALL">SEMUA</button>
          </div>
        </div>
      </div>
      <div class="col-xs-1 text-right">
        <button class="btn btn-clear" data-trigger="nifty" data-target="#searchModal">
          <i class="icon-magnifier"></i>
        </button>
      </div>
      <div class="col-xs-1 text-right">
        <button class="btn btn-clear" data-trigger="nifty" data-target="#filterModal">
          <i class="icon-equalizer2"></i>
        </button>
      </div>
    </div>

    <div class="mobile-border"></div>
    <div class="mobile-border"></div>

    

<input type="hidden" id="hiddenGameCode">

<div class="row games no-gutters">
<?php if(isset($gamelist) && $gamelist->count()): ?>
    <?php $__currentLoopData = $gamelist; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $game): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <a class="col-xs-4 col-md-3 game-box text-center"
           data-title="<?php echo e($game->game_name); ?>"
           data-filter="ALL,slot"
           style="order: -<?php echo e($game->id); ?>;" 
           onclick="showGameLinks(
               event,
               '<?php echo e($game->game_name); ?>',
               '<?php echo e(asset($game->game_image)); ?>',
               '<?php echo e($game->game_code); ?>'
           )">

            <div class="content-wrapper">
                <img class="lazy"
                     data-src="<?php echo e(asset($game->game_image)); ?>"
                     alt="<?php echo e($game->game_name); ?>">
            </div>

            <h5><?php echo e($game->game_name); ?></h5>

<div class="rtp-below"
     data-game="<?php echo e($game->game_code); ?>"
     data-provider="<?php echo e($game->game_provider); ?>">
    <span class="rtp-text">RTP</span>
    <span class="rtp-value">--%</span>
    <div class="rtp-bar">
        <div class="rtp-fill"></div>
    </div>
</div>

        </a>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
<?php else: ?>
    <p class="text-center">No games available.</p>
<?php endif; ?>
</div>

  </div>

  
  <div class="nifty-modal slide-in-bottom" id="gamelinksModal-1">
    <div class="md-content">
      <div class="md-body">
        <div class="row mb-4 no-gutters">
          <div class="col-xs-5">
            <img src="" class="img-fluid" id="gamePreviewImg">
          </div>
          <div class="col-xs-7">
            <div class="g-title"></div>
          </div>
        </div>

        <button class="btn btn-primary btn-block" onclick="launchGame(event)">
          MAIN SEKARANG
        </button>
      </div>
    </div>
  </div>
  <div class="md-overlay"></div>

  
  <div class="nifty-modal slide-in-bottom" id="searchModal">
    <div class="md-content">
      <div class="md-body">
        <div class="search_filter">
          <input type="text" placeholder="Search" class="search" id="searchInput">
          <button class="btn srch_button" id="clearSearch">
            <i class="icon-x-square"></i>
          </button>
        </div>
      </div>
    </div>
  </div>
  <div class="md-overlay"></div>

</div>
<script>
document.addEventListener('DOMContentLoaded', function () {

  fetch('/game/rtp-all')
    .then(res => res.json())
    .then(list => {

      document.querySelectorAll('.rtp-below').forEach(el => {

        const key = el.dataset.game + '_' + el.dataset.provider;
        const data = list[key];

        if (!data) return;

        const percent = parseFloat(data.rtp);
        const valueEl = el.querySelector('.rtp-value');
        const barEl   = el.querySelector('.rtp-fill');

        valueEl.innerText = percent + '%';
        barEl.style.width = percent + '%';

        barEl.classList.add(
          percent >= 90 ? 'rtp-green' :
          percent >= 80 ? 'rtp-yellow' : 'rtp-red'
        );
      });

    });
});
</script>




<?php if(Auth::check()): ?>
<script>
let isLaunching = false;

function showGameLinks(e, name, imgSrc, gameCode) {
  e.preventDefault();
  $('#gamelinksModal-1 .g-title').text(name);
  $('#gamePreviewImg').attr('src', imgSrc);
  $('#hiddenGameCode').val(gameCode);
  $('#gamelinksModal-1').nifty('show');
}

function launchGame(e) {
  e.preventDefault();

  // ⛔ cegah klik berkali-kali
  if (isLaunching) return;
  isLaunching = true;

  let gameCode = $('#hiddenGameCode').val();
  if (!gameCode) {
    isLaunching = false;
    Swal.fire('Error', 'Game tidak valid', 'error');
    return;
  }

  // ✅ tutup modal agar tidak ganggu redirect
  $('#gamelinksModal-1').nifty('hide');

  $.ajax({
    type: 'POST',
    url: "<?php echo e(route('game.launch')); ?>",
    data: {
      _token: document
        .querySelector('meta[name="csrf-token"]')
        .getAttribute('content'),
      game_code: gameCode
    },
    beforeSend() {
      $('#loader').show();
    },
    success(res) {
      $('#loader').hide();

      if (res && res.status === true && res.url) {
        // 🔥 INI KUNCI SEMUANYA
        window.location.href = res.url;
      } else {
        isLaunching = false;
        Swal.fire('Gagal', res.message ?? 'Game gagal dibuka', 'error');
      }
    },
    error(xhr) {
      isLaunching = false;
      $('#loader').hide();

      if (xhr.status === 401) {
        Swal.fire('Session habis', 'Silakan login ulang', 'warning')
          .then(() => location.reload());
        return;
      }

      if (xhr.status === 419) {
        Swal.fire('Session expired', 'Refresh halaman dan coba lagi', 'warning');
        return;
      }

      Swal.fire('Error', 'Terjadi kesalahan sistem', 'error');
    }
  });
}
</script>
<?php else: ?>
<script>
function launchGame() {
  Swal.fire('Warning', 'Silakan login terlebih dahulu', 'warning');
}
</script>
<?php endif; ?>

<?php $__env->stopSection(); ?>
<?php $__env->startSection('isDesktop'); ?>

<style>
/* =========================
   CARD
========================= */
.game-card {
    background: linear-gradient(145deg, #1e1e1e, #252525);
    border-radius: 12px;
    padding: 10px;
    cursor: pointer;
    transition: 0.25s;
}

.game-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.4);
}

/* =========================
   IMAGE (FIX PROPORSI)
========================= */
.game-img {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.game-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: 0.3s;
}

.game-card:hover img {
    transform: scale(1.05);
}

/* =========================
   OVERLAY PLAY
========================= */
.play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: 0.2s;
}

.game-card:hover .play-overlay {
    opacity: 1;
}

.play-btn {
    background: #28a745;
    padding: 6px 12px;
    border-radius: 6px;
    color: #fff;
    font-size: 12px;
    font-weight: bold;
}

/* =========================
   TITLE
========================= */
.game-card h6 {
    font-size: 12px;
    color: #fff;
    margin-top: 8px;
    min-height: 30px;
}

/* =========================
   RTP
========================= */
.rtp-below {
    margin-top: 5px;
    font-size: 11px;
}

.rtp-text { color: #aaa; }
.rtp-value {
    float: right;
    font-weight: bold;
}

.rtp-bar {
    height: 5px;
    background: #333;
    border-radius: 3px;
    margin-top: 3px;
}

.rtp-fill {
    height: 100%;
    border-radius: 3px;
}

.rtp-green { background: #28a745; }
.rtp-yellow { background: #ffc107; }
.rtp-red { background: #dc3545; }
</style>

<div class="content my01">
    <div class="container pt-3">

        <h3 class="title mb-3">SLOTS GAMES</h3>

        <input type="hidden" id="hiddenGameCode">

        <div class="row">

            <?php if(isset($gamelist) && $gamelist->count()): ?>
                <?php $__currentLoopData = $gamelist; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $game): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                <div class="col-lg-2 col-md-3 col-sm-4 col-6 mb-3">

                    <div class="game-card text-center"
                         onclick="showGameLinks(
                             event,
                             '<?php echo e($game->game_name); ?>',
                             '<?php echo e(asset($game->game_image)); ?>',
                             '<?php echo e($game->game_code); ?>'
                         )">

                        <div class="game-img">
                            <img src="<?php echo e(asset($game->game_image)); ?>"
                                 alt="<?php echo e($game->game_name); ?>">

                            <div class="play-overlay">
                                <div class="play-btn">MAIN</div>
                            </div>
                        </div>

                        <h6><?php echo e($game->game_name); ?></h6>

                        <div class="rtp-below"
                             data-game="<?php echo e($game->game_code); ?>"
                             data-provider="<?php echo e($game->game_provider); ?>">

                            <span class="rtp-text">RTP</span>
                            <span class="rtp-value">--%</span>

                            <div class="rtp-bar">
                                <div class="rtp-fill"></div>
                            </div>
                        </div>

                    </div>

                </div>

                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            <?php else: ?>
                <p class="text-center">No games available.</p>
            <?php endif; ?>

        </div>

    </div>
</div>

<!-- =========================
     MODAL GAME
========================= -->
<div class="nifty-modal slide-in-bottom" id="gamelinksModal-1">
  <div class="md-content">
    <div class="md-body">

      <div class="row mb-3">
        <div class="col-4">
          <img src="" class="img-fluid" id="gamePreviewImg">
        </div>
        <div class="col-8">
          <div class="g-title" style="font-weight:bold;"></div>
        </div>
      </div>

      <button class="btn btn-success btn-block" onclick="launchGame(event)">
        MAIN SEKARANG
      </button>

    </div>
  </div>
</div>
<div class="md-overlay"></div>


<?php if(Auth::check()): ?>
<script>
let isLaunching = false;

function showGameLinks(e, name, imgSrc, gameCode) {
    e.preventDefault();

    document.querySelector('#gamelinksModal-1 .g-title').innerText = name;
    document.getElementById('gamePreviewImg').src = imgSrc;
    document.getElementById('hiddenGameCode').value = gameCode;

    $('#gamelinksModal-1').nifty('show');
}

function launchGame(e) {
    e.preventDefault();

    if (isLaunching) return;
    isLaunching = true;

    let gameCode = document.getElementById('hiddenGameCode').value;

    if (!gameCode) {
        isLaunching = false;
        Swal.fire('Error', 'Game tidak valid', 'error');
        return;
    }

    $('#gamelinksModal-1').nifty('hide');

    $.ajax({
        type: 'POST',
        url: "<?php echo e(route('game.launch')); ?>",
        data: {
            _token: document.querySelector('meta[name="csrf-token"]').getAttribute('content'),
            game_code: gameCode
        },
        beforeSend() {
            $('#loader').show();
        },
        success(res) {
            $('#loader').hide();

            if (res.status && res.url) {
                window.location.href = res.url;
            } else {
                isLaunching = false;
                Swal.fire('Gagal', res.message ?? 'Game gagal dibuka', 'error');
            }
        },
        error(xhr) {
            isLaunching = false;
            $('#loader').hide();

            if (xhr.status === 401) {
                Swal.fire('Session habis', 'Login ulang', 'warning')
                    .then(() => location.reload());
                return;
            }

            if (xhr.status === 419) {
                Swal.fire('Session expired', 'Refresh halaman', 'warning');
                return;
            }

            Swal.fire('Error', 'Terjadi kesalahan sistem', 'error');
        }
    });
}
</script>
<?php else: ?>
<script>
function launchGame() {
    Swal.fire('Warning', 'Silakan login terlebih dahulu', 'warning');
}
</script>
<?php endif; ?>

<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.main', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/ybjqutnd/jp.royalkingz.top/resources/views/games/slots/habanero.blade.php ENDPATH**/ ?>