@use './media-player-variables';

$max-z-index: 5900;

.q-media {
  position: relative;
  min-width: 230px !important;
  min-height: 40px !important;
  overflow: hidden !important;
  display: flex;
  flex-direction: column;
  background: var(--mediaplayer-background);
  color: var(--mediaplayer-color);

  &--player {
    width: 100%;
    height: 100%;
    vertical-align: bottom;
    align-self: flex-end;

    &--bottom-controls--standard {
      height: calc(100vh - 80px);
    }

    &--bottom-controls--dense {
      height: calc(100vh - 40px);
    }
  }

  &__audio--standard {
    width: 100%;
    height: 80px !important;
    vertical-align: bottom;
    align-self: flex-end;
  }

  &__audio--dense {
    width: 100%;
    height: 40px !important;
    vertical-align: bottom;
    align-self: flex-end;
  }

  &__error-window {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 40px;
    font-size: 0.8rem;
    text-align: center;
    background: var(--mediaplayer-error-background);
    color: var(--mediaplayer-error-color);
    transition: height 250ms ease-in;

    &--button {
      position: absolute;
      right: 0;
      top: 0;
    }
  }

  &__overlay-window {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    height: auto;
    background: transparent;
    z-index: 1;
  }

  &__loading {
    &--video {
      position: absolute;
      left: 50%;
      margin-left: -1.5rem;
      top: 50%;
      margin-bottom: -1.5rem;
      width: 3rem;
      height: 3rem;
      color: white;
      background: transparent;
    }

    &--audio {
      position: absolute;
      left: 50%;
      margin-left: -0.5rem;
      top: 50%;
      margin-bottom: -0.5rem;
      width: 1.5rem;
      height: 1.5rem;
      color: white;
      background: transparent;
    }
  }

  &--big-button {
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: center;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 3rem;
    height: 3rem;
    cursor: pointer;
    border-radius: 1.5rem;
    opacity: 1;
    font-size: 3rem;
    z-index: 1000; // Do not cover drawers from the sides.
    background: var(--big-play-button-background);
    color: var(--big-play-button-color);
    border: var(--big-play-button-border);
    transition: all 200ms ease-in;
    transition-property: color, background, border;

    &-bottom-controls {
      // margin-bottom: 0 !important; // doesn't show at the screen center in Safari
      // needs to be aligned for fullscreen and controls at the bottom
    }

    &:hover {
      color: var(--big-play-button-hover-color) !important;
      background: var(--big-play-button-hover-background) !important;
      border: var(--big-play-button-border-hover) !important;
    }

    &-icon {
      position: relative;
      font-size: 2rem;
    }
  }

  &__controls {
    position: absolute;
    left: 0;
    bottom: 0;
    right: 0;
    overflow: hidden;
    z-index: 2;

    &--overlay {
      background: rgba(0, 0, 0, 0.4);
    }

    &--bottom-controls {
      position: relative !important;
    }

    &--row {
      height: 40px;
    }

    &--standard {
      height: 80px !important;
      transition: height 250ms ease-in;
      z-index: 2;
    }

    &--dense {
      height: 40px !important;
      transition: height 250ms ease-in;
      z-index: 2;
    }

    &--hidden {
      height: 0 !important;
      transition: height 250ms ease-out;
    }

    &--button {
      max-width: 40px !important;
      min-width: 40px !important;
      max-height: 40px !important;
      min-height: 40px !important;
    }

    &--volume-box {
      max-height: 40px !important;
      min-height: 40px !important;
    }

    &--video-time-text {
      min-width: 50px;
      padding: 0 0.25rem;
      font-size: 0.8rem;
      text-align: center;
    }

    &--video-slider {
      padding: 0 4px;
    }
  }

  &__fullscreen {
    z-index: $max-z-index;

    &--window {
      position: fixed !important;
      top: 0 !important;
      left: 0 !important;
      height: 100vh !important;
      width: 100vw !important;
      max-height: 100vh !important;
      max-width: 100vw !important;
      overflow: hidden;
    }
  }
}

// ::-webkit-media-controls {
//   display: none !important;
// }

// video::-webkit-media-controls {
//   display: none !important;
// }

// video::-webkit-media-controls-enclosure {
//   display: none !important;
// }

.q-dark div,
.body--dark div,
.q-media--dark {
  &.q-media {
    background: var(--mediaplayer-background-dark);
    color: var(--mediaplayer-color-dark);

    &--big-button {
      background: var(--big-play-button-background-dark);
      color: var(--big-play-button-color-dark);
      border: var(--big-play-button-border-dark);

      &:hover {
        color: var(--big-play-button-hover-color-dark) !important;
        background: var(--big-play-button-hover-background-dark) !important;
        border: var(--big-play-button-border-hover-dark) !important;
      }
    }

    &__error-window {
      background: var(--mediaplayer-error-background-dark);
      color: var(--mediaplayer-error-color-dark);
    }
  }
}
