<template>
  <div class="dropdown profile-dropdown d-sm-flex align-items-center">
    <a
      @click="getListUnseen()"
      title="اعلانات"
      class="nav-link dropdown-toggle"
      href="#"
      role="button"
      data-bs-toggle="dropdown"
      aria-expanded="false"
    >
      <span class="badge bg-primary" title="اعلانات خوانده نشده">
        <svg class="icon icon-Component-285--2">
          <use xlink:href="#icon-Component-285--2"></use>
        </svg>
        {{ countUnseen ?? 0 }}
      </span>

      <span class="badge bg-primary" title="اعلانات خوانده نشده">
        {{ countUnseen ?? 0 }}
      </span>
    </a>

    <ul
      class="dropdown-menu dropdown-menu-end text-right"
      aria-labelledby="navbarDropdown"
    >
      <the-content-loading
        class="absolute-positioning"
        v-if="fetchingData"
      ></the-content-loading>

      <div v-else>
        <div v-if="listUnseen && listUnseen.length">
          <div class="user__container p-0">
            <notification-item
              v-for="item in listUnseen"
              :item="item"
              :key="item._id"
              :shortenTitle="true"
              @go-to-notification-show-page="goToNotificationShowPage(item)"
            ></notification-item>
          </div>
        </div>
        <no-data v-else>
          <div class="d-flex justify-content-center align-items-center">
            <div
              class="alert alert-warning d-flex justify-content-center align-items-center"
            >
              <span
                class="tavasi tavasi-warning-circle color-inherit ml-1 text__32"
              ></span>
              اعلان خوانده نشده ندارید
            </div>
          </div>
        </no-data>
        <hr />
        <more-button-component
          @go-to-notification-show-page="goToNotificationPage()"
          :list="listUnseen"
        ></more-button-component>
      </div>
    </ul>
  </div>
</template>

<script>
import notificationMixin from "~/mixins/notifications/notificationMixin";

export default {
  extends: notificationMixin,

  mounted() {
    this.getCountUnseen();
  },
};
</script>

<style scoped lang="scss">
.user {
  &__container {
    padding-left: 30px;
  }

  &__header {
    h4 {
      font-size: 16px;
      padding-bottom: 14px;
      padding-top: 18px;
    }
  }

  &__item {
    // @include border-top(1px, var(--color-14));
    display: flex;
    padding-top: 16px;
    margin-bottom: 12px;

    .color-1 span {
      background-color: var(--color-17) !important;
    }

    .color-2 span {
      background-color: var(--color-19) !important;
    }

    .color-3 span {
      background-color: var(--color-19) !important;
    }

    .color-4 span {
      background-color: var(--color-20) !important;
    }

    .color-5 span {
      background-color: var(--color-35) !important;
    }

    .color-6 span {
      background-color: var(--color-21) !important;
    }

    .color-7 span {
      background-color: var(--color-22) !important;
    }

    .color-8 span {
      background-color: var(--color-23) !important;
    }
  }

  &__pic {
    margin-left: 15px;

    img {
      width: 32px;
      height: 32px;
      border-radius: 50%;
      overflow: hidden;
    }
  }

  &__no-pic {
    span {
      width: 32px;
      height: 32px;
      color: var(--color-14);
      font-size: 14px;
      display: flex;
      justify-content: center;
      align-items: center;
      border-radius: 50%;
    }

    &.color-3 span {
      background: var(--color-24);
    }
  }

  &__content {
    flex: 1;
    display: flex;
    flex-direction: column;
  }

  &__item-head {
    display: flex;
    align-items: center;
    margin-bottom: 3px;
  }

  &__name {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-4);
    display: flex;
    align-items: center;
  }

  &__status {
    margin-left: auto;
    font-weight: normal;
    padding-right: 5px;
    font-size: 14px;
    color: var(--color-9);
  }

  &__date {
    margin-right: auto;
    font-size: 12px;
    color: var(--color-7);
  }

  &__breadcrumb {
    ul {
      display: flex;
      align-items: center;
      list-style: none;
    }

    li {
      display: flex;
      align-items: center;

      &:not(:last-child):after {
        content: ">";
        padding-right: 8px;
        padding-left: 8px;
        padding-top: 4px;
        font-size: 10px;
        font-weight: bold;
        color: var(--color-7);
        display: flex;
        justify-content: center;
        align-items: center;
      }

      &:last-child {
        flex: 1;

        a {
          // @include lineclamp(1);
        }
      }
    }

    a {
      display: block;
      font-size: 12px;
      color: var(--color-4);
    }
  }

  &__text {
    font-size: 14px;
    color: var(--color-9);
    margin-top: 4px;
  }

  &__invite {
    color: var(--color-1);
  }
}
.user-avatar-component {
  position: absolute;
  top: calc(50% - 20px);
  left: 0;
}

.in-sidebar {
  position: absolute;
  bottom: 6em;

  // &.#{$VITE_BUILD_NAME}-sidebar {
  //   margin-right: 0.5em;

  //   .user-avatar {
  //     width: 2.7em;
  //     height: 3em;
  //   }
  // }
  // &.#{$VITE_BUILD_NAME}-navbar {
  //   .dropdown-toggle{
  //     color: #fff;
  //   }
  // }

  .nav-link.dropdown-toggle {
    &::after {
      content: none;
    }
    span {
      display: none;
    }
  }
}
.button {
  min-height: 32px;
  min-width: 92px;
  width: -webkit-max-content;
  width: -moz-max-content;
  width: max-content;
  border: 2px solid #00b6e3;
  border-radius: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0 10px;
  color: var(--primary-color);
  text-decoration: none;
}
.button:hover {
  color: #fff !important;
  background-color: var(--primary-color);
}
.dropdown-toggle:hover {
  color: var(--primary-color);
}
.dropdown-menu {
  width: 20em;
  padding: 1em;

  max-height: 30em;
  overflow-y: auto;
}
.icon-Component-285--2 {
  position: relative;
  width: 0.5em;
  height: 0.5em;
  line-height: 0.5em;
  border-radius: 50%;
  text-align: center;
  background: #fff;
  padding: 0.1em;
  font-size: 3.5rem;
  box-shadow: rgba(23, 23, 23, 0.24) 0px 1px 3px;
  &:hover {
    box-shadow: rgba(23, 23, 23, 0.24) 0px 2px 4px;
  }
}
.badge {
  position: absolute;
  top: 0;
  right: 0;
}
</style>