//
// Tab overrides
//
GeditNotebook.notebook,
ScratchMainWindow .notebook,
EphyNotebook.notebook,
MidoriNotebook .notebook,
TerminalWindow .notebook,
PantheonTerminalPantheonTerminalWindow .notebook {

  tab.reorderable-page.top, tab.top {
    &:active, &.active-page, &.active-page:hover {
      box-shadow: inset 0 1px $borders_color,
                  inset 0 -1px $borders_color,
                  inset 1px 0 $borders_color,
                  inset -1px 0 $borders_color;
    }
  }
}

TerminalWindow .notebook,
PantheonTerminalPantheonTerminalWindow .notebook {

  tab.reorderable-page.top, tab.top {
    padding-top: 7px;
    border-top-width: 3px;
  }

  &.header.top {
    box-shadow: inset 0  1px opacify($header_border, 1),
                inset 0 -1px $borders_color;
  }
}

//
// Evolution
//
// needed for webkit/GtkStyle/Evolution compatibility
GtkHTML {
  background-color: $base_color;
  color: $text_color;

  &:active {
    color: $selected_fg_color;
    background-color: $selected_bg_color;
  }
}

//
// Sushi
//
// used by gnome-font-viewer and sushi
SushiFontWidget {
  padding: 6px 12px;
}

//
// GNOME System Monitor
//
#gnome-system-monitor headerbar {
  // we have to do this because the headerbar is moved into the toolbar
  // position in DE's like Cinnamon
  box-shadow: none;
}

//
// GNOME Terminal
//
vte-terminal.terminal-screen {
  -TerminalScreen-background-darkness: 1.0;
  background-color: $terminal_bg;
  color: #fff;
}

terminal-screen-container,
terminal-screen-container scrollbar:not(slider) {
  border-color: transparent;
  background-color: transparent;
}

TerminalWindow {
  .notebook {
    tab .button {
      color: mix($bg_color, $fg_color, 35%);

      &:hover {
        color: $fg_color;
        border-color: $button_border;
        background-color: $button_bg;
      }
    }
    .active-page, .prelight-page {
      .button {
        @extend %undecorated_button;
        &:hover { color: lighten(red, 15%); @extend %undecorated_button;}
        &:active { color: $selected_bg_color; @extend %undecorated_button;}
      }
    }
  }
}

//
// MATE Terminal
//
vte-terminal {
  -TerminalScreen-background-darkness: 1.0;
  background-color: $terminal_bg;
  color: #fff;
}

//
// Terminator
//
.terminator-terminal-window > paned {
  background-color: $bg_color;

  &.wide {
    background-color: $bg_color;
  }
}

//
// Nautilus
//
.nautilus-canvas-item {
  border-radius: 2px;
}

%nautilus_canvas_item,
.nautilus-desktop.nautilus-canvas-item {
  color: $selected_fg_color;
  text-shadow: 1px 1px transparentize(black, 0.4);

  &:active { color: $fg_color; }
  &:selected { color: $selected_fg_color; }
}

.nautilus-canvas-item.dim-label,
.nautilus-list-dim-label {
  color: mix($fg_color, $bg_color, 50%);

  &:selected, &:selected:focus { color: mix($selected_fg_color, $selected_bg_color, 80%); }
}

.nautilus-window {
  paned > separator {
    background-image: _solid($dark_sidebar_border);

    @if $variant=='light' {
      &:dir(ltr) { margin-left: -1px; }
      &:dir(rtl) { margin-right: -1px; }
    }
  }
}

.nautilus-window,
filechooser {
  .csd.background, placessidebar list { background-color: transparent; }

  placessidebar.sidebar list {
    background-color: $dark_sidebar_bg;

    row.sidebar-row {
      border: none;
      color: $dark_sidebar_fg;

      &.has-open-popup,
      &:hover { background-color: transparentize($dark_sidebar_fg, 0.85); }

      &:disabled {
        &, label, image { color: transparentize($dark_sidebar_fg, 0.6); }
      }

      &:selected.has-open-popup,
      &:selected, &:selected:hover, &:active:hover {
        @extend %selected_items;

        .sidebar-icon { color: inherit; }
      }

      &:not(:selected) button.sidebar-button {
        color: $dark_sidebar_fg;

        &:hover { @include button(osd-hover); }
        &:active { @include button(active); }

        &:not(:hover):not(:active) > image { opacity: 0.5 };
      }

      &.sidebar-new-bookmark-row {
        color: $selected_bg_color;

        .sidebar-icon { color: inherit; }
      }

      &:drop(active):not(:disabled) {
        &, label, .sidebar-icon { color: $drop_target_color; }

        &:selected {
          &, label, .sidebar-icon { color: $selected_fg_color; }
          background-color: $drop_target_color;
        }
      }
    }

    separator { background-color: transparent; }
  }

  &.maximized placessidebar.sidebar { background-color: opacify($dark_sidebar_bg, 1); }
}

filechooser placessidebar > viewport.frame {
  border: 1px solid $borders_color;
  border-width: 1px 0 0 0;
}

NautilusQueryEditor .search-bar.toolbar {
  padding: 5px;
  box-shadow: none;
  background-color: $base_color;
}

.nautilus-circular-button.image-button.button {
  border-radius: 50%;
  -gtk-outline-radius: 50%;
  padding: 8px;
}

$disk_space_unknown: transparentize($fg_color, 0.5);
$disk_space_used: transparentize($selected_bg_color, 0.2);
$disk_space_free: darken($bg_color, 3%);

.disk-space-display {
  border-style: solid;
  border-width: 1px;

  &.unknown {
    background-color: $disk_space_unknown;
    border-color: darken($disk_space_unknown, 10%);
  }
  &.used {
    background-color: $disk_space_used;
    border-color: darken($disk_space_used, 10%);
  }
  &.free {
    background-color: $disk_space_free;
    border-color: darken($disk_space_free, 10%);
  }
}

// View
NautilusListView .view { border-bottom: 1px solid $borders_color; }

//
// Nemo
//
.nemo-desktop.nemo-canvas-item { @extend %nautilus_canvas_item; }

.nemo-window {

  .nemo-window-pane widget.entry {
    border: 1px solid;
    border-radius: 3px;

    @include entry(focus);

    &:selected { &:focus, & { @extend %selected_items; }}
  }

  .nemo-inactive-pane .view {
    background-color: darken($base_color, 5%);

    &:selected { &:focus, & { @extend %selected_items; }}
  }

  .places-treeview {
    -NemoPlacesTreeView-disk-full-bg-color: if($variant == 'light', #aaaaaa, $dark_sidebar_fg);
    -NemoPlacesTreeView-disk-full-fg-color: darken($selected_bg_color, 10%);
    -GtkTreeView-vertical-separator: 7;

    .view.cell:hover { background-color: transparentize($dark_sidebar_fg, 0.75); }
  }

  .nemo-places-sidebar.frame { border-width: 0; }

  .sidebar {
    color: $dark_sidebar_fg;
    background-color: $dark_sidebar_bg;

    .frame { border: none; }

    .view, row {
      background-color: $dark_sidebar_bg;
      color: $dark_sidebar_fg;

      &.cell:selected {
        background-color: $selected_bg_color;
        color: $selected_fg_color;
      }

      &.expander {
        color: mix($dark_sidebar_fg, $dark_sidebar_bg, 50%);

        &:hover { color: $dark_sidebar_fg; }
      }
    }
  }

  /* This is to keep the separator next to the sidebar dark so we don't see a gap
     between it and the trash bar */
  grid > paned > separator { background-image: _solid($borders_color); }

  // Fix padding of the statusbar buttons
  & widget .toolbar .image-button { padding: 0; }
}

//
// Caja
//

.caja-navigation-window {

  /* This seems to be needed to get proper highlighting in the caja view
   * when split panes are used. Without it the inactive pane isn't displayed
   * properly
   */
  .view .cell:selected {
    &, &:focus {
      background-image: _solid($selected_bg_color);

      @extend %selected_items;
    }
  }

  .frame { border-width: 1px 0 1px 0; }

  .caja-side-pane {

    .view,
    textview text,
    notebook {
      background-color: $dark_sidebar_bg;
      color: $dark_sidebar_fg;
    }

    .frame { border-width: 1px 0 0 0; }

    .view > box,
    viewport.frame {
      border: 1px solid $borders_color;
      border-width: 1px 0 0 0;
    }
  }
}

// need so you can see the caret when renaming
.caja-desktop,
.caja-navigation-window {
  .entry { caret-color: black; }
}

//
// Gedit
//
.gedit-headerbar-paned { color: $header_border; }
.gedit-side-panel-paned > separator { background-image: _solid($dark_sidebar_border); }
.gedit-bottom-panel-paned > separator { background-image: _solid($borders_color); }

.open-document-selector-treeview.view {
  padding: 3px 6px 3px 6px;
  border-color: $base_color;  // disable borders, making them transparent doesn't work for some reason

  &:hover {
    background-color: transparentize(black, 0.95);

    &:selected {
      color: $selected_fg_color;
      background-color: $selected_bg_color;
    }
  }
}

.open-document-selector-name-label {
  color: $fg_color;
}

.open-document-selector-path-label {
    color: mix($fg_color, $base_color, 50%);
    font-size: smaller;

    &:selected { color: transparentize($selected_fg_color, 0.1); }
}

.gedit-document-panel {
  background-color: $dark_sidebar_bg;

  row {
    color: $dark_sidebar_fg;
    background-color: transparentize($dark_sidebar_fg, 1);

    &:hover {
      background-color: transparentize($dark_sidebar_fg, 0.85);
    }
    &:active {
      color: $selected_fg_color;
      background-color: $selected_bg_color;

      button { color: $selected_fg_color; }
    }
    &:selected, &:selected:hover {
      color: $selected_fg_color;
      background-color: $selected_bg_color;
    }
    &:hover:not(:selected) button:active {
      color: $dark_sidebar_fg;
    }
  }

  row button {
    min-width: 22px;
    min-height: 22px;
    color: transparent;
    background: none;
    border: none;
    box-shadow: none;
    padding: 4px;

    image { color: inherit; }
  }

  row:hover:not(:selected) button {
    color: mix($bg_color, $fg_color, 35%);

    &:hover { color: lighten(red, 15%); }
    &:active { color: $fg_color; }
  }

  row:hover:selected button:hover {
    color: lighten(red, 20%);
    background: none;
    border: none;
    box-shadow: none;

    &:active { color: $selected_fg_color; }
  }
}

.gedit-document-panel-dragged-row {
  border: 1px solid $borders_color;
  background-color: darken($bg_color, 10%);
  color: $fg_color;
}

.gedit-side-panel-paned statusbar {
  border-top: 1px solid $borders_color;
  background-color: $bg_color;
}

.gedit-search-slider {
  @extend %search_slider;
}

.gedit-search-entry-occurrences-tag {
  color: transparentize($fg_color, 0.4);
  border: none;
  margin: 2px;
  padding: 2px;
}

.gedit-map-frame {
  border {
    @if $variant=='light' { border-color: transparentize(black, 0.7); }
    border-width: 0;

    &:dir(ltr) { border-left-width: 1px; }
    &:dir(rtl) { border-right-width: 1px; }
  }
}

%search_slider {
  background-color: lighten($bg_color, 2%);
  padding: 6px;
  border-color: $borders_color;
  border-radius: 0 0 2px 2px;
  border-width: 0 1px 1px 1px;
  border-style: solid;
}

//
// Pluma
//

.pluma-window statusbar frame > border { border: none; }

.pluma-window notebook > stack scrolledwindow { border-width: 0 0 1px 0; }

#pluma-status-combo-button {
  min-height: 0;
  padding: 0;

  border-top: none;
  border-bottom: none;
  border-radius: 0;
}

//
// Gnome Builder
//
.gb-search-entry-occurrences-tag { background: none; }

workbench.csd > stack.titlebar:not(headerbar) {
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;

  headerbar {
    &,
    &:first-child,
    &:last-child { border-radius: 3px 3px 0 0; }
  }
}

editortweak .linked > entry.search:focus + .gb-linked-scroller { border-top-color: $selected_bg_color; }

layouttab {
  background-color: $base_color;
}

layout {
  border: 1px solid $borders_color;
  -PnlDockBin-handle-size: 1;
}

eggsearchbar box.search-bar {
  border-bottom: 1px solid $borders_color;
}

pillbox {
  color: $selected_fg_color;
  background-color: $selected_bg_color;
  border-radius: 3px;

  &:disabled label { color: transparentize($selected_fg_color, 0.5) }
}

docktabstrip {
  padding: 0 6px;

  background-color: $bg_color;
  border-bottom: 1px solid $borders_color;

  docktab {
    min-height: 28px;
    border: solid transparent;
    border-width: 0 1px;

    label { opacity: 0.5; }
    &:checked, &:hover { label { opacity: 1; }}

    &:checked {
      border-color: $borders_color;
      background-color: $base_color;
    }
  }
}

dockbin {
  border: 1px solid $borders_color;
  -PnlDockBin-handle-size: 1;
}

dockpaned {
  border: 1px solid $borders_color;
}

dockoverlayedge {
  background-color: $bg_color;

  docktabstrip {
    padding: 0;
    border: none;
  }

  &.left-edge tab:checked,
  &.right-edge tab:checked {
    border-width: 1px 0;
  }
}

popover.messagepopover {
  &.background { padding: 0; }

  .popover-content-area { margin: 16px; }
  .popover-action-area {
    margin: 8px;

    button:not(:first-child):not(:last-child) { margin: 0 4px; }
  }
}

popover.popover-selector {
  padding: 0;

  list {
    row { padding: 5px 0; }
    row image { margin-left: 3px; margin-right: 10px; }
  }
}

entry.search.preferences-search {
  border: none;
  border-right: 1px solid $borders_color;
  border-bottom: 1px solid $borders_color;
  border-radius: 0;
}

preferences stacksidebar.sidebar {
  list { background-image: _solid($base_color); }

  list separator { background-color: transparent; }
}

devhelppanel entry:focus,
symboltreepanel entry:focus {
  border-color: $borders_color
}

button.run-arrow-button {
  min-width: 12px;
}

omnibar.linked > entry:not(:only-child) { border-style: solid; border-radius: 3px; margin-left: 1px; margin-right: 1px; }

gstyleslidein {
  #scale_box,
  #strings_controls,
  #palette_controls,
  #components_controls {
    button.toggle:checked { color: $fg_color; }
  }
}

configurationview {
  entry.flat { background: none; }
  list { border-width: 0; }
}

//
// Epiphany / Xreader
//
EphyWindow .floating-bar { // Epiphany overrides the floating-bar style, so reset it
  color: $fg_color;
}

.xreader-window .primary-toolbar .button.the-button-in-the-combobox {
	@include button(header-hover);

	&:hover { background-color: lighten($header_button_bg, 15%); }
	&:disabled { color: transparentize($header_fg, 0.4); }
}

//
// Gnome Calendar
//
calendar-view event {
  &.color-light label { color: black; }
  &.color-light.timed  label { color: $fg_color; }

  &.color-dark label { color: white; }
  &.color-dark.timed label { color: $fg_color; }
}

//
// Gnome Documents
//
.documents-scrolledwin.frame { border-width: 0; }

button.documents-load-more {
  border-width: 1px 0 0;
  border-radius: 0;
}

.documents-icon-bg {
  background-color: $selected_bg_color;
  color: $selected_fg_color;
  border-radius: 2px;
}

.documents-collection-icon {
  background-color: transparentize($fg_color, 0.7);
  border-radius: 2px;
}

.documents-favorite.button:active,
.documents-favorite.button:active:hover {
  color: lighten($selected_bg_color, 20%);
}

.documents-entry-tag {
  background-color: $selected_bg_color;
  color: $selected_fg_color;
  border-radius: 2px;
  border-width: 0;
  margin: 2px;
  padding: 4px;

  &:hover {
    color: $selected_fg_color;
    background-color: lighten($selected_bg_color, 4%);
  }
  &:active {
    color: $selected_fg_color;
    background-color: darken($selected_bg_color, 4%);
  }
}

//
// Gnome Photos
//
.photos-entry-tag { @extend .documents-entry-tag; }

.photos-collection-icon { @extend .documents-collection-icon; }

.photos-fade-in {
    opacity: 1.0;
    transition: opacity 0.2s ease-out;
}

.photos-fade-out {
    opacity: 0.0;
    transition: opacity 0.2s ease-out;
}

//
// Gnome Tweak Tool
//
.tweak-categories,
.tweak-category:not(:selected):not(:hover) {
  background-image: _solid($base_color);
}

.content-view.document-page {
  border-style: solid;
  border-width: 3px 3px 6px 4px;
  border-image: url("assets/thumbnail-frame.png") 3 3 6 4;
}

//
// Totem
//
TotemGrilo.vertical GdMainView.frame {
  border-width: 0;
}

//
// Synapse
//
SynapseGuiSelectionContainer *:selected,
SynapseGuiViewVirgilio *:selected { background-color: $selected_bg_color; }

//
// Transmission
//
.tr-workarea .undershoot,
.tr-workarea .overshoot {
  border-color: transparent; // Remove black border on over- and undershoot
}

//
// Fallback Mode/Budgie Panel/Mate Panel
//
.gnome-panel-menu-bar,
.mate-panel-menu-bar {
  color: $panel_fg;
  background-color: $panel_bg;

  &, menubar { background-color: $panel_bg; }

  menubar,
  #PanelApplet label,
  #PanelApplet image { color: $panel_fg; }

  menu > menuitem {
    color: $fg_color;
  }

  button:not(#tasklist-button) { @extend %panelbutton; }

  button,
  #tasklist-button {
    label, image { color: inherit; }
  }

  #tasklist-button {
    color: $panel_fg;
    border-radius: 0;
    border: none;
    padding-bottom: 0;
    padding-top: 0;

    &:hover { background-color: transparentize(white, 0.95); }

    &:checked,
    &:active {
      background-color: $selected_bg_color;

      label { color: white; }
    }
  }

  PanelSeparator {
    color: rgba(255,255,255, 0);
    padding-top: 4px;
    padding-bottom: 4px;
  }

  na-tray-applet {
    -NaTrayApplet-icon-padding: 1px;
  }
}

MatePanelAppletFrameDBus > MatePanelAppletFrameDBus {
    background-image: none;
    background-color: transparent;
    background-repeat: no-repeat;
    background-position: left;
}

.mintmenu:hover { background-color: lighten($panel_bg, 5%); }
.mintmenu:selected {
  color: $selected_fg_color;
  background-color: $selected_bg_color;
}

.wnck-pager {
    background-color: transparentize(black, 0.96);

    &:selected { background-color: transparentize($selected_bg_color, 0.4); }
    &:hover { background-color: transparentize($selected_bg_color, 0.8); }
}

// Xfce Panel
.xfce4-panel.panel {
  background-color: $xfce_panel_bg;
  color: $panel_fg;

  button {
    @extend %panelbutton;
  }

  frame > border { border: 0; }
  label { font-weight: normal; }
}

%panelbutton {
  color: $panel_fg;
  border-radius: 0;
  border: none;
  background-color: transparentize($xfce_panel_bg, 1);

  &:hover {
    border: none;
    background-color: lighten($xfce_panel_bg, 10%);
  }

  &:active, &:checked {
    color: $selected_fg_color;
    border: none;
    background-color: $selected_bg_color;
  }

  label, image { color: inherit; }
}

//
// Floating Bar
//
.floating-bar {
  background-color: $selected_bg_color;
  color: $selected_fg_color;

  &.top { border-radius: 0 0 2px 2px; }
  &.right { border-radius: 2px 0 0 2px; }
  &.bottom { border-radius: 2px 2px 0 0; }
  &.left { border-radius: 0 2px 2px 0; }

  .button {
    background-color: transparent;
    box-shadow: none;
    border: none;
  }
}

// Elementary Apps

//
// Birdie
//
BirdieWidgetsTweetList * {
  background-image: none;
  background-color: transparent;
}

//
// Marlin / Pantheon Files
//
MarlinViewWindow {

  *:selected, *:selected:focus {
    color: $selected_fg_color;
    background-color: $selected_bg_color;
    outline-color: transparent;
  }
  GtkIconView.view:selected {
    &, &:focus, &:hover, &:focus:hover { background-color: transparent; }
  }
  FMListView, FMColumnView { outline-color: transparent; }
}

.marlin-pathbar.pathbar {
  border-radius: 3px;
  padding-left: 4px;
  padding-right: 4px;

  @include entry(header-normal);

  &:focus { @include entry(header-focus) }

  &:disabled { @include entry(header-insensitive) }

  &:active, &:checked {
    color: $selected_bg_color;
  }
}

//
// Gala
//
.gala-notification {
    border: 1px solid rgba(0, 0, 0, 0.35);
    border-radius: 3px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    background-color: white;

  .title, .label {
    color: #5c616c;
  }
}

//
// Pantheon Terminal
//
PantheonTerminalPantheonTerminalWindow.background {
   background-color: transparent;
}

//
// Switchboard
//
SwitchboardCategoryView .view:selected,
SwitchboardCategoryView .view:selected:focus {
  color: $fg_color;
}

//
// Cinnamon Settings
//
.cs-header {
  padding: 6px;
  background-color: if($variant == 'light', darken($bg_color, 2%), darken($bg_color, 1%));
  border-bottom: 1px solid $borders_color;
}

//
// Xed
//
.xed-window {

  .xed-panel {
    &.side notebook tab.top { padding: 8px 12px; }
    &.bottom notebook.frame { border: none; }
  }

  .small-button { padding: 2px 4px; }

  .xed-searchbar {
    border: 0px solid $borders_color;
    border-top-width: 1px;
  }

  statusbar {
    & widget border { border-color: transparent; }
    // remove some extra padding
    button, widget frame, widget frame border { padding: 0; }
  }

  .xed-goto-line-box { @extend %search_slider }
}

//
// XReader
//
EvWindow .content-view .view:selected,
EvWindow .content-view .view:focus:selected {
  background-color: $selected_bg_color;
  color: $selected_fg_color;
}

%dark_sidebar_button {
  @include button(osd);

  &:hover { @include button(osd-hover); }
  &:active, &:checked { @include button(osd-active); }
  &:disabled { @include button(osd-insensitive); }
}

//
// Thunar
//
.thunar {
  .sidebar .view {
    background-color: $dark_sidebar_bg;
    color: $dark_sidebar_fg;

    &:selected, &:active {
      background: $selected_bg_color;
      color: $selected_fg_color;
    }
  }

  toolbar.horizontal button image {
    -gtk-icon-transform: scale(0.9);
  }

  @if $variant=='light' {
      toolbar {
        color: $header_fg;
        background-color: $header_bg;
      }
  }
}
