/**
 * Copyright (c) Microblink Ltd. All rights reserved.
 */

@import "../styles/_globals-sass";

:host {
  * {
    box-sizing: border-box;
  }
  display: grid;
  font-family: inherit;
  font-size: var(--mb-font-size);

  .active-camera {
    all: unset;
    box-sizing: border-box;
    display: flex;
    cursor: pointer;
    min-width: 0;
    max-width: 100%;

    // Width + border
    // width: var(--mb-toolbar-selection-width);
    // width: 100%;

    // Line height + padding + border
    align-items: center;

    color: var(--mb-toolbar-color);
    line-height: var(--mb-line-height);

    text-align: center;
    text-decoration: none;

    border: 1px solid transparent;
    border-radius: var(--mb-toolbar-border-radius);

    .icon {
      width: 20px;
      height: 20px;

      svg {
        width: 20px;
        height: 20px;
      }
    }

    .name {
      // width = 100% - padding width - 2 * width of an icon
      // max-width: calc(100% - #{ 2 * $padding-unit-medium } - 40px);

      font-weight: var(--mb-toolbar-camera-name-font-weight);

      padding: 0 $padding-unit-medium 0 $padding-unit-small;

      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    // States
    & {
      padding: $padding-unit-small $padding-unit-large;
      background-color: transparent;
    }

    &:hover,
    &:active,
    &:focus {
      background-color: rgba(
        map-get(
          map-get(map-get($base-colors, text-secondary), onlight),
          foreground
        ),
        0.3
      );
    }

    &.active,
    &:active,
    &:focus {
      padding: $padding-unit-small $padding-unit-large;
      border-color: var(--mb-toolbar-border-color);
    }
  }

  #list-background {
    position: fixed;
    top: 0;
    left: 0;

    width: 100vw;
    height: 100vh;

    &:not(.visible) {
      display: none;
    }
  }

  .list {
    position: absolute;
    top: calc(var(--mb-font-size) * 1.5 + #{$padding-unit-small * 2 * 2});
    left: calc(50% - var(--mb-toolbar-selection-width) / 2);

    width: var(--mb-toolbar-selection-width);

    padding: 0;

    background-color: var(--mb-toolbar-list-background);
    border-radius: var(--mb-toolbar-border-radius);
    box-shadow: var(--mb-toolbar-list-shadow);

    &:not(.visible) {
      display: none;
    }

    svg,
    .name,
    .spacer {
      display: inline-block;
      vertical-align: middle;
    }

    .spacer,
    svg {
      width: 24px;
      height: 20px;
    }

    .name {
      max-width: calc(100% - 24px);

      overflow: hidden;
      text-overflow: ellipsis;
    }

    ul {
      margin: 0;
      padding: $padding-unit-medium;

      border-radius: var(--mb-toolbar-list-border-radius);

      list-style: none;

      li {
        display: block;
        &.active {
          color: map-get(
            map-get(map-get($base-colors, primary-blue), onlight),
            background
          );
        }
      }

      button {
        all: unset;
        box-sizing: border-box;
        display: block;
        width: 100%;
        appearance: none;

        border-radius: var(--mb-toolbar-list-item-border-radius);

        padding: $padding-unit-small $padding-unit-large;
        line-height: var(--mb-line-height);
        cursor: pointer;

        &:hover,
        &:focus {
          background-color: rgba(
            map-get(
              map-get(map-get($base-colors, fill-quaternary), onlight),
              foreground
            ),
            0.08
          );
        }
      }
    }
  }
}
