@import (reference) url('./Dropdown.less');

.Notification {
  margin-top: calc(-1 * var(--gap-l));
  padding-bottom: var(--gap-l);

  &-controls {
    align-items: center;
    display: flex;
    padding: 10px;

    > * {
      flex-shrink: 0;
      margin-right: var(--gap-m);
    }

    &-toggle {
      .IconButton;

      --IconButton-name: 'settings';

      .Popup .ActionBar & {
        width: 45px;
      }
    }

    &-list {
      .Dropdown;

      & li {
        .Dropdown-item;

        padding: 0;
      }

      & a {
        display: block;
      }
    }

    &-menu {
      margin-left: auto;
      order: 2;

      &.is-open {
        .Notification-controls-toggle {
          &:hover,
          &:focus {
            --IconButton-name: 'close';
          }
        }

        .Notification-controls-list {
          .Dropdown.is-open;
        }
      }
    }
  }

  &-pagination {
    position: absolute;
    right: calc(4 * var(--gap-l) - var(--gap-s));
    top: calc(
      var(--gap-m) + var(--lineHeight-m) / 2 - var(--Icon-size) / 2 -
        var(--gap-s)
    );
    z-index: 10;
  }

  &-date {
    background-color: var(--color-gray2);
    font-weight: bold;
    margin: 0 calc(-1 * var(--gap-l));
    padding: 10px var(--gap-l);
  }

  &-item {
    border-bottom: 1px solid var(--color-gray2);
    padding: 5px 0;

    &:last-child {
      border-bottom: none;
    }

    > div {
      margin: 5px 0;
    }

    &:hover,
    &:focus-within {
      a.Button-clearSingle {
        opacity: 1;
      }
    }
  }

  &-info {
    display: flex;
    justify-content: space-between;
  }

  &-type {
    font-weight: bold;
    padding-right: var(--gap-m);
  }

  &-clear {
    a.Button-clearSingle {
      .IconButton;
      .IconButton.is-red;

      --IconButton-name: 'close';

      opacity: 0;
    }
  }

  &-new {
    color: var(--color-blue5);
    position: relative;

    &::before {
      content: '●';
      left: calc(-1 * var(--gap-m) - 1px);
      position: absolute;
    }
  }

  &-error,
  &-error-new {
    color: var(--color-red5);
    position: relative;
    text-decoration-color: var(--color-red5);

    &::before {
      color: var(--color-red5);
      content: '!';
      font-weight: bold;
      left: calc(-1 * var(--gap-m));
      position: absolute;
    }
  }

  &-details {
    background-color: var(--color-gray2);
    padding: 5px;

    > span {
      color: var(--color-gray6);
      font-style: italic;
    }
  }

  &-contentError {
    max-height: 5vh;
    overflow-y: scroll;

    &-errorInfoButton {
      &.is-active {
        opacity: 1;
      }

      .error-message {
        display: none;
      }
    }

    &:hover {
      .Notification-contentError-errorInfoButton {
        opacity: 1;
      }
    }
  }

  &-list {
    list-style: decimal;
    padding-left: 20px;
  }

  &-footer {
    background-color: var(--color-white);
    bottom: var(--gap-l);
    box-shadow: inset 0 1px 0 0 var(--color-gray2);
    font-size: 16px;
    margin-bottom: calc(-1 * var(--gap-l));
    padding: var(--gap-s) 0;
    position: absolute;
    text-align: right;
    width: 100%;
  }
}

.Widget.ToolUserNotifications {
  position: unset;

  .Button-clearAll {
    .Button;

    background: transparent;
    border-color: var(--color-red5);
    color: var(--color-red5);

    &:hover {
      border-color: var(--color-red6);
      color: var(--color-red6);
    }
  }
}

// Hides the add/remove buttons on Automatic Subscriptions
.inputContainer[data-field='cms.notification.automaticSubscriptions/subscriptionOptions']
  > .RCIG
  > .RCIG-controls {
  display: none;
}

.inputContainer[data-field='cms.notification.automaticSubscriptions/subscriptionOptions']
  > .RCIG
  > .RCIG-list
  > .RCIG-item
  > .RCIG-remove {
  display: none;
}

// Hides the effectively read-only subscription field needed to power other dynamic texts.
[data-type='com.psddev.cms.notification.AutomaticToolSubscriptionOption']
  > [data-field-name='subscription'] {
  display: none;
}

.Notification-actionBar {
  padding-bottom: var(--gap-xs);
  padding-top: var(--gap-xs);

  .Notification-action {
    display: inline-block;

    &:not(:first-child) {
      padding-left: var(--gap-m);
    }
  }

  .Notification-actionRefresh {
    display: none;
  }

  .Actions-controls {
    display: inline;

    .Additional-actionsToggle {
      .IconButton;

      background: transparent;
      border: 0;
      padding: 0;

      --IconButton-name: 'more_horiz';

      &[aria-expanded='true'] {
        .IconButton.is-focus;

        --IconButton-name: 'close';
      }
    }

    .Actions-controlsList > li > form.Notification-action {
      display: contents;
    }

    .Actions-controlsList [role='menuitem'] {
      .Dropdown-item;
    }

    &.is-open .Actions-controlsList {
      .Dropdown.is-open;
    }
  }
}
