// 3rd party application styles

// *********
// * Gedit *
// *********

.org-gnome-gedit, .gedit-side-panel-paned {
  notebook > header {
    background-color: $headerbar_bg_color;
    &:backdrop { background-color: $headerbar_backdrop_color; }
    box-shadow: inset 0 -1px $headerbar_shade_color;
  }
}

.gedit-search-slider {
  // gives gedit search entry some padding and a border
  // otherwise it's right under the headerbar
  background: $bg_color;
  border: 1px solid $borders_color;
  border-top-style: none;
  padding: 4px 8px;
  border-radius: 0 0 $button_radius $button_radius;

  button {
    padding-top: 7px;
    padding-bottom: 7px;
  }
}

.gedit-document-panel {
  // 'documents' pane

  background-color: $bg_color;

  row.activatable {
    padding: 6px;
  }

  row button {
    // 'close' button
    min-width: 22px;
    min-height: 22px;
    padding: 0;
    margin: 0;
    border: none;
  }

  row:hover button {
    &:hover {
      background-color: gtkalpha(currentColor, .15);
    }

    &:active {
      background-color: gtkalpha(currentColor, .3);
    }
  }

  row:hover:selected button:hover {
    color: $fg_color;
  }
}

// *********
// * XFCE4 *
// *********

.XfceHeading {
  background-color: $base_color;
  margin: 0;
  padding: 0;
  border-width: 0;
}

XfdesktopIconView.view {
  background: transparent;
  color: $osd_fg_color;
  border-radius: $button_radius;
  &:active {
    background: gtkalpha(gtkmix(black, $selected_bg_color, 15%), 0.5);
    text-shadow: 0 1px 1px black;
  }
  .label { text-shadow: 1px 1px 2px black; }
  .rubberband {
    @extend rubberband;
    border-radius: 0;
  }
}

// Xfce4 panel
@define-color panel_bg_color black;
@define-color panel_fg_color white;
$panel_bg_color: gtkcolor(panel_bg_color);
$panel_fg_color: gtkcolor(panel_fg_color);
$panel_transition_duration: 250ms;
.xfce4-panel.background {
  border: none; 
  background-color: $panel_bg_color;
  color: $panel_fg_color;
  transition-duration: $panel_transition_duration;

  .tasklist button,
  #actions-button,
  #clock-button { margin: 0 1px; }

  &.horizontal .tasklist {
    button {
      margin: 0 1px;
      label { padding-right: 3px; }
    }
  }
  &.vertical .tasklist {
    button {
      margin: 1px 0;
      label { padding-bottom: 3px; }
    }
  }

  .tasklist image {
    //-gtk-icon-transform: scale(0); margin: -10px; // Removes the icon
    margin-left: 2px;
    margin-right: 2px;
  }

  button {
    label {
      padding-left: 6px;
      padding-right: 6px;
    }
  }

  button {
    padding: 0 6px;
    min-height: 12px;
    min-width: 12px;
    border-radius: 24px;
    color: $panel_fg_color;
    transition-duration: $panel_transition_duration;
    @include button(undecorated);

    &:disabled {
      background-color: transparent;
      color: gtkalpha($panel_fg_color, 0.2);
    }

    &:hover:not(:active):not(:checked) {
      color: $panel_fg_color;
      background-color: gtkalpha($panel_fg_color, 0.25);
      background-image: none;
    }

    &:checked {
      background-color: gtkalpha($panel_fg_color, 0.2);
      color: $panel_fg_color;

      &:hover { background-color: gtkalpha($panel_fg_color, 0.35); }

      &:disabled {
        @include button(undecorated);
        color: gtkalpha($panel_fg_color, 0.2);
      }
    }

    &:drop(active) {
      color: $drop_target_color;
      border-color: $drop_target_color;
      box-shadow: inset 0 0 0 1px $drop_target_color;
    }

    entry { caret-color: $text_color; }
    menu {
      -gtk-icon-effect: none;

      text-shadow: none;
      // Theme pulseaudio-plugin's mpris buttons
      .linked button {
        @extend %linked;
        @include button(normal, $menu_color, $text_color);
        &:disabled {
          @include button(insensitive);
          border-color: gtkalpha($borders_color, $disabled_opacity);
        }
      }
    }
  }

  progressbar {
    margin: 0;

    &.horizontal {
      trough {
        min-height: 6px;
        padding: 0;
      }
      progress { min-height: 4px; }
    }

    &.vertical {
      trough {
        min-width: 6px;
        padding: 0;
      }
      progress { min-width: 4px; }
    }

    progress { border-radius: 0px; }

    trough {
      background: gtkshade($panel_bg_color, 0.7);
      border-radius: 0px;
      border-color: gtkshade($panel_bg_color, 0.4);
    }
  }
}

// Workspace switcher
wnck-pager {
  background-color: gtkalpha($panel_fg_color, 0.1);
  &:selected { background-color: gtkshade($selected_bg_color, 0.88); }
  &:hover { background-color: $selected_bg_color; }
}

// Xfwm4's alt-tab dialog, aka "tabwin"
#xfwm-tabwin {
  padding: 12px;
  border-radius: $window_radius;
  // Set the application icon- and preview-size
  -XfwmTabwinWidget-icon-size: 64px;
  -XfwmTabwinWidget-preview-size: 128px;

  .tabwin-app-grid button {
    min-width: 96px;
    min-height: 96px;
  }
}

// Whisker menu
window#whiskermenu-window {
  button { transition: none; }
}

#whiskermenu-button {
  transition: none;
}

// XfceNotifyWindow
#XfceNotifyWindow {
  border-radius: $menu_radius;
  background-color: $base_color;
}

// ********
// * Nemo *
// ********

%desktop-canvas-item,
.nemo-desktop.nemo-canvas-item {
  color: $selected_fg_color;
  text-shadow: 1px 1px 2px transparentize(black, 0.2);
}

.nemo-properties-dialog {
  .dialog-action-box .dialog-action-area {
    // add margin to preferences buttons
    margin: 2px 6px 4px;
  }

  toolbar stackswitcher.linked button {
    margin-right: 0;

    &:backdrop {
      color: $backdrop_fg_color;
      background-color: $backdrop_bg_color;
    }
  }
}

.nemo-window {
  .sidebar {
    scrolledwindow.frame.nemo-places-sidebar {
      // get rid of double border in sidebar
      border: none;
    }

    viewport.frame box.vertical treeview.view.places-treeview {
      // use sidebar bg color
      background-image: image($bg_color);
      border-radius: 0; // get rid of weird radius on selected rows

      &:selected {
        background: $selected_bg_color;
      }

      &:not(:selected) {
        &:not(:backdrop):hover {
          $base_hover_color: gtkalpha($fg_color, 0.05);
          background-image: image($base_hover_color);
        }
      }
    }
  }

  .nemo-inactive-pane .view,
  .nemo-inactive-pane iconview {
    // Shades the background of the inactive pane
    background-color: $backdrop_bg_color;
  }

  .nemo-window-pane {
    widget.entry {
      // Add border around rename text entry
      border: 1px solid;
      border-radius: 3px;
      color: $fg_color;
      border-color: $selected_bg_color;
      background-color: $bg_color;
    }

    widget.entry:selected {
      // Add highlighting to selected text in rename text entry
      border: 1px solid;
      border-radius: 3px;
      color: $selected_fg_color;
      border-color: $selected_bg_color;
      background-color: $selected_bg_color;
    }
  }

  toolbar.horizontal.primary-toolbar {
    // add border under toolbar
    border-bottom: 1px solid $borders_color;

    widget.linked.raised button {
      // use proper icons for next and left in stackswitcher-like pathbar
      &:first-child widget {
        -gtk-icon-source: -gtk-icontheme('go-previous-symbolic');
      }
      &:last-child widget {
        -gtk-icon-source: -gtk-icontheme('go-next-symbolic');
      }
    }

    toolitem box widget * {
      // reset toolbar button dimensions
      min-height: 0;
      min-width: 0;
    }

    .linked button {
      // link linked buttons
      margin-right: 0;
    }
  }
}

// ************
// * Chromium *
// ************

window.background.chromium {
  background-color: if($variant == 'light', $bg_color, gtkmix(currentColor, $bg_color, 10%));

  // If there was/is an incognito class then https://github.com/lassekongo83/adw-gtk3/issues/147
  // could be fixed, so disabled for now until a better solution is found.
  //headerbar.titlebar button.titlebutton {
  //  color: white;
  //}

  entry,
  > button {
    border-color: gtkmix(currentColor, $bg_color, 27%);
    background-color: gtkmix(currentColor, $bg_color, 20%);
  }

  textview.view {
    background-color: $base_color;
  }

  menuitem {
    border-radius: 0;
  }
}

// ******************
// * gnome-calendar *
// ******************

.org-gnome-Calendar {
  .titlebar .text-button { @extend %colored_buttons; }
}

// ***********
// * Firefox *
// ***********

#MozillaGtkWidget.background {
  button { font-weight: initial; }

  // https://github.com/lassekongo83/adw-gtk3/issues/234
  check, radio {
    padding: 0;
    min-height: 12px;
    min-width: 12px;
  }
}

// Make sure text selection is somewhat visible on websites with various backgrounds
// in both chromium and firefox
window.background.chromium,
#MozillaGtkWidget.background {
  selection {
    &:focus, & {
      background-color: $selected_bg_color;
      color: $selected_fg_color;
    }
  }
}

// https://github.com/lassekongo83/adw-gtk3/issues/283
#MozillaGtkWidget {
  > widget > frame > border { border-top-color: transparent; }
}

// ******************
// * gnome-terminal *
// ******************

terminal-window notebook > header {
  &.top,
  &.bottom {
    tabs {
      &:not(:only-child) {
        &:first-child { margin-left: 0px; }
        &:last-child { margin-right: 0px; }
      }
    }
  }
}

terminal-window notebook {
  scrollbar {
    slider {
      // Fix for Ubuntu
      // avoids scrollbar protruding from the terminal window on wayland session
      // workaround for https://bugs.launchpad.net/ubuntu/+source/gnome-terminal/+bug/1720651
      margin: 0;
      border-width: 3px;
    }
  }
}

// ********
// * Caja *
// ********

window.background.caja-navigation-window #Toolbar {
  border-bottom: 1px solid $borders_color;

  &:backdrop {
    background-color: $backdrop_bg_color;
    border-color: $backdrop_borders_color;
  }
}

.caja-pathbar button {
  min-width: 32px;
  border-radius: 0;
  border-right-width: 0;
  margin-right: -3px;

  &.slider-button:nth-child(odd) {
    border-radius: $button_radius 0px 0px $button_radius;
  }
  &.slider-button:nth-child(even) {
    border-radius: 0 $button_radius $button_radius 0;
    border-right-width: 1px;
  }
}

.caja-side-pane .frame {
  border-style: solid none none none;
}
.caja-notebook {
  .view, .view.frame, .frame {
    border-left: 0;
    border-right: 0;
  }
}

// Gets rid of fat separator on backdrop
.caja-side-pane + separator + box:backdrop {
  background: $backdrop_bg_color;
}

.caja-navigation-window,
.caja-desktop-window {
  widget.view widget.entry {
    background: gtkmix(currentColor, $bg_color, 5%);
    color: $fg_color;
    border-color: $borders_color;
  
    &:selected {
      background: $selected_bg_color;
      color: $selected_fg_color;
    }
  }
}

// desktop mode
.caja-desktop.caja-canvas-item {
  @extend %desktop-canvas-item;
}

// ************
// * GNU Cash *
// ************

#gnc-id-main-window {
  // https://github.com/lassekongo83/adw-gtk3/issues/148
  treeview.view {
    &:not(:selected):hover {
      background-color: gtkmix(currentColor, $base_color, 7%);
    }
  }
}

gnc-id-sheet-list { background-color: $window_bg_color; }

// *********
// * Geary *
// *********

geary-conversation-viewer#conversation_viewer {
  list.background.conversation-listbox.content {
    background-color: $bg_color;
    border: none;
    border-radius: 0;

    > row.activatable {
      border: 1px solid $borders_color;
      border-bottom-width: 0;

      &:first-child {
        border-top-left-radius: $card_radius;
        border-top-right-radius: $card_radius;
      }
    }

    .geary-attachment-pane {
      border-radius: 0 0 $card_radius $card_radius;

      actionbar.background {
        background-color: transparent;

        > revealer > box {
          border-radius: 0 0 $card_radius $card_radius;
        }
      }
    }

    geary-composer-editor {
      > box.background {
        background-color: transparent;

        > actionbar > revealer > box {
          border-radius: 0 0 $card_radius $card_radius;
        }
      }
    }
  }

  searchbar {
    > revealer > box {
      background-color: $base_color;
      border-color: $borders_color;
    }
  }
}

.geary-folder-popover-list-row {
  border-radius: 0;
  margin: 0;
}

// newer versions
.geary-main-window leaflet > leaflet > box {
  &:first-child {
    background-color: $sidebar_bg_color;
    &:backdrop { background-color: $sidebar_backdrop_color; }
  }
}

.geary-main-window leaflet > box {
  &:first-child > .titlebar {
    background-color: $sidebar_bg_color;
    background-image: none;
    border-bottom: transparent;
    box-shadow: none;
    &:backdrop { background-color: $sidebar_backdrop_color; }

    button {
      background-color: transparent;
      &:hover { background-color: $titlebutton_normal_hover; }
      &:hover:active, &:active, &:hover:checked, &:checked  { background-color: $titlebutton_normal_active; }
      &:backdrop { background: transparent; }
      &:backdrop:hover { background: $titlebutton_backdrop_hover; }
    }
  }

  &:not(:first-child) > .titlebar {
    border-bottom: transparent;
    box-shadow: none;
    &:backdrop {
      background-image: none;
      background-color: $new_title_bg_color;
    }
  }
}

.geary-main-window separator.sidebar {
  background-color: $borders_color;
}

.geary-main-window .titlebar .image-button {
  padding: 0 6px;
}

.geary-folder {
  .sidebar.view {
    &:selected {
      background-color: $selected_color;
      &:hover { background-color: $selected_hover_color; }
    }
    &:hover {
      background-color: $hover_color;
    }
  }
}

// ************
// * Inkscape *
// ************

#DialogNotebook treeview.view:hover {
  background-color: gtkalpha($selected_bg_color, .5);
}

// **********
// * Budgie *
// **********

.budgie-panel {
  button {
    min-height: 16px;
    min-width: 16px;
    padding: 0;
    border-radius: 0;

    &.flat.launcher {
      padding: 0;
    }
  }

  &.horizontal button,
  #tasklist-button {
    padding: 0 4px;
  }

  &.vertical button {
    padding: 4px 0;
  }

  &.vertical #tasklist-button {
    min-height: 32px;
  }
}
