/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file. */

tree {
  display: block;
  outline: none;
  overflow: auto;
}

.tree-item > .tree-row {
  background-color: rgba(255, 255, 255, 0);
  border: 1px solid rgba(255, 255, 255, 0); /* transparent white */
  border-radius: 2px;
  color: black;
  cursor: default;
  line-height: 28px;
  padding: 0 3px;
  position: relative;
  user-select: none;
  white-space: nowrap;
}

.expand-icon {
  background: url(../images/tree_triangle.svg) no-repeat center center;
  background-size: 8px 5px;
  display: inline-block;
  height: 16px;
  opacity: .6;
  position: relative;
  top: 6px;
  transform: rotate(-90deg);
  transition: all 150ms;
  vertical-align: top;
  width: 16px;
}

html[dir=rtl] .expand-icon {
  transform: rotate(90deg);
}

.tree-item[expanded] > .tree-row > .expand-icon {
  background-image: url(../images/tree_triangle.svg);
  opacity: .5;
  transform: rotate(0);
}

.tree-row .expand-icon {
  visibility: hidden;
}

.tree-row[may-have-children] .expand-icon {
  visibility: visible;
}

.tree-row[has-children=false] .expand-icon {
  visibility: hidden;
}

.tree-row:hover {
  background-color: hsl(214, 91%, 97%);
  border-color: hsl(214, 91%, 85%);
  z-index: 1;
}

/* WebKit has a bug with attribute selectors so we apply selected to the tree
 * row as well. https://bugs.webkit.org/show_bug.cgi?id=12519. */
.tree-row[selected] {
  background-image: -webkit-linear-gradient(rgba(255, 255, 255, 0.8),
                                            rgba(255,255,255,0));
}

.tree-row[selected] {
  background-color: hsl(0, 0%, 90%);
  border-color: hsl(0, 0%, 85%);
  z-index: 2;
}

.tree-row[selected]:hover,
tree:focus .tree-row[selected] {
  background-color: hsl(214, 91%, 89%);
  border-color: rgb(125, 162, 206);
}

.tree-children[expanded] {
  display: block;
}

.tree-children {
  display: none;
}

.tree-item > .tree-row > * {
  box-sizing: border-box;
  display: inline-block;
}

.tree-label {
  -webkit-padding-start: 20px;
  background-position: 0 50%;
  background-repeat: no-repeat;
  white-space: pre;
}

html[dir=rtl] .tree-label {
  background-position: 100% 50%;
}

.tree-label,
.tree-row[may-have-children] > .tree-label {
  background-image: -webkit-image-set(
      url(../../../resources/default_100_percent/common/folder_closed.png) 1x,
      url(../../../resources/default_200_percent/common/folder_closed.png) 2x);
}

.tree-item[expanded] > .tree-row > .tree-label {
  background-image: -webkit-image-set(
      url(../../../views/resources/default_100_percent/common/folder_open.png) 1x,
      url(../../../views/resources/default_200_percent/common/folder_open.png) 2x);
}

<if expr="not is_macosx and not is_ios">
html[dir=rtl] .tree-label,
html[dir=rtl] .tree-row[may-have-children] > .tree-label {
  background-image: -webkit-image-set(
      url(../../../resources/default_100_percent/common/folder_closed_rtl.png) 1x,
      url(../../../resources/default_200_percent/common/folder_closed_rtl.png) 2x);
}

html[dir=rtl] .tree-item[expanded] > .tree-row > .tree-label {
  background-image: -webkit-image-set(
     url(../../../views/resources/default_100_percent/common/folder_open_rtl.png) 1x,
     url(../../../views/resources/default_200_percent/common/folder_open_rtl.png) 2x);
}
</if>

tree[icon-visibility=hidden] .tree-label {
  -webkit-padding-start: 0;
  background-image: none !important;
}

tree[icon-visibility=parent] .tree-label,
tree[icon-visibility=parent] .tree-row[has-children=false] > .tree-label {
  background-image: none;
}

/* We need to ensure that even empty labels take up space */
.tree-label:empty::after {
  content: ' ';
  white-space: pre;
}

.tree-rename > .tree-row > .tree-label {
  -webkit-user-modify: read-write-plaintext-only;
  background: white;
  color: black;
  outline: 1px solid black;
  user-select: auto;
}

.tree-item[editing] input {
  /* Do not inherit the line-height */
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  margin: -2px -8px -2px -3px;
<if expr="not is_macosx and not is_ios">
  outline: none;
</if>
  padding: 1px 7px 1px 1px;
}

html[dir=rtl] .tree-item[editing] input {
  margin: -2px -3px -2px -8px;
  padding: 1px 1px 1px 7px;
}
