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: ${({ theme: { colors } }) => colors.dateFilter};

  @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%;
  cursor: pointer;
  
  @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: 10px;
      line-height: 24px;
    `
    : ''};
`

type DateButtonProps = {
  isActive: boolean,
}

export const DateButton = styled(BaseButton) <DateButtonProps>`
  position: absolute;
  top: 0.2rem;
  right: 4.6rem;
  width: 1.3rem;
  height: 1.26rem;
  color: ${({ theme: { colors } }) => colors.dateButton};
  margin-left: 10px;
  
  ${isMobileDevice
    ? css`
      position: static;
      width: 9px;
      height: 9px;
      margin-left: 10px;
    `
    : ''};

  :hover {
    opacity: 0.7;
  }

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

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

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: ${({ theme: { colors } }) => colors.dateFilter};
  min-width: 38px;

  :hover {
    color: #FFFFFF;
  }

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

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

export const WeekName = styled.span`
  font-weight: bold;
  font-size: 1.04rem;
  line-height: 1.5rem;
  ${isMobileDevice
    ? css`
      font-weight: 600;
      font-size: 10px;
      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`
      height: 100%;
      padding: 0 5px;
      width: 35px;
    `
    : ''};

`

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%;

  ${({ direction }) => (
    direction === 'left'
      ? 'transform: translate(-50%, -50%) rotate(45deg);'
      : 'transform: translate(-50%, -50%) rotate(225deg);'
  )}
  
    ${isMobileDevice
    ? css`
      padding: 4px;
      border-left: 0.4rem solid rgba(255, 255, 255, 0.5);
      border-bottom: 0.4rem solid rgba(255, 255, 255, 0.5);
      width: 8px;
      height: 8px;
    `
    : ''};
`
