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

import { isMobileDevice } from 'config/userAgent'

import { ModalWindow } from 'features/Modal/styled'
import { Modal as BaseModal } from 'features/Modal'
import { Header as BaseHeader } from 'features/PopupComponents'

import { ButtonSolid } from 'features/Common'
import { Checkbox as BaseCheckbox } from 'features/Common/Checkbox'
import { Label } from 'features/Common/Checkbox/styled'
import { CheckboxSvg } from 'features/Common/Checkbox/Icon'
import { ArrowLoader } from 'features/ArrowLoader'

export const Modal = styled(BaseModal)`
  background-color: rgba(0, 0, 0, 0.7);
  padding: 0 60px;

  ${ModalWindow} {
    width: 1066px;
    height: 781px;
    padding: 0;
    background-color: #333333;
    border-radius: 5px;

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


    ${isMobileDevice
    ? css`
      @media (max-width: 650px){
        width: 95vw;
        height: auto;
        top: -7vh;
      }

      @media (orientation: landscape){
        min-width: 95vw;
      }
    `
    : ''};
  }
`

type WrapperProps = {
  isFetching?: boolean,
}

export const Wrapper = styled.div<WrapperProps>`
  ${({ isFetching }) => (
    isFetching
      ? css`pointer-events: none;`
      : ''
  )}
`

export const Header = styled(BaseHeader)`
  height: auto;
  padding-top: 40px;
  justify-content: center;
  ${isMobileDevice
    ? css`
      @media (max-width: 650px){
        padding-top: 33px;
      }
    `
    : ''};
`

export const HeaderTitle = styled.span`
  font-weight: 600;
  font-size: 1.13rem;
  line-height: 1.13rem;
  color: #FFFFFF;
  ${isMobileDevice
    ? css`
      @media (max-width: 650px){
        font-size: 14px;
        line-height: 20px;
      }

      @media (orientation: landscape) {
        font-size: 20px;
      }
    `
    : ''};
`

export const BlockTitle = styled.span`
  font-weight: 600;
  font-size: 0.56rem;
  line-height: 0.85rem;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
  ${isMobileDevice
    ? css`
      @media (max-width: 650px){
        font-size: 8px;
        line-height: 15px;
      }

      @media (orientation: landscape){
        font-size: 10px;
        line-height: 16px;
      }

    `
    : ''};
`

export const Body = styled.div`
  padding: 25px 40px 0 42px;
  display: flex;
  ${isMobileDevice
    ? css`
      @media (max-width: 650px){
        padding: 13px 25px 0;
        flex-direction: column;
      }

      @media (orientation: landscape){
        padding: 22px 23px 0 29px;
      }
    `
    : ''};
`

export const Footer = styled.div`
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 1.89rem;
  ${isMobileDevice
    ? css`
      @media (max-width: 650px){
        padding: 20px 25px 20px;
      }
    `
    : ''};
`

export const Checkbox = styled(BaseCheckbox)`
  ${Label} {
    font-weight: 600;
    font-size: 0.66rem;
    line-height: 0.94rem;
    letter-spacing: 0.1px;
    ${isMobileDevice
    ? css`
      @media (max-width: 650px),(orientation: landscape){
        font-size: 12px;
        line-height: 18px;
      }
    `
    : ''};
  }
  ${CheckboxSvg} {
    align-self: auto;
    margin-right: 18px;
    max-width: 20px;
    max-height: 20px;
  }
`

export const ApplyButton = styled(ButtonSolid)`
  width: 270px;
  border-radius: 5px;
  ${isMobileDevice
    ? css`
      @media (max-width: 650px){
        width: 100%;
        min-height: 42px;
      }
      
      @media (orientation: landscape){
        width: 290px;
        min-height: 42px;
      }
    `
    : ''};
`

export const Loader = styled(ArrowLoader)`
  position: absolute;
  z-index: 10;
  background-color: #3f3f3f60;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
`
