import { ActionMenu } from "@ax/components";
import { Cell, Row } from "@ax/components/TableList/TableItem/style";

import styled from "styled-components";

const CheckCell = styled(Cell)`
  padding-right: 0;
  padding-left: ${(p) => p.theme.spacing.m};
  label {
    margin-bottom: ${(p) => p.theme.spacing.s};
    padding-left: ${(p) => p.theme.spacing.s};
  }
`;

const NameCell = styled(Cell)`
  flex-grow: 1;
  min-width: 0;
  position: relative;
  > * {
    min-width: 0;
  }
`;

const Title = styled.div`
  ${(p) => p.theme.textStyle.uiL};
  color: ${(p) => p.theme.color.textHighEmphasis};
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  width: 100%;
`;

const ActionsCell = styled(Cell)`
  flex: 0 0 85px;
  padding-left: 0;
`;

const ActionsWrapper = styled.div`
  opacity: 0;
  transition: opacity 0.1s;
  text-align: right;
`;

const TransCell = styled(Cell)`
  ${(p) => p.theme.textStyle.uiXS};
  flex: 0 0 115px;
  align-items: center;
`;

const LiveCell = styled(Cell)`
  flex: 0 0 80px;
  align-items: center;
  svg {
    width: ${(p) => p.theme.spacing.m};
    height: ${(p) => p.theme.spacing.m};
  }
`;

const StatusCell = styled(Cell)`
  flex: 0 0 170px;
  align-items: center;
  div:nth-child(2) {
    margin-top: ${(p) => p.theme.spacing.xs};
  }
`;

const ModDate = styled.div`
  ${(p) => p.theme.textStyle.uiXS};
  color: ${(p) => p.theme.color.textLowEmphasis};
`;

const StyledActionMenu = styled(ActionMenu)`
  opacity: 0;
  width: 32px;
  display: flex;
  margin-left: auto;
`;

const StructuredDataRow = styled(Row)<{ disabled: boolean }>`
  cursor: ${(p) => (p.disabled ? "default" : "pointer")};
  &:hover {
    ${StyledActionMenu} {
      opacity: 1;
    }
  }
  ${NameCell}, ${LiveCell}, ${StatusCell} {
    pointer-events: ${(p) => (p.disabled ? "none" : "auto")};
  }
`;

const FlagsWrapper = styled.div`
  svg {
    margin-right: 2px;
    margin-bottom: -3px;
    display: inline;
    vertical-align: baseline;
  }
`;

const ColumnCell = styled(Cell)`
  flex: 0 0 215px;
  position: relative;
  align-items: center;
`;

export {
	CheckCell,
	NameCell,
	ActionsCell,
	ActionsWrapper,
	StyledActionMenu,
	TransCell,
	LiveCell,
	StatusCell,
	ModDate,
	StructuredDataRow,
	FlagsWrapper,
	Title,
	ColumnCell,
};
