$headerToph: 40px;

header {
  .dropdown {
    cursor: pointer;

    &:hover {
      .dropdown-menu {
        display: block;
      }
    }
  }

  .header-top {
    background-color: #1B1F22;
    color: #fff;
    height: $headerToph;
    display: flex;
    align-items: center;

    .top-info {
      a {
        color: inherit;
        margin-right: 10px;
        &:hover {
          > a {
            color: $primary;
          }
        }
      }
    }

    .language-switch {
      .dropdown {
        cursor: pointer;

        &:hover {
          > a {
            color: $primary;
          }
        }

        > a {
          color: inherit;
          border-radius: 0;
          border: none;
          padding: 0;
          height: $headerToph;
          line-height: $headerToph;

          img {
            width: 20px;
          }
        }
      }
    }
  }

  // 与移动端公用搜索框样式
  .search-group {
    background-color: #F1F3F5;
    position: relative;
    &:hover {
      input {
        background-color: #eee;
      }
    }

    input {
      background-color: transparent;
      padding-right: 40px;
      border-radius: 4px;
      border: none;
      width: 210px;
      font-size: 16px;
      height: 44px;
      box-shadow: none;
    }

    .btn {
      position: absolute;
      right: 0;
      top: 50%;
      transform: translateY(-50%);
      i {
        font-size: 22px;
      }
    }
  }

  .header-desktop {
    padding: 30px 0;

    @media (max-width: 992px) {
      display: none;
    }

    .left {
      display: flex;
      align-items: center;

      .logo {
        max-width: 180px;
        max-height: 60px;
        margin-bottom: 0;
      }

      .menu {
        margin-left: 40px;
        .navbar {
          padding: 0;
        }

        .navbar {
          .nav-item {
            > .dropdown > .nav-link, > .nav-link {
              font-weight: bold;
              color: #222;
              font-size: 16px;
              padding-left: 6px;
              padding-right: 6px;
              margin: 0 14px;
              position: relative;

              &::after {
                content: "";
                position: absolute;
                right: 0;
                bottom: 0;
                width: 0;
                border-bottom: 1px solid;
                border-bottom-width: 2px;
                transition: width .3s;
              }
            }

            &:hover {
              > .dropdown > .nav-link, > .nav-link {
                &::after {
                  width: 100%;
                  left: 0;
                }
              }

              .dropdown-menu {
                border-radius: 2px;
                box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
                border: none;
                display: block;
              }
            }
          }
        }
      }
    }

    .right {
      display: flex;
      align-items: center;

      .dropdown {
        .dropdown-toggle {
          &::after {
            display: none;
          }
        }
      }

      .icons {
        display: flex;
        align-items: center;

        .account-icon {
          .dropdown-menu {
            left: 50%;
            transform: translateX(-50%);
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
            border: none;
            text-align: center;
            a {
              padding: 10px 0;
            }
          }
        }

        .item {
          margin-left: 26px;
          position: relative;

          .icon-quantity {
            position: absolute;
            top: -5px;
            right: -10px;
            background-color: $primary;
            color: #fff;
            font-size: 11px;
            border-radius: 50%;
            width: 18px;
            height: 18px;
            display: flex;
            align-items: center;
            justify-content: center;
          }
        }
      }
    }
  }

  .header-mobile {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;

    @media (min-width: 992px) {
      display: none;
    }

    .logo {
      max-width: 160px;
      max-height: 50px;
      margin-bottom: 0;
    }

    .mb-icon {
      i {
        font-size: 30px;
        line-height: 1;
      }
    }

    .header-cart-icon {
      position: relative;

      .icon-quantity {
        position: absolute;
        top: -5px;
        right: -10px;
        background-color: $primary;
        color: #fff;
        font-size: 11px;
        border-radius: 50%;
        width: 18px;
        height: 18px;
        display: flex;
        align-items: center;
        justify-content: center;
      }
    }

    #mobile-menu-offcanvas {
      width: 76%;

      .offcanvas-header {
        border-bottom: 1px solid #f1f1f1;
        // background-color: #f7f7f7;
        display: flex;
        justify-content: space-between;

        .search-group {
          margin-right: 10px;

          input {
            height: 38px;
          }

          .btn {
            i {
              font-size: 18px;
            }
          }
        }

        .account-icon {
          img {
            width: 24px;
          }
        }
      }

      .close-offcanvas {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        right: -26px;
        width: 26px;
        height: 50px;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 24px;
        background-color: #fff;
        border-radius: 0 5px 5px 0;
        &:active {
          background-color: #f1f1f1;
        }
      }

      .mobile-menu-wrap {
        padding: 0;

        #menu-accordion {
          // border-top: 1px solid #e5e5e5;

          .accordion-item {
            border-bottom: 1px solid #e5e5e5;

            .nav-item-text {
              display: flex;
              align-items: center;
              justify-content: space-between;

              > a {
                flex: 1;
                height: 44px;
                padding: 0 14px;
                display: flex;
                align-items: center;
                &:active {
                  background-color: #eee;
                }

                .badge {
                  position: relative;
                  margin-left: 13px;
                  // padding: 2px 4px;
                  font-weight: 400;

                  &::before {
                    content: "";
                    position: absolute;
                    top: 50%;
                    right: 100%;
                    transform: translate(0, -50%);
                    border: 4px solid;
                    border-right-width: 7px;
                    border: 5px solid #0000;
                    border-right-color: inherit;
                  }
                }
              }

              > span {
                width: 44px;
                height: 44px;
                display: flex;
                // border-left: 1px solid #e5e5e5;
                align-items: center;
                justify-content: center;
                &:active {
                  background-color: #eee;
                }

                &[aria-expanded="true"] {
                  // background-color: #eee;
                  i {
                    transform:rotate(180deg);
                  }
                }
              }
            }

            > .accordion-collapse {
              // padding: 0 10px;
              border-top: 1px solid #e5e5e5;

              .children-group {
                padding: 5px 0;

                .children-title {
                  height: 44px;
                  span {
                    margin-right: -10px;
                    width: 44px;
                    height: 42px;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    &:active {
                      background-color: #eee;
                    }

                    &[aria-expanded="true"] {
                      i::before {
                        content: "\F63B";
                      }
                    }
                  }
                }

                .nav {
                  a {
                    color: #333;
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
