/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/

$divider-color: --iui-color-background-disabled;
$hovered-icon-color: --iui-color-background-accent;
$default-icon-height: 20px;
$default-font-size: --iui-font-size-1;

.map-manager-layer-host {
  margin: 0 6px;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;

  .map-expandable-blocks-block {
    width: 100%;
    border: none;
  }
}

.map-manager-top-header {
  display: flex;
  align-items: center;
  width: 100%;
  padding-top: 5px;
  padding-bottom: 4px;
  margin-bottom: 15px;
  border-bottom-color: #ccc;
  border-bottom-style: solid;
  border-bottom-width: 1px;

  .map-manager-header-label {
    font-size: $default-font-size;
    width: auto;
    white-space: nowrap;
    flex: 1 1 auto;
    padding-left: 10px;
  }

  .map-manager-header-buttons-group {
    margin-left: auto;
    border: none;
    display: flex;
    padding-right: 5px;
  }
}

.map-manager-container {
  margin: 10px 6px 0px 6px;
  //border: 1px solid #ccc;

  * {
    box-sizing: border-box;
  }

  map-manager-settings-container {
    display: flex;
    margin-top: 8px;
    width: 100%;
  }

  .map-manager-layer-wrapper {
    border: 1px solid #ccc;
    margin-bottom: 15px;
    padding: 10px;
    max-height: 300px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .map-manager-layers {
    display: flex;

    .map-manager-attach-layer-button {
      margin-left: auto;
    }
  }

  .map-manager-attach-layer-label {
    font-style: normal;
  }
  .core-ls {
    position: absolute;
    top: 50%;
    left: 50%;
    padding: 4px, 0;
    transform: translate(-50%, -50%);
  }

  .map-manager-source-listbox-header {
    margin-bottom: 4px;
    display: flex;
    flex-direction: row;
    align-items: center;
    column-gap: 6px;
  }

  .map-manager-source-list-filter {
    padding-top: 3.3px;
    padding-bottom: 3.3px;
    width: calc(100% - 40px);
  }

  .map-manager-source-list {
    margin-top: 0;
  }

  .map-manager-layers-label {
    // display: block;
    flex: 1 1;
    text-overflow: ellipsis;
    /* Required for text-overflow to do anything */
    white-space: nowrap;
    overflow: hidden;
    margin-left: 2px;
    margin-bottom: 4px;
  }

  .map-manager-no-layers-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px;
    border-color: var(--buic-inputs-border);
    background-color:  var(--iui-color-background);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
    color: var(--iui-color-text-muted);
    font-style: italic;
    border-style: dotted;
    border-width: 2px;
    margin: 6px;
    width: auto;
    height: 6.5em; // Avoid container resize when dragging layer the first time.
  }

  .map-manager-no-layers-label {
    margin-bottom: 10px;
  }

  .map-manager-item-divider {
    width: 100%;
    height: 2px;
    background: $divider-color;
    margin: 1em 0 1em 0;
  }

  .map-manager-item-menu {
    padding: 5px;
  }

  .map-manager-header {
    display: flex;
    flex-direction: column;
    height: auto;
    width: 100%;
    align-items: center;
    margin-top: 8px;

    .map-manager-add-source-button {
      margin-left: 4px;
    }

    .map-manager-add {
      height: 2em;
      flex: initial;
      width: fit-content;
      margin-left: 6px;
    }

    .core-split-button-label {
      line-height: inherit;
    }

    .core-split-button {
      height: 2em;
    }

    .core-split-button > .core-split-button-arrow > .core-split-button-arrow-icon {
      line-height: 16px;
    }
  }

  .map-manager-attachments {
    height: auto;
    min-height: 91px;
    max-height: 30%;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: auto;

    &.is-dragging-map-over {
      background-color:var(--iui-color-background-disabled);
    }
  }
}

.map-manager-source-header {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 2em;
  width: 100%;
  padding-left: 10px;
  border-width: 0 0 1px 0;
  border-style: solid;
  border-color: var(--buic-inputs-border);

  .map-manager-item-label {
    width: 465px;
    min-width: 3em;
  }

  .map-manager-item-transparency {
    max-width: 160px;
    width: 160px;
    display: flex;
    justify-content: center;
  }
}

.map-manager-layer-action-buttons {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  height: 2.5em;
  width: 100%;
  padding-right: 4px;
  border-bottom: #ccc;
  border-bottom-style: solid;
  border-bottom-width: thin;
  margin-bottom: 1em;
  background-color:  var(--iui-color-background);
}

.map-manager-layer-action-unlink-button {
  margin-right: 2px;
}

.map-manager-layer-action-buttons-inside-separator {
  border-left-width: thin;
  border-left-style: solid;
  border-left-color: #ccc;
  margin-left: 10px;
  padding-left: 5px;
}

.map-manager-basemap-visibility {
  margin: 0 2px;
}

.map-manager-source-item {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  min-height: 2.5em;
  width: 100%;
  background-color:  var(--iui-color-background);
  border: solid 1px var(--iui-color-border);
  border-radius: var(--iui-border-radius-1);
  padding-inline: 4px;

  .map-manager-item-label {
    flex: 1 1;
    text-overflow: ellipsis;
    /* Required for text-overflow to do anything */
    white-space: nowrap;
    overflow: hidden;
    margin-left: 2px;
  }

  .map-manager-item-label-disabled {
    @extend .map-manager-item-label;
    color: var(--iui-color-text-disabled);
  }

  .map-manager-item-transparency {
    margin-right: 6px;
  }

  .map-layer-settings {
    margin-left: 2px;
  }

  .map-layer-source-item-warnMessage-icon {
    background-color: transparent;
    border: none;
    color: var(--iui-color-icon-warning);
    background-color: transparent;
    &:focus {
      outline: none;
      box-shadow: rgba(var(--iui-color-border-accent), var(--iui-opacity-4)) 0px 0px 0px 2px;
    }
  }
}

.map-manager-item-dropdown-slider {
  /* Make the slider a little bit wider, otherwise its quite small in the dropdown menu*/
  width: 100px;
}

.map-manager-item-sub-layer-container {
  z-index: var(--uicore-z-index-dialog-popup);
}

.map-manager-sublayer-panel {
  width: 400px; // Ideally I would let the popup's content drives the width, unfortunately without an explicit width, the popup location is not consistent.
  color: var(--iui-color-text-muted);
  font-size: $default-font-size;
  padding: 4px;
  display: block;
  box-sizing: border-box;
  border-radius: 4px;
  border: 1px solid var(--iui-color-background-disabled);
  background: var(--iui-color-background-hover);
  color: var(--iui-color-text);
  cursor: default;
  z-index: var(--uicore-z-index-dialog-popup);
}

.map-manager-sublayer-label {
  width: 100%;
  min-width: 100px;
  text-overflow: ellipsis;
  /* Required for text-overflow to do anything */
  white-space: nowrap;
  overflow: hidden;
}

.map-layer-settings-popup-panel {
  color: var(--iui-color-text-muted);
  font-size: $default-font-size;
  display: grid;
  grid-row-gap: 4px;
  padding: 4px;

  &:hover {
    color: var(--iui-color-text);
    cursor: auto;
  }

  .core-context-menu-item {
    display: flex;
    cursor: default;
    align-items: center;
    position: relative;

    &:hover {
      background-color: var(--iui-color-background-hover);
    }
  }

  .map-manager-no-layers-label {
    display: block;
    justify-content: center;
    align-items: center;
    height: 100%;
    width: 100%;
    padding-left: 4px;
    padding-right: 4px;
    border-width: 1px;
    border-style: solid;
    border-color: var(--buic-inputs-border);
    border-radius: 3px;
    background-color:  var(--iui-color-background);
    overflow: hidden;
    color: var(--iui-color-text-muted);
    font-style: italic;
  }
}

.map-manager-not-geo-located-text {
  width: 90%;
  color: var(--iui-color-text-muted);
  font-style: italic;
  text-align: center;
}


.map-sources-popup-panel {
  padding: 4px;
  width: 400px;

  * {
    box-sizing: border-box;
  }

  .map-manager-source-listbox-header {
    display: flex;
    margin-left: 1px;
    column-gap: 4px;
  }

  ul.core-listbox {
    background-color:  var(--iui-color-background);
  }

  .map-manager-sources {
    margin-top: 4px;
    height: 250px;
    min-height: 60px;

    .map-source-list-entry {
      button.map-source-list-entry-button {
        height: auto;
        padding: 0 4px 0 4px;
      }

      .map-source-list-entry-name {
        flex: 1 1 auto;
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow: hidden;
        margin-right: 4px;
      }

      .map-source-list-entry-attach {
        margin-right: 10px;
        display: none;
        width: auto;
      }

      &[aria-selected="true"] {
        .map-source-list-entry-attach {
          display: inline-block;
        }
      }
    }
  }
}
