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

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

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

import { ButtonSolid, ButtonOutline } from 'features/Common/Button'

export const SolidButton = styled(ButtonSolid)`
  width: auto;
  height: 2.4rem;
  padding: 0 0.94rem;
  color: white;
  font-weight: bold;
  background-color: #294fc4;
  box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.3);
  border-color: transparent;
  border-radius: 5px;
  display: flex;
  align-items: center;

  @media ${devices.tablet} {
    height: 5rem;
    font-size: 2.0rem;
    width: 100%;
    justify-content: center;
  }

  ${isMobileDevice
    ? css`
      @media (max-width: 650px){
        height: 35px;
        display: flex;
        justify-content: center;
        width: 100%;
      }
      @media (orientation: landscape){
        width: auto;
      }
    `
    : ''};
`

export const OutlineButton = styled(ButtonOutline)`
  width: auto;
  height: 50px;
  padding: 0 20px;
  color: white;
  font-weight: 600;
  box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.3);
  border-color: #fff;
  border-radius: 5px;
  font-size: 20px;
  display: flex;
  align-items: center;

  @media ${devices.mobile} {
    width: 100%;
  }
  ${isMobileDevice
    ? css`
      height: 39px;
      font-size: 14px;
    `
    : ''};
`

type IconProps = {
  src: string,
}

export const Icon = styled.span<IconProps>`
  display: inline-block;
  width: 25px;
  height: 25px;
  margin-right: 14px;
  background-image: url(/images/${({ src }) => src}.svg);
  background-size: contain;
  background-repeat: no-repeat;
`

export const ContentWrapper = styled.div`
  width: 100%;
  display: flex;
  padding-left: 3.3rem;

  @media ${devices.tablet} {
    padding-top: 0;
    padding-left: 0;
  }

  ${isMobileDevice
    ? css`
      margin-top: 10px;
      @media (orientation: landscape){
        margin-top: 0;
        padding-left: 28px;
        height: 100%;
      }
    `
    : ''};
`

export const UserAccountWrapper = styled.div`
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 32px 30px 60px 36px;
  ${isMobileDevice
    ? css`
     padding: 15px 15px 0;
     align-items: center;
    `
    : ''};
`

export const Body = styled.div`
  display: flex;
  height: 100%;

  @media ${devices.tablet} {
    flex-direction: column;
  }

  ${isMobileDevice
    ? css`
      width: 100%;
      @media (orientation: landscape){
        flex-direction: row;
        height: auto;
      }
    `
    : ''};
`

export const Aside = styled.aside`
  position: relative;
  height: 100%;

  @media ${devices.tablet} {
    height: auto;
  }
  ${isMobileDevice
    ? css`
      height: auto;
      @media (orientation: landscape){
        min-width: 30%;
      }
    `
    : ''};
`

export const Navigations = styled.nav`
  width: 20rem;
  height: 29.3rem;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.4);

  @media ${devices.tablet} {
    height: auto;
    width: 100%;
    border: none;
    margin-bottom: 0;
  }

  @media ${devices.mobile} {
    width: 100%;
  }

  ${isMobileDevice
    ? css`
      @media (orientation: landscape){
        border-right: 1px solid rgba(255, 255, 255, 0.4);
        height: 100%;
      }
    `
    : ''};
`

type StyledLinkProps = {
  disabled?: boolean,
}

export const StyledLink = styled(NavLink).attrs(
  () => ({
    activeStyle: { color: 'rgba(255, 255, 255)' },
  }),
)<StyledLinkProps>`
  font-weight: bold;
  font-size: 1.2rem;
  line-height: 3.2rem;
  color: rgba(255, 255, 255, 0.4);

  ${({ disabled }) => (disabled
    ? css`
      color: rgba(255, 255, 255, 0.1);
      pointer-events: none;
    `
    : css`
      color: rgba(255, 255, 255, 0.4);
    `)}

  @media ${devices.tablet} {
    font-size: 2.8rem;
    line-height: 5.3rem;
  }

  ${isMobileDevice
    ? css`
      @media (orientation: landscape){
        font-size: 16px;
        line-height: 35px;
      }
      @media (max-width: 750px){
        font-size: 16px;
        line-height: 35px;
      }
    `
    : ''};
`

type InlineButtonProps = {
  color?: string,
}

export const InlineButton = styled.button<InlineButtonProps>`
  display: flex;
  justify-content: center;
  align-items: center;
  position: absolute;
  right: 0;
  border: none;
  height: 100%;
  margin: 0;
  padding: 12px;
  color: white;
  background-color: ${({ color = '#eb5757' }) => color};
  font-weight: 600;
  font-size: 13px;
  line-height: 14px;
  cursor: pointer;
  transition: transform 0.3s ease-in-out;
  transform: translateX(calc(100% + 1px));
  :disabled {
    opacity: 0.5;
  }
`
