
.sidebar-pane {
  background-color: $sidebar_bg_color;
  color: $sidebar_fg_color;

  &:backdrop {
    background-color: $sidebar_backdrop_color;
    transition: background-color $backdrop_transition;
  }

  @if $rimless == 'true' {
    headerbar {
      border-top-right-radius: 0;
    }
  }

  @if $colorscheme != 'default' or $blackness == 'true' or $colortype == 'fixed' {
    listview,
    list:not(.navigation-sidebar),
    list.boxed-list {
      background-color: gtkmix(white, $sidebar_bg_color, 5%);
      color: $sidebar_fg_color;
    }

    list.boxed-list-separate {
      color: $sidebar_fg_color;
    }
  }

  flap,
  leaflet,
  navigation-view,
  overlay-split-view {
    @include transition-shadows($sidebar_shade_color);
  }

  banner > revealer > widget {
    background-color: gtkmix($accent_bg_color, $sidebar_bg_color, 30%);
    color: $sidebar_fg_color;

    &:backdrop {
      background-color: gtkmix($accent_bg_color, $sidebar_backdrop_color, 15%);
    }
  }

  &:dir(ltr), &.end:dir(rtl) {
    &, banner > revealer > widget {
      box-shadow: inset -1px 0 $sidebar_border_color;
    }
  }

  &:dir(rtl), &.end:dir(ltr) {
    &, banner > revealer > widget {
      box-shadow: inset 1px 0 $sidebar_border_color;
    }
  }
}

.sidebar-pane, .content-pane {
  toolbarview.undershoot-top scrolledwindow {
    @include undershoot(top, $sidebar_shade_color, $style: frame);

    columnview.view ~ undershoot.top {
      box-shadow: none;
    }
  }

  toolbarview.undershoot-bottom scrolledwindow {
    @include undershoot(bottom, $sidebar_shade_color, $style: frame);
  }

  scrolledwindow {
    &.undershoot-top {
      @include undershoot(top, $sidebar_shade_color, $style: frame);
    }

    &.undershoot-bottom {
      @include undershoot(bottom, $sidebar_shade_color, $style: frame);
    }

    &.undershoot-start {
      &:dir(ltr) { @include undershoot(left, $sidebar_shade_color, $style: frame); }
      &:dir(rtl) { @include undershoot(right, $sidebar_shade_color, $style: frame); }
    }

    &.undershoot-end {
      &:dir(ltr) { @include undershoot(right, $sidebar_shade_color, $style: frame); }
      &:dir(rtl) { @include undershoot(left, $sidebar_shade_color, $style: frame); }
    }
  }
}

/* Middle pane in three-pane setups */
.content-pane .sidebar-pane,
.sidebar-pane .content-pane {
  background-color: $secondary_sidebar_bg_color;
  color: $secondary_sidebar_fg_color;

  &:backdrop {
    background-color: $secondary_sidebar_backdrop_color;
    transition: background-color $backdrop_transition;
  }

  @if $rimless == 'true' {
    headerbar {
      border-radius: 0;
    }
  }

  toolbarview.undershoot-top scrolledwindow {
    @include undershoot(top, $secondary_sidebar_shade_color);
  }

  toolbarview.undershoot-bottom scrolledwindow {
    @include undershoot(bottom, $secondary_sidebar_shade_color);
  }

  scrolledwindow {
    &.undershoot-top {
      @include undershoot(top, $secondary_sidebar_shade_color);
    }

    &.undershoot-bottom {
      @include undershoot(bottom, $secondary_sidebar_shade_color);
    }

    &.undershoot-start {
      &:dir(ltr) { @include undershoot(left, $secondary_sidebar_shade_color); }
      &:dir(rtl) { @include undershoot(right, $secondary_sidebar_shade_color); }
    }

    &.undershoot-end {
      &:dir(ltr) { @include undershoot(right, $secondary_sidebar_shade_color); }
      &:dir(rtl) { @include undershoot(left, $secondary_sidebar_shade_color); }
    }
  }

  flap,
  leaflet,
  navigation-view,
  overlay-split-view {
    @include transition-shadows($secondary_sidebar_shade_color);
  }

  banner > revealer > widget {
    background-color: gtkmix($accent_bg_color, $secondary_sidebar_bg_color, 30%);
    color: $secondary_sidebar_fg_color;

    &:backdrop {
      background-color: gtkmix($accent_bg_color, $secondary_sidebar_backdrop_color, 15%);
    }
  }

  &:dir(ltr), &.end:dir(rtl) {
    &, banner > revealer > widget {
      box-shadow: inset -1px 0 $sidebar_border_color;
    }
  }

  &:dir(rtl), &.end:dir(ltr) {
    &, banner > revealer > widget {
      box-shadow: inset 1px 0 $sidebar_border_color;
    }
  }
}

@if $rimless == 'true' {
  .content-pane headerbar {
    border-top-left-radius: 0;
  }
}

.sidebar-pane .sidebar-pane {
  background-color: transparent;
  color: inherit;
}

stacksidebar row {
  padding: $base_padding + 4px $base_padding / 2 + 1px;

  > label {
    padding-left: $base_padding;
    padding-right: $base_padding;
  }

  &.needs-attention > label {
    @extend %needs_attention;
    background-size: $base_padding $base_padding, 0 0;
  }
}

%header_button_reset {
  color: $window_fg_color;

  &:focus:not(:hover):not(:active) { color: $window_fg_color; }

  &:hover { color: $window_fg_color; }

  &.keyboard-activating, &:active { color: $window_fg_color; }

  &:disabled { color: $window_fg_color; }

  &:checked {
    color: $window_fg_color;

    &:hover { color: $window_fg_color; }

    &:active { color: $window_fg_color; }

    &:disabled { color: $window_fg_color; }
  }
}

@if $colorscheme != 'default' or $blackness == 'true' or $colortype == 'fixed' {
  .content-pane {
    headerbar {
      color: $window_fg_color;

      button:not(.raised):not(.suggested-action):not(.destructive-action):not(.opaque) {
        &,
        &.arrow-button,
        &.image-button,
        &.image-text-button {
          @extend %header_button_reset;
        }
      }

      menubutton:not(.raised):not(.suggested-action):not(.destructive-action):not(.opaque) {
        &.image-button > button {
          @extend %header_button_reset;
        }
      }

      entry {
        color: $window_fg_color;
      }

      windowcontrols {
        > button:not(.raised):not(.suggested-action):not(.destructive-action):not(.opaque) {
          @if $window_button == 'mac' {
            &.minimize, &.maximize, &.close {
              color: transparent;

              &:hover, &:active {
                color: if($colorscheme != 'dracula', white, rgba(black, 0.5));
              }

              &:backdrop {
                > image { background-color: gtkalpha($window_fg_color, 0.3); }
          
                &:hover, &:active {
                  color: gtkalpha($window_fg_color, 0.45);
                }
              }
            }
          } @else {
            &.minimize, &.maximize, &.close {
              color: gtkalpha(currentColor, 0.75);

              &:hover {
                color: currentColor;
              }

              &:active {
                color: currentColor;
              }
            }
          }
        }
      }

      switch {
        background-color: gtkalpha($window_fg_color, .15);

        &:hover { background-color: gtkalpha($window_fg_color, .2); }
        &:active { background-color: gtkalpha($window_fg_color, .25); }

        &:hover > slider,
        &:active > slider {
          box-shadow: 0 2px 3px transparent, 0 0 0 6px gtkalpha($window_fg_color, .1);
        }

        &:checked {
          background-color: $accent_bg_color;
        }
      }
    }

    tabbar {
      .box {
        color: $window_fg_color;
      }

      tab {
        color: $window_fg_color;

        &:selected {
          color: $window_fg_color;
        }

        &:hover { color: $window_fg_color; }
        &:active { color: $window_fg_color; }
      }
    }
  }
}


/**********************
 * Navigation Sidebar *
 **********************/

.navigation-sidebar {
  padding: $base_padding 0; //only vertical padding. horizontal row size would clip

  &, &.view, &.view:disabled {
    background-color: transparent;
    color: inherit;
  }

  &.background {
    &, &:disabled {
      background-color: $window_bg_color;
      color: $window_fg_color;
    }
  }

  > row {
    min-height: $medium_size;
    padding: 0 $base_padding + 2px;
    border-radius: $menuitem_radius;
    margin: 0 $base_padding $base_padding / 2;
  }

  > separator {
    margin: $base_padding;
    background: none;
  }

  row {
    &.activatable {
      &:hover { background-color: $hover_color; }

      &:active { background-color: $active_color; }

      // this is for indicathing which row generated a popover see https://bugzilla.gnome.org/show_bug.cgi?id=754411
      &.has-open-popup { background-color: $hover_color; }

      &:selected {
        &:hover { background-color: $selected_hover_color; }

        &:active { background-color: $selected_active_color; }

        &.has-open-popup { background-color: $selected_hover_color; }
      }
    }

    &:selected {
      background-color: $selected_color;
    }
  }
}
