/************
 * Terminal *
 ************/
terminal-window > headerbar.titlebar > box.right > .close {
  margin-right: -2px;
  margin-left: -2px;
}

// Terminal needs a border to help with the case of overlapping windows.
terminal-window > box {
  border: 2px solid $titlebar_bg_color;
  
  &:backdrop {
    border: 2px solid $inactive_titlebar_bg_color;
  }
}

/******************
 * Control center *
 *****************/

window.csd {
  .titlebar > box > headerbar {
    padding: $mini_padding_em $standard_padding_em;
  }
  > box.horizontal > stack > box.vertical > widget > stack { 
    overlay > box.vertical > grid.horizontal > stack > button.toggle {
      @extend %flat_button;
    }

    viewport > grid.horizontal box row.activatable button.circular.image-button {
      @extend %flat_button;
    }
  }
}

headerbar .sidebar {
  border-right-style: none;
  border-right-color: transparent;
  background-color: transparent;
  margin: 0px;
}

/****************
 * Eye of GNOME *
 ****************/

// Next/Previous button shadows are cut off. See issue #10.
window > box > box > box > paned > overlay > grid > overlay > revealer {
  > button {
    margin: $tiny_padding;
  }

  > box.linked {
    padding: $tiny_padding;
  }
}

// Zoom in button is using the styling of the adjacent entry, which looks odd
window.csd > headerbar.titlebar > box.linked > button.image-button {
  border-image: none;
}

/**********
 * Evince *
 **********/
// Need to reduce the size of some entries in order to keep the design nice.
// Needed because entries need min-width of 80px to avoid cutting off letters.

window.csd > headerbar.toolbar > toolitem > box.raised > entry {
  min-width: $medium_size;

  &:first-child { // Current page number
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;

    &:focus { border-bottom-left-radius: 0;}

  }

  &:nth-child(2) { // Total page count
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;

    &:focus { border-bottom-right-radius: 0;}
  }
}



/************
 * Nautilus *
 ************/
// based css:
// https://gitlab.gnome.org/GNOME/nautilus/blob/master/src/resources/css/Adwaita.css
// hard-coded css:
// https://gitlab.gnome.org/GNOME/nautilus/blob/master/src/resources/css/nautilus.css

.nautilus-window row:selected {
  background-color: $accent_color;
  
  &:backdrop { background-color: backdrop($accent_color); }
}

.nautilus-window,
.nautilus-window notebook,
.nautilus-window notebook > stack {
  background-color: $base_color;
}

.nautilus-canvas-item {
  // border-radius: $material_radius;
}

.nautilus-canvas-item.dim-label,
.nautilus-list-dim-label {
  // @extend .dim-label;
}

%at-root %nautilus_desktop_nautilus_canvas_item,
.nautilus-desktop.nautilus-canvas-item:not(:selected) {
  // background-color: rgba($black, $lower_opacity);
  color: $inverse_fg_color;
  text-shadow: $shadow_1;
}

// Toolbar
@keyframes needs_attention_keyframes {
  to { background-color: $fill_color; }
}

.nautilus-operations-button-needs-attention {
  animation: needs_attention_keyframes $longer_duration $standard_curve 2 alternate;
}

.nautilus-operations-button-needs-attention-multiple {
  animation: needs_attention_keyframes $longer_duration $standard_curve 4 alternate;
}

// Floating status bar
.nautilus-window .floating-bar {
  @extend %osd;

  // @extend .toolbar.osd;

  min-height: $large_size;
  padding: 0;
  border-style: solid solid none;
  border-width: $border_size;
  border-color: $border_color;
  border-radius: (2px + 1px) (2px + 1px) 0 0;
  background-color: $base_color;
  background-clip: $extra_background_clip;
  transition: $longer_transition, border-width 0;

  &.bottom.left { // axes left border and border radius
    margin-right: 8px - 1px;
    border-left-style: none;
    border-top-left-radius: 0;
  }

  &.bottom.right { // axes right border and border radius
    margin-left: 8px - 1px;
    border-right-style: none;
    border-top-right-radius: 0;
  }

  button {
    margin: $tiny_padding;

    @extend %small_button;
  }
}

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

  &.unknown { background-color: $warning_color; }

  &.used { background-color: $primary_color; }

  &.free { background-color: $divider_color; }
}

// View
// Hide superfluous treeview drop target indication
.nautilus-list-view .view:not(.dnd) {
  // border-bottom: 1px solid $border_color;
}

.documents-entry-tag {
  @extend .entry-tag;
}

// Workaround for the double border of the searchbar since we use a revealer which
// always allocates at least 1 pixel
.nautilus-window {
  searchbar { border-top: 1px solid $border_color; }

  .searchbar-container { margin-top: -1px; }
}

.conflict-row:not(:selected) { background-color: mix($warning_color, $base_color, percentage($lower_opacity)); }

// Icon view
.nautilus-window flowboxchild {
  // > widget > box > .icon-background { background-color: black; }

  > widget > .icon-item-background {
    padding: 4px;
    border-radius: $material_radius;
  }

  &:selected {
    background-color: transparent;

    > widget > .icon-item-background { background-color: $primary_color; }
  }
}

// Batch rename dialog
dialog.background > box.dialog-vbox.vertical > grid.horizontal {
  > scrolledwindow.frame { border-style: none; }

  > box.horizontal:last-child {
    margin: -6px 0 0 -6px;
    border-top: 1px solid $border_color;

    > label { margin: 0 8px; }

    > box > button { border-radius: 0; }
  }
}

// Tweak to fix the messy sizing of the popover menu
.nautilus-window > popover.menu:not(:last-child) {
  padding: 3px;

  > stack > box > box > box {
    margin-top: -6px;

    > box {
      margin-bottom: -6px;

      &.linked { margin-top: 1px; }
    }
  }

  separator { margin-bottom: -2px; }
}

.nautilus-menu-sort-heading {
  // min-height: 26px;
  // padding-left: 5px;
  // padding-right: 5px;
  margin: 1px 3px;
  font-weight: 500;

  &:disabled { color: $hint_fg_color; }
}

// Make operations button circular
.nautilus-window headerbar > revealer > button { @extend %circular_button; }

// Ensure paned separator rendering. See issue #84 for details.
.nautilus-window paned > separator { background-color: $bg_color; }


/*********
 * gedit *
 *********/
// based css:
// https://git.gnome.org/browse/gedit/tree/gedit/resources/css/gedit.adwaita.css
// hard-coded css:
// https://git.gnome.org/browse/gedit/tree/gedit/resources/css/gedit-style.css

// Only normal state is handle
.open-document-selector-name-label {
  // font-weight: bold;
}

// Only normal state is handle
.open-document-selector-path-label {
  color: $secondary_fg_color;
  font-size: smaller;

  &:selected { color: $inverse_secondary_fg_color; }
}

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

  // Try to look as the notebook tab close button
  row button.flat {
    margin-top: 8px;
    margin-bottom: 8px;

    @extend %small_button;
  }
}

.gedit-document-panel-group-row:not(:first-child) {
  border-top: 1px solid $border_color;
}

.gedit-side-panel-paned statusbar {
  border-top: 1px solid $border_color;
}

.gedit-search-slider {
  border-radius: 0 0 $pocillo_radius $pocillo_radius;
  padding: $small_padding;
  margin: 0 $standard_padding $standard_padding $standard_padding;
  background-color: $bg_color;
  box-shadow: $shadow_2;
  
  .linked > button,
  .linked > button:nth-child(n-2) {
    @include entry(normal);
    @extend %linked;
    
    &:disabled {
      @include entry(disabled);
    }
    &:hover {
      box-shadow: $shadow_2;
    }
    &:active {
      @include entry(focus);
    }
  }
}

frame.gedit-map-frame > border {
  &:dir(ltr) { border-style: none none none solid; }
  &:dir(rtl) { border-style: none solid none none; }
}


/**************
 * Tweak Tool *
 **************/
// hard-coded css:
// https://git.gnome.org/browse/gnome-tweak-tool/tree/data/shell.css

// the sidebar
.tweak-categories {
  // padding: 4px 0;
  // background-color: shade(@theme_bg_color, 0.99);
  background-image: image($lighter_bg_color);
  .tweak-category:selected {
    background-color: $accent_color;
    
    &:backdrop { background-color: backdrop($accent_color); }
  }

  separator { @extend %hide_separators; }
}

.tweak {
  // padding-top: 3px;
  padding: 3px;

  &.title:hover { box-shadow: none; }
}

.tweak-group-white,
.tweak-white,
.tweak-white:hover {
  // background-color: white;
  background-image: image($base_color);
}

.tweak-startup,
.tweak-startup:hover {
  // background-color: lighter(shade(@theme_bg_color, 0.9));
  background-image: image($base_color);
}

.tweak-group-startup {
  // background-color: @view_separators;
  background-image: image($base_color);
  border: 1px solid $border_color;
}

//
// Workaround for 3.26
//

row#Focus,
row#StaticWorkspaceTweak,
row#PrimaryWorkspaceTweak {
  padding: 0;
  border: 1px solid $border_color;

  row:not(:last-child) { border-bottom: 1px solid $border_color; }
}

// Add more spaces between title and list
row#Focus,
row#PrimaryWorkspaceTweak {
  margin-top: 4px;
}


/***********
 * Builder *
 ***********/
// based css for 3.26:
// https://git.gnome.org/browse/gnome-builder/tree/data/themes?h=gnome-builder-3-26

window.workbench > stack.titlebar headerbar omnibar.linked.horizontal {
  & entry:first-child {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    padding-right: 3px;
    border-right: 0 transparent;
  }

  & button:last-child {
    @include entry(normal);
    background-color: $bg_color;
    padding-left: 1em;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-left: 0 transparent;

    &:hover {
      background-color: $base_color;
    }
  }
}

button.dzlmenubutton image {
  min-width: $large_size - 6px;

  &.arrow { min-width: $large_size - 9px; }
}

button.dzlmenubuttonitem {
  color: $fg_color;
  font-weight: normal;

  &:disabled { color: $disabled_fg_color; }
}

idelayoutstackheader {
  border-bottom: 1px solid $border_color;

  button:checked { color: $fg_color; }
}

// utilities stack switcher
ideeditorutilities > dzldockpaned > box > stackswitcher {
  background-color: $bg_color;

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

  button {
    background-color: transparent;

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


// buildui panel
ideeditorsidebar notebook header {
  background: transparent;
}

popover.messagepopover {
  // padding: 0;

  list {
    border: 1px solid $border_color;

    row:not(:last-child) { border-bottom: 1px solid $border_color; }
  }
}


/**********
 * Photos *
 **********/
// based css:
// https://git.gnome.org/browse/gnome-photos/tree/data/Adwaita.css

GdMainIconView.content-view {
  -GdMainIconView-icon-size: 48;

  // Make spinner visible on both dark and bright backgrounds w/o making
  // it look ugly/weird.
  // &.cell:active { color: $hint_fg_color; }
}

.documents-counter {
  margin: 8px;
  border-radius: $circular_radius;
  box-shadow: $shadow_2;
  background-color: $accent_color;
  color: $inverse_fg_color;
  font-weight: bold;
}

.photos-entry-tag {
  @extend .entry-tag;
}

.documents-scrolledwin.frame {
  border-style: none;

  frame.content-view > border { border-style: none; }
}

.photos-icon-bg {
}

.photos-fade-in {
  opacity: 1;
  transition: opacity $shorter_duration $deceleration_curve;
}

.photos-fade-out {
  opacity: 0;
  transition: opacity $shorter_duration $deceleration_curve;
}

.photos-collection-icon {
}

overlay grid.horizontal > revealer > scrolledwindow.frame {
  &:dir(ltr) { border-style: none none none solid; }
  &:dir(rtl) { border-style: none solid none none; }
}


/*********
 * Music *
 *********/
// hard-coded css:
// https://git.gnome.org/browse/gnome-music/tree/data/application.css

.side-panel:dir(ltr) {
  // border-width: 0 1px 0 0;
  border-style: solid;
  border-color: $border_color;
}

.side-panel:dir(rtl) {
  // border-width: 0 0 0 1px;
  border-style: solid;
  border-color: $border_color;
}

.side-panel .view {
  // background-color: mix(@theme_fg_color, @theme_bg_color, 0.9);
  background-image: image($lighter_bg_color);

  &:hover { background-image: image(mix($fg_color, $lighter_bg_color, percentage(0.05))); }
}

.side-panel .view:selected {
  // background-color: mix(@theme_fg_color, @theme_bg_color, 0.5);
  background-image: image($primary_color);

  &:hover { background-image: image(mix($inverse_fg_color, $primary_color, percentage(0.05))); }
}

.songs-list {
  // box-shadow: inset 0 -1px shade(@borders, 1.30);
  // background-color: @theme_bg_color;

  &:hover { background-image: image($row_fill_color); }
}

frame.documents-dropdown {
  @extend %toolbar_osd;

  margin: 8px;

  > border { border: none; }
}

box.vertical > revealer > toolbar.search-bar {
  border-bottom: 1px solid $border_color;
  background-clip: border-box; // avoid black border

  button > widget {
    -gtk-icon-source: -gtk-icontheme("pan-down-symbolic");
    // -GtkArrow-arrow-scaling: 1;
  }
}


/*********
 * To Do *
 *********/
taskrow {
  transition: $shorter_transition;
  margin: 0 -8px;

  &:hover { transition: none; }

  label { margin: 0 8px; }

  image { min-width: 16px; }
}

task-list-view > box > revealer > box > button {
  margin: (12px * 2 - $large_size) / 2;
}


/*******
 * eog *
 *******/
#eog-thumb-nav {
  scrolledwindow { border-top: none; }

  button { -gtk-outline-radius: 2px; }
}


/*************
 * Evolution *
 *************/
frame.taskbar > border { border-style: solid none none; }

box.vertical > paned.horizontal notebook widget .frame { border-style: none; }


/********
 * gitg *
 ********/
frame.commit-frame > border { border-style: solid none none; }


/**************
 * Characters *
 **************/
box.dialog-vbox scrolledwindow.related { border: 1px solid $border_color; }

list.categories { background-image: image($lighter_bg_color); }


/*********
 * Boxes *
 *********/
.transparent-bg + stack overlay > label {
  min-height: 24px;
  padding: 0 4px;
  border-radius: $material_radius;
  background-color: rgba($black, $lower_opacity);
  color: $inverse_fg_color;
}


/**************
 * Calculator *
 **************/
button.title label { min-height: $large_size; }


/*********
 * Geary *
 *********/
// fix a issue that separator seems double
.geary-titlebar-left {
  &:dir(ltr) {
    margin-right: 5px;
    padding-right: 0;
  }

  &:dir(rtl) {
    margin-left: 5px;
    padding-left: 0;
  }

  > separator { background-color: rgba($black, 0.05); }
}

.geary-titlebar-right {
  &:dir(ltr) { margin-left: -5px; }

  &:dir(rtl) { margin-right: -5px; }
}

// fix clipped dialog buttons
dialog.background > box.dialog-vbox > box.dialog-action-box > buttonbox.dialog-action-area {
  padding: 12px;
}

// dark text in embedded composer
$geary_composer_color:  if($titlebar == 'dark',
                          $light_fg_color,
                          $dark_fg_color);

// We need a specific selector to override some styling for buttons in lists 
.geary-expanded > .geary-composer-embed > widget headerbar image,
.geary-expanded > .geary-composer-embed > widget headerbar label {
  color: $geary_composer_color;
}
