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

import { popupScrollbarStyles } from 'features/PopupComponents'
import { Price as BasePrice } from 'features/Price'
import {
  PriceAmount,
  PriceDetails,
  Period,
} from 'features/Price/styled'

export const List = styled.ul`
  width: 100%;
  height: 460px;
  overflow-y: auto;
  margin-top: 25px;
  padding: 0 40px;

  ${popupScrollbarStyles}

  @media (max-width: 1370px) {
    max-height: 415px;
    height: auto;
  }

  @media (max-height: 768px) {
    max-height: 280px;
  }

  @media (max-height: 500px) {
    max-height: 140px;
  }

  ${isMobileDevice
    ? css`
      padding: 0;
      margin-top: 19px;
      @media screen and (orientation: landscape){
        margin-top: 10px;
      }
    `
    : ''};
`

type ItemProps = {
  active?: boolean,
}

export const Item = styled.li.attrs(() => ({
  tabIndex: 0,
}))<ItemProps>`
  width: 100%;
  min-height: 140px;
  padding: 20px 30px 20px 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 100%), #3F3F3F;
  box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.3);
  border-radius: 2px;

  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: background-color 0.3s;

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

  ${({ active, theme: { colors } }) => (
    active ? `background-color: ${colors.button}` : ''
  )};

  @media (max-width: 1370px) {
    min-height: 125px;
  }

  @media (max-width: 750px) {
    height: 100%;
  }
  
  ${isMobileDevice
    ? css`
      padding: 5px 10px;

      @media (max-width: 750px) {
        min-height: 52.29px;
        height: auto;
      }

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

        @media screen and (orientation: landscape) {
          margin-bottom: 5.24px;
        }
      }
    ` : ''};

  @media (max-width: 850px) and (orientation: landscape){
    min-height: 52.29px;
    height: auto;
  }
`

export const InfoWrapper = styled.div`
  width: 75%;
  display: flex;
  flex-direction: column;
  align-self: flex-start;
  ${isMobileDevice
    ? css`
      align-self: center;
      @media (max-width: 850px) and (orientation: landscape){
        height: 100%;
      }
    `
    : ''};
`

export const Name = styled.span`
  font-weight: 500;
  font-size: 20px;
  line-height: 23px;
  letter-spacing: 0.03em;

  @media (max-width: 1370px) {
    line-height: 20px;
  }
  ${isMobileDevice
    ? css`
      @media (max-width: 750px){
        font-size: 12px;
        line-height: 10.04px;
      }
      @media screen and (orientation: landscape){
        font-size: 14px;
      }
    `
    : ''};
`

export const Pass = styled(Name)`
  font-weight: 600;
  text-transform: uppercase;
  ${isMobileDevice
    ? css`
      line-height: 12px;
      @media screen and (orientation: landscape){
        line-height: 14px;
      }
    `
    : ''};
`

export const Description = styled.span`
  width: 68%;
  margin-top: 13px;
  font-weight: 500;
  font-size: 15px;
  line-height: 20px;
  letter-spacing: 0.03em;

  @media (max-width: 1370px) {
    line-height: 18px;
  }
  ${isMobileDevice
    ? css`
       @media (max-width: 750px){
         font-size: 8px;
         line-height: 8px;
         margin-top: 5px;
         width: 100%;
       }
       @media (max-width: 850px) and (orientation: landscape){
        margin-top: 0;
        line-height: 8px;
        font-size: 10px;
      }
    `
    : ''};
`

export const Price = styled(BasePrice)`
  ${PriceAmount} {
    font-size: 24px;
    line-height: 24px;
    font-weight: normal;
    ${isMobileDevice
    ? css`
      font-size: 14px;
    `
    : ''};
  }

  ${PriceDetails} {
    font-weight: 500;
    font-size: 12px;
    line-height: 18px;
    ${isMobileDevice
    ? css`
      font-size: 8px;
    `
    : ''};
  }

  ${Period} {
    text-transform: capitalize;
  }
`

export const ScAutoRenewal = styled(PriceDetails)`
  line-height: 21px;
  font-size: 12px;
  text-transform: none;
  margin: 0;
  color: ${({ theme: { colors } }) => colors.white70};

  ${isMobileDevice
    ? css`
      line-height: normal;
      font-size: 10px;
      text-align: center;
    `
    : ''};
`

export const ScPriceContainer = styled.div`
  display: flex;
  flex-direction: column;
`
