@import "palette";

/* set $ambiance to null, unless already defined */
$ambiance: null !default;

/***********
 * Tweak Tool *
 ***********/
 list.tweak-categories separator {
    // hide sidebar separators
    // make the sidebar look like a normal sidebar
    background: transparent;
  }

  /***********
   * Nautilus *
   ***********/
  .nautilus-window {
    // keep details box visible
    // details box looks ugly when many items are selected and it floats above the orange
    background-image: none;
    background-color: if($variant=='light', white, $base_color);
    &:backdrop { background-color: $backdrop_base_color }

    // Makes icons less bright in backdrop
    @at-root %dim_icons_in_backdrop,
    & *scrolledwindow:backdrop { opacity: 0.9; }

    infobar {
      background-color: if($variant=="light", lighten($silk, 10%), $slate);
      &:backdrop { background-color: $backdrop_bg_color; }
    }

    paned box.floating-bar {
      background-color: $bg_color;
      border-style: solid;
      border-color: if($variant=='light', lighten($borders_color, 8.3%), darken($borders_color, 1%));
      border-width: 1px 0 0 1px;
      border-radius: $button_radius 0 0 0;

      button:dir(ltr).circular.flat.image-button {
        background: radial-gradient(circle at 50%, white 35%, $bg_color 1%);
        color: $destructive_color;
      }

      button:dir(ltr).circular.flat.image-button:hover {
        border: 1px solid $borders_color;
        background: radial-gradient(circle at 50%, white 30%, $base_hover_color 16%);
        color: lighten($destructive_color, 5%);

      }
    }

    .searchbar-container searchbar {
      // get rid of a 1px white line shown at the top of the window
      // applies to the desktop too
      background: transparent;
      border-color: transparent;
    }

    treeview:drop(active):focus {
      // drop target green bottom border was missing
      border-bottom: 1px solid $drop_target_color;
    }

    treeview.view header button {
      background-color: if($variant=='light', $base_color, $base_color);
      background-image: none;
      border-color: transparentize($borders_color, 0.6);
      border-left: 1px;

      &:hover {background-color: $bg_color;}
      &:backdrop { background-color: $backdrop_base_color;}
    }

    .nautilus-list-view .view {
      border-bottom: 1px solid transparentize($borders_color, 0.8);

      // Hide superfluous treeview drop target indication
      &.dnd { border-style: none; }
    }

    notebook > header {
      background: $bg_color;
    }

    paned > separator {
      // separator between sidebar and main window view
      background-image: image(if($variant=='light', transparentize($borders_color, 0.6), darken($borders_color, 1%)));
      &:backdrop { background-image: image(transparentize($borders_color, 0.7)); }
    }

    // custom code from nautilus Adwaita.css for entries and the pathbar
    entry.search > * {
      margin: 5px;
    }

    .path-bar-box {
      border-radius: 5px;
      border: 1px solid if($ambiance, darken($headerbar_bg_color, 9%), $borders_color);
      &:backdrop { border-color: if($ambiance, $headerbar_bg_color, $backdrop_borders_color);}
      background-color: if($ambiance, lighten($headerbar_bg_color, 6.5%), $bg_color);
      padding-right: 6px;
      &:backdrop { border-color: if($ambiance, darken($inkstone, 9%), $backdrop_borders_color); }
    }

    .nautilus-path-bar button {
      margin: 0px;
    }

    .nautilus-path-bar button:first-child {
      border-width: 0px 1px 0px 0px;
      border-radius: 3.5px 0px 0px 3.5px;
    }

    .nautilus-path-bar button:not(:first-child) {
      border-width: 0px 1px 0px 1px;
      border-radius: 0px 0px 0px 0px;
    }

    .nautilus-path-bar button:not(:checked) image { opacity: 0.8; } /* dim the icon when not checked */

    // This is the Icon + Text beneath - it's one widget
    .nautilus-canvas-item {
      outline-width: 0;
      // First, remove the background
      background-color: rgba(255, 255, 255, 0.1);
      // Then bring it back for when it receives a direction
      &:selected:not(:backdrop) {
        &:dir(ltr) { background-color: $selected_bg_color; }
        &:not(:dir(ltr)) { background-color: rgba(175, 175, 175, 0.5); }
      }

      &:backdrop:selected {
        background-color: $selected_bg_color;
        color: $backdrop_selected_fg_color;
      }
    }
}

// Nautilus disk space dialogue styling
// Copied from the nautilus adwaita.css
// keeping the CSS code style to make upstream updates easier

$_disk_space_unknown: $insensitive_bg_color;
$_disk_space_used: $progress_bg_color;
$_disk_space_free: if($variant=='light', darken($bg_color, 10%), $bg_color);

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

.disk-space-display.unknown {
    background-color: $_disk_space_unknown;
    border-color: transparentize($_disk_space_unknown, 0.7);
    color: $_disk_space_unknown;
}
.disk-space-display.unknown.border {
    color: transparentize($_disk_space_unknown, 0.7);
}

.disk-space-display.used {
    background-color: $_disk_space_used;
    border-color: transparentize($_disk_space_used, 0.7);
    color: $_disk_space_used;
}
.disk-space-display.used.border {
    color: transparentize($_disk_space_used, 0.7);
}

.disk-space-display.free {
    background-color: $_disk_space_free;
    border-color: transparentize($_disk_space_free, 0.7);
    color: $_disk_space_free;
}
.disk-space-display.free.border {
    color: transparentize($_disk_space_free, 0.7);
}

/************
 * Terminal *
 ************/

$_terminal_bg_color: #300A24;
$_terminal_fg_color: white;

terminal-window {

    // use unity 8 colors
    // only colors, let everything else be inherited
    .terminal-screen {
        // inherits from .background
        background-color: $_terminal_bg_color;
        color: $_terminal_fg_color;

        &:backdrop {
            background-color: lighten($_terminal_bg_color, 2%);
            color: $backdrop_selected_fg_color;
        }
    }

    notebook {
        scrollbar {
            // inherits from scrollbar
            background-color: transparent;
            border-color: transparent;

            &:backdrop {
                background-color: transparent;
                border-color: transparent
            }

            slider {
                // 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;

                &:backdrop {
                  background-color: gtkalpha(currentColor, 0.1);
                }

                &:disabled {
                    background-color: transparent;
                }
            }

            &.dragging,
            &.hovering {
                background-color: transparent;
            }
        }
    }
}

  /******************
   * GNOME Software *
   ******************/
  .review-row {
    margin-bottom: 10px;
    padding: 6px 12px;
    box-shadow: 0 1px 2.5px transparentize(black, 0.75);
    outline-offset: -1px;

    &,
    &:not(:selected):not(:backdrop):hover,
    &:not(:selected):not(:backdrop):active { background-color: $base_color; }

    &:backdrop { background-color: $backdrop_base_color; }

    &:last-child { margin-bottom: 0; }

    > grid { margin-top: -24px; }
  }

  .app-listbox-header { background: $dark_fill; }

  .list-box-app-row {
    border-radius: 0;
    border-color: $borders_color;
    border-style: none solid solid solid;
    border-width: 0 1px 1px 1px;
    margin: -1px 0 0 0;

    & ~ separator {
      background-color: $bg_color;
      border: none;
      min-height: 0px;
    }
  }

  // Avoid double border when list in included in a box (e.g. Updates view)
  box > list row.list-box-app-row {
      border: none;
  }

  //Used as update count in GNOME software
  .counter-label {
    margin-top: 2px;
    margin-bottom: 2px;
    border-width: 0px;
    padding-left: 2px;
    padding-right: 2px;
    box-shadow: inset 0 0 10px 10px $success_color;
  }

  /*********
   * Gedit *
   *********/
  .gedit-bottom-panel-paned notebook > header {
      background: if($variant==light, $porcelain, $bg_color);
  }

  .gedit-bottom-panel-paned ~ statusbar {
    // give gedit's bottom panel a border
    border-top: 1px solid $borders_color;

    &:backdrop { border-color: $backdrop_borders_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 5px 5px; // same radius as tooltips

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

  .gedit-search-entry-occurrences-tag {
      color: transparentize($fg_color, 0.65);
      border: none; // Removed ugly tag border
      box-shadow: none; // Removed button inset shadow
      margin: 2px;
      padding: 2px;
  }

  .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: rgba($fg_color, 0.15);
          }
          &:active {
              background-color: rgba($fg_color, 0.25);
          }
      }

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

  /***************
   * GNOME Disks *
   ***************/

  headerbar button image ~ window decoration ~ menu separator {
    // gnome disks headerbar menu seems to inherit the headerbar separator bg color
    // no unique class names or id used here so this rule is as specific as it can be
    background: $borders_color;
  }

  /********
   * Nemo *
   ********/
  .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($sidebar_bg_color);
        border-radius: 0; // get rid of weird radius on selected rows
        &:backdrop { background-image: image($backdrop_sidebar_bg_color); }
        &:selected { background: $selected_bg_color; }
        &:not(:selected) {
          &:not(:backdrop):hover { 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;
      }
    }

    .view {
      // imports nautilus tweaks
      // dim icons in backdrop
      &:backdrop { @extend %dim_icons_in_backdrop; }
    }

    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;
      }

      button {
        // return non-flat buttons
        @each $state, $t in ("", "normal"),
        (":hover", "hover"),
        (":active, &:checked", "active"),
        (":disabled", "insensitive"),
        (":disabled:active, &:disabled:checked", "insensitive-active"),
        (":backdrop", "backdrop"),
        (":backdrop:active, &:backdrop:checked", 'backdrop-active'),
        (":backdrop:disabled", 'backdrop-insensitive'),
        (":backdrop:disabled:active, &:backdrop:disabled:checked", 'backdrop-insensitive-active') {
          &#{$state} { @include button($t) }
        }
      }
    }
  }

  /*************
  * GNOME ToDo *
  **************/

  .org-gnome-Todo {
    taskrow.activatable.new-task-row button.popup.toggle {
     border-radius: 0px;
     border: none;
     border-left: 1px solid $borders-color;
     padding-left: 10px; padding-right: 10px;
     -gtk-outline-radius: 0px;

    }

    viewport.view, listbox.transparent {
     background-color: darken($base_color,5%);
     &:backdrop { background-color: $backdrop_base_color}
    }
  }

  /***********
   * Firefox *
   ***********/
  #MozillaGtkWidget.background  {
    // REMOVE THIS when firefox supports rounded menus
    menu, .menu,.context-menu { border-radius: 0; }

    @if $ambiance {
      menubar,
      .menubar,
      menubar > menuitem:hover {
        background-color: $headerbar_bg_color;
        color:$headerbar_fg_color;
      }
    }

    // Adapt scrollbars a bit more to the GTK Scrollbar styling
    scrollbar {
      background-color: transparent;
      border-color: transparent;

      slider  {
        background-color: darken($scrollbar_slider_color, 10%);
        &:hover { background-color: darken($scrollbar_slider_hover_color, 10%); }
        &:hover:active { background-color: $scrollbar_slider_active_color; }
        &:backdrop { background-color: $backdrop_scrollbar_slider_color; }
        &:disabled { background-color: transparent; }
      }

      trough {
        background-color: transparentize($bg_color, 0.8);
      }
    }
  }

  normal-button {
    @include button(normal);

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

    &:disabled {@include button(insensitive);}
  }

  /***********
   * Ubiquity *
   ***********/

  #live_installer {

    #title_eventbox {
      background-color: $bg_color;
      color: $fg_color;
      &:backdrop {
        background-color: $backdrop_bg_color;
        color: $backdrop_fg_color;
      }
    }

    #dot_grid progressbar	{
      border-radius: 100%;
      padding: 1px;
      padding-top: 2px;
      background-color: white;
      border: 1px solid $progress_bg_color;

      .empty {
        border-radius: 100%;
        background-color: white;
        padding: 0px;
      }

      .full progress {
        border-radius: 100%;
        padding: 1px;
        padding-top: 2px;
        margin-bottom: 2px;
      }
    }
  }
  #dialog-action_area1 { padding-bottom: 5px; padding-right: 5px }

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

  .geary-expanded headerbar { border: none; }

  /***********
   * usb-creator-gtk *
   ***********/

   #dialog-action_area3 { margin: 5px; }

   /***********
   * Evolution *
   ***********/

   assistant.background scrolledwindow .vertical checkbutton {
     // checkbox is clipped but this is undetectable till it gets keyboard focus
     // so we're pushing it to the right to have the focus ring be displayed properly
     margin-left: 1px
  }

/***********
* Unity7 *
***********/

$panel_bg_color: $headerbar_bg_color; //lighten($jet, 2%);
$panel_fg_color: $porcelain;
$wm_border_unfocused: none;
$wm_border_focused: if($variant=='light', transparentize(black, 0.9), transparentize($borders_color, 0.1));
$titlebar_bg_color: $headerbar_bg_color;
$titlebar_fg_color: $headerbar_fg_color;

UnityDecoration {
  -UnityDecoration-extents: 32px 0px 0px 0px;
  -UnityDecoration-input-extents: 10px;

  -UnityDecoration-shadow-offset-x: 1px;
  -UnityDecoration-shadow-offset-y: 1px;
  -UnityDecoration-active-shadow-color: transparentize(black, 0.5);
  -UnityDecoration-active-shadow-radius: 10px;
  -UnityDecoration-inactive-shadow-color: transparentize(black, 0.999);
  -UnityDecoration-inactive-shadow-radius: 0px;

  -UnityDecoration-glow-size: 0px;
  -UnityDecoration-glow-color: $selected_bg_color;

  -UnityDecoration-title-indent: 0px;
  -UnityDecoration-title-fade: 0px;
  -UnityDecoration-title-alignment: 0.5;

  // Unity "titlebars"
  .top {
    border: none;
    border-radius: $window_radius $window_radius 0 0;
    // padding used for the min/max/close titlebuttons
    padding: 1px (4px + 3px) 0 (4px + 3px);
    background-color: $titlebar_bg_color;
    color: $titlebar_fg_color;
    text-shadow: none;
    box-shadow: inset 0 1px $headerbar_border_color;

    &:hover {
      // nothing changes here
    }

    &:backdrop {
      border: none;
      background-color: $backdrop_headerbar_bg_color;
      color: $backdrop_headerbar_fg_color;
      box-shadow: inset 0 1px transparentize($headerbar_border_color, 0.4);
    }
  }

  // this is the window border outside of the titlebar!
  .left, .right, .bottom {
    border: none;
    background-color: transparent;
    &:backdrop { background-color: transparent; }
  }
}

// unity 7 top panel - equivalent to the gnome panel
UnityPanelWidget, .unity-panel {
  background-color: $panel_bg_color;
  color: $panel_fg_color;
  border: 0;
}

.unity-panel {
  &.menuitem, .menuitem {
    border-width: 0 1px;
    color: $panel_fg_color;
    background-color: transparent;

    &:hover, *:hover {
      box-shadow: inset 0 -2px 0 0 $selected_bg_color;
      background-color: transparent;
      color: $panel_fg_color;
    }
  }
}

SheetStyleDialog.unity-force-quit { background-color: $bg_color; }
