/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/* ===== listbox.css =======================================================
  == Styles used by XUL listbox-related elements.
  ======================================================================= */


@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");

/* ::::: listbox ::::: */

listbox {
  -moz-appearance: listbox;
  margin: 2px 4px;
  border: 2px solid;
  -moz-border-top-colors: ThreeDShadow ThreeDDarkShadow;
  -moz-border-right-colors: ThreeDHighlight ThreeDLightShadow;
  -moz-border-bottom-colors: ThreeDHighlight ThreeDLightShadow;
  -moz-border-left-colors: ThreeDShadow ThreeDDarkShadow;
  background-color: -moz-Field;
  color: -moz-FieldText;
}

listbox[disabled="true"] {
  color: GrayText;
}

/* ::::: listitem ::::: */

listitem {
  border: 1px solid transparent;
}

listbox:focus > listitem[selected="true"][current="true"] {
  outline: 1px dotted #F3D982;
}

listbox:focus > listitem[current="true"] {
  outline: 1px dotted Highlight;
  outline-offset: -1px;
}

listitem[selected="true"] {
  background-color: -moz-cellhighlight;
  color: -moz-cellhighlighttext;
}

listbox:focus > listitem[selected="true"] {
  background-color: Highlight;
  color: HighlightText;
}

/* ::::: listheader ::::: */

listheader {
  -moz-appearance: treeheadercell;
  -moz-box-align: center;
  border: 2px solid;
  -moz-border-top-colors: ThreeDHighlight ThreeDLightShadow;
  -moz-border-right-colors: ThreeDDarkShadow ThreeDShadow;
  -moz-border-bottom-colors: ThreeDDarkShadow ThreeDShadow;
  -moz-border-left-colors: ThreeDHighlight ThreeDLightShadow;
  background-color: -moz-Dialog;
  color: -moz-DialogText;
  padding: 0 4px;
}

listheader[sortable="true"]:hover:active {
  border-top: 2px solid;
  border-right: 1px solid;
  border-bottom: 1px solid;
  border-left: 2px solid;
  -moz-border-top-colors: ThreeDShadow -moz-Dialog;
  -moz-border-right-colors: ThreeDShadow;
  -moz-border-bottom-colors: ThreeDShadow;
  -moz-border-left-colors: ThreeDShadow -moz-Dialog;
  padding-top: 1px;
  padding-bottom: 0px;
  padding-inline-start: 5px;
  padding-inline-end: 4px;
}

.listheader-icon {
  margin-inline-end: 2px;
}

.listheader-label {
  margin: 0px !important;
}

/* ..... sort direction icon ..... */

.listheader-sortdirection {
  list-style-image: none;
}

.listheader-sortdirection[sortDirection="ascending"] {
  list-style-image: url("chrome://global/skin/tree/sort-asc.png");
}

.listheader-sortdirection[sortDirection="ascending"]:-moz-system-metric(windows-classic) {
  list-style-image: url("chrome://global/skin/tree/sort-asc-classic.png");
}

.listheader-sortdirection[sortDirection="descending"] {
  list-style-image: url("chrome://global/skin/tree/sort-dsc.png");
}

.listheader-sortdirection[sortDirection="descending"]:-moz-system-metric(windows-classic) {
  list-style-image: url("chrome://global/skin/tree/sort-dsc-classic.png");
}

/* ::::: listcell ::::: */

.listcell-label {
  margin: 0px !important;
  padding-top: 0px;
  padding-bottom: 1px;
  padding-inline-start: 4px;
  padding-inline-end: 0px;
  white-space: nowrap;
}

.listcell-icon {
  margin-inline-end: 2px;
}

.listcell-label[disabled="true"] {
  color: GrayText;
}

/* ::::: listcell checkbox ::::: */

.listcell-check {
  -moz-appearance: checkbox;
  -moz-box-align: center;
  margin: 0px 2px;
  border: 1px solid -moz-DialogText;
  min-width: 13px;
  min-height: 13px;
  background: -moz-Field no-repeat 50% 50%;
}

@media (-moz-windows-default-theme) {
  listitem {
    --listitem-selectedColor: rgb(217,217,217);
    --listitem-selectedBorder: var(--listitem-selectedColor);
    --listitem-selectedBottomBorder: rgb(204,204,204);
    --listitem-selectedBackground: var(--listitem-selectedColor);
    --listitem-selectedImage: none;
    --listitem-selectedCurrentBorder: rgb(123,195,255);
    --listitem-selectedFocusColor: rgb(205,232,255);
    --listitem-selectedFocusBorder: var(--listitem-selectedFocusColor);
    --listitem-selectedFocusBottomBorder: rgb(165,214,255);
    --listitem-selectedFocusBackground: var(--listitem-selectedFocusColor);
    --listitem-selectedFocusImage: none;
    --listitem-selectedFocusCurrentBorder: var(--listitem-selectedFocusColor);
    --listitem-selectedFocusCurrentBottomBorder: var(--listitem-selectedFocusBottomBorder);
    --listitem-selectedFocusCurrentBackground: var(--listitem-selectedFocusColor);

    color: -moz-FieldText;
    margin-inline-start: 1px;
    margin-inline-end: 1px;
    padding-top: 1px;
    padding-bottom: 1px;
    border-width: 1px;
    background-repeat: no-repeat;
    background-size: 100% 100%;
  }

  listitem[selected="true"] {
    border-top-color: var(--listitem-selectedBorder);
    border-right-color: var(--listitem-selectedBorder);
    border-left-color: var(--listitem-selectedBorder);
    border-bottom-color: var(--listitem-selectedBottomBorder);
    background-image: var(--listitem-selectedImage);
    background-color: var(--listitem-selectedBackground);
    color: -moz-DialogText;
  }

  listbox:focus > listitem[selected="true"] {
    border-top-color: var(--listitem-selectedFocusBorder);
    border-right-color: var(--listitem-selectedFocusBorder);
    border-left-color: var(--listitem-selectedFocusBorder);
    border-bottom-color: var(--listitem-selectedFocusBottomBorder);
    background-image: var(--listitem-selectedFocusImage);
    background-color: var(--listitem-selectedFocusBackground);
    color: -moz-DialogText;
  }

  listbox:focus > listitem[current="true"] {
    border-color: var(--listitem-selectedCurrentBorder);
    outline: none;
  }

  listbox:focus > listitem[selected="true"][current="true"] {
    border-top-color: var(--listitem-selectedFocusCurrentBorder);
    border-right-color: var(--listitem-selectedFocusCurrentBorder);
    border-left-color: var(--listitem-selectedFocusCurrentBorder);
    border-bottom-color: var(--listitem-selectedFocusCurrentBottomBorder);
    background-color: var(--listitem-selectedFocusCurrentBackground);
    outline: none;
  }

  @media (-moz-os-version: windows-win7) {
    listitem {
      --listitem-selectedBottomBorder: var(--listitem-selectedColor);
      --listitem-selectedBackground: rgba(190,190,190,.15);
      --listitem-selectedImage: linear-gradient(rgba(190,190,190,.1), rgba(190,190,190,.4));
      --listitem-selectedCurrentBorder: rgb(125,162,206);
      --listitem-selectedFocusColor: rgb(132,172,221);
      --listitem-selectedFocusBottomBorder: var(--listitem-selectedFocusColor);
      --listitem-selectedFocusBackground: rgba(131,183,249,.02);
      --listitem-selectedFocusImage: linear-gradient(rgba(131,183,249,.16), rgba(131,183,249,.375));
      --listitem-selectedFocusCurrentBackground: rgba(131,183,249,.15);

      border-radius: 3px;
      box-shadow: inset 0 0 0 1px rgba(255,255,255,.4), inset 0 -1px 0 1px rgba(255,255,255,.2);
    }
  }

  @media (-moz-os-version: windows-win8) {
    listitem {
      --listitem-selectedBottomBorder: var(--listitem-selectedColor);
      --listitem-selectedBackground: rgba(190,190,190,.15);
      --listitem-selectedImage: linear-gradient(rgba(190,190,190,.4), rgba(190,190,190,.4));
      --listitem-selectedCurrentBorder: rgb(125,162,206);
      --listitem-selectedFocusColor: rgb(132,172,221);
      --listitem-selectedFocusBottomBorder: var(--listitem-selectedFocusColor);
      --listitem-selectedFocusBackground: rgba(131,183,249,.02);
      --listitem-selectedFocusImage: linear-gradient(rgba(131,183,249,.375), rgba(131,183,249,.375));
      --listitem-selectedFocusCurrentBackground: rgba(131,183,249,.15);
    }
  }
}