.ui-panel {
  align-self: start;
  border-radius: $base-border-radius;
  display: grid;
  grid-template-areas: "header" "body" "footer";
  grid-template-rows: auto 1fr auto;
  max-width: 100%;
  overflow: hidden;
  position: relative;

  $base: unquote(".ui-panel");

  &.ui-table-panel {
    .ui-panel__body {
      padding: 0;
    }
  }

  &__group {
    > #{$base} {
      border-radius: 0;

      &:first-child {
        border-top-left-radius: $base-border-radius;
        border-top-right-radius: $base-border-radius;
      }

      &:last-child {
        border-bottom-left-radius: $base-border-radius;
        border-bottom-right-radius: $base-border-radius;
      }
    }
  }

  &__body {
    grid-area: body;
    overflow: auto;
    position: relative;
    padding: 1rem;
    transition: max-height 0.3s;

    > compose {
      display: grid;
      grid-area: content;
      grid-template-areas: "content";
      grid-template-columns: 1fr;
      grid-template-rows: 1fr;
    }
  }

  &__header {
    align-items: center;
    display: grid;
    grid-area: header;
    grid-template-areas: "drag-handle header actions";
    grid-template-columns: auto 1fr auto;
    position: relative;

    .ui-header {
      position: static;

      &::after {
        transition: opacity 0.3s;
      }
    }

    .ui-btn__wrapper {
      font-size: 0.75em;
    }

    &__actions {
      align-items: center;
      align-self: stretch;
      display: grid;
      grid-area: actions;
      grid-auto-flow: column;
      grid-gap: 2px;

      > .ui-divider {
        margin: 4px;
        @extend %vr;
      }

      &:not(:empty) {
        @include property-prefix(margin-start, -1em);
        padding: 0 0.5em;
      }
    }
  }

  &[data-collapsed="true"] {
    .ui-footer,
    .ui-panel__body {
      // stylelint-disable-next-line declaration-no-important
      display: none;
    }

    .ui-header {
      &::after {
        opacity: 0 !important;
        transition: opacity 0.3s;
      }
    }
  }

  &[data-expanded="true"] {
    .ui-footer,
    .ui-panel__body {
      // stylelint-disable-next-line declaration-no-important
      max-height: unset !important;
      min-height: unset;
    }

    @include position(fixed, 1em);
    box-shadow: 0 0 4em rgba(0, 0, 0, 0.9);
    z-index: 5000;
  }
}
