@use "../variables.scss" as *;

.navbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 250px;
  height: 100lvh;
  background-color: $adminNavbarBackgroundColor;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 0.8rem;
  box-shadow: 2px 0 8px $adminNavbarShadow;
  color: $adminNavbarTextColor;
  z-index: 9999;
  overflow: hidden;
  transform: translateX(0);
  transition: transform 0.3s ease;

  &.expanded {
    transform: translateX(0);
  }

  &.collapsed {
    transform: translateX(-100%);
  }

  @media (max-width: 768px) {
    width: 50vw;
    padding: 1rem 0.5rem;
  }

  .logoContainer {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;

    img {
      max-width: 80%;
      height: auto;
    }
  }

  .menu {
    list-style: none;
    padding: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;

    li {
      width: 100%;
      cursor: pointer;
      position: relative;
      display: flex;
      flex-direction: column;
      align-items: start;

      > span,
      > a {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 0.6rem 0.8rem;
        color: $adminNavbarTextColor;
        text-decoration: none;
        font-weight: 500;
        border-radius: 6px;
        transition: background-color 0.3s ease;
        font-size: 1rem;

        &:hover {
          background-color: $adminNavbarMenuHoverColor;
        }
      }

      .chevronIcon {
        margin-left: auto;
        transition: 0.3s ease;
      }

      .subMenu {
        list-style: none;
        width: 100%;
        padding: 0.3rem 0;
        margin-top: 0.4rem;
        background-color: darken($adminNavbarBackgroundColor, 5%);
        border-radius: 6px;
        overflow: hidden;
        max-height: 0;
        opacity: 0;
        display: flex;
        flex-direction: column;
        gap: 0.4rem;
        transition: max-height 0.5s ease, opacity 0.5s ease;

        li {
          opacity: 0;
          transform: translateY(-10px);
          animation: slideIn 0.3s forwards ease;

          &:nth-child(1) {
            animation-delay: 0.1s;
          }
          &:nth-child(2) {
            animation-delay: 0.2s;
          }
          &:nth-child(3) {
            animation-delay: 0.3s;
          }
          &:nth-child(4) {
            animation-delay: 0.4s;
          }
          &:nth-child(5) {
            animation-delay: 0.5s;
          }
          &:nth-child(6) {
            animation-delay: 0.6s;
          }
          &:nth-child(7) {
            animation-delay: 0.7s;
          }
          &:nth-child(8) {
            animation-delay: 0.8s;
          }

          a {
            padding: 0.4rem 0.7rem;
            font-size: 0.85rem;
            color: lighten($adminNavbarTextColor, 15%);
            background-color: darken($adminNavbarBackgroundColor, 5%);
            border-radius: 4px;

            &:hover {
              background-color: darken($adminNavbarMenuHoverColor, 5%);
            }
          }
        }
      }

      &.active .subMenu {
        max-height: 400px;
        opacity: 1;

        li {
          animation-name: slideIn;
        }
      }

      &.active .chevronIcon {
        transform: rotate(180deg);
      }
    }
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hamburgerButton {
  position: fixed;
  top: 0.8rem;
  left: 0.8rem;
  width: 35px;
  height: 35px;
  background-color: $adminNavbarBackgroundColor;
  color: $adminNavbarTextColor;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  z-index: 10000;

  &:hover {
    background-color: $adminNavbarMenuHoverColor;
  }

  .icon {
    font-size: 1rem;
  }
}

.content {
  margin-left: 250px;
  padding: 1.5rem;

  @media (max-width: 768px) {
    margin-left: 0;
  }
}

/* Mobil Uyumluluk İçin Ekstra Ayarlar */
@media (max-width: 768px) {
  .navbar {
    width: 50vw;
    padding: 1rem 0.5rem;
  }

  .menu {
    gap: 0.5rem;

    li {
      > span,
      > a {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
      }
    }

    .subMenu {
      padding: 0.3rem 0;

      li {
        a {
          padding: 0.4rem 0.7rem;
          font-size: 0.8rem;
        }
      }
    }
  }

  .hamburgerButton {
    width: 30px;
    height: 30px;

    .icon {
      font-size: 0.9rem;
    }
  }
}
