import styled, { css } from 'styled-components/macro'

import { isMobileDevice } from 'config/userAgent'

import { ProfileLogo } from 'features/ProfileLogo'

import { Tabs as TabsBase, Tab as TabBase } from '../PlayersPlaylists/styled'
import {
  BlockTitle as BlockTitleBase,
  Button as ButtonBase,
} from '../../styled'

export const Wrapper = styled.div`
  display: flex;
  flex-direction: column;
  align-items: center;
`

export const HalfList = styled.ul`
  width: 100%;
`

export const HalfEvents = styled.li``

export const List = styled.ul``

export const Event = styled.li`
  width: 100%;
  height: 48px;
  margin-bottom: 12px;

  :first-child {
    margin-top: 12px;
  }
`

export const TextEvent = styled.li`
  width: 100%;

  :not(:last-child) {
    margin-bottom: 12px;
  }

  :last-child {
    margin-bottom: 0px;
  }
`

type AvatarProps = {
  isHomeTeam: boolean,
  isPlayer: boolean,
}

export const Avatar = styled(ProfileLogo)<AvatarProps>`
  position: absolute;
  width: 35px;
  height: 43px;
  object-fit: cover;

  ${({ isHomeTeam }) => (
    isHomeTeam
      ? css`left: 5px;`
      : css`right: 5px;`
  )}

  ${({ isPlayer }) => (
    isPlayer
      ? css`bottom: 0;`
      : css`
        top: 50%;
        transform: translateY(-50%);
      `
  )}

  ${({ isHomeTeam }) => (
    isMobileDevice
      ? css`
          @media (max-width: 750px) and (orientation: portrait){
            ${isHomeTeam ? 'left: 20px;' : 'right: 20px;'}
          }
        `
      : ''
  )}
`

export const EventInfo = styled.div`
  display: flex;
  width: 100%;
`

export const EventDesc = styled.div`
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
`

export const Title = styled.span`
  font-weight: 600;
  font-size: 14px;
  line-height: 15px;
  color: #ffffff;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
`

export const SubTitle = styled(Title)`
  font-size: 10px;
  line-height: 16px;
  font-weight: normal;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 2px;
`

export const EventTime = styled(Title)`
  font-size: 14px;
  font-weight: normal;
  margin-right: 10px;
  width: auto;
  overflow: initial;
  min-width: 29px;
`

export const Tabs = styled(TabsBase)`
  margin-top: 0px;
  margin-bottom: 18px;
`

export const Tab = styled(TabBase)`
  text-transform: none;

  :first-child {
    margin-right: 15px;
  }
`

export const BlockTitle = styled(BlockTitleBase)`
  text-align: center;
  width: 100%;
  display: inline-block;
`

type ButtonProps = {
  isHomeTeam: boolean,
}

export const Button = styled(ButtonBase)<ButtonProps>`
  &:hover ${EventDesc} {
    overflow: visible;
  }

  ${({ isHomeTeam }) => (
    isHomeTeam
      ? css`padding-left: 60px;`
      : css`padding: 0 40px 0 60px;`
  )}

  ${({ isHomeTeam }) => (
    isMobileDevice
      ? css`
        @media (max-width: 750px) and (orientation: portrait){
          ${isHomeTeam ? 'padding-left: 90px;' : 'padding: 0 60px 0 90px;'}
        }
      `
      : ''
  )}
`
