//
// Copyright © 2021 Anticrm Platform Contributors.
// 
// Licensed under the Eclipse Public 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 https://www.eclipse.org/legal/epl-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.
//

/* Overlays */
.antiOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background-color: var(--card-overlay-color);
  pointer-events: all;
}

/* Cards */
.antiCard {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--popup-bg-color);
  border-radius: .5rem;
  box-shadow: var(--card-shadow);

  .antiCard-header {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    padding: 1rem 1rem 1.5rem;

    &__title {
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
      user-select: none;
      min-width: 0;
      font-weight: 500;
      font-size: 1rem;
      color: var(--accent-color);
    }
    &__error {
      min-width: 0;
      flex-grow: 1;
      position: absolute;
      display: flex;
      top: 2.5rem;
      left: 1rem;
      right: 1rem;
      font-weight: 500;
      font-size: .75rem;
      color: var(--system-error-color);
      &:empty { visibility: hidden; }
    }
  }

  .antiCard-content {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    flex-shrink: 1;
    margin: 0 1rem;
    height: fit-content;
    min-height: 0;

    & > *:not(:last-child) { margin-bottom: 1rem; }
  }

  .antiCard-pool {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    margin: 0 1rem .75rem;
    color: var(--theme-caption-color);
    flex-wrap: wrap;

    &__separator {
      margin: 1rem 0;
      height: 1px;
      background-color: var(--theme-card-divider);
    }
  }

  .antiCard-footer {
    overflow: hidden;
    flex-shrink: 0;
    display: grid;
    grid-auto-flow: column;
    direction: rtl;
    justify-content: flex-start;
    align-items: center;
    column-gap: .75rem;
    padding: 1.5rem 1rem 1rem;
    height: 4.5rem;
    border-radius: 0 0 .5rem .5rem;
  }

  .antiCard-group {
    padding: .5rem 1rem;

    &:not(:last-child) { border-bottom: 1px solid var(--popup-divider); }
    &.grid {
      display: grid;
      grid-template-columns: 5rem auto;
      grid-auto-rows: minmax(2rem, auto);
      column-gap: .5rem;
      
      .label {
        display: flex;
        align-items: center;
        text-align: left;
        font-weight: 500;
        font-size: .75rem;
        line-height: .75rem;
        color: var(--content-color);
      }    
      .value {
        display: flex;
        align-items: center;
        justify-content: flex-end;
      }    
    }
  }

  &.dialog {
    width: 45rem;
    height: auto;
    max-width: 60rem;
    max-height: inherit;
    &.full {
      width: max-content;
      // max-width: 100%;
    }
  }
  &.mobile {
    width: 90vw;
    max-width: 90vw;
    max-height: 90vh;
  }
  &.dialog,
  &.mobile {
    .antiCard-header {
      padding: .75rem .75rem .375rem;

      &__title-wrap {
        display: flex;
        align-items: center;
        min-width: 0;

        & > *:not(:first-child) { margin-left: .375rem; }
      }

      &__divider, &__title {
        font-weight: 400;
        font-size: .8125rem;
      }
      &__divider { color: var(--content-color); }
      &__title { color: var(--accent-color); }
    }
    .antiCard-content { margin: .5rem 1.125rem 1rem; }
    .antiCard-pool {
      flex-direction: row;
      align-items: center;
      margin: 0 .5rem .25rem;
      font-size: .75rem;

      & > * { margin: 0 .25rem .5rem; }
    }
    .antiCard-footer {
      direction: ltr;
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: .75rem;
      height: auto;
      border-top: 1px solid var(--divider-color);

      &.reverse { flex-direction: row-reverse; }
      &__error {
        flex-grow: 1;
        display: flex;
        margin-left: .375rem;
        min-width: 0;
        font-weight: 500;
        font-size: .75rem;
        color: var(--system-error-color);
        &:empty { visibility: hidden; }
      }
    }
  }
}
