import styled from 'styled-components/macro'

import { devices } from 'config/devices'

import {
  InputWrapper,
  InputStyled,
  Column,
  Error,
} from 'features/Common/Input/styled'

import {
  CenterBlock,
  ButtonsBlock,
  BlockTitle,
} from 'features/Login/styled'

export const Row = styled.div`
  width: 100%;
  display: flex;

  & div:last-child {
    margin-left: 16px;
  }
`

export const Card = styled.div`
  width: 546px;
  height: 340px;
  margin: 20px 0;
  padding: 0 32px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-sizing: border-box;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  ${Row} {
   ${Column} {
     :first-of-type {
       ${InputWrapper} {
         width: 280px;
       }
       ${InputStyled} {
         width: 85px;
       }
     }

     :last-of-type {
      ${InputWrapper} {
        width: 184px;
      }
      ${InputStyled} {
        width: 30px;
      }
     }
   }
  }

  
  @media ${devices.laptop} {
    margin-top: 17px;
    margin-bottom: 61px;
    width: 482px;
    height: 294px;
    padding: 0 30px;

    ${InputStyled} {
        text-align: center;
    }

    ${Column} {
      margin-bottom: 8px;
    }

    ${Row} {
      ${Column} {
        :first-of-type {
          max-width: 242px;
          ${InputWrapper} {
            width: 242px;
          }
          ${InputStyled} {
            width: 85px;
          }
        }
   
        :last-of-type {
          max-width: 160px;
         ${InputWrapper} {
           width: 160px;
         }
         ${InputStyled} {
           width: 30px;
         }
        }
      }
     }
  }

  @media ${devices.mobile} {
    width: 375px;
    height: auto;
    border: 0;
    margin-top: 0;

    ${Row} {
      width: 335px;
      ${Column} {
        :first-of-type {
          max-width: 163px;
          ${InputWrapper} {
            width: 163px;
          }
          ${InputStyled} {
            width: 85px;
          }
        }
   
        :last-of-type {
          max-width: 162px;
          margin-left: 10px;
         ${InputWrapper} {
           width: 162px;
         }
         ${InputStyled} {
           width: 30px;
         }
        }
      }
     }
  }
`
type CustomCenterBlockProps = {
  isCardStep: boolean,
  isSubsStep: boolean,
}

export const CustomCenterBlock = styled(CenterBlock)<CustomCenterBlockProps>`

  @media ${devices.laptop} {
    margin-top: ${({ isCardStep, isSubsStep }) => {
    if (isCardStep) return '154px'
    if (isSubsStep) return '89px'
    return '53px'
  }};

    ${InputWrapper} {
      margin-top: 12px;
    }
    ${InputStyled}::placeholder {
      text-align: center;
    }

    ${Column} {
      position: relative;
    }

    ${ButtonsBlock} {
      margin-top: ${({ isSubsStep }) => ((isSubsStep) ? '84px' : '63px')};
  
    }

    ${Error} {
      position: absolute;
      top: 50%;
      right: -85%;
      transform: translateY(-50%);
      width: 328px;

      @media ${devices.tablet} {
        position: static;
        margin-top: 5px;
      }
    }
  }

  @media ${devices.tablet} {
    margin-top: ${({ isCardStep, isSubsStep }) => {
    if (isCardStep) return '154px'
    if (isSubsStep) return '69px'
    return '53px'
  }};

    ${InputWrapper} {
      margin-top: -8px;
    }  
  }

  @media ${devices.mobile} {
    ${InputStyled} {
      text-align: center;
    }

    ${BlockTitle} {
      margin-bottom: 38px;
    }
  }
`
