/* 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/. */

/* Bug 1869845 - Styles in this file are still experimental!  */

.container {
  display: flex;
  flex-direction: column;
  padding: 20px;
}

virtualized-list {
  position: relative;
  overflow: auto;
  margin-block: 20px;
  padding-inline: 20px;
  flex-grow: 1;
  .lines-container {
    padding-inline-start: unset;
  }
}

.line {
  display: flex;
  align-items: stretch;
  position: absolute;
  width: calc(100% - 40px);
  user-select: none;
  box-sizing: border-box;
  height: 64px;

  background-color: var(--in-content-box-background-odd);
  border-inline: 1px solid var(--in-content-border-color);

  color: var(--in-content-text-color);

  &.start {
    border-block-start: 1px solid var(--in-content-border-color);
    border-start-start-radius: 8px;
    border-start-end-radius: 8px;
  }

  &.end {
    border-block-end: 1px solid var(--in-content-border-color);
    border-end-start-radius: 8px;
    border-end-end-radius: 8px;
    height: 54px;
  }

  > .menuButton {
    position: relative;
    visibility: hidden;

    > button {
      border: none;
      border-radius: 4px;
      margin-inline-start: 2px;
      padding: 2px;
      background-color: transparent;
      /* Fix: too lazy to load the svg  */
      width: 32px;
      color: unset;

      &:hover {
        background-color: var(--in-content-button-background-hover);
      }
    }

    > .menuPopup {
      position: absolute;
      inset-inline-end: 0;
      box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2);
      z-index: 1;
      background-color: var(--in-content-table-background);
      padding: 4px;

      > .separator {
        border-block-start: 1px solid var(--in-content-border-color);
        margin: 4px 0;
      }

      > button {
        text-align: start;
        border-style: none;
        padding: 12px;
        margin-block-end: 2px;
        width: 100%;
        text-wrap: nowrap;
      }
    }
  }

  > .content {
    flex-grow: 1;

    &:not(.section) {
      display: grid;
      grid-template-rows: max-content 1fr;
      grid-template-columns: max-content;
      grid-column-gap: 8px;
      padding-inline-start: 8px;
      padding-block-start: 4px;
    }

    > div {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;

      &:last-child {
        padding-block-end: 10px;
      }
    }

    > .icon {
      border-radius: 4px;
      margin-inline-start: 4px;
      width: 16px;
      height: 16px;
      -moz-context-properties: fill;
      fill: currentColor;

      &:hover {
        background-color: var(--in-content-button-background-hover);
      }
    }

    > .label {
      color: var(--text-color-deemphasized);
      padding-block: 2px 4px;
      grid-row: 1;
      align-content: end;
    }

    > .value {
      user-select: text;

      > .icon {
        -moz-context-properties: fill;
        fill: currentColor;
        width: auto;
        height: 16px;
        margin-inline-end: 4px;
        vertical-align: text-bottom;
      }

      > .icon:not([src]) {
        display: none;
      }

      &:is(a) {
        color: currentColor;
      }
    }

    > .stickers {
      grid-row: 1;
      align-content: start;

      > span {
        padding: 4px;
        margin-inline-end: 2px;
        border-radius: 24px;
        font-size: xx-small;
      }

      /* Hard-coded colors will be addressed in FXCM-1013 */
      > span.risk {
        background-color: slateblue;
        border: 1px solid darkslateblue;
        color: whitesmoke;
      }

      > span.warning {
        background-color: firebrick;
        border: 1px solid maroon;
        color: whitesmoke;
      }

      > span.error {
        background-color: orange;
        border: 1px solid orangered;
        color: black;
      }
    }

    &.section {
      font-size: larger;
      overflow: hidden;
      display: flex;
      min-width: 0;

      > .label {
        display: inline-block;
        margin: 0;
        color: unset;
        margin-inline: 8px;
        align-content: start;
      }

      > .value {
        margin-inline-end: 8px;
        text-align: end;
        font-size: smaller;
        color: var(--text-color-deemphasized);
        user-select: unset;
        align-content: end;
        flex-grow: 1;
      }
    }
  }

  &.selected {
    color: var(--in-content-item-selected-text);
    background-color: var(--in-content-item-selected);

    > .menuButton {
      visibility: inherit;
    }
  }

  &:hover {
    color: var(--in-content-item-hover-text);
    background-color: var(--in-content-item-hover);

    > .menuButton {
      visibility: visible;
    }
  }
}

/* Dialog styles */
.dialog-overlay {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  background-color: rgba(0, 0, 0, 0.5);
  box-sizing: border-box;
  /* TODO: probably want to remove this later ? */
  backdrop-filter: blur(6px);
}

.dialog-container {
  display: grid;
  padding: 16px 32px;
  color: var(--in-content-text-color);
  background-color: var(--background-color-box);
  border: 1px solid var(--in-content-border-color);
  box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.1);
}

.dialog-title {
  margin: 0;
}

.dismiss-button {
  justify-self: end;
}

.dialog-content {
  margin-block-start: 16px;
  margin-block-end: 16px;

  .checkbox-text {
    margin-block-start: 8px;
  }
}

/* Password Card styles */
password-card,
.empty-state-card {
  margin-block: var(--space-small);
}

.passwords-list {
  display: flex;
  flex-direction: column;
}

login-form {
  margin-block-start: var(--space-small);
}

.edit-button {
  justify-self: end;
}

.searchContainer {
  height: 32px;
  padding-inline-start: var(--space-small);
  cursor: text;
  border-radius: var(--border-radius-small);
  border: 1px solid var(--in-content-border-color);
  box-sizing: border-box;
  display: flex;

  &:focus-within {
    outline: 1px auto;
  }
}

.searchIcon {
  background-image: url(chrome://global/skin/icons/search-textbox.svg);
  background-position: center;
  background-repeat: no-repeat;
  -moz-context-properties: fill;
  fill: currentColor;
  width: var(--icon-size-default);
  margin-inline-end: var(--space-xsmall);
  flex-shrink: 0;
}

.search {
  border: none;
  background-color: transparent;
  outline: none;
  width: 100%;
}

.first-row {
  display: grid;
  grid-template-columns: 1fr min-content;
  grid-gap: 12px;
  align-items: center;
  margin-block-end: 20px;
}

.second-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-block-end: var(--space-small);
}

.selected::part(button) {
  background-color: var(--button-background-color-active);
}

.no-logins-card-buttons {
  display: flex;
  flex-direction: column;
  gap: var(--space-small);

  > moz-button {
    width: 100%
  }
}

.no-logins-card-content {
  display: flex;
  flex-direction: column;

  > img {
    align-self: center;
  }
}

.alert-card {
  display: flex;
  flex-direction: column;
  margin-block: var(--space-medium);

  > ul {
    list-style-type: none;
    padding-inline: var(--space-small);
    margin-block: var(--space-small);

    > li:not(:last-child) {
      margin-block-end: var(--space-medium);
    }
  }
}
