@use "sass:list";

.#{$lts-prefix}header {
  position: fixed;
  top: 0;
  right: 0;
  left: var(--#{$lts-prefix}sidebar-width);
  z-index: var(--#{$lts-prefix}base-zindex);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  height: var(--#{$lts-prefix}header-height);
  padding: 0 4px;
  margin: 0;
  list-style: none;
  background-color: var(--#{$prefix}body-bg);
  box-shadow: 0 1px 1px -1px rgba(var(--#{$prefix}dark-rgb), 0.25);

  @include transition(
    padding-left $lts-transition-speed $lts-transition-fn,
    left $lts-transition-speed $lts-transition-fn
  );
  @include media-breakpoint-down(lg) {
    left: 0;
    padding: 0;
  }

  // 每个li
  > li {
    height: inherit;

    &.dropdown {
      // lg屏幕下取消定位否则无法全屏
      @include media-breakpoint-down(lg) {
        position: static !important;
      }
    }

    // 头部导航的下拉菜单
    .dropdown-menu {
      max-width: 360px;
      border: 0;

      @include border-radius($border-radius-lg);

      // 阴影效果
      box-shadow: 0 0.125rem 0.25rem
        rgb(var(--#{$lts-prefix}secondary-color-rgb) 0.075);

      @include media-breakpoint-down(lg) {
        min-width: 100%;
      }

      // 下拉菜单的卡片
      .card {
        min-width: 300px;
        max-height: 280px;
        border: 0;

        @include media-breakpoint-down(lg) {
          min-width: 100%;
        }

        .card-body {
          // 应用容器
          .#{$lts-prefix}app-box {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 45px;
            height: 45px;
            margin-bottom: 8px;
            font-size: 26px;
            cursor: pointer;
            background-color: #f6f6f6;
            @include border-radius($border-radius-lg);
          }

          // 应用标题
          .#{$lts-prefix}app-title {
            font-size: 14px;
            color: $secondary;
          }
        }
      }

      // 下拉菜单的item项目
      .dropdown-item {
        display: block;
        padding: 8px 20px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;

        // 激活状态背景色也保持不变
        &:active {
          color: var(--#{$prefix}body-color);
          background-color: var(--#{$prefix}tertiary-bg);
        }
      }
    }

    .#{$lts-prefix}header-item {
      position: relative;
      display: flex;
      align-items: center;
      justify-content: center;
      height: inherit;
      padding: 0 12px;
      font-size: 20px;
      color: var(--#{$prefix}body-color);
      cursor: pointer;
      background: inherit;

      &::after {
        position: absolute;
        top: 0;
        left: 0;
        width: 0;
        height: 2px;
        content: "";
        background-color: #212529;
        @include border-radius(0);
        @include transition(all $lts-transition-speed);
      }

      &:hover {
        &::after {
          width: 100%;
        }
      }

      // lg屏幕下每个item的字体和间距再小一点，保证可以展示头部所有的项目
      @include media-breakpoint-down(lg) {
        padding: 0 20px;
        font-size: 18px;
      }

      @include media-breakpoint-down(md) {
        padding: 0 16px;
      }

      @include media-breakpoint-down(sm) {
        padding: 0 12px;
      }

      @include media-breakpoint-down(xsm) {
        padding: 0 8px;
      }

      // 用户区域
      .#{$lts-prefix}user-area {
        display: flex;
        align-items: center;

        // 用户头像
        .#{$lts-prefix}user-avatar {
          flex-shrink: 0;
          width: 35px;
          height: 35px;
          overflow: hidden;
          user-select: none;
          @include border-radius(50%);

          // lg屏幕下用户头像再放小一点
          @include media-breakpoint-down(lg) {
            width: 32px;
            height: 32px;
          }

          // 小于342像素时
          @include media-breakpoint-down(three-four-two) {
            width: 30px;
            height: 30px;
          }
        }

        // 用户详情
        .#{$lts-prefix}user-details {
          display: block;
          flex-shrink: 0;
          max-width: 150px;
          margin-left: 8px;

          // xl设备下直接隐藏用户详情只展示头像
          @include media-breakpoint-down(xl) {
            display: none;
          }
          // 用户名
          .#{$lts-prefix}user-name {
            font-size: 15px;
          }
          //用户角色
          .#{$lts-prefix}user-role {
            font-size: 13px;
            color: $secondary;
          }
        }
      }
    }
  }
}
