/*
 * Backpack - Skyscanner's Design System
 *
 * Copyright 2016 Skyscanner Ltd
 *
 * 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 '~bpk-mixins/index.scss';

$bpk-spacing-v2: true;

.bpk-banner-alert {
  background-color: $bpk-banner-alert-background-color;
  overflow: hidden;

  @include bpk-border-radius-sm;

  &--primary {
    @include bpk-border-sm(
      var(--bpk-banner-alert-primary-color, $bpk-banner-alert-primary-color),
      ''
    );
  }

  &--success {
    @include bpk-border-sm(
      var(--bpk-banner-alert-success-color, $bpk-banner-alert-success-color),
      ''
    );
  }

  &--warn {
    @include bpk-border-sm(
      var(--bpk-banner-alert-warn-color, $bpk-banner-alert-warn-color),
      ''
    );
  }

  &--error {
    @include bpk-border-sm(
      var(--bpk-banner-alert-error-color, $bpk-banner-alert-error-color),
      ''
    );
  }

  &--neutral {
    @include bpk-border-sm($bpk-banner-alert-neutral-color, '');
  }

  &--event {
    @include bpk-border-sm($bpk-banner-alert-event-color, '');
  }

  &__header {
    display: flex;
    padding: bpk-spacing-md();
    flex-direction: row;
    align-items: center;

    &--expandable {
      cursor: pointer;

      @include bpk-hover {
        background-color: $bpk-banner-alert-header-expandable-hover-background-color;
      }

      &:active {
        background-color: $bpk-banner-alert-header-expandable-active-background-color;
      }
    }
  }

  // Make sure the items in the flexbox are display: inline-block; for older IE's
  &__icon,
  &__message,
  &__toggle {
    display: inline-block;
  }

  &__message {
    padding: 0 bpk-spacing-md();
    flex-grow: 1;
  }

  &__primary-icon {
    @include bpk-themeable-property(
      fill,
      --bpk-banner-alert-primary-color,
      $bpk-banner-alert-primary-color
    );
  }

  &__success-icon {
    @include bpk-themeable-property(
      fill,
      --bpk-banner-alert-success-color,
      $bpk-banner-alert-success-color
    );
  }

  &__warn-icon {
    @include bpk-themeable-property(
      fill,
      --bpk-banner-alert-warn-color,
      $bpk-banner-alert-warn-color
    );
  }

  &__error-icon {
    @include bpk-themeable-property(
      fill,
      --bpk-banner-alert-error-color,
      $bpk-banner-alert-error-color
    );
  }

  &__neutral-icon {
    fill: $bpk-text-secondary-day;
  }

  &__event-icon {
    fill: $bpk-banner-alert-event-color;
  }

  &__toggle-button {
    padding: 0;
    border: 0;
    background-color: transparent;
    cursor: pointer;
    appearance: none;
  }

  &__expand-icon {
    fill: $bpk-banner-alert-expand-icon-fill;

    &--flipped {
      transform: scaleY(-1);
    }
  }

  &__children-container {
    // Temporarily adding an extra 2px padding to align alert message and description until the icon size changes to 16px
    $extra-padding: 2 * $bpk-one-pixel-rem;

    padding: 0 bpk-spacing-xxl() bpk-spacing-md()
      (bpk-spacing-xl() + $extra-padding);
    color: $bpk-banner-alert-children-color;

    @include bpk-text;
    @include bpk-caption;
  }
}
