import styled from "styled-components";

const IconWrapper = styled.div`
  background-color: ${(p) => p.theme.color.uiBackground03};
  border-radius: ${(p) => p.theme.radii.s};
  height: calc(${(p) => p.theme.spacing.s} * 2);
  width: calc(${(p) => p.theme.spacing.s} * 2);
  display: flex;
  justify-content: center;
  align-items: center;
  margin-right: ${(p) => p.theme.spacing.xs};
`;

const HiddenButtonsWrapper = styled.div`
  margin-left: auto;
  display: none;
  opacity: 0;
`;

const Component = styled.div<{ disabled?: boolean }>`
  ${(p) => p.theme.textStyle.fieldLabel};
  color: ${(p) => p.theme.color.textHighEmphasis};
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  background-color: ${(p) => p.theme.color.uiBackground02};
  border: 1px solid transparent;
  margin-bottom: ${(p) => p.theme.spacing.xs};
  padding: calc(${(p) => p.theme.spacing.xs} - 1px) ${(p) => p.theme.spacing.xs};
  border-radius: ${(p) => p.theme.radii.s};
  box-shadow: ${(p) => p.theme.shadow.shadowS};
  text-align: left;
  cursor: ${(p) => (p.disabled ? `default` : `pointer`)};
  min-height: 48px;

  &:hover,
  &.active {
    border: 1px solid ${(p) => p.theme.color.overlayHoverPrimary};
    cursor: ${(p) => (p.disabled ? `default` : `pointer`)};
    &:before {
      content: "";
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      border-radius: ${(p) => p.theme.radii.s};
      background-color: ${(p) => p.theme.color.overlayHoverPrimary};
    }
    span.light {
      border-color: ${(p) => p.theme.color.interactiveInactive};
    }
    ${HiddenButtonsWrapper} {
      display: flex;
      opacity: 1;
    }
  }

  &:focus,
  &:active {
    background: ${(p) => (p.disabled ? p.theme.color.uiBackground02 : p.theme.color.overlayFocusPrimary)};
    border: 1px solid ${(p) => (p.disabled ? `transparent` : p.theme.color.interactive01)};
    outline: none;
  }
`;

const Title = styled.div<{ disabled?: boolean }>`
  ${(p) => p.theme.textStyle.headingXS};
  color: ${(p) => (p.disabled ? p.theme.color.interactiveDisabled : p.theme.color.textMediumEmphasis)};
  margin: ${(p) => p.theme.spacing.xxs} 0;
`;

const Filters = styled.div`
  display: flex;
  height: ${(p) => p.theme.spacing.l};
  align-items: center;
  & > * {
    &:not(:last-child) {
      margin-right: ${(p) => p.theme.spacing.m};
    }
  }
  .headerWrapper {
    padding: 0;
  }
`;

const FilterWrapper = styled.div`
  position: relative;
`;

export { Component, IconWrapper, Title, HiddenButtonsWrapper, Filters, FilterWrapper };
