// Theme variables
$themes: (
        light: (
                background: #ffffff,
                text: mix($black, $white, 75%),
                heading: #a1a6b0,
                active-bg: $blue,
                active-text: $white,
                shadow: rgba(33, 40, 50, 0.15),
                logo-color: $blue
        ),
        dark: (
                background: #212529,
                text: #e9ecef,
                heading: #adb5bd,
                active-bg: #3d8bfd,
                active-text: #ffffff,
                shadow: rgba(0, 0, 0, 0.25),
                logo-color: #3d8bfd
        ),
        blue: (
                background: #4f39f6,
                text: #c6d2ff,
                heading: #6c757d,
                active-bg: #432dd7,
                active-text: #ffffff,
                shadow: rgba(0, 123, 255, 0.15),
                logo-color: $white,
        ),
        orange: (
                background: #fff5eb,
                text: #4a3f35,
                heading: #917c6f,
                active-bg: #fd7e14,
                active-text: #ffffff,
                shadow: rgba(255, 87, 34, 0.15),
                logo-color: #fd7e14
        )
);

$sidebarFontSize: 15px;
$sidebarFontWeight: 400;
$sidebarIconSize: 16px;
$sidebarMenuHeaderFontSize: 11px;
$sidebarMenuHeaderFontWeight: 300;

.sidebar-overly {
  @include media-breakpoint-down(sm) {
    position: fixed;
    height: 100%;
    width: 100%;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.2));
    z-index: 9999;
    top: 0;
    bottom: 0;
    right: 0;

    &.hide-sidebar {
      display: none;
    }

    .close-btn {
      display: block !important;
      position: absolute;
      right: 10px;
      color: mix($white, $black, 86%);

      i {
        font-size: 2.5em;
      }
    }
  }

  .close-btn {
    display: none;
  }
}

aside {
  &.sidebar {
    z-index: 5;
    width: 250px;
    overflow-y: auto;
    height: 100vh;
    top: 63px;
    transition: transform 0.3s ease, background-color 0.3s ease, color 0.3s ease;
    box-shadow: 0.11rem 0 1.85rem 0 rgba(33, 40, 50, 0.15) !important;
    background-color: #ffffff; // Default background

    // Apply themes
    @each $theme, $colors in $themes {
      &.theme-#{$theme} {
        background-color: map-get($colors, background) !important;
        color: map-get($colors, text);
        box-shadow: 0.11rem 0 1.85rem 0 map-get($colors, shadow) !important;

        .logo h4 {
          color: map-get($colors, logo-color);
        }

        .accordion {
          .sidebar-menu-heading {
            color: map-get($colors, heading);
          }

          .accordion-item {
            // Make sure accordion item has theme background
            background-color: map-get($colors, background);

            .accordion-header {
              background-color: map-get($colors, background);

              .accordion-button {
                background-color: map-get($colors, background);
                color: map-get($colors, text);

                &:not(.collapse) {
                  background-color: map-get($colors, background);
                  color: map-get($colors, text);
                }

                &:focus {
                  background-color: map-get($colors, background);
                }
              }
            }

            .accordion-body {
              background-color: map-get($colors, background);

              a {
                color: map-get($colors, text);

                &:hover {
                  background-color: rgba(map-get($colors, active-bg), 0.1);
                  border-radius: 4px;
                }
              }
            }
          }
        }

        .router-link-exact-active {
          background-color: map-get($colors, active-bg) !important;
          color: map-get($colors, active-text) !important;
        }
      }

      .log {
        h4 {
          color: map-get($colors, logo-color)!important;
        }
      }
    }

    .logo {
      img {
        width: 40px;
        height: auto;
      }

      h4 {
        font-size: 1.2rem;
        font-weight: bold;
        margin-bottom: 0;
        width: 165px;
        height: 1.5rem;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        //color: $blue; // Default color, will be overridden by theme
      }

      margin-top: 0.5rem;
      margin-bottom: 1rem;
    }

    &.full-height {
      top: 0;
    }

    @include media-breakpoint-down(sm) {
      z-index: 9999;
      width: 300px;
      position: fixed;
      top: 0;
      left: 0;
    }

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

    .accordion {
      padding: 10px 10px;

      .sidebar-menu-heading {
        font-size: $sidebarMenuHeaderFontSize;
        font-weight: $sidebarMenuHeaderFontWeight;
        color: #a1a6b0; // Default color, will be overridden by theme
      }

      .accordion-item {
        // Default background, will be overridden by theme
        background-color: #ffffff;

        .accordion-header {
          border-radius: 0;
          background-color: #ffffff; // Default, will be overridden by theme

          a {
            font-size: $sidebarFontSize;
            text-decoration: inherit;
            font-weight: $sidebarFontWeight;
          }

          .accordion-button {
            padding: 7px 7px;
            font-weight: $sidebarFontWeight;
            font-size: $sidebarFontSize;
            background-color: #ffffff; // Default, will be overridden by theme

            &:not(.collapse) {
              background-color: #ffffff; // Default, will be overridden by theme
              box-shadow: none;
              color: mix($black, $white, 75%); // Default, will be overridden by theme
            }

            &:after {
              background-size: 12px;
              width: 12px;
              height: 12px;
            }

            &.no-arrow {
              &:after {
                display: none;
              }
            }
          }
        }

        .accordion-body {
          padding: 7px 0;
          background-color: #ffffff; // Default, will be overridden by theme

          a {
            padding: 7px 15px;
            color: inherit;
            text-decoration: inherit;
            font-size: $sidebarFontSize;
            font-weight: $sidebarFontWeight;
            transition: background-color 0.2s ease;

            &:hover {
              background-color: rgba($blue, 0.1);
              border-radius: 4px;
            }

            i {
              margin-right: 6px;
            }
          }
        }
      }
    }

    .router-link-exact-active {
      background-color: $blue !important; // Default value, will be overridden by theme
      color: $white !important; // Default value, will be overridden by theme
      border-radius: 4px;
    }
  }
}