// based css:
// https://github.com/mate-desktop/mate-themes/blob/master/desktop-themes/Menta/gtk-3.0/mate-applications.css

/**************
 * Mate-Panel *
 **************/
// first make all transparent
.mate-panel-menu-bar menubar,
#PanelApplet-window-menu-applet-button {
  background-color: transparent;
}

// let's start it
.mate-panel-menu-bar {
  background-color: $panel;
  color: on($panel, secondary);
  font-weight: 500;

  button {
    @extend %button-flat;
    @extend %button-on-dark;

    min-height: 16px;
    min-width: 16px;
    padding: 0; // NOTE: Most buttons padding are hard-coded to 0 (except for hide buttons)
    border-radius: 0;
  }
}

// hide buttons
PanelToplevel.horizontal > grid > button {
  min-width: 24px;
}

PanelToplevel.vertical > grid > button {
  min-height: 24px;
}

#PanelApplet {
  // border-width: 0;
}

PanelSeparator {
  color: on($panel, divider);
}

// the grid left from na-tray and wncktasklist
MatePanelAppletFrameDBus {
  border-style: solid;
  border-color: on($panel, divider);

  .mate-panel-menu-bar.horizontal & { border-width: 0 1px; }
  .mate-panel-menu-bar.vertical & { border-width: 1px 0; }
}

// main menu
.mate-panel-menu-bar {
  // set normal menubar button
  menubar > menuitem {
    color: on($panel, secondary);

    &:hover { color: on($panel); }

    &:disabled { color: on($panel, secondary-disabled); }
  }

  &.horizontal menubar > menuitem { padding: 0 8px; }
  &.vertical menubar > menuitem { padding: 8px 0; }

  // set normal menubar menuitem
  menubar menu > menuitem {
    // adjust sizing since the menuitem has large icons
    min-height: $menuitem-size;
    padding: 0 6px;
    // font-weight: initial;
  }
}

// all applets
.mate-panel-menu-bar #PanelApplet button {
  -GtkWidget-window-dragging: true;
  // padding: 4px;
}

.mate-panel-menu-bar #tasklist-button {
  border-image: radial-gradient(circle closest-corner at center calc(100% - 1px),
                                currentColor 0%,
                                transparent 0%)
                                0 0 0 / 0 0 0px;

  &:checked {
    border-image: radial-gradient(circle closest-corner at center calc(100% - 1px),
                                  currentColor 100%,
                                  transparent 0%)
                                  0 0 2 / 0 0 2px;
  }

  // instead of #tasklist-button { padding: 0 4px; }
  image:dir(ltr), label:dir(rtl) { padding-left: 4px; }
  label:dir(ltr), image:dir(rtl) { padding-right: 4px; }
}

// #tasklist-button is always horizontal even if the panel is vertical
.mate-panel-menu-bar.vertical #tasklist-button { min-height: 32px; }

#showdesktop-button {
  .mate-panel-menu-bar.horizontal & image {
    min-width: 24px;
    padding: 0 4px;
  }

  .mate-panel-menu-bar.vertical & image {
    min-height: 24px;
    padding: 4px 0;
  }
}

// WnckPager
PanelApplet.wnck-applet .wnck-pager {
  background-color: transparent;
  color: $primary;

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

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

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

#clock-applet-button {
  .mate-panel-menu-bar.horizontal & label { padding: 0 8px; }
  .mate-panel-menu-bar.vertical & label { padding: 8px 0; }
}

#MatePanelPopupWindow {
  border: 1px solid $frame;
  border-radius: $corner-radius + 1px;
  box-shadow: inset 0 1px highlight($surface);
  background-color: $surface;

  frame > border { border-style: none; }

  calendar {
    border-style: none;

    &:not(:selected) { background-color: transparent; }

    // Add separator between calendar and location
    + box {
      margin-top: -5px;
      padding-top: 5px;
      border-top: 1px solid $divider;
    }
  }

  expander > title { min-height: 32px; }

  button {
    @extend %button-flat-simple;

    padding: 4px 16px;
  }

  // Weird, this sets the border color of the clockmap
  > frame > box > box > box > widget { color: $divider; }
}

na-tray-applet {
  -NaTrayApplet-icon-padding: 3px;
  -NaTrayApplet-icon-size: 16;
}

// remove right space a bit
na-tray-applet > widget > box {
  // margin-right: 2px;
}

// no background for icon-padding area
na-tray-applet widget box widget {
  // background-color: transparent;
}

// Classic icon style
.mate-panel-menu-bar {
  -PanelMenuBar-icon-visible: true;
}

// volume applet, brightness applet
.mate-panel-applet-slider {
  border: 1px solid $frame;
  border-radius: $corner-radius + 1px;
  box-shadow: inset 0 1px highlight($surface);
  background-color: $surface;

  frame > border { border-style: none; }
}

// mate-menu

// #PanelApplet itself cannot change the background-color
#PanelApplet {
  &:not(:selected) > box { transition: $transition; }

  &:selected > box {
    background-color: $overlay-checked;
    color: on($panel);
  }
}

#mate-menu {
  // FIXME, does not work
  border: 1px solid $frame;
  background-color: $surface;

  button {
    @extend %button-flat-simple;

    min-height: 24px;
    min-width: 24px;
    padding: 4px 0;
    color: $text;
    font-weight: normal;

    &:not(.flat) { background-color: $overlay-checked; }

    image,
    label + label { color: $text-secondary; }
  }

  entry {
    margin: 0 0 4px;

    image { margin: 0; }

    + button {
      margin: 0 4px 4px;
      padding: ($medium-size - 24px) / 2;
    }
  }
}

// brisk-menu
.brisk-menu {
  box-shadow: inset 0 1px highlight($surface);
  background-color: $surface;

  entry {
    margin-bottom: -2px;
    border-bottom: 1px solid $divider;
    border-image: none;
    box-shadow: none;
    background-color: transparent;
  }

  entry + box > box {
    &:dir(ltr) {
      margin-right: -2px;
      border-right: 1px solid $divider;
    }

    &:dir(rtl) {
      margin-left: -2px;
      border-left: 1px solid $divider;
    }
  }

  .categories-list {
    padding-top: 4px;

    button {
      margin: 0 4px;

      &:checked { color: $primary; }
    }
  }

  .session-button { padding: ($large-size - 24px) / 2; }

  .frame { border-style: none; }

  .apps-list {
    padding: 4px 0;
    background-color: transparent;

    row {
      padding: 0;

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

    button {
      border-radius: 0;
      color: $text;
      font-weight: normal;
    }
  }
}


/*********************
 * CAJA File manager *
 *********************/
// pathpar toggle button
.caja-navigation-window button.toggle.image-button {
  border-radius: $corner-radius;
}

// pathbar
// pathbar buttons
.caja-pathbar button {
  margin: 0 -1px 0 -2px;
  // padding: 4px;

  @extend %pathbar_button;

  // NOTE: padding is hard-coded to 0
  &.slider-button { min-width: 24px; }

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

// places, treeview, history, information, emblems and notes
// .caja-side-pane notebook treeview.view,
// .caja-side-pane notebook textview.view text,
.caja-side-pane notebook viewport.frame,
.caja-side-pane notebook widget .vertical {
  background-color: $base;
}

// treeview rows
.caja-side-pane treeview.view {
  // padding: 2px 0;
}

.caja-side-pane notebook,
.caja-notebook {
  border-top: 1px solid $divider;

  .frame { border-style: none; }
}

// window and desktop mode
.caja-canvas-item {
  border-radius: $corner-radius;
}

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

.caja-desktop EelEditableLabel.entry {
}

// override https://github.com/mate-desktop/caja/blob/master/data/caja.css
.caja-desktop.view .entry,
.caja-navigation-window .view .entry {
  border: none;
  border-radius: $corner-radius;
  background-color: $fill;
  background-image: none;
  color: $text;

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

.caja-desktop.view .entry {
  background-color: $scrim-alt;
  color: on(dark);
  text-shadow: $text-shadow;
  caret-color: currentColor; // this shouldn't be needed.

  &:selected { background-color: $overlay-selected; } // FIXME: this should have light overlay.
}

// statusbar
.caja-navigation-window statusbar {
  margin: 0 -10px;
  padding: 0 4px;
  border-top: 1px solid $divider;
}

// infobar
.caja-notebook frame > border {
  border-style: none;
}

#caja-extra-view-widget {
  border-bottom: 1px solid $divider;
  background-color: $base; // needs overriding

  > box > box > label { font-weight: bold; }
}


/*********
 * Pluma *
 *********/
// Pluma status bar
.pluma-window statusbar {
  margin: 0 -10px;
  padding: 0 4px;
  border-top: 1px solid $divider;

  frame {
    > border { border-style: none; }

    button.flat {
      padding: 0 4px;
      border-radius: 0;

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

// Printpreview
.pluma-print-preview {
  toolbar { border-bottom: 1px solid $divider; }

  // scrolledwindow { background-color: $base; }
}

// sidebar file-browser
.pluma-window paned.horizontal box.vertical {
  box.horizontal button.flat {
    margin: 1px;

    @extend %small-button;
  }

  .frame { border-style: none; }

  notebook.frame {
    margin-top: -1px;
    border-top: 1px solid $divider;

    box.vertical toolbar.horizontal { border-bottom: 1px solid $divider; }
  }
}


/*********
 * Atril *
 *********/
.atril-window paned.horizontal box.vertical {
  .frame { border-style: none; }

  notebook .frame { border-top: 1px solid $divider; }
}


/* mate-screensaver lock dialog */
.lock-dialog {
  border: 1px solid $frame;
  border-radius: 0; // Using rounded corners will reveal a black background
  background-color: $surface;

  notebook { 
    background-color: $surface;
  }

  frame > border { border-style: none; border-color: transparent; }

  button {
    @extend %button-flat;

    &:not(:disabled) { color: $primary; }
  }
}

/* multimedia OSD */
MsdOsdWindow.background.osd {
  border-radius: $corner-radius;
  background-color: $tooltip;
  color: on($tooltip);

  .trough {
    border-radius: 0;
    background-color: on($tooltip, track-disabled);
  }

  .progressbar {
    border-radius: 0;
    background-color: $primary;
  }

  // For mate-settings-daemon noncomposited osd windows
  &.msd-osd-window-solid {
  }
}
