// ArraySubs -> Webhooks endpoint rows: details, row actions and the notice
// of an endpoint switched off after failures.

.arraysubs-webhooks-endpoints {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.arraysubs-webhooks-endpoint {
  margin: 0;
  padding: 16px;
  border: 1px solid #dcdcde;
  border-radius: 6px;
  background: #fff;

  &--disabled {
    border-color: #f1aeb5;
  }

  &__row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
  }

  &__main {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
  }

  &__title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;

    h3 {
      margin: 0;
      color: #1d2327;
      font-size: 14px;
      font-weight: 600;
      line-height: 1.5;
      overflow-wrap: anywhere;
    }
  }

  &__url {
    display: block;
    max-width: 100%;
    overflow: hidden;
    padding: 2px 6px;
    border-radius: 3px;
    background: #f6f7f7;
    color: #1d2327;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: fit-content;
  }

  &__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 16px;
    margin: 2px 0 0;
    padding: 0;
    color: #646970;
    font-size: 12px;
    line-height: 1.5;
    list-style: none;

    > li {
      margin: 0;
      min-width: 0;
    }
  }

  &__muted {
    color: #646970;
  }

  &__failed {
    color: #991b1b;
    font-weight: 600;
  }

  &__link {
    color: var(--wp-admin-theme-color);
    font-weight: 500;
    text-decoration: none;

    &:hover,
    &:focus {
      color: var(--wp-admin-theme-color-darker-10);
      text-decoration: underline;
    }
  }

  &__last {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 6px;
    max-width: 100%;

    > svg {
      flex-shrink: 0;
    }

    &--success > svg {
      color: #00a32a;
    }

    &--error > svg {
      color: #d63638;
    }
  }

  &__result {
    max-width: 320px;
    overflow: hidden;
    color: #50575e;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  &__actions {
    display: flex;
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
    max-width: 50%;

    .button {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      min-height: 30px;
      white-space: nowrap;
    }
  }

  // A narrow row moves a whole group to the next line, right-aligned. The
  // buttons inside a group wrap only when the group alone is too wide.
  &__action-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
    min-width: 0;
  }

  &__delete.button:not(:disabled) {
    border-color: #d63638;
    color: #b32d2e;

    &:hover,
    &:focus {
      border-color: #b32d2e;
      background: #fcf0f1;
      color: #8a2424;
    }
  }

  &__alert {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    padding: 12px;
    border-left: 4px solid #d63638;
    border-radius: 4px;
    background: #fcf0f1;
    color: #1d2327;

    > svg {
      flex-shrink: 0;
      margin-top: 2px;
      color: #d63638;
    }

    p {
      margin: 0 0 6px;
      font-size: 13px;
      line-height: 1.5;
      overflow-wrap: anywhere;
    }
  }

  &__alert-body {
    flex: 1;
    min-width: 0;
  }

  &__alert-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;

    .button {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      min-height: 30px;
    }
  }
}

@media (max-width: 782px) {
  .arraysubs-webhooks-endpoint {
    &__row {
      flex-direction: column;
      align-items: stretch;
      gap: 12px;
    }

    &__actions,
    &__action-group {
      justify-content: flex-start;
    }

    &__actions {
      max-width: none;
    }

    &__result {
      max-width: 100%;
    }
  }
}

@media (max-width: 480px) {
  .arraysubs-webhooks-endpoint {
    padding: 12px;

    &__action-group {
      flex: 1 1 100%;
    }

    &__actions .button,
    &__alert-actions .button {
      flex: 1 1 auto;
      justify-content: center;
    }
  }
}
