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

import { devices } from 'config/devices'
import { isMobileDevice } from 'config/userAgent'

import { Name } from 'features/Name'
import { ProfileLogo } from 'features/ProfileLogo'
import { Tooltip as TooltipBase } from 'features/TournamentSubtitle/styled'

export const CardWrapperOuter = styled.li.attrs({
  tabIndex: 0,
})`
  padding-top: 100%;
  position: relative;
  ${isMobileDevice
    ? css`
      width: 100%;
      padding-top: 0;
      height: 90px;
      margin-bottom: 10px;

      @media screen and (orientation: landscape){
        width: 49%;
        :nth-child(odd){
        margin-right: 10px;
      }
      }
    `
    : ''};
`

export const CardWrapper = styled.div`
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  padding-bottom: 0.75rem;
  border-radius: 2px;
  background: linear-gradient(236.13deg, rgba(53, 96, 225, 0.56) -4.49%, rgba(0, 0, 0, 0) 98.29%), #3F3F3F;
  cursor: pointer;
  ${isMobileDevice
    ? css`
      width: 100%;
      height: 90px;
      padding-bottom: 0;
    `
    : ''};
`

export const HoverFrame = styled.div`
  position: absolute;
  min-width: 100%;
  min-height: 100%;
  border-radius: 2px;
  border: 2px solid transparent;
  transition: border 0.5s ease-out;
  z-index: 2;

  &:hover {
    border: 2px solid #fff
  }
`

export const PreviewWrapper = styled.div`
  position: relative;
  display: flex;
  justify-content: center;
  width: 100%;
  height: 60%;
  ${isMobileDevice
    ? css`
      width: 50%;
      height: 100%;
    `
    : ''};
`

export const MatchTimeInfo = styled.div`
  width: 100%;
  position: absolute;
  top: 0.519rem;
  padding: 0 0.519rem;
  display: flex;
  flex-direction: row;
`

type MatchDateProps = {
  isHomePage?: boolean,
}

export const MatchDate = styled.div<MatchDateProps>`
  width: fit-content;
  height: 0.9rem;
  border-radius: 2px;
  padding: ${({ isHomePage }) => (!isHomePage ? '0 0.27rem' : '')};
  font-weight: bold;
  font-size: 0.472rem;
  line-height: 0.567rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  color: white;
  background-color: #6D6D6D;

  @media ${devices.tablet} {
    padding: ${({ isHomePage }) => (!isHomePage ? '0.27rem 0.36rem' : '')};
  }
  ${isMobileDevice
    ? css`
     height: 15px;
     font-size: 8px;
    `
    : ''};
`

export const LiveSign = styled(MatchDate)`
  background-color: #CC0000;
  margin-left: auto;
`

export const Time = styled.span`
  margin: 0 0.2rem;
`

export const Info = styled.div`
  display: flex;
  flex-direction: column;
  padding: 0 0.472rem 0 0.519rem;
  color: #fff;
  text-overflow: ellipsis;
  white-space: nowrap;

  ${isMobileDevice
    ? css`
      position: absolute;
      top: 0;
      left: 50%;
      width: 50%;
      height: 100%;
      padding: 13px 12px 13px 10px;
    `
    : ''};
`

export const FirstInfo = styled.div`
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 5px 0;
`

export const SecondaryInfo = styled.div`
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 2rem;
`

export const CountryFlag = styled.img`
  width: 0.71rem;
  height: 0.75rem;
  object-fit: contain;
  object-position: bottom;

  ${isMobileDevice
    ? css`
      width: 12px;
      height: 8px;
    `
    : ''};
`

export const CountMatches = styled.span`
  display: block;
  margin-top: 3px;
  text-align: center;
  font-weight: 400;
  font-size: 10px;
  line-height: 16px;
  color: #FFFFFF;
  text-transform: lowercase;
`

export const TournamentName = styled(Name)`
  max-height: 100%;
  font-weight: 600;
  font-size: 13px;
  text-align: center;
  color: #ffffff;
  overflow: hidden;
  white-space: initial;

  @media ${devices.laptop} {
    font-size: 10px;
  }
`

export const TournamentLogo = styled(ProfileLogo)`
  padding: 10px;
  max-height: 100%;
`

export const Tooltip = styled(TooltipBase)`
  transform: translateX(-50%);
  left: 50%;
  bottom: 100%;
  top: auto;
`

type FavoriteSignProps = {
  color?: string,
}

export const FavoriteSign = styled.span<FavoriteSignProps>`
  margin-left: 0.567rem;
  color: ${({ color }) => color};
  display: flex;
  justify-content: center;
  align-items: center;
  width: 10px;
  height: 10px;
`
