import { buttonClasses } from '@mui/material/Button';
import { dashboardLayoutNotificationListClassnames } from '../../DashboardLayoutNotificationList';
import { dashboardSidebarClassnames } from '../../DashboardSidebar/constants';
import { IconButton } from '../../IconButton';
import { menuOrganizationClassnames } from '../../MenuOrganization/constants';
import { MOBILE_BUTTON_HEIGHT } from '../../MenuOrganization/OrganizationButton/constants';
import { profileClassnames } from '../../Profile/constants';
import { styled } from '../../styled';
import { dashboardLayoutClassnames, HEADER_HEIGHT_DESKTOP, HEADER_HEIGHT_LAPTOP, HEADER_HEIGHT_MOBILE, } from '../constants';
import { dashboardLayoutHeaderClassnames } from './constants';
export const HeaderRoot = styled('header', {
    shouldForwardProp: (prop) => !['$isFocusedMode'].includes(prop),
}) `
  z-index: ${({ theme }) => theme.zIndex.appBar};

  display: flex;
  grid-column: 1 / -1;
  grid-row: 1;
  align-items: center;
  justify-content: space-between;

  width: 100%;
  height: ${HEADER_HEIGHT_DESKTOP};
  margin-top: ${({ $isFocusedMode }) => $isFocusedMode ? `-${HEADER_HEIGHT_DESKTOP}` : 0};
  margin-bottom: ${({ theme }) => theme.spacing(4)};

  transition: ${({ theme }) => {
    return theme.transitions.create(['margin-top'], {
        duration: theme.transitions.duration.complex,
    });
}};

  ${({ theme }) => theme.breakpoints.down('laptop')} {
    height: ${HEADER_HEIGHT_LAPTOP};
  }

  ${({ theme }) => theme.breakpoints.down('sm')} {
    grid-row: 2;
    justify-content: flex-start;

    height: ${HEADER_HEIGHT_MOBILE};
    margin-bottom: 0;
    padding: ${({ theme }) => theme.spacing(0, 2, 0, 1)};

    background-color: ${({ theme }) => theme.palette.background.default};
    border-bottom: 1px solid ${({ theme }) => theme.palette.components.border.default};

    transition: unset;
  }
`;
export const MobileSidebarTogglerWrapper = styled.div `
  ${({ theme }) => theme.breakpoints.up('sm')} {
    display: none;
  }
  
  .${buttonClasses.root} {
    padding: ${({ theme }) => theme.spacing(2)};
  }
  
  /* Причина игнора: Не критично для отображения */
  /* stylelint-disable-next-line plugin/no-unsupported-browser-features */
  .${dashboardLayoutClassnames.root}:not(:has(.${dashboardSidebarClassnames.root}))
    & {
    display: none;
  }
`;
export const HeaderSection = styled.div `
  display: flex;
  gap: ${({ theme }) => theme.spacing(1)};
  align-items: center;

  ${({ theme }) => theme.breakpoints.down('sm')} {
    flex-grow: 1;
  }
`;
export const HeaderContentSection = styled(HeaderSection) `
  gap: ${({ theme }) => theme.spacing(6)};
  justify-content: flex-end;

  ${({ theme }) => theme.breakpoints.down('sm')} {
    gap: ${({ theme }) => theme.spacing(2)};

    &.${dashboardLayoutHeaderClassnames.priorityFeatureMenuOrg} {
      & .${menuOrganizationClassnames.organizationData} {
        display: none;
      }
      & .${menuOrganizationClassnames.button} {
        border-radius: ${({ theme }) => theme.shape.medium};
      }
    }
  }
`;
export const ProductSwitcherWrapper = styled.div `
  ${({ theme }) => theme.breakpoints.down('sm')} {
    display: none;
  }
`;
export const ProfileWrapper = styled('div', {
    shouldForwardProp: (prop) => !['$isShow'].includes(prop),
}) `
  display: contents;

  ${({ theme }) => theme.breakpoints.down('sm')} {
    display: ${({ $isShow }) => ($isShow ? 'block' : 'none')};
  }
`;
export const ExitButton = styled(IconButton, {
    shouldForwardProp: (prop) => !['$isShow'].includes(prop),
}) `
  display: none;

  ${({ theme }) => theme.breakpoints.down('sm')} {
    display: ${({ $isShow }) => (!$isShow ? 'none' : 'flex')};
  }
`;
export const HeaderContent = styled.div `
  display: flex;
  flex-grow: 1;
  justify-content: space-between;

  ${({ theme }) => theme.breakpoints.down('sm')} {
    padding: 0;
  }
`;
/**
 * Обертка для элементов которые должны быть в мобильном хедере или помещены в sidebar.
 */
export const PriorityFeatureWrapper = styled.div `
  ${({ theme }) => theme.breakpoints.down('sm')} {
    &.${dashboardLayoutHeaderClassnames.featureInSidebar} {
      position: absolute;
      z-index: ${({ theme }) => theme.zIndex.appBar - 1};
      top: calc(var(--alert-height, 0px) + ${HEADER_HEIGHT_MOBILE});
      left: 0;
      
      /* Необходимо для анимации компонента вместе с sidebar */
      transform: translateX(-100vw);

      display: flex;
      flex-direction: row;
      align-items: center;

      width: 100vw;

      background-color: ${({ theme }) => theme.palette.background.default};

      transition: ${({ theme }) => {
    return theme.transitions.create(['transform'], {
        duration: theme.transitions.duration.standard,
    });
}};

      &.${dashboardLayoutHeaderClassnames.mobileSidebarPriorityFeatureVisible} {
        transform: translateX(0);
      }

      & .${menuOrganizationClassnames.button}, & .${profileClassnames.button} {
        height: ${MOBILE_BUTTON_HEIGHT};
        padding: ${({ theme }) => theme.spacing(3, 4)};

        border-bottom: 1px solid ${({ theme }) => theme.palette.components.border.default};

        &:hover {
          border-bottom: 1px solid ${({ theme }) => theme.palette.components.border.default};
        }

        &:active {
          border-bottom: 1px solid ${({ theme }) => theme.palette.components.border.default};
        }
      }

      &.${dashboardLayoutHeaderClassnames.hasNotificationList} {
        gap: ${({ theme }) => theme.spacing(4)};

        height: ${MOBILE_BUTTON_HEIGHT};
        padding: ${({ theme }) => theme.spacing(2, 3)};

        border-bottom: 1px solid ${({ theme }) => theme.palette.components.border.default};

        & .${menuOrganizationClassnames.button}, & .${profileClassnames.button} {
          flex-grow: 1;

          height: unset;
          padding: unset;

          border-bottom: none;
        }
      }

      &.${dashboardLayoutHeaderClassnames.priorityFeatureMenuOrg} {
        & .${dashboardLayoutHeaderClassnames.profile} {
          display: block;
          flex-grow: 1;
        }


        & .${profileClassnames.button} {
          width: 100%;
          max-width: unset;

          border-radius: 0;
        }

        & .${profileClassnames.avatar} {
          display: none;
        }

        & .${profileClassnames.user} {
          display: flex;
          align-items: center;
          justify-content: space-between;

          width: 100%;
        }
      }
    }
  }
`;
export const MobileNotificationListWrapper = styled.div `
  display: none;

  ${({ theme }) => theme.breakpoints.down('sm')} {
    display: block;
    
    & .${dashboardLayoutNotificationListClassnames.root} {
      display: block;
    }
  }
`;
