import { Link } from 'react-router-dom'

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

import { isMobileDevice } from 'config/userAgent'

import { outlineButtonStyles } from 'features/Common/Button'
import { T9n } from 'features/T9n'

import { AuthProviders } from '../../config/authProviders'

type TAuthButtonImage = {
  authProvider: AuthProviders,
}

export const RegisterButton = styled(Link)`
  ${outlineButtonStyles}
  width: 100%;
  height: 50px;
  border-radius: 5px;
  margin-top: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  ${isMobileDevice
    ? css`
        height: 44px;
        margin-top: 12px;
        font-weight: 500;
        font-size: 17px;
        border-radius: 10px;
        @media screen and (orientation: landscape) {
          margin: 12px auto 0;
        }
      `
    : ''};
`

export const ContinueWith = styled(T9n)`
  margin: 20px auto;
  font-size: 16px;
  color: ${({ theme }) => theme.colors.white};
`

export const AuthButtonsContainer = styled.div`
  width: 100%;
  display: flex;
  gap: 10px;

  ${isMobileDevice
    ? css`
       flex-direction: column;
      `
    : ''};
`

export const AuthButton = styled.button`
  ${outlineButtonStyles}
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 50px;
  border-radius: 5px;

  ${isMobileDevice
    ? css`
       height: 44px;
       border-radius: 10px;
      `
    : ''};
`

export const AuthButtonText = styled.span`
  opacity: 0.8;
  font-size: 20px;
`

export const AuthButtonImage = styled.div<TAuthButtonImage>`
  background-repeat: no-repeat;
  background-position: center;
  margin-right: 20px;
  background-position: right;

  ${({ authProvider }) => {
    switch (authProvider) {
      case AuthProviders.Google:
        return css`
            width: 32px;
            height: 32px;
            background-image: url(/images/oauth/google.svg);          `

      case AuthProviders.Facebook:
        return css`
            width: 32px;
            height: 32px;
            background-image: url(/images/oauth/facebook.svg);

            ${isMobileDevice ? css`width: 57px;` : ''};
          `

      case AuthProviders.AppleID:
        return css`
            background-image: url(/images/oauth/appleID.svg);
          `

      default: return ''
    }
  }}
`
