@import '../variables';
@import '../theme-colors';

.container-scroller {
  overflow: hidden;
  position: relative;
  background-color: var(--base-color);
}

.page-body-wrapper {
  display: flex;
  flex-direction: row;
  padding: $navbar-height 0 0 0;
  min-height: calc(100vh - #{$navbar-height});
}

.main-panel {
  display: flex;
  flex-direction: column;
  margin-left: $sidebar-width-lg;
  width: calc(100% - #{$sidebar-width-lg});
  min-height: calc(100vh - #{$navbar-height});
  transition: width $default-transition-duration $action-transition-timing-function, margin $default-transition-duration $action-transition-timing-function;

  @media (max-width: 991px) {
    width: 100%;
    margin-left: 0;
  }
}

.content-wrapper {
  width: 100%;
  flex-grow: 1;
  padding: $main-content-wrapper-padding;
  background: var(--app-background-color);
}

.navbar {
  &.fixed-top {
    + .page-body-wrapper {
      padding-top: $navbar-height;
    }
  }
}

// Sidebar Icon Only
.sidebar-icon-only {
  @media (min-width: 992px) {
    .container-scroller {
      position: relative;
    }

    .navbar {
      margin-left: $sidebar-width-icon;

      .navbar-menu-wrapper {
        width: calc(100% - #{$sidebar-width-icon});
      }
    }

    .sidebar {
      min-height: 100%;
      position: absolute;
      width: $sidebar-width-icon;

      .navbar-brand-wrapper {
        z-index: 12;
        position: fixed;
        width: $sidebar-width-icon;

        .brand-logo {
          display: none;
        }

        .brand-logo-mini {
          display: inline-block;
        }
      }

      .nav {
        overflow: visible;
        margin-top: $navbar-height;

        .nav-item {
          position: relative;
          padding: 0 1rem;

          .nav-link {
            display: block;
            text-align: center;

            .menu-title, .badge {
              display: none;
            }

            .menu-title {
              border-radius: 0 5px 5px 0;
            }

            i {
              &.menu-icon {
                margin-right: 0;
                margin-left: 0;
              }

              &.menu-arrow {
                display: none;
              }
            }

            &[aria-expanded] {
              .menu-title {
                border-radius: 0 5px 0 0;
              }
            }
          }

          .collapse {
            display: none;
          }

          &.hover-open {
            .nav-link {
              display: flex;

              .menu-title {
                position: absolute;
                top: 0;
                bottom: 0;
                z-index: 1;
                display: flex;
                align-items: center;
                margin-left: 0;
                text-align: left;
                line-height: 1.8;
                left: $sidebar-width-icon;
                background: var(--sidebar-bg);
                width: $icon-only-collapse-width;
                box-shadow: var(--menu-title-shadow);
                padding: $sidebar-submenu-item-padding;

                &:after {
                  display: none;
                }
              }
            }

            .collapse, .collapsing {
              margin: 0;
              display: block;
              position: absolute;
              border-radius: 0 0 5px 0;
              left: $sidebar-width-icon;
              background: var(--sidebar-bg);
              width: $icon-only-collapse-width;
              box-shadow: var(--submenu-shadow);

              .sub-menu {
                .nav-link {
                  line-height: 1.15;
                  white-space: initial;
                  border-radius: 0 0 5px 0;
                }
              }
            }

            .collapse-multi-level {
              display: none;
            }

            .hover-open {
              .collapse-multi-level {
                display: block;
                top: 0;
                left: $icon-only-collapse-width;
                border-radius: 0 5px 5px 0;

                .sub-menu {
                  margin: 0;
                  padding-left: 0;
                  border-radius: 0 5px 5px 0;

                  .nav-item {
                    padding: 0;

                    &:first-child {
                      .nav-link {
                        padding-top: 0.75rem;
                      }
                    }
                  }
                }
              }
            }
          }
        }

        &.sub-menu {
          margin-top: 0;
          border-radius: 0 0 5px 0;
          background-color: var(--sidebar-bg);

          .nav-item {
            .nav-link {
              padding-left: 0;
              padding-right: 0;
              text-align: left;

              .icon-wrapper {
                background-color: $navbar-brand-bg;
              }
            }

            &:first-child {
              .nav-link {
                padding-top: initial;
              }
            }
          }
        }
      }
    }

    .main-panel {
      min-height: 1200px;
      margin-left: $sidebar-width-icon;
      width: calc(100% - #{$sidebar-width-icon});
    }
  }
}

// Sidebar Hover Only
.sidebar-hover-only {
  @media (min-width: 992px) {
    .navbar {
      margin-left: $sidebar-width-icon;
      z-index: 10;

      .navbar-menu-wrapper {
        width: calc(100% - #{$sidebar-width-icon});
      }
    }

    .sidebar {
      width: $sidebar-width-icon;

      .navbar-brand-wrapper {
        width: $sidebar-width-icon;

        .brand-logo {
          display: none;
        }

        .brand-logo-mini {
          display: inline-block;
        }
      }

      &:hover {
        width: $sidebar-width-lg;
        box-shadow: 1px 0px 5px 2px rgba(0, 0, 0, 0.5);

        .navbar-brand-wrapper {
          width: $sidebar-width-lg;
        }

        .nav {
          .nav-item {
            .nav-link {
              .menu-title {
                display: block;
              }

              i {
                &.menu-arrow {
                  display: inline-block;
                }
              }

            }

            &.active {
              .nav-link {
                &[aria-expanded="false"] {
                  .menu-arrow {
                    transform: none;
                  }
                }
              }
            }
          }
        }
      }

      .navbar-brand-wrapper {

        .brand-logo {
          display: none;
        }

        .brand-logo-mini {
          display: inline-block;
        }
      }

      .nav {
        .nav-item {
          padding: 0 1rem;

          .nav-link {
            .menu-title {
              display: none;
            }

            i {
              &.menu-icon {
                margin-right: 0;
                margin-left: 0;
              }

              &.menu-arrow {
                display: none;
              }
            }
          }
        }

        &.sub-menu {
          .nav-item {
            padding: 0;
          }
        }
      }
    }

    .main-panel {
      margin-left: $sidebar-width-icon;
      width: calc(100% - #{$sidebar-width-icon});
    }
  }
}

// SCSS for RTL Layout
[dir="rtl"] {
  .main-panel {
    margin-left: 0;
    margin-right: $sidebar-width-lg;

    @media (max-width: 991px) {
      margin-right: 0 !important;
    }
  }

  .sidebar-icon-only {
    @media (min-width: 992px) {
      .sidebar {
        .nav {
          .nav-item {
            .nav-link {
              &[aria-expanded] {
                .menu-title {
                  border-radius: 5px 0 0 0;
                }
              }
            }

            &.hover-open {
              .nav-link {
                .menu-title {
                  right: 62px;
                  box-shadow: var(--menu-title-shadow-rtl);
                }
              }

              .collapse {
                left: auto;
                right: $sidebar-width-icon;
                border-radius: 0 0 0 5px;
                box-shadow: var(--submenu-shadow-rtl);
              }

              .hover-open {
                .collapse-multi-level {
                  top: 0;
                  left: auto;
                  right: $icon-only-collapse-width;
                  border-radius: 5px 0 0 5px;

                  .sub-menu {
                    padding-right: 0;
                    border-radius: 5px 0 0 5px;
                  }
                }
              }
            }
          }

          &.sub-menu {
            border-radius: 0 0 0 5px;
          }
        }
      }

      .main-panel {
        margin-left: 0;
        margin-right: $sidebar-width-icon;

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

  .sidebar-hover-only {
    .main-panel {
      margin-left: 0;
      margin-right: $sidebar-width-icon;

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