import styled, { css } from 'styled-components/macro'
import { isMobileDevice } from 'config/userAgent'
import { ButtonBase } from 'features/StreamPlayer/styled'

export const SettingsButton = styled(ButtonBase)`
  width: 22px;
  height: 20px;
  margin-left: 25px;
  background-image: url(/images/settings.svg);

  ${isMobileDevice
    ? css`
      width: 20px;
      height: 18px;
      margin-left: 10px;
      cursor: pointer;
    `
    : ''};
`

export const QualitiesList = styled.ul`
  position: absolute;
  z-index: 1;
  bottom: calc(100% + 14px);
  right: 24px;
  width: 52px;
  list-style: none;
  border-radius: 2px;
  background-color: rgba(0, 0, 0, 0.5);
  overflow: hidden;

  ${isMobileDevice
    ? css`
      right: 0;
      bottom: 35px;
    `
    : ''};
`

type QualityItemProps = {
  active: boolean,
}

const activeIcon = css`
  :before {
    position: absolute;
    top: 45%;
    transform: rotate(-45deg);
    content: '';
    left: 8px;
    width: 5px;
    height: 3px;
    border-left: 1px solid #fff;
    border-bottom: 1px solid #fff;
  }
`

export const QualityItem = styled.li<QualityItemProps>`
  width: 100%;
  padding: 5px 8px;
  text-align: right;
  font-style: normal;
  font-weight: normal;
  /* stylelint-disable-next-line */
  font-family: Montserrat;
  font-size: 10px;
  line-height: 12px;
  letter-spacing: 0.01em;
  color: #fff;
  cursor: pointer;
  position: relative;

  :hover, :focus {
    background-color: rgba(255, 255, 255, 0.1);
  }

  ${({ active }) => (active ? activeIcon : '')}
`
