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

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

export const BaseButton = styled.button`
  border: none;
  outline: none;
  padding: 0;
  background-color: transparent;
  cursor: pointer;
`

export const Wrapper = styled.div`
  position: relative;
  width: 32.8rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: #656565;

  @media (max-width: 750px) {
    width: 100%;
  }

  ${isMobileDevice
    ? css`
      padding-top: 4px;
      min-height: 84px;
      justify-content: space-between;

      @media (max-width: 450px){
        justify-content: flex-end;
      }
    `
    : ''};
`

export const MonthWrapper = styled.div`
  position: relative;
  text-align: center;
  align-self: center;
  width: 100%;
  
  @media (max-width: 750px) {
    width: 32.8rem;
  }

  @media (max-width: 450px) {
    width: 100%;
  }
`

export const MonthYear = styled.span`
  display: inline-block;
  font-weight: 600;
  font-size: 1.04rem;
  line-height: 1.8rem;
  text-transform: uppercase;
  ${isMobileDevice
    ? css`
      font-size: 13px;
      line-height: 24px;
    `
    : ''};
`

type DateButtonProps = {
  isActive: boolean,
}

export const DateButton = styled(BaseButton)<DateButtonProps>`
  position: absolute;
  top: 0.2rem;
  right: 3.6rem;
  width: 1.3rem;
  height: 1.26rem;
  color: #fff;
  opacity: 0.5;

  ${isMobileDevice
    ? css`
      top: 4px;
    `
    : ''};

  :hover {
    opacity: 0.7;
  }

  ${({ isActive }) => (
    isActive
      ? 'opacity: 1;'
      : ''
  )}

  ${isMobileDevice
    ? css`
      right: 14px;
      width: 16px;
      height: 16px;
      @media screen and (orientation: landscape){
        right: 20px;
      }
    `
    : ''};
`

export const WeekDaysWrapper = styled.div`
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 0.567rem;
  ${isMobileDevice
    ? css`
     padding: 0 20px;
    `
    : ''};
`

export const Week = styled.div`
  margin: 0 0.95rem;
  display: flex;

  @media (max-width: 600px) {
    width: 100%;
    justify-content: space-between;
  }
`

type WeekDayProps = {
  selected?: boolean,
}

export const WeekDay = styled(BaseButton)<WeekDayProps>`
  width: 4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #656565;
  min-width: 38px;

  :hover {
    color: #FFFFFF;
  }

  ${({ selected }) => (
    selected
      ? 'color: #FFFFFF;'
      : ''
  )};

  @media ${devices.mobile} {
    width: 45px;
  }
`

export const WeekName = styled.span`
  font-weight: bold;
  font-size: 1.04rem;
  line-height: 1.5rem;
  ${isMobileDevice
    ? css`
      font-size: 14px;
      line-height: 13px;
      padding-top: 6px;
    `
    : ''};
`

export const WeekNumber = styled.span`
  font-weight: 600;
  font-size: 1.3rem;
  line-height: 1.8rem;

  @media ${devices.mobile} {
    font-size: 16px;
    line-height: 24px;
  }
`

export const ArrowButton = styled(BaseButton)`
  position: relative;
  margin-top: 0.22rem;
  width: 2.28rem;
  height: 2.28rem;
  ${isMobileDevice
    ? css`
      width: 15px;
      height: 14px;
    `
    : ''};

`

type ArrowProps = {
  direction: 'left' | 'right',
}

export const Arrow = styled.span<ArrowProps>`
  width: 0.65rem;
  height: 0.65rem;
  position: absolute;
  border-left: 0.15rem solid #fff;
  border-bottom: 0.15rem solid #fff;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);

  ${({ direction }) => (
    direction === 'left'
      ? 'transform: translate(-50%, -50%) rotate(45deg);'
      : 'transform: translate(-50%, -50%) rotate(225deg);'
  )}
    ${isMobileDevice
    ? css`
      border-left: 1px solid #fff;
      width: 10px;
      height: 10px;
    `
    : ''};
`
