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: ${({ theme: { colors } }) => colors.button};
  box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.3);
  border-color: transparent;
  border-radius: 5px;
  display: flex;
  align-items: center;
  margin-right: 15px;

  @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%;
        margin-bottom: 10px;
      }
      @media (orientation: landscape){
        width: auto;
      }
    `
    : ''};
`

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

  &:hover {
    background: #FFFFFF;
    border: 1px solid #FFFFFF;
    color: #000000;
  }

  @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;
      }
    ` : ''};
`

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;
  flex-direction: column;
  padding-left: 3.3rem;
  height: 100%;
  
  @media ${devices.tablet} {
    padding-top: 0;
    padding-left: 0;
  }

  ${isMobileDevice
    ? css`
      margin-top: 10px;
      min-height: 100vh;
      overflow-y: auto;
      @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: 20px 25px 60px 36px;
  position: relative;
  ${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%;
      overflow-y: auto;
      min-height: 100vh;

      @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;
    border-bottom: 1px solid rgba(255,255,255,0.4);
  }

  @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;
  }
`

export const ScButtonGetHighlight = styled(ButtonOutline)`
  padding: 0;
  margin: 30px 0;
  border: 1px solid #FFFFFF;
  border-radius: 5px;
  width: 95%;
  filter: drop-shadow(0px 1px 1px rgba(0, 0, 0, 0.3));

  ${isMobileDevice
    ? css`
      margin: 5px 0;
      height: 100%;
      width: 100%;
    `
    : ''};
`
