<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>PyMRF 4 Mobile</title>
</head>

<body>
  
  <style>
    html, body {
      overflow-x: hidden;
    }
    body {
      font: 12px/1.5 sans-serif;
      margin: 0;
      padding: 0;
      position: relative;
      background:#eee;
    }

    /* * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    } */

    body {
        font-family: Arial, sans-serif;
    }

    /* On mobile: full width */
    .phone-container {
        width: 100%;
        min-height: 100vh;
        background: white;
    }

    /* On desktop: phone-sized centered container */
    @media (min-width: 768px) {
        body {
            background: #f0f0f0;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            padding: 20px;
        }

        .phone-container {
            width: 375px; /* iPhone width */
            max-width: 100%;
            min-height: 812px; /* iPhone height */
            border-radius: 20px;
            box-shadow: 0 10px 50px rgba(0,0,0,0.3);
            overflow: hidden;
            padding-bottom: 40px;
        }
    }

    h1 {
      text-align: center;
    }
    span.num {
      font: "Courier New", monospace
    }
    .announces, .announces td {
      display: none
    }
    .torrent-list {
      padding: 0;
      width: 100%;
    }
    .torrent-item {
      border-bottom: solid 1px #ccc;
      display: flex;
      width: 100%;
      padding: 1em 0;
      margin: 0.5em 0;
      line-height: 1.3em;
      background: #fff;
      color:#333;
    }
    .torrent-item .torrent-item__inner {
      display: flex;
      margin: 0 1em;
      flex-grow: 1;
    }
    .torrent-item .torrent-item-site {
      display: inline-block;
      width: fit-content;
      background: #00312f;
      color: #fff;
      border-radius: 4px;
      line-height: 1em;
      padding: 3px 5px;
      font-size: 9px;
      margin-right:3px;
    }
    .torrent-item .torrent-item__side {
      width: 16%;
      padding-left: 0.5em;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-content: center;
      flex-shrink: 0;
    }
    .torrent-item .torrent-item__main {
      flex-grow: 1;
      flex-direction: column;
    }
    .torrent-item .torrent-item__hash {
      font-family: "Courier New", monospace;
      font-size: 90%;
      color:#996;
    }
    .torrent-item .torrent-item__stats {
      color: #666
    }
    .torrent-item .torrent-item__name {
      /* overflow: wrap;     */
      height: 1.4em;
      text-overflow: ellipsis;
      overflow: hidden;
      max-width: 95vw;
      white-space: nowrap;
    }
    .torrent-item.stopped {
      background-color: #eeeeee;
    }
    .torrent-item button {
      padding: 0.5em;
      border: 1px solid #ccc;
      border-radius: 4px;
      background-color: #f8f8f8;
      cursor: pointer;
    }
    .harvestor-status {
      position: fixed;
      top: 0;
      width: 100%;
      /* height: 2.5em; */
      height: fit-content;
      line-height: 2em;
      background: #FFF;
      opacity: 0.8;
    }
    .harvestor-status .progress-bar {
      position: absolute;
      bottom: 0;
      height: 3px;
      background: #ccc;
      width: 100%;
    }
    .harvestor-status .progress-bar--indicator {
      position: absolute;
      bottom: 0;
      height: 3px;
      background: #0c0;
      /* width: 50%; */
    }
    .harvestor-status .harvestor-opr {
      position: absolute;
      bottom: -2.5em;
      display: flex;
      width: 100%;
      justify-content: center;
    }
    .harvestor-status button.harvestor-stop {
      width: 30px;
      height: 30px;
      border-radius: 50%;
      padding: 0;
    }
    .harvestor-status .harvestor-stats {
      text-align:center;
    }
    .torrent-item__stats {
      display: flex;
      flex-direction: row;
      width: 100%;
    }
    .torrent-item__stats .stat-box {
      display: flex;
      flex-direction: column;
      flex: 1 0;
      flex-basis: 25%;
    }
    .torrent-item__stats .stat-box .stat-box__label {
      font-variant-caps: all-petite-caps;
      color:#666;
      padding: 4px 0;
    }
    .torrent-item__stats .stat-box .stat-box__value {
      color:#000;
    }
    .action, .torrent-action {
      margin-top: 12px;
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      flex-wrap: wrap
    }
    .action {
      justify-content: center;
    }
    .action button,
    .torrent-action button {
      /* font-variant-caps: all-petite-caps; */
      font-size: 90%;
    }
    .tag-color-1 {
      background-color: #d32d41;
    }
    .tag-color-2 {
      background-color: #00312f;
    }
    .tag-color-3 {
      background-color: #1c4e80;
    }
    .tag-color-4 {
      background-color: #2c8;
    }
    .tag-color-5 {
      background-color: #ffa500;
    }
  </style>
  <script src="/vue.global.js"></script>
  <script type="module">
    // import { createApp } from '/petite-vue.js'

    import { PyMRF } from '/app.js'
    Vue.createApp(PyMRF).mount("#pymrf4")


  </script>
  <div id="pymrf4" class="phone-container">
    <h1>PyMRF 4 Web UI</h1>
    <div style="text-align: center;">
      Overall up speed: {{convertSize(totalUploadSpeed)}}/s | {{foldedItems.length}} folded
    </div>
    <div style="text-align: center;" class="action">
      <button @click="autoFold()">Auto fold</button>
      <button @click="unfoldAll()">Unfold all</button>
    </div>
    <div class="torrent-list" v-if="allCtx.length > 0">
      <div class="torrent-item" v-for="ctx in allCtx" :key="ctx.id" :class="{'stopped': ctx.last_event == 'stopped'}">
        <div class="torrent-item__inner">
          <div class="torrent-item__main">
            <div class="torrent-item__name">
              <div class="torrent-item-site" :style="tagColorBySite(ctx.site)">{{ctx.site}}</div>
              <span v-if="ctx.is_seeding">🌱</span>
              <span v-else>🔻</span>
              {{ctx.name}}</div>
            <div class="torrent-item__stats">
              <div class="stat-box">
                <div class="stat-box__label">Size</div>
                <div class="stat-box__value">{{convertSize(ctx.size)}}</div>
              </div>
              <div class="stat-box">
                <div class="stat-box__label">Download</div>
                <div class="stat-box__value">{{convertSize(ctx.session_download)}}</div>
              </div>
              <div class="stat-box">
                <div class="stat-box__label">Leechers</div>
                <div class="stat-box__value">{{ctx.leechers}}</div>
              </div>
              <div class="stat-box">
                <div class="stat-box__label">Speed</div>
                <div class="stat-box__value">{{convertSize(ctx.upload_speed)}}/s</div>
              </div>
            </div>
            <div class="torrent-item__stats">
              <div class="stat-box" style="flex-grow:1; flex-basis:50%">
                <div class="stat-box__label">Upload</div>
                <div class="stat-box__value">{{convertSize(ctx.session_upload)}} → {{convertSize(ctx.session_upload_actual)}}
                  &nbsp;({{ Math.round(ctx.session_upload_actual / ctx.session_upload) }}x)
                </div>
              </div>
              <div class="stat-box">
                <div class="stat-box__label">Share radio</div>
                <div class="stat-box__value">{{shareRatio(ctx)}}</div>
              </div>
              <div class="stat-box">
                <div class="stat-box__label">CP Value</div>
                <div class="stat-box__value">{{cpValue(ctx)}}</div>
              </div>
            </div>

            <!-- <div class="torrent-item__hash">{{ctx.info_hash}}</div> -->

            <div class="torrent-action">
              <button @click="harvest(ctx.id, 'movie')">🎬 Movie</button>
              <button @click="harvest(ctx.id, 'tvshow')">📺 TV Show</button>
              <button @click="harvest(ctx.id, 'documentary')">🐻 Documentary</button>
              <button @click="harvest(ctx.id, 'anime')">🎃 Anime</button>
              <button @click="harvest(ctx.id, 'music')">🎶 Music</button>
              <button @click="fold(ctx.id, $event)">👻 Fold</button>
            </div>
          </div>
      </div>

      </div>
    </div>

    <div class="harvestor-status" v-if="harvestor.status == 'running'">
      <div class="harvestor-stats">
        [Harvestor] {{harvestor.filesLeft}}F | {{harvestor.workers}}W | {{convertSize(harvestor.copiedSize)}}/{{convertSize(harvestor.totalSize)}} |
        Speed: {{convertSize(harvestor.speed)}}/s | Progress: {{harvestor.progress}}
      </div>
      <div class="harvestor-opr">
        <button class="harvestor-stop" @click="stopHarvestor()">❌</button>
      </div>
      <div class="progress-bar">
        <div class="progress-bar--indicator"
          v-bind:style="harvestor.progressStyle"></div>
      </div>
    </div>

  </div>



</body>

</html>