.igd-player {
  --plyr-range-fill-background: var(--color-primary);
  --plyr-video-control-background-hover: var(--color-primary);
  --plyr-audio-control-background-hover: var(--color-primary);

  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  height: 100%;
  background-color: #fff;

  &.playlist-left,
  &.playlist-right {
    padding: 10px;

    .media-wrap {
      flex-direction: column;
      align-items: flex-start;
      border: none;

      .igd-player-media-wrap {
        //margin-top: 10px;
        margin-left: 0;
      }
    }

    .igd-player-playlist {
      .playlist-item-wrap {
        padding: 5px 0;
      }
    }

    &.type-audio {
      .media-wrap {
        border: 1px solid #eee;
      }
    }

  }

  &.playlist-left {
    flex-wrap: wrap;
    flex-direction: row;
    column-gap: 10px;

    .igd-player-playlist {
      width: calc(40% - 10px);
      order: 1;
      margin: 0;
      padding-right: 10px;
      border-right: 1px solid #eee;
    }

    .playlist-search {
      margin: 0;
    }

    .media-wrap {
      flex: 1;
      order: 2;
      position: sticky;
      top: 10px;
      z-index: 9;
    }

    &:has(.igd-player-playlist) {
      .media-wrap {
        max-width: 60%;
      }
    }

  }

  &.playlist-right {
    flex-wrap: wrap;
    flex-direction: row;
    column-gap: 10px;
    padding-right: 5px;

    .igd-player-playlist {
      width: calc(40% - 10px);
      order: 2;
      margin: 0;
      padding-left: 10px;
      border-left: 1px solid #eee;
      padding-right: 5px;
    }

    .playlist-search {
      margin: 0;
    }

    .media-wrap {
      flex: 1;
      order: 1;
      position: sticky;
      top: 10px;
      z-index: 9;
    }

    &:has(.igd-player-playlist) {
      .media-wrap {
        max-width: 60%;
      }
    }

  }

  &.playlist-bottom {
    .playlist-search {
      width: calc(100% - 20px);
      margin: 10px auto;
    }
  }

  &.playlist-grid {
    .igd-player-playlist {
      display: flex;
      flex-wrap: wrap;
      padding: 20px;

      .playlist-search {
        width: 100%;
        margin: 0 0 10px 0;
      }

      .playlist-item-wrap {
        width: calc(20% - 16px);
        margin: 8px;
        padding: 0;
        border-radius: 5px;
        overflow: hidden;
        transition: all .3s linear;
        border: 1px solid #ddd;

        &:last-child {
          margin-right: auto;
        }

        &:hover {
          box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;
        }

        .playlist-item {
          flex-direction: column;
          position: relative;
          padding: 0;
          font-size: 1rem;

          img {
            width: 100%;
            aspect-ratio: 16/9;
            margin: 0;
            height: unset;
          }

          .item-name {
            margin-right: unset;
            max-width: 100%;
            font-size: 14px;
            padding: 0 7px;
            width: 100%;
            flex: 1;
          }

          .dashicons-controls-play,
          .dashicons-controls-pause {
            position: absolute;
            top: 15%;
            color: #eee;
            width: 60px;
            font-size: 50px;
            border: 2px solid;
            border-radius: 50%;
            height: 60px;
            padding: 5px;
            background: rgba(0, 0, 0, 0.5);

            &.dashicons-controls-play:before {
              position: relative;
              left: 3px;
              top: -2px;
            }


            &.dashicons-controls-pause:before {
              position: relative;
              left: -2px;
              top: -2px;
            }


          }

          .item-meta {
            padding: 3px 7px 4px 7px;
            justify-content: space-between;
            width: 100%;

            .item-size {
              margin: 0;
            }
          }

          &:not(.folder-item) {
            .item-index {
              position: absolute;
              left: 0;
              top: 0;
              background: rgba(#333, .7);
              color: rgb(255, 255, 255);
              padding: 7px;
              font-size: 14px;
              line-height: 1;
              border-bottom-right-radius: 5px;
            }

            .item-name {
              border-top: 1px solid #ddd;
            }
          }

        }

        &.folder-item-wrap {
          height: 50px;
          display: flex;
          align-items: center;

          .folder-item {
            flex-direction: row;
            padding: 0 5px 0 10px;
            overflow: hidden;

            img {
              width: 30px;
              height: 20px;
            }

            .item-meta {
              display: none;
            }
          }
        }

        &.folder-item-break {
          width: 100%;
          height: 0;
          border: navajowhite;
          padding: 0;
          margin: 0;
        }

      }
    }

    @media screen and (max-width: 767px) {
      .igd-player-playlist {
        .playlist-item-wrap {
          .playlist-item {
            .dashicons-controls-play,
            .dashicons-controls-pause {
              width: 40px;
              height: 40px;
              font-size: 30px;

              &.dashicons-controls-play:before {
                left: 0;
              }
            }
          }
        }
      }

    }

  }

  .media-wrap {
    width: 100%;
    display: flex;
    align-items: center;
    flex-wrap: wrap;

    .current-item {
      display: flex;
      align-items: center;
      overflow: hidden;
      justify-content: flex-start;
      text-align: center;
      width: 100%;
      flex: 1;

      img {
        margin-right: 10px;
        width: 40px;
      }

      .item-caption {
        display: flex;
        flex-direction: column;
        overflow: hidden;

        .item-title {
          font-weight: 500;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
        }

        .item-description {
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
        }


      }

    }

    .igd-player-media-wrap {
      position: relative;
    }

    iframe {
      border: none;
      aspect-ratio: 16/9;
    }

  }

  &.type-video {

    .igd-player-media-wrap {
      width: 100%;
      height: 0;
      overflow: hidden;
      padding-bottom: 56.25%; /* 16:9 aspect ratio; for a 4:3 aspect ratio use 75% */

      .igd-player-media-video,
      .plyr,
      video {
        position: absolute;
        top: 0;
        left: 0;
        width: 100% !important;
        height: 100% !important;
      }

      &:has(.plyr--loading) {
        .plyr__control--overlaid {
          background: url("../images/preloader/default.svg") no-repeat center center;
          opacity: 1;
          visibility: visible;

          svg {
            opacity: 0;
          }
        }
      }

    }

  }

  &.type-audio {
    .media-wrap {
      padding: 15px;
      border-bottom: 1px solid #ddd;
      background: #f5f5f5;
    }

    .igd-player-media-wrap {
      margin-left: auto;

      .plyr__controls {
        padding: 0;
        background: transparent;
      }

    }

  }

  .igd-player-playlist {
    width: 100%;
    height: 100%;
    overflow-y: auto;

    .playlist-item {
      position: relative;
      cursor: pointer;
      display: flex;
      align-items: center;
      color: #333;
      padding: 3px;

      &.active {
        color: var(--color-primary);
        font-weight: 500;

        .dashicons-controls-play,
        .dashicons-controls-pause, {
          border-color: var(--color-primary);
          color: var(--color-primary);
        }
      }


      &:not(:has(img)) {
        padding: 5px;
      }

      &-wrap {
        border-bottom: 1px solid #eee;
        padding: 5px 10px;

        .sub-item {
          margin-left: 30px;
        }

        &:hover {
          background-color: #f5f5f5;
        }

      }

      .item-index {
        margin-right: 7px;
        white-space: nowrap;
      }

      .igd-spinner {
        margin-left: 0;
        width: 18px;
        height: 18px;
        margin-right: 5px;
      }

      img {
        width: 30px;
        height: 30px;
        object-fit: cover;
        border-radius: 3px;
        margin-right: 5px;
      }

      .item-name {
        margin-right: auto;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      .item-size {
        margin: 0 10px;
        white-space: nowrap;
      }

      .item-duration {
        display: inline-flex;
        align-items: center;
        margin-right: 10px;

        i {
          color: #555;
          font-size: 18px;
          margin-right: 3px;
        }
      }

      .item-meta {
        display: flex;
        align-items: center;
        color: #777;
        font-size: 12px;
      }

      .dashicons {
        font-size: 25px;
        color: #555c66;
        height: auto;
        width: auto;

        &.dashicons-arrow-right,
        &.dashicons-arrow-down, {
          margin-left: -5px;
          margin-right: 5px;
        }

        &:hover {
          color: #444;
          border-color: var(--color-primary);
        }

      }

    }

    .search-result-info {
      display: flex;
      align-items: center;
      margin-bottom: 7px;
      margin-top: 7px;
      width: 100%;

      .clear-button {
        margin-left: 7px;
        padding: 7px 10px;
      }
    }

    //scroll style
    &::-webkit-scrollbar {
      width: 5px;
      height: 5px;
    }

    &::-webkit-scrollbar-thumb {
      background: #ddd;
      border-radius: 10px;
    }

    &::-webkit-scrollbar-track {
      background: #eee;
      border-radius: 10px;
    }

    &.igd-item-col-1 {
      .playlist-item-wrap {
        width: 100%;
      }

      &:not(.list-view) {
        .file-item {
          margin: 4px;
        }
      }

    }

    &.igd-item-col-2 {
      .playlist-item-wrap {
        width: calc(50% - 16px);
      }
    }

    &.igd-item-col-3 {
      .playlist-item-wrap {
        width: calc(33.33% - 16px);

        .file-item-footer {
          .file-item-size {
            display: none;
          }
        }

      }
    }

    &.igd-item-col-4 {
      .playlist-item-wrap {
        width: calc(25% - 16px);
      }
    }

    &.igd-item-col-5 {
      .playlist-item-wrap {
        width: calc(20% - 16px);
      }
    }

    &.igd-item-col-6 {
      .playlist-item-wrap {
        width: calc(16.66% - 16px);
      }
    }

    &.igd-item-col-7 {
      .playlist-item-wrap {
        width: calc(14.28% - 16px);
      }
    }

    &.igd-item-col-8 {
      .playlist-item-wrap {
        width: calc(12.5% - 16px);
      }
    }

  }

  .igd-player-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin: 15px 0;

    button {
      margin: 0 10px;
      padding: 0;
      border: none;
      background: none;
      cursor: pointer;
      color: #555;
      transition: color .3s linear;

      i {
        font-size: 28px;
        height: 28px;
        width: 28px;
      }

      &:hover {
        color: var(--color-primary);
      }
    }

    &:empty {
      display: none;
    }
  }

  &:not(.playlist-grid) {
    .playlist-item {

      &-wrap {
        &:last-child {
          border-bottom: 0;
        }
      }

      &:last-child {
        border-bottom: 0;
      }
    }
  }

  .playlist-no-items {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    font-size: 20px;
    color: #777;
    padding: 30px;

    i {
      margin-right: 10px;
    }
  }

  // Search
  .playlist-search {
    position: relative;
    display: flex;
    align-items: center;
    transition: width .3s linear;
    line-height: 1;
    overflow: hidden;
    border: 1px solid #ddd;
    border-radius: 5px;
    width: 100%;
    padding: 0 15px;
    margin: 10px 0;

    .search-dismiss {
      cursor: pointer;
    }

    .igd-spinner {
    }

    input {
      height: 40px;
      padding: 0 15px;
      font-size: 14px;
      width: 100%;
      border: none !important;
      box-shadow: none !important;
      border-radius: 0 !important;
      background: transparent;

      &:focus {
        outline: none;
      }

    }

    .search-submit {
      position: relative;
      z-index: 2;

      .dashicons {
        font-family: 'dashicons';
      }

    }

    &:has(input:focus) {
      box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;
    }

    &.active {
      .input-wrap {
        right: -10px;
      }

      .search-submit {
        svg {
          fill: #333;
        }
      }

    }

  }

  video {
    display: inline-block;
    max-width: 100%;
    min-height: 100%;
  }

  audio {
    display: none;
    max-width: 100%;
    width: 100%;
  }

  .plyr__controls {
    .plyr__controls__item {
      &.plyr__time {
        white-space: nowrap;
      }
    }
  }

  .plyr__control {
    &:focus {
      background: transparent;
      color: currentColor;
    }
  }

  .plyr__volume input[type=range] {
    max-width: 60px;
  }

  &.size-xs,
  &.size-sm {
    &.type-audio {
      .media-wrap {
        flex-direction: column;

        .current-item {
          justify-content: center;

          img {
            width: 30px;
          }
        }

        .igd-player-media-wrap {
          margin-top: 15px;
          margin-left: 0;
        }

      }
    }

    .plyr__volume input[type=range] {
      max-width: 40px;
      min-width: 40px;
    }

    &.playlist-left,
    &.playlist-right {
      flex-direction: column;

      .media-wrap,
      .igd-player-playlist, {
        width: 100%;
        max-width: 100% !important;
      }

      .media-wrap {
        position: unset;
      }

      .igd-player-playlist {
        order: 999;
      }

    }
  }

  &.size-xs {
    &.type-audio {
      .plyr__controls {
        .plyr__controls__item {
          padding: 3px;

          &.plyr__time {
            &.plyr__time--duration {
              display: none;
            }
          }
        }
      }
    }
  }

}