/**
 *
 * @ai-apps/angular v2.152.0 | _image-tile.scss
 *
 * Copyright 2014, 2023 IBM
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0

 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


@import '../../globals/vars';

$title-height: 3rem;

@mixin image-container($max-height, $max-width) {
  height: $max-height;
  width: $max-width;
  display: flex;
  align-items: center;
  justify-content: center;
  img {
    max-width: $max-width;
    max-height: $max-height;
  }
}

.#{$iot-prefix}--image-tile {
  $image-max-height: 12rem;
  $image-max-width: 20rem;

  background-color: $ui-01;
  width: $image-max-width;
  height: calc(#{$image-max-height} + #{$title-height});
  padding: 0;

  .#{$iot-prefix}--image-tile__image-container {
    @include image-container($image-max-height, $image-max-width);
  }
}

.#{$iot-prefix}--image-tile--wide {
  $image-max-height: 3rem;
  $image-max-width: 5rem;

  width: 100%;
  height: $title-height;
  padding: $spacing-03;
  border-top: 1px solid $ui-03;

  &:nth-of-type(1) {
    border-color: transparent;
  }
  // The border must be hidded when focused or selected, also for sibling
  &.#{$prefix}--tile--is-selected,
  &:focus {
    border-color: transparent;
    & + input + .#{$prefix}--tile {
      border-color: transparent;
    }
  }

  .#{$prefix}--tile-content {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
  }

  .#{$iot-prefix}--image-tile__image-container {
    @include image-container($image-max-height, $image-max-width);
  }

  .#{$iot-prefix}--image-tile__title {
    background-color: unset;
    width: calc(100% - #{$image-max-width});
  }
}

.#{$iot-prefix}--image-tile__title {
  height: $title-height;
  display: flex;
  align-items: center;
  background-color: $ui-01;
  padding-left: $spacing-05;
  padding-right: $spacing-07; // Make room for check mark when selected
  span {
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
  }
}

// position the button on the far right
.#{$prefix}--btn.#{$prefix}--btn--icon-only.#{$iot-prefix}--image-tile__title__delete {
  position: absolute;
  right: 0rem;
  bottom: 0rem;
}

html[dir='rtl'] {
  .#{$iot-prefix}--image-tile.#{$prefix}--tile--selectable {
    padding: 0;
  }
  .#{$iot-prefix}--image-tile--wide.#{$prefix}--tile--selectable {
    padding: $spacing-03;
  }

  .#{$iot-prefix}--image-tile__title {
    padding-left: $spacing-08;
    padding-right: $spacing-05;
  }
}
