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

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

import { customScrollbar } from 'features/Common'

export const Wrapper = styled.div`
${isMobileDevice
    ? css`
      @media (orientation: landscape){
        min-width: 250px;
      }
      @media (max-width: 569px) and (orientation: landscape){
        min-width: 200px;
      }
    `
    : ''};
`

export const TabsWrapper = styled.div`
  padding-left: 14px;
  padding-right: 18px;
  position: relative;

  ${isMobileDevice
    ? css`
      padding: 0 5px;
    `
    : ''};
`

type TContainer = {
  forVideoTab?: boolean,
}

export const Container = styled.div<TContainer>`
  width: 320px;
  margin-top: 14px;
  padding: 0 10px 0 14px;
  max-height: calc(100vh - 170px);
  overflow-y: ${({ forVideoTab }) => (forVideoTab ? 'none' : 'scroll')};

  ${customScrollbar}

  @media ${devices.tablet} {
    max-height: calc(100vh - 40px);
    margin-top: 15px;
  }

  ${isMobileDevice
    ? css`
      padding: 0 5px;
      overflow-y: auto;

      @media (max-width: 750px){
        width: 100%;
      }
      @media (orientation: landscape){
        width: 100%;
      }
    `
    : ''};
`

type ButtonProps = {
  active?: boolean,
}

export const Button = styled.button<ButtonProps>`
  border: none;
  outline: none;
  position: relative;

  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  background: linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.1) 0%,
      rgba(255, 255, 255, 0) 100%
    ),
    #3F3F3F;
  box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.3);
  border-radius: 2px;

  ${({ disabled }) => (
    disabled
      ? css`
          pointer-events: none;
          opacity: 0.5;
        `
      : css`
          cursor: pointer;
        `
  )}

  :hover {
    background-color: #555555;
  }

  @media ${devices.mobile} {
    justify-content: center;
    border-radius: 1.8px;
  }

  ${({ active, theme }) => {
    const bgColor = theme.colors.button
    const bgHoverColor = theme.colors.buttonHover

    return active ? css`
      background-color: ${bgColor};
      &:hover {
        background-color: ${bgHoverColor};
      }
    ` : ''
  }}
`

export const Title = styled.span`
  font-weight: 600;
  font-size: 14px;
  max-width: 55%;
  line-height: 16px;
  color: #ffffff;
  overflow: hidden;
  white-space: nowrap;
  text-overflow:ellipsis;
`

export const BlockTitle = styled.span`
  font-weight: 600;
  font-size: 12px;
  line-height: 18px;
  text-align: start;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
`

export const BackToTopBtn = styled.div`
  position: absolute;
  left: 50%;
  bottom: -100%;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 0px 0 20px 20px; 
  width: 37px;
  height: 34px;
  z-index: 1;
  cursor: pointer;
  transform: translate(-50%, 6%);

  :after {
    content: '';
    width: 10px;
    height: 10px;
    position: absolute;
    border-left: 2px solid rgb(255, 255, 255);
    border-top: 2px solid rgb(255, 255, 255);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
  }
`
