@import "_defaults";

.ace_gutter {
	background: $ui-gutter-background;
	color: $ui-gutter-color;
}
.ace_print-margin {
	width: 2px;
	background: $ui-margin-line;
}
.ace_editor {
	background-color: $ui-background;
	color: $ui-foreground;
}
.rstudio-themes-flat {
	&.ace_editor_theme {
		background-color: $ui-background;
		color: $ui-foreground;
		.profvis-flamegraph {
			background-color: $ui-background;
			color: $ui-foreground;
		}
	}
	.ace_editor_theme {
		background-color: $ui-background;
		color: $ui-foreground;
	}
	&.ace_editor_theme a {
		color: $ui-foreground !important;
		font-weight: bold;
	}
	.gwt-Label {
	  color: $ui-foreground;
	}
}
.ace_cursor {
	color: $ui-cursor;
}
.normal-mode .ace_cursor {
  border: 0!important;
  background-color: $ui-cursor-normal-mode;
  opacity: 0.5;
}
.ace_marker-layer {
	.ace_selection {
		background: $ui-selection;
	}
	.ace_step {
		background: lighten($rlang-string, 10%);
	}
	.ace_bracket {
		margin: -1px 0 0 -1px;
		border: 1px solid $ui-bracket;
	}
	.ace_active-line {
		background: $ui-line-active;
	}
	.ace_selected-word {
		border: 1px solid $ui-selection;
	}
	.ace_foreign_line {
		position: absolute;
		z-index: -1;
		background-color: $ui-code-chunk-background;
	}
	.ace_active_debug_line {
		position: absolute;
		z-index: -1;
		background-color: $ui-debug-background;
	}
	.ace_find_line {
		position: absolute;
		z-index: -1;
		background-color: $ui-line-find;
	}
}
.ace_gutter-active-line {
	background-color: $ui-line-active-gutter;
}
.ace_fold {
	background-color: $ui-fold-arrows-background;
	border: 1px solid $ui-fold-arrows-color !important;
}
.ace_indent-guide{
	border-right: 1px solid $ui-indent_guide;
	margin-right: -1px;
}
.ace_active-line ~ .ace_selection.ace_start {
	background-color: $ui-line-active-selection;
}
.ace_keyword {
	font-style: normal;
	color: $rlang-reserved;
	&.ace_operator {
		font-style: normal;
		color: $rlang-operator;
	}
	&.ace_other.ace_unit {
		font-style: normal;
		color: $rlang-value;
	}
}
.ace_constant {
	&.ace_language {
		color: $rlang-message;
	}
	&.ace_numeric {
		color: $rlang-value;
	}
	&.ace_character {
		color: $rlang-value;
	}
	&.ace_other {
		color: $ui-foreground;
	}
}
.ace_support {
	&.ace_function {
		color: $rlang-function;
	}
	&.ace_constant {
		color: $rlang-value;
	}
	&.ace_class {
		font-style: $rlang-namespace-font-style;
		color: $rlang-namespace;
	}
	&.ace_type {
		color: $rlang-namespace;
	}
}
.ace_paren {
	&.ace_keyword.ace_operator {
		color: $rlang-bracket;
	}
}
.ace_storage {
	color: $rlang-reserved;
	&.ace_type {
		color: $rlang-reserved;
	}
}
.ace_invalid {
	background-color: transparentize($rlang-variable, 0.5);
	&.ace_deprecated {
		background-color: transparentize($rlang-reserved, 0.5);
	}
}
.ace_string {
	color: $rlang-string;
}
.ace_comment {
	color: $rlang-comment;
}
.ace_invisible {
	color: $ui-invisible;
}
.ace_variable {
	color: $rlang-variable;
	&.ace_parameter {
		color: $rlang-value;
	}
}
.ace_entity {
	&.ace_name {
		&.ace_function {
			color: $rlang-function;
		}
		&.ace_tag {
			color: $other-tag;
		}
	}
	&.ace_other.ace_attribute-name {
		color: $rlang-reserved;
	}
}
.ace_bracket {
	margin: 0 !important;
	border: 0 !important;
	background-color: $ui-bracket;
}
.ace_console_error {
	background-color: $ui-line-find;
}
.ace_layer {
	z-index: 3;
	&.ace_print-margin-layer {
		z-index: 2;
	}
	&.ace_marker-layer {
		z-index: 1;
	}
}
.ace_selection.ace_start {
	box-shadow: 0 0 3px 0 $ui-background;
	border-radius: 2px;
}
.ace_meta.ace_tag {
	color: $rlang-operator;
}
.ace_markup.ace_heading, 
.ace_markup.ace_heading ~ .ace_heading {
	font-weight: $rmd-heading-weight;
	color: $rmd-heading-color;
}
.ace_support.ace_function {
  &.ace_codebegin, &.ace_codeend {
    color: $rmd-chunk-header;
  }
}
.ace_markup.ace_href {
  color: $rmd-href;
}
.nocolor.ace_editor .ace_line span {
	color: $rlang-reserved !important;
}

/* ---- RStudio Theme ---- */
/* background */
.rstudio-themes-flat .rstudio-themes-default {
	background: $ui-rstudio-background !important;
	color: $ui-rstudio-color !important;
  .rstudio-themes-background {
    background: $ui-rstudio-background !important;
  }
}

/* inactive tabs */
table.rstheme_tabLayoutCenter, .rstudio-themes-flat .rstudio-themes-default .gwt-TabLayoutPanelTabs, .rstheme_multiPodUtilityTabArea {
	background: $ui-rstudio-tabs-inactive !important;
	.gwt-Label {
		color: $ui-rstudio-tabs-inactive-color;
	}
}

/* toolbar and selected tab */
.rstudio-themes-flat .rstudio-themes-default {
  .rstheme_center, .gwt-TabLayoutPanelTabs .gwt-TabLayoutPanelTab-selected table.rstheme_tabLayoutCenter {
		background: $ui-rstudio-tabs-selected !important;
  }
	.gwt-TabLayoutPanelTab-selected .gwt-Label {
		color: $ui-rstudio-tabs-selected-color;
	}
}


.rstudio-themes-flat {
  .rstheme_toolbarWrapper {
    background: $ui-rstudio-toolbar !important;
    button, a, div {
      color: $ui-rstudio-toolbar-color !important;
    }
  }
	.rstudio-themes-default {
		/* spliters */
    .gwt-SplitLayoutPanel-HDragger, .gwt-SplitLayoutPanel-VDragger {
      background: transparent !important;
    }
  }
	/* search */
  .search, &.rstudio-themes-default-menus .search {
    background: $ui-rstudio-search !important;
  }
}

/* pane toolbars */
.rstheme_secondaryToolbar, .rstudio-themes-flat .dataGridHeader {
     background: $ui-rstudio-toolbar !important;
}
/* menu background */
.rstudio-themes-flat {
  .popupMiddleCenter, .menuPopupMiddleCenter, .suggestPopupMiddleCenter {
  		 background: $ui-completions-background !important;
  		 color: $ui-completions-color !important;
  		 
  		 .item.item-selected, .item-selected {
    		 color: $ui-completions-background !important;
    		 background: $ui-completions-color !important;
  		 }
  }
  .themedPopupPanel {
  	border: solid 1px $ui-completions-border;
  	& ~ div.popupContent div:nth-child(1) {
  	  border: solid 1px $ui-completions-border;
  	}
  }
  .popupContent {
    background: $ui-completions-background;
  	color: $ui-completions-color;
  	&:not(.popupMiddleCenterInner) div div:nth-child(2) {
    	background: $ui-completions-background !important;
    	border: solid 1px $ui-completions-border;
    }
  }
  .gwt-PopupPanel .popupContent {
    background: inherit;
    color: $ui-completions-color;
  	table {
      background: $ui-completions-color;
      border: 0;
      .gwt-Label {
        color: $ui-completions-background;
      }
    }
  }
}

/* hacky toolbars section */
.rstudio-themes-flat .rstudio-themes-default {
  div.windowframe > div:last-child > div > div > div > div > div:not(.gwt-TabLayoutPanelTabs) {
    background: $ui-rstudio-tabs-inactive !important;
  }
}

/* Data Frame Preview */
.dataTables_wrapper thead th {
    background: $ui-rstudio-tabs-selected !important;
    color: $ui-rstudio-tabs-selected-color !important;
}
.dataTables_scrollBody table tbody td:first-child {
    background: $ui-rstudio-tabs-selected !important;
    color: $ui-rstudio-tabs-selected-color !important;
}
.dataTables_info {
    background: $ui-rstudio-tabs-selected !important;
    color: $ui-rstudio-tabs-selected-color !important;
}

/* scrollbars */
.rstudio-themes-flat .rstudio-themes-default .gwt-TabLayoutPanelTabs,
.rstudio-themes-flat .rstudio-themes-default .rstheme_minimizedWindowObject .rstheme_center,
.rstudio-themes-flat .rstudio-themes-default.rstudio-themes-scrollbars ::-webkit-scrollbar-track,
.rstudio-themes-flat .rstudio-themes-default.rstudio-themes-scrollbars ::-webkit-scrollbar-corner,
.rstudio-themes-flat .rstudio-themes-default.rstudio-themes-scrollbars::-webkit-scrollbar-track,
.rstudio-themes-flat .rstudio-themes-default.rstudio-themes-scrollbars::-webkit-scrollbar-corner,
.rstudio-themes-flat.rstudio-themes-default-menus .rstudio-themes-scrollbars ::-webkit-scrollbar-track,
.rstudio-themes-flat.rstudio-themes-default-menus .rstudio-themes-scrollbars ::-webkit-scrollbar-corner {
  background: $ui-rstudio-scrollbar-background;
}

.rstudio-themes-flat .rstudio-themes-default.rstudio-themes-scrollbars ::-webkit-scrollbar-thumb,
.rstudio-themes-flat .rstudio-themes-default.rstudio-themes-scrollbars::-webkit-scrollbar-thumb,
.rstudio-themes-flat.rstudio-themes-default-menus .rstudio-themes-scrollbars ::-webkit-scrollbar-thumb {
  background: $ui-rstudio-scrollbar-handle;
  border: 4px solid $ui-rstudio-scrollbar-background;
}
