// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only

@mixin system-message-icon($url) {
  @include light-theme {
    -webkit-mask: url($url) no-repeat center;
    -webkit-mask-size: 100%;
  }
  @include dark-theme {
    -webkit-mask: url($url) no-repeat center;
    -webkit-mask-size: 100%;
  }
}

.SystemMessage {
  @include font-body-2;
  align-items: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 16px;
  padding-bottom: 16px;
  padding-top: 16px;

  @include light-theme {
    color: $color-gray-60;
  }
  @include dark-theme {
    color: $color-gray-25;
  }

  &__contents {
    max-width: 400px;
    text-align: center;
    user-select: none;

    p {
      display: block;
      margin-block-start: 0;
      margin-block-end: 4px;
      margin-inline-start: 0;
      margin-inline-end: 0;

      &:first-child {
        display: inline-block;
      }

      &:last-child {
        margin-block-end: 0;
      }
    }

    &::before {
      content: '';
      display: inline-block;
      height: 16px;
      margin-inline-end: 8px;
      width: 16px;
      vertical-align: text-top;

      @include light-theme {
        background-color: $color-gray-60;
      }
      @include dark-theme {
        background-color: $color-gray-25;
      }
    }

    &--icon-audio-incoming::before {
      @include system-message-icon(
        '../images/icons/v3/phone/phone-compact.svg'
      );
    }

    &--icon-audio-missed::before {
      @include system-message-icon(
        '../images/icons/v3/phone/phone-compact.svg'
      );
    }

    &--icon-audio-outgoing::before {
      @include system-message-icon(
        '../images/icons/v3/phone/phone-compact.svg'
      );
    }

    &--icon-group::before {
      @include system-message-icon(
        '../images/icons/v3/group/group-compact.svg'
      );
    }

    &--icon-group-access::before {
      @include system-message-icon(
        '../images/icons/v3/megaphone/megaphone-compact.svg'
      );
    }

    &--icon-group-add::before {
      @include system-message-icon(
        '../images/icons/v3/person/person-plus-compact.svg'
      );
    }

    &--icon-group-approved::before {
      @include system-message-icon(
        '../images/icons/v3/person/person-check-compact.svg'
      );
    }

    &--icon-group-avatar::before {
      @include system-message-icon(
        '../images/icons/v3/photo/photo-square-compact.svg'
      );
    }

    &--icon-group-decline::before {
      @include system-message-icon(
        '../images/icons/v3/person/person-x-compact.svg'
      );
    }

    &--icon-group-edit::before {
      @include system-message-icon('../images/icons/v3/edit/edit-compact.svg');
    }

    &--icon-group-leave::before {
      @include system-message-icon(
        '../images/icons/v3/leave/leave-compact.svg'
      );
    }

    &--icon-group-remove::before {
      @include system-message-icon(
        '../images/icons/v3/person/person-minus-compact.svg'
      );
    }

    &--icon-group-summary::before {
      @include system-message-icon('../images/icons/v3/info/info-compact.svg');
    }

    &--icon-info::before {
      @include system-message-icon('../images/icons/v3/info/info-compact.svg');
    }

    &--icon-phone::before {
      @include system-message-icon(
        '../images/icons/v3/phone/phone-compact.svg'
      );
    }

    &--icon-profile::before {
      @include system-message-icon(
        '../images/icons/v3/person/person-compact.svg'
      );
    }

    &--icon-safety-number::before {
      @include system-message-icon(
        '../images/icons/v3/safety_number/safety_number-compact.svg'
      );
    }

    &--icon-session-refresh::before {
      @include system-message-icon('../images/icons/v3/refresh/refresh.svg');
    }

    &--icon-timer::before {
      @include system-message-icon(
        '../images/icons/v3/timer/timer-compact.svg'
      );
    }

    &--icon-timer-disabled::before {
      @include system-message-icon(
        '../images/icons/v3/timer/timer-slash-compact.svg'
      );
    }

    &--icon-unsupported::before {
      @include system-message-icon(
        '../images/icons/v3/error/error-circle-compact.svg'
      );
    }

    &--icon-unsupported--can-process::before {
      @include system-message-icon(
        '../images/icons/v3/check/check-circle-compact.svg'
      );
    }

    &--icon-verified::before {
      @include system-message-icon(
        '../images/icons/v3/check/check-compact.svg'
      );
    }

    &--icon-verified-not::before {
      @include system-message-icon(
        '../images/icons/v3/safety_number/safety_number-compact.svg'
      );
    }

    &--icon-video::before {
      @include system-message-icon(
        '../images/icons/v3/video/video-compact.svg'
      );
    }

    &--icon-video-incoming::before {
      @include system-message-icon(
        '../images/icons/v3/video/video-compact.svg'
      );
    }

    &--icon-video-missed::before {
      @include system-message-icon(
        '../images/icons/v3/video/video-compact.svg'
      );
    }

    &--icon-video-outgoing::before {
      @include system-message-icon(
        '../images/icons/v3/video/video-compact.svg'
      );
    }

    &--icon-warning::before {
      @include system-message-icon(
        '../images/icons/v3/error/error-circle-compact.svg'
      );
    }

    &--icon-payment-event::before {
      @include system-message-icon('../images/icons/v3/payment/payment.svg');
    }

    &--icon-merge::before {
      @include system-message-icon(
        '../images/icons/v3/merge/merge-compact.svg'
      );
    }
  }

  &--error {
    .SystemMessage__contents::before {
      @include light-theme {
        background-color: $color-accent-red;
      }
      @include dark-theme {
        background-color: $color-accent-red;
      }
    }
  }

  &--danger {
    @include light-theme {
      color: $color-accent-red;
    }
    @include dark-theme {
      color: $color-accent-red;
    }

    .SystemMessage__contents::before {
      @include light-theme {
        background-color: $color-accent-red;
      }
      @include dark-theme {
        background-color: $color-accent-red;
      }
    }
  }

  &__button-container {
    margin-top: 12px;
  }
}
